sldeditor 0.12.1 → 0.13.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/canvas/AnnotationLayer.d.ts +3 -0
- package/dist/canvas/AnnotationLayer.d.ts.map +1 -1
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/internal-model.d.ts +2 -0
- package/dist/compiler/internal-model.d.ts.map +1 -1
- package/dist/i18n/messages.d.ts +4 -0
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/lib/export-dxf.d.ts.map +1 -1
- package/dist/lib/export-image.d.ts.map +1 -1
- package/dist/lib/wire-labels.d.ts +31 -0
- package/dist/lib/wire-labels.d.ts.map +1 -0
- package/dist/model/types.d.ts +6 -0
- package/dist/model/types.d.ts.map +1 -1
- package/dist/sldeditor.cjs +46 -46
- package/dist/sldeditor.cjs.map +1 -1
- package/dist/sldeditor.js +4951 -4853
- package/dist/sldeditor.js.map +1 -1
- package/dist/store/store.d.ts +5 -0
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/sldeditor.cjs
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var pv=Object.defineProperty;var gv=(e,t,n)=>t in e?pv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var gt=(e,t,n)=>gv(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),I=require("react"),Dr=require("react-dom");function yv(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=yv(I);/**
|
|
2
2
|
* @license lucide-react v0.469.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const xv=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Fr=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v0.469.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/var
|
|
11
|
+
*/var bv={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 wv=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:s="",children:r,iconNode:i,...a},l)=>I.createElement("svg",{ref:l,...bv,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Fr("lucide",s),...a},[...i.map(([c,f])=>I.createElement(c,f)),...Array.isArray(r)?r:[r]]));/**
|
|
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 ae=(e,t)=>{const n=I.forwardRef(({className:o,...
|
|
21
|
+
*/const ae=(e,t)=>{const n=I.forwardRef(({className:o,...s},r)=>I.createElement(wv,{ref:r,iconNode:t,className:Fr(`lucide-${xv(e)}`,o),...s}));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 Wr=ae("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 vv=ae("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 kv=ae("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 Hr=ae("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 qr=ae("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 _v=ae("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 On=ae("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 $v=ae("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 Sv=ae("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 jv=ae("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 Ev=ae("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 Gr=ae("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 Io=ae("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 Nv=ae("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 Mv=ae("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 Xr=ae("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 Tv=ae("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 Zn=ae("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 Av=ae("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 Iv=ae("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 Cv=ae("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 Qn=ae("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 Yr=ae("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 Co=ae("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 Kr=ae("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 Ov=ae("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 Vr=ae("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 Pv=ae("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 Bv=ae("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 Ur=ae("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 Jr=ae("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 eo=ae("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 Zn=ae("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Ur(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=Ur(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Jr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Ur(e))&&(o&&(o+=" "),o+=t);return o}const Qn="-",Pv=e=>{const t=Lv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Qn);return a[0]===""&&a.length!==1&&a.shift(),Zr(a,t)||Bv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Zr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Zr(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=/^\[(.+)\]$/,Bv=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}},Lv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return zv(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(Rv(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},Rv=e=>e.isThemeGetter,zv=(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,Dv=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)}}},Qr="!",Fv=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(Qr),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},Hv=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},Wv=e=>({cache:Dv(e.cacheSize),parseClassName:Fv(e),...Pv(e)}),qv=/\s+/,Gv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(qv);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=Hv(f).join(":"),$=u?b+Qr:b,v=$+g;if(s.includes(v))continue;s.push(v);const P=r(g,h);for(let B=0;B<P.length;++B){const W=P[B];s.push($+W)}a=c+(a.length>0?" "+a:a)}return a};function Xv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=es(t))&&(o&&(o+=" "),o+=n);return o}const es=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=es(e[o]))&&(n&&(n+=" "),n+=t);return n};function Yv(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((f,u)=>u(f),e());return n=Wv(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=Gv(l,n);return r(l,f),f}return function(){return s(Xv.apply(null,arguments))}}const he=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},ts=/^\[(?:([a-z-]+):)?(.+)\]$/i,Kv=/^\d+\/\d+$/,Vv=new Set(["px","full","screen"]),Uv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Jv=/\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$/,Zv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Qv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,e2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=e=>st(e)||Vv.has(e)||Kv.test(e),He=e=>ct(e,"length",l2),st=e=>!!e&&!Number.isNaN(Number(e)),gn=e=>ct(e,"number",st),yt=e=>!!e&&Number.isInteger(Number(e)),t2=e=>e.endsWith("%")&&st(e.slice(0,-1)),ne=e=>ts.test(e),We=e=>Uv.test(e),n2=new Set(["length","size","percentage"]),o2=e=>ct(e,n2,ns),r2=e=>ct(e,"position",ns),s2=new Set(["image","url"]),i2=e=>ct(e,s2,d2),a2=e=>ct(e,"",c2),xt=()=>!0,ct=(e,t,n)=>{const o=ts.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},l2=e=>Jv.test(e)&&!Zv.test(e),ns=()=>!1,c2=e=>Qv.test(e),d2=e=>e2.test(e),u2=()=>{const e=he("colors"),t=he("spacing"),n=he("blur"),o=he("brightness"),r=he("borderColor"),s=he("borderRadius"),i=he("borderSpacing"),a=he("borderWidth"),l=he("contrast"),c=he("grayscale"),f=he("hueRotate"),u=he("invert"),m=he("gap"),p=he("gradientColorStops"),h=he("gradientColorStopPositions"),g=he("inset"),b=he("margin"),$=he("opacity"),v=he("padding"),P=he("saturate"),B=he("scale"),W=he("sepia"),k=he("skew"),F=he("space"),X=he("translate"),Z=()=>["auto","contain","none"],G=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",ne,t],D=()=>[ne,t],se=()=>["",Le,He],ie=()=>["auto",st,ne],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],re=()=>["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",ne],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ne=()=>[st,ne];return{cacheSize:500,separator:":",theme:{colors:[xt],spacing:[Le,He],blur:["none","",We,ne],brightness:Ne(),borderColor:[e],borderRadius:["none","","full",We,ne],borderSpacing:D(),borderWidth:se(),contrast:Ne(),grayscale:xe(),hueRotate:Ne(),invert:xe(),gap:D(),gradientColorStops:[e],gradientColorStopPositions:[t2,He],inset:A(),margin:A(),opacity:Ne(),padding:D(),saturate:Ne(),scale:Ne(),sepia:xe(),skew:Ne(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",ne]}],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:[...de(),ne]}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:Z()}],"overscroll-x":[{"overscroll-x":Z()}],"overscroll-y":[{"overscroll-y":Z()}],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",yt,ne]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ne]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",yt,ne]}],"grid-cols":[{"grid-cols":[xt]}],"col-start-end":[{col:["auto",{span:["full",yt,ne]},ne]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[xt]}],"row-start-end":[{row:["auto",{span:[yt,ne]},ne]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ne]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ne]}],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:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[F]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[F]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ne,t]}],"min-w":[{"min-w":[ne,t,"min","max","fit"]}],"max-w":[{"max-w":[ne,t,"none","full","min","max","fit","prose",{screen:[We]},We]}],h:[{h:[ne,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ne,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ne,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ne,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:[xt]}],"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",ne]}],"line-clamp":[{"line-clamp":["none",st,gn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Le,ne]}],"list-image":[{"list-image":["none",ne]}],"list-style-type":[{list:["none","disc","decimal",ne]}],"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,ne]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ne]}],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",ne]}],"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:[...de(),r2]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",o2]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},i2]}],"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,ne]}],"outline-w":[{outline:[Le,He]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:se()}],"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,a2]}],"shadow-color":[{shadow:[xt]}],opacity:[{opacity:[$]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",We,ne]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[P]}],sepia:[{sepia:[W]}],"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":[P]}],"backdrop-sepia":[{"backdrop-sepia":[W]}],"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",ne]}],duration:[{duration:Ne()}],ease:[{ease:["linear","in","out","in-out",ne]}],delay:[{delay:Ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",ne]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[B]}],"scale-x":[{"scale-x":[B]}],"scale-y":[{"scale-y":[B]}],rotate:[{rotate:[yt,ne]}],"translate-x":[{"translate-x":[X]}],"translate-y":[{"translate-y":[X]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ne]}],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",ne]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ne]}],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"]}}},f2=Yv(u2);function Ee(...e){return f2(Jr(e))}const os=I.createContext(null);function m2(){const e=I.useContext(os);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Lt=8;function h2({children:e}){const[t,n]=I.useState({open:!1,x:0,y:0,items:[]}),[o,r]=I.useState(null),s=I.useRef(null),i=I.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=I.useCallback((c,f,u)=>{r(null),n({open:!0,x:c,y:f,items:u})},[]),l=I.useMemo(()=>({open:a,close:i}),[a,i]);return I.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let f=t.x,u=t.y;f+c.width>window.innerWidth-Lt&&(f=Math.max(Lt,t.x-c.width)),u+c.height>window.innerHeight-Lt&&(u=Math.max(Lt,t.y-c.height)),r({left:f,top:u})},[t]),I.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(os.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},p2=(e=>e?Co(e):Co),g2=e=>e;function y2(e,t=g2){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const Oo=e=>{const t=p2(e),n=o=>y2(t,o);return Object.assign(n,t),n},tn=(e=>e?Oo(e):Oo),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)。别拿母线连两个器件——点对点直接拉线(W)就行。","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":"A busbar is a shared rail, not a wire","onboard.step3.body":"Use the Busbar tool (B) only when several circuits share one rail. Don't use a bus to join two devices — just wire the pins (W).","onboard.dismiss":"Got it"}},rs="ole-locale";function x2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(rs);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(rs,e)}catch{}}const It=tn((e,t)=>({locale:x2(),setLocale:n=>{Bo(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Bo(n),e({locale:n})}}));function ss(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function is(e,t){return Po[e][t]??Po.zh[t]??t}function we(e,t){return ss(is(It.getState().locale,e),t)}function ce(){const e=It(t=>t.locale);return(t,n)=>ss(is(e,t),n)}function as(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)}}}},b2=(e,t)=>(n,o,r)=>{let s={storage:as(()=>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 v=++a;i=!1,l.forEach(B=>{var W;return B((W=o())!=null?W:p)});const P=(($=s.onRehydrateStorage)==null?void 0:$.call(s,(b=o())!=null?b:p))||void 0;return Cn(f.getItem.bind(f))(s.name).then(B=>{if(B)if(typeof B.version=="number"&&B.version!==s.version){if(s.migrate){const W=s.migrate(B.state,B.version);return W instanceof Promise?W.then(k=>[!0,k]):[!0,W]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,B.state];return[!1,void 0]}).then(B=>{var W;if(v!==a)return;const[k,F]=B;if(h=s.merge(F,(W=o())!=null?W:p),n(h,!0),k)return u()}).then(()=>{v===a&&(P==null||P(o(),void 0),h=o(),i=!0,c.forEach(B=>B(h)))}).catch(B=>{v===a&&(P==null||P(void 0,B))})};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},w2=b2,Re=.5;function ls(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])<Re&&Math.abs(s[1]-e[r][1])<Re||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>Re&&l>Re){const f=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Re?"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])<Re&&Math.abs(i[0]-a[0])<Re,c=Math.abs(s[1]-i[1])<Re&&Math.abs(i[1]-a[1])<Re;l||c||o.push(i)}return o.push(n[n.length-1]),o}function cs(){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 ds(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 On(e){return e===90||e===270?"y":"x"}function Oe(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 v2={n:"e",e:"s",s:"w",w:"n"},k2={n:"n",s:"s",e:"w",w:"e"};function St(e,t){let n=t.mirror?k2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=v2[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 us{constructor(){gt(this,"parent",new Map);gt(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"],Ro={n:"s",s:"n",e:"w",w:"e"};function Rt(e,t){const n=Lo.indexOf(e),r=((Lo.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const yn=320,zt=220,bt=260,xn=720,wt=30,zo=30,qe=80,Do=10,_2=60,$2=520,S2=80,j2=80,Fo=8,Ho=new Set(["source","renewable"]);function E2(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 w=p.get(y);if(w)return s.get(w.kind)},b=new Set(n.map(y=>y.id)),$=y=>b.has(y),v=new Set(o.map(y=>y.id)),P=new Set(o.filter(y=>{var w;return(w=y.layout)==null?void 0:w.at}).map(y=>y.id)),B=new us;for(const y of r)B.add(y.ends[0]),B.add(y.ends[1]),B.union(y.ends[0],y.ends[1]);for(const y of t){const w=s.get(y.kind);if(w)for(const S of w.terminals)B.add(`${y.id}.${S.id}`)}for(const y of n)B.add(y.id);const W=[];for(const[,y]of B.groups())y.length>=2&&W.push(y);const k=new Map;for(const y of W)for(const w of y)k.set(w,[y]);const F=new Map;for(const y of W){const w=y.filter($);if(w.length!==0)for(const S of w){const E=y.filter(_=>_!==S),j=F.get(S)??[];j.push(...E),F.set(S,j)}}{const S=T=>p.has(T)&&!!g(T),E=T=>{if($(T))return null;if(v.has(T))return T;const N=T.indexOf(".");return N>0?T.slice(0,N):null},j=new Map,_=new Set,M=(T,N)=>{j.has(T)||j.set(T,new Set),j.has(N)||j.set(N,new Set),T!==N&&(j.get(T).add(N),j.get(N).add(T))};for(const T of W){const N=[];let L=!1;for(const q of T){if($(q)){L=!0;continue}const Q=E(q);Q&&N.push(Q)}const R=[...new Set(N)];for(const q of R)j.has(q)||j.set(q,new Set),L&&_.add(q);const H=R.filter(q=>v.has(q)),Y=R.filter(q=>!v.has(q));if(H.length>0){for(const q of H)for(const Q of Y)M(q,Q);for(let q=0;q<H.length;q++)for(let Q=q+1;Q<H.length;Q++)M(H[q],H[Q])}else for(let q=0;q<Y.length;q++)for(let Q=q+1;Q<Y.length;Q++)M(Y[q],Y[Q])}const z=(T,N)=>{const L=g(T);if(!L)return null;for(const R of L.terminals){const H=`${T}.${R.id}`;for(const Y of k.get(H)??[])for(const q of Y)if(E(q)===N)return R}return null},C=T=>{const N=U=>{var te;return((te=j.get(U))==null?void 0:te.size)??0},L=U=>{var te;return((te=g(U))==null?void 0:te.category)??""},R=U=>{const te=L(U);return te==="source"?0:te==="renewable"?1:2+Math.min(N(U),9)/10},H=T.filter(S).sort((U,te)=>R(U)-R(te)||U.localeCompare(te))[0];if(!H)return;const Y=new Map([[H,null]]),q=new Map([[H,0]]),Q=new Map,ee=[],K=[H],V=new Set([H]);for(;K.length;){const U=K.shift();ee.push(U);for(const te of[...j.get(U)??[]].sort(($e,Se)=>$e.localeCompare(Se)))V.has(te)||(V.add(te),Y.set(te,U),q.set(te,(q.get(U)??0)+1),Q.has(U)||Q.set(U,[]),Q.get(U).push(te),K.push(te))}let J=0;const ue=new Map,be=U=>{const te=Q.get(U)??[];if(te.length===0){ue.set(U,J++);return}for(const Se of te)be(Se);const $e=te.map(Se=>ue.get(Se));ue.set(U,$e.reduce((Se,Bt)=>Se+Bt,0)/$e.length)};be(H);for(const U of ee){const te=pe(yn+(ue.get(U)??0)*160),$e=pe(zt+(q.get(U)??0)*140);if(v.has(U)){f.set(U,[te,$e]);continue}let Se=0;const Bt=Y.get(U)??null;if(Bt){const pt=z(U,Bt);pt&&(Se=Rt(pt.orientation,"n"))}else{const pt=(Q.get(U)??[])[0],No=pt?z(U,pt):null;No&&(Se=Rt(No.orientation,"s"))}l.set(U,{at:[te,$e],rot:Se,mirror:!1}),u.add(U)}},O=new Set;for(const T of j.keys()){if(O.has(T))continue;const N=[],L=[T];for(O.add(T);L.length;){const R=L.pop();N.push(R);for(const H of j.get(R)??[])O.has(H)||(O.add(H),L.push(H))}N.length<2||N.some(R=>_.has(R))||N.some(R=>l.has(R)||P.has(R))||N.some(S)&&C(N)}}const X=new Map;for(const y of W){const w=y.filter($);if(w.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),M=X.get(j)??[];for(const z of w)M.some(C=>C.busId===z&&C.pin===_)||M.push({busId:z,pin:_});X.set(j,M)}}const Z=[],G=new Set;for(const[y,w]of X)if(new Set(w.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";Z.push({elementId:y,attachments:w,orientation:E}),E==="vertical"&&G.add(y)}const A=new Map,D=(y,w)=>{y!==w&&(A.has(y)||A.set(y,new Set),A.has(w)||A.set(w,new Set),A.get(y).add(w),A.get(w).add(y))};for(const y of r)D(y.ends[0],y.ends[1]);for(const y of t){const w=s.get(y.kind);if(!w||w.terminals.length<2)continue;const S=w.terminals.map(E=>`${y.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)D(S[E],S[j])}for(const y of t){if(G.has(y.id))continue;const w=s.get(y.kind);if(!w||w.category!=="transformer"||w.terminals.length<2)continue;const S=w.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const M=_.slice(y.id.length+1);E.set(M,new Set);const z=new Set(S.filter(T=>T!==_)),C=new Set([_]),O=[_];for(;O.length>0;){const T=O.shift();if($(T)){E.get(M).add(T);continue}const N=A.get(T);if(N)for(const L of N)C.has(L)||z.has(L)||(C.add(L),O.push(L))}}const j=new Set;for(const _ of E.values())for(const M of _)j.add(M);if(j.size>=2){const _=[];for(const[M,z]of E)for(const C of z)_.push({busId:C,pin:M});Z.push({elementId:y.id,attachments:_,orientation:"vertical"}),G.add(y.id)}}const se=(y,w)=>{var z;const S=g(w),E=S?S.terminals.map(C=>`${w}.${C.id}`):[],j=y,_=new Set([j,...E]),M=[j];for(;M.length>0;){const C=M.shift(),O=C.indexOf(".");if(O>0){const N=C.slice(0,O),L=p.get(N);if(L){const R=(z=s.get(L.kind))==null?void 0:z.category;if(R&&Ho.has(R))return!0}}const T=A.get(C);if(T)for(const N of T)_.has(N)||(_.add(N),M.push(N))}return!1};for(const y of Z){if(y.orientation!=="horizontal")continue;const w=new Set(y.attachments.map(E=>E.busId));let S=0;for(const E of w)se(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 w=s.get(y.kind);if(!w||w.terminals.length!==2)continue;const S=w.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of S){const M=_.slice(y.id.length+1),z=new Set(S.filter(T=>T!==_)),C=new Set([_]),O=[_];for(;O.length>0;){const T=O.shift();if($(T)){E.set(M,T);break}const N=A.get(T);if(N)for(const L of N){if(C.has(L)||z.has(L))continue;const R=L.indexOf(".");if(R>0){const H=L.slice(0,R);if(H!==y.id){const Y=p.get(H),q=Y?s.get(Y.kind):void 0;if((q==null?void 0:q.category)==="transformer")continue}}C.add(L),O.push(L)}}}if(new Set(E.values()).size>=2){const _=[];for(const[M,z]of E)_.push({busId:z,pin:M});Z.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ie=new Map;for(const y of n)ie.set(y.id,new Map);for(const y of Z){const w=Array.from(new Set(y.attachments.map(S=>S.busId)));for(const S of w)for(const E of w)S!==E&&(($o=ie.get(S))==null||$o.set(E,y))}const de=y=>{var S;const w=(S=s.get(y))==null?void 0:S.category;return w?Ho.has(w):!1},oe=[];for(const y of n){const w=F.get(y.id);if(w)for(const S of w){if($(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=p.get(j);if(_&&de(_.kind)){oe.push(y.id);break}}}oe.length===0&&n.length>0&&oe.push(n[0].id);const re=new Map;for(const y of oe)re.set(y,0);{const y=[...oe];for(;y.length>0;){const w=y.shift(),S=re.get(w),E=ie.get(w);if(E)for(const[j,_]of E){if(re.has(j))continue;const M=_.orientation==="horizontal"?S:S+1;re.set(j,M),y.push(j)}}}for(const y of n){if(re.has(y.id))continue;const w=re.size===0?-1:Math.max(...Array.from(re.values()));re.set(y.id,w+1)}const ye=new Map;for(const y of n){const w=re.get(y.id),S=ye.get(w)??[];S.push(y.id),ye.set(w,S)}const xe=[...ye.keys()].sort((y,w)=>y-w),_e=(y,w,S)=>{const E=`${y.elementId}.${S}`,j=w,_=g(y.elementId),M=new Set;if(_)for(const N of _.terminals)N.id!==S&&M.add(`${y.elementId}.${N.id}`);const z=new Set([E]),C=[{ref:E,dist:0}],O=new Map,T=(N,L,R,H)=>{z.add(N),O.set(N,L),C.push({ref:N,dist:H+R})};for(;C.length>0;){const{ref:N,dist:L}=C.shift();if(N===j){const q=O.get(j);let Q;if(q){const ee=q.indexOf(".");if(ee>0){const K=q.slice(0,ee);K!==y.elementId&&(Q=K)}}return{extent:L,head:Q}}const R=N.indexOf(".");if(R<0)continue;const H=N.slice(0,R),Y=N.slice(R+1);if(!$(H)&&!G.has(H)){const q=g(H),Q=q==null?void 0:q.terminals.find(ee=>ee.id===Y);if(q&&Q)for(const ee of q.terminals){if(ee.id===Y)continue;const K=`${H}.${ee.id}`;z.has(K)||M.has(K)||T(K,N,Math.abs(Q.y-ee.y),L)}}for(const q of k.get(N)??[])for(const Q of q){if(Q===N||z.has(Q)||M.has(Q))continue;const ee=$(N)||$(Q);T(Q,N,ee?zo:wt,L)}}return{extent:0}},Ne=(y,w)=>{var N,L,R;const S=(N=ie.get(y))==null?void 0:N.get(w);if(!S||S.orientation==="horizontal")return bt;const E=g(S.elementId);if(!E)return bt;const j=(L=S.attachments.find(H=>H.busId===y))==null?void 0:L.pin,_=(R=S.attachments.find(H=>H.busId===w))==null?void 0:R.pin;if(!j||!_)return bt;const M=E.terminals.find(H=>H.id===j),z=E.terminals.find(H=>H.id===_);if(!M||!z)return bt;const C=Math.abs(z.y-M.y),O=_e(S,y,j).extent,T=_e(S,w,_).extent;return O+C+T},dn=new Map;for(const y of Z){if(y.orientation!=="vertical")continue;const w=y.attachments.slice().sort((z,C)=>(re.get(z.busId)??0)-(re.get(C.busId)??0));if(w.length<2)continue;const S=w[0].busId,E=w[1].busId,j=w[0].pin,M=_e(y,S,j).head??y.elementId;dn.set(M,{lowerBusId:E})}const lo=30,co=y=>{const w=g(y);return Math.max((w==null?void 0:w.width)??qe,qe)},ov=2,uo=(y,w,S,E=0)=>{const j=g(w);let _=co(w);if(j&&!S.has(w)&&E<ov){S.add(w);let M=0;for(const z of j.terminals){const C=`${w}.${z.id}`;if(C!==y)for(const O of k.get(C)??[]){const T=new Set;let N=!1;for(const R of O){if(R===C)continue;if($(R)){N=!0;continue}const H=R.indexOf(".");if(H<0)continue;const Y=R.slice(0,H);Y===w||S.has(Y)||G.has(Y)||T.add(Y)}if(N||T.size===0)continue;let L=0;for(const R of T){const H=[...O].find(Y=>Y.indexOf(".")>0&&Y.slice(0,Y.indexOf("."))===R);L+=(H?uo(H,R,S,E+1):co(R))+lo}M=Math.max(M,L-lo)}}S.delete(w),_=Math.max(_,M)}return _},ft=320,et=new Map,fo=(y,w)=>{if(!G.has(y))return!1;const S=Z.find(M=>M.elementId===y),E=S==null?void 0:S.attachments.find(M=>M.busId!==w);if(!E)return!1;const j=re.get(w)??0;return(re.get(E.busId)??0)<j},mt=(y,w,S)=>{const E=dn.get(y);if(E){const _=et.get(E.lowerBusId);if(_!==void 0)return Math.max(w,_+qe)}let j=0;return S&&(j=uo(S,y,new Set)),Math.max(w,qe,j)},mo=(y,w)=>{if(et.has(y))return et.get(y);if(w.has(y))return ft;w.add(y);const S=F.get(y)??[];let E=0,j=0;for(const M of S){if($(M))continue;const z=M.indexOf(".");if(z<0)continue;const C=M.slice(0,z),O=M.slice(z+1);if(fo(C,y))continue;const T=g(C);if(!T)continue;const N=T.terminals.find(H=>H.id===O);if(!N)continue;const L=dn.get(C);L&&mo(L.lowerBusId,w);const R=mt(C,T.width,`${C}.${O}`);N.y>0?E+=R:j+=R}const _=Math.max(ft,Math.max(E,j)+qe);return et.set(y,_),w.delete(y),_};for(const y of n)mo(y.id,new Set);const Fe=new Map,rv=(y,w,S)=>{const E=g(w);if(!E)return;const j=`${w}.${S}`,_=E.terminals.filter(C=>C.id!==S).map(C=>`${w}.${C.id}`);if(_.length===0)return;const M=new Set([j,..._]),z=_.slice();for(;z.length>0;){const C=z.shift();if($(C)&&C!==y){const T=c.get(C);return T?T.at[0]:void 0}for(const T of k.get(C)??[])for(const N of T)N===C||M.has(N)||(M.add(N),z.push(N));const O=C.indexOf(".");if(O>0){const T=C.slice(0,O);if(!$(T)){const N=g(T);if(N)for(const L of N.terminals){const R=`${T}.${L.id}`;M.has(R)||(M.add(R),z.push(R))}}}}},sv=y=>{const w=F.get(y);if(!w||w.length===0)return;const S=c.get(y);if(!S)return;const E=w.flatMap(N=>{if($(N))return[];const L=N.indexOf(".");if(L<0)return[];const R=N.slice(0,L),H=N.slice(L+1);if(l.has(R))return[];if(fo(R,y))return[];const Y=g(R);if(!Y)return[];const q=Y.terminals.find(Q=>Q.id===H);return q?[{elId:R,lib:Y,localTerm:q,isLinker:G.has(R),busFacingRef:`${R}.${H}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const M=N=>N.reduce((L,R)=>L+mt(R.elId,R.lib.width,R.busFacingRef),0),z=Math.max(M(j),M(_))+qe,C=Math.max(S.span,z);C!==S.span&&!m.has(y)&&c.set(y,{...S,span:C});const O=c.get(y),T=(N,L)=>{if(N.length===0)return;const R=new Map;for(const V of N){const J=rv(y,V.elId,V.localTerm.id);J!==void 0&&R.set(V.elId,J)}N.sort((V,J)=>{const ue=R.get(V.elId)??O.at[0],be=R.get(J.elId)??O.at[0];if(ue!==be)return ue-be;const U=mt(V.elId,V.lib.width,V.busFacingRef);return mt(J.elId,J.lib.width,J.busFacingRef)-U});const H=N.map(V=>mt(V.elId,V.lib.width,V.busFacingRef)),Y=H.reduce((V,J)=>V+J,0),q=Math.max(C,Y),Q=(q-Y)/(N.length+1);let ee=O.at[0]-q/2+Q;const K=O.at[1]+L*zo;for(let V=0;V<N.length;V++){const J=N[V],ue=H[V],be=ee+ue/2;J.isLinker?Fe.has(J.elId)||Fe.set(J.elId,be):l.set(J.elId,{at:[pe(be-J.localTerm.x),pe(K-J.localTerm.y)],rot:0,mirror:!1}),ee+=ue+Q}};T(j,-1),T(_,1)},iv=y=>{if(l.has(y.elementId)||y.orientation==="horizontal")return;const w=g(y.elementId);if(!w)return;const S=y.attachments.filter(ee=>c.has(ee.busId));if(S.length<2)return;const E=S.slice().sort((ee,K)=>(re.get(ee.busId)??0)-(re.get(K.busId)??0)),j=E[0].busId,_=c.get(j),M=E[0].pin,z=E[E.length-1].pin,C=w.terminals.find(ee=>ee.id===M),O=w.terminals.find(ee=>ee.id===z);if(!C||!O)return;const T=C.y<=O.y?0:180,N=re.get(j)??0,L=S.filter(ee=>(re.get(ee.busId)??0)===N),R=[];let H=0;for(const ee of L){const K=_e(y,ee.busId,ee.pin);H=Math.max(H,K.extent);const V=K.head?l.get(K.head):void 0;V?R.push(V.at[0]):Fe.has(y.elementId)?R.push(Fe.get(y.elementId)):R.push(c.get(ee.busId).at[0])}let Y;R.length>0?Y=R.reduce((ee,K)=>ee+K,0)/R.length:Fe.has(y.elementId)?Y=Fe.get(y.elementId):Y=_.at[0];const q=_.at[1]+H,Q=T===0?[pe(Y-C.x),pe(q-C.y)]:[pe(Y+C.x),pe(q+C.y)];if(l.set(y.elementId,{at:Q,rot:T,mirror:!1}),L.length>1){const ee=l.get(y.elementId),K=Oe([C.x,C.y],ee),V=St(C.orientation,ee);av(`${y.elementId}.${M}`,K,V,Y)}},av=(y,w,S,E)=>{const j=new Set([y]);let _=y,M=w,z=S;for(;;){const C=k.get(_)??[];let O,T=!1;for(const te of C){if(te.length>=3){T=!0;break}const $e=te.find(Se=>Se!==_);if(!(!$e||j.has($e))){if($($e)){T=!0;break}O=$e;break}}if(T||!O)break;const N=O.indexOf(".");if(N<0)break;const L=O.slice(0,N),R=O.slice(N+1);if($(L)||G.has(L)||l.has(L))break;const H=g(L);if(!H)break;const Y=H.terminals.find(te=>te.id===R);if(!Y)break;const q=Pn(z),Q=[M[0]+q[0]*wt,M[1]+q[1]*wt],ee=Ro[z],K=Rt(Y.orientation,ee),V=Oe([Y.x,Y.y],{at:[0,0],rot:K,mirror:!1}),J=[pe(E-V[0]),pe(Q[1]-V[1])];l.set(L,{at:J,rot:K,mirror:!1}),j.add(O);const ue=H.terminals.find(te=>te.id!==R);if(!ue)break;const be=`${L}.${ue.id}`;j.add(be);const U={at:J,rot:K,mirror:!1};M=Oe([ue.x,ue.y],U),z=St(ue.orientation,U),_=be}},lv=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const w=g(y.elementId);if(!w)return;const S=y.attachments.filter(L=>c.has(L.busId));if(S.length<2)return;const E=S.map(L=>{const R=_e(y,L.busId,L.pin),H=R.head?l.get(R.head):void 0,Y=H?H.at[0]:c.get(L.busId).at[0];return{att:L,x:Y,extent:R.extent}});E.sort((L,R)=>L.x-R.x);const j=E[0],_=E[E.length-1],M=w.terminals.find(L=>L.id===j.att.pin),z=w.terminals.find(L=>L.id===_.att.pin);if(!M||!z)return;const C=M.y<=z.y?270:90,O=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(y.elementId,{at:[pe(O),pe(N)],rot:C,mirror:!1})},ho=100;let Pt=zt;for(let y=0;y<xe.length;y++){const w=xe[y],S=ye.get(w);let E;if(y===0)E=zt;else{const _=ye.get(xe[y-1]);let M=0;for(const z of _)for(const C of S)(So=ie.get(z))!=null&&So.get(C)&&(M=Math.max(M,Ne(z,C)));M===0&&(M=bt),E=Pt+M}Pt=E;let j=yn;for(const _ of S){if(c.has(_)){Pt=Math.max(Pt,c.get(_).at[1]);continue}let M;if(y>0){const C=ye.get(xe[y-1]),O=[];for(const T of C){const N=(jo=ie.get(T))==null?void 0:jo.get(_);if(!N||N.orientation!=="vertical")continue;const L=(Eo=N.attachments.find(H=>H.busId===T))==null?void 0:Eo.pin;if(!L)continue;const R=_e(N,T,L);R.head&&l.has(R.head)?O.push(l.get(R.head).at[0]):Fe.has(N.elementId)?O.push(Fe.get(N.elementId)):O.push(c.get(T).at[0])}O.length>0&&(M=O.reduce((T,N)=>T+N,0)/O.length)}if(M===void 0){const C=et.get(_)??xn;M=j+C/2,j+=C+ho}const z=et.get(_)??xn;c.set(_,{at:[pe(M),pe(E)],rot:0,span:z,axis:On(0)})}for(const _ of S)sv(_);if(y>0)for(const _ of Z)l.has(_.elementId)||!_.attachments.some(z=>S.includes(z.busId))||iv(_);for(const _ of Z)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>S.includes(z.busId))||lv(_)}if(n.length===0&&l.size<t.length){const y=j=>{const _=new Set,M=g(j);if(!M)return _;for(const z of M.terminals){const C=`${j}.${z.id}`;for(const O of k.get(C)??[])for(const T of O){if(T===C||$(T))continue;const N=T.indexOf(".");if(N<0)continue;const L=T.slice(0,N);L!==j&&_.add(L)}}return _},w=new Set,S=[];for(const j of t){if(w.has(j.id)||!g(j.id))continue;const _=[],M=[j.id];for(w.add(j.id);M.length>0;){const z=M.pop();_.push(z);for(const C of y(z))w.has(C)||(w.add(C),M.push(C))}_.length>=2&&S.push(_)}let E=yn;for(const j of S){if(j.some(O=>l.has(O)))continue;j.sort((O,T)=>{var Y,q;const N=de(((Y=p.get(O))==null?void 0:Y.kind)??"")?0:1,L=de(((q=p.get(T))==null?void 0:q.kind)??"")?0:1;if(N!==L)return N-L;const R=y(O).size,H=y(T).size;return R!==H?R-H:O.localeCompare(T)});const _=j[0],M=g(_);if(!M)continue;const z=M.terminals.slice().sort((O,T)=>T.y-O.y)[0],C=z?Oe([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[pe(E-C[0]),pe(zt-C[1])],rot:0,mirror:!1}),E+=Math.max(xn,j.length*qe)+ho}}const cv=y=>{if($(y))return c.has(y);const w=y.indexOf(".");return w<0?!1:l.has(y.slice(0,w))};let un=!0,dv=t.length+4;for(;un&&dv-- >0;){un=!1;for(const y of W){if(y.length<2)continue;const w=[],S=new Map;for(const K of y){if($(K))continue;const V=K.indexOf(".");if(V<0)continue;const J=K.slice(0,V),ue=K.slice(V+1);if(l.has(J)){w.push(K);continue}if(G.has(J)||S.has(J))continue;const be=g(J);if(!be)continue;const U=be.terminals.find(te=>te.id===ue);U&&S.set(J,{ref:K,elId:J,lib:be,localTerm:U})}if(S.size===0||w.length===0)continue;const E=[...S.values()],j=new Map;for(const K of E)for(const V of k.get(K.ref)??[])for(const J of V){if(J===K.ref||$(J)||!cv(J))continue;const ue=J;j.set(ue,(j.get(ue)??0)+1)}let _;if(j.size>0){let K=-1;for(const[V,J]of j)(J>K||J===K&&(_===void 0||V<_))&&(K=J,_=V)}if(_||(_=[...w].sort()[0]),!_)continue;const M=_.indexOf("."),z=_.slice(0,M),C=_.slice(M+1),O=g(z),T=l.get(z);if(!O||!T)continue;const N=O.terminals.find(K=>K.id===C);if(!N)continue;const L=Oe([N.x,N.y],T),R=St(N.orientation,T),H=Pn(R),Y=[-H[1],H[0]];E.sort((K,V)=>K.elId.localeCompare(V.elId));const q=E.map(K=>Math.max(K.lib.width,qe));let ee=-q.reduce((K,V)=>K+V,0)/2;for(let K=0;K<E.length;K++){const V=E[K],J=q[K],ue=ee+J/2;ee+=J;const be=Ro[R],U=Rt(V.localTerm.orientation,be),te=Oe([V.localTerm.x,V.localTerm.y],{at:[0,0],rot:U,mirror:!1}),$e=[L[0]+H[0]*wt+Y[0]*ue,L[1]+H[1]*wt+Y[1]*ue],Se=[pe($e[0]-te[0]),pe($e[1]-te[1])];l.set(V.elId,{at:Se,rot:U,mirror:!1}),un=!0}}}const ht=y=>{const w=l.get(y),S=g(y);if(!w||!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:w.at[0]-N,max:w.at[0]+N}}const[j,_,M,z]=E,C=[[j,_],[j+M,_],[j,_+z],[j+M,_+z]];let O=1/0,T=-1/0;for(const N of C){const L=Oe(N,w);O=Math.min(O,L[0]),T=Math.max(T,L[0])}return{min:O,max:T}},fn=y=>{const w=new Set,S=g(y);if(!S)return w;for(const E of S.terminals){const j=`${y}.${E.id}`;for(const _ of k.get(j)??[])for(const M of _){if(M===j||$(M))continue;const z=M.indexOf(".");if(z<0)continue;const C=M.slice(0,z);C!==y&&w.add(C)}}return w},po=40,mn=y=>{const w=l.get(y),S=g(y);if(!w||!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:w.at[1]-N,max:w.at[1]+N}}const[j,_,M,z]=E,C=[[j,_],[j+M,_],[j,_+z],[j+M,_+z]];let O=1/0,T=-1/0;for(const N of C){const L=Oe(N,w);O=Math.min(O,L[1]),T=Math.max(T,L[1])}return{min:O,max:T}},uv=(y,w)=>{const S=new Set,E=[];for(const j of F.get(y)??[]){if($(j))continue;const _=j.indexOf(".");if(_<0)continue;const M=j.slice(0,_),z=l.get(M);!z||z.at[1]>=w-1||S.has(M)||(S.add(M),E.push(M))}for(;E.length>0;){const j=E.pop();for(const _ of fn(j)){if(S.has(_))continue;const M=l.get(_);!M||M.at[1]>=w-1||(S.add(_),E.push(_))}}return S},go=(y,w,S)=>{const E=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const M of fn(_))M===w||E.has(M)||!S.has(M)||(E.add(M),j.push(M))}return E},yo=(y,w)=>{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 M=_+1;M<y.length;M++){const z=y[_],C=y[M],O=ht(z),T=ht(C),N=mn(z),L=mn(C);if(!O||!T||!N||!L)continue;const R=Math.min(O.max,T.max)-Math.max(O.min,T.min),H=Math.min(N.max,L.max)-Math.max(N.min,L.min);if(R<=0||H<=0)continue;const Y=go(z,C,w),q=go(C,z,w);if(Y.has(C)||q.has(z))continue;const Q=![...Y].some(U=>u.has(U)),ee=![...q].some(U=>u.has(U));if(!Q&&!ee)continue;const K=(O.min+O.max)/2,V=(T.min+T.max)/2;let J,ue;Q&&(!ee||Y.size<=q.size)?(J=Y,ue=K<=V?-1:1):(J=q,ue=V<=K?-1:1);const be=pe(ue*(R+po));if(be!==0){for(const U of J){const te=l.get(U);te&&l.set(U,{...te,at:[te.at[0]+be,te.at[1]]})}E=!0,j=!0;break}}}return E};for(const y of n){const w=c.get(y.id);if(!w)continue;const S=uv(y.id,w.at[1]);if(S.size<2)continue;const E=[...S];if(yo(E,S)){let _=1/0,M=-1/0;for(const z of E){const C=ht(z);C&&(_=Math.min(_,C.min),M=Math.max(M,C.max))}if(Number.isFinite(_)){const C=E.some(T=>u.has(T))?0:pe(w.at[0]-(_+M)/2);if(C!==0)for(const T of E){const N=l.get(T);N&&l.set(T,{...N,at:[N.at[0]+C,N.at[1]]})}const O=M-_+po;if(O>w.span&&!m.has(y.id)){const T=c.get(y.id);c.set(y.id,{...T,span:O})}}}}const xo=()=>{const w=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:ht(E),y:mn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<w.length;E++)for(let j=E+1;j<w.length;j++){const _=Math.min(w[E].x.max,w[j].x.max)-Math.max(w[E].x.min,w[j].x.min),M=Math.min(w[E].y.max,w[j].y.max)-Math.max(w[E].y.min,w[j].y.min);_>1&&M>1&&S++}return S},fv=xo(),bo=new Map;for(const[y,w]of l)bo.set(y,{...w,at:[...w.at]});const wo=new Map;for(const[y,w]of c)wo.set(y,{...w,at:[...w.at]});const hn=120,vo=new Map;{const y=new Map,w=new Map,S=[];for(const j of n)for(const _ of F.get(j.id)??[]){if($(_))continue;const M=_.indexOf(".");if(M<0)continue;const z=_.slice(0,M);l.has(z)&&S.push({el:z,bus:j.id,d:1})}S.sort((j,_)=>j.d-_.d);let E=0;for(;E<S.length;){const{el:j,bus:_,d:M}=S[E++],z=y.get(j);if(z===void 0)y.set(j,M),w.set(j,_);else if(M===z&&w.get(j)!==_){w.set(j,null);continue}else continue;for(const C of fn(j))l.has(C)&&(y.has(C)||S.push({el:C,bus:_,d:M+1}))}for(const[j,_]of w)_&&vo.set(j,_)}for(const y of xe){const w=(ye.get(y)??[]).filter(O=>c.has(O));if(w.length<2||w.some(O=>m.has(O)))continue;const S=[];let E=0;for(const O of w){const T=c.get(O),N=[];let L=1/0,R=-1/0;for(const[H,Y]of vo){if(Y!==O)continue;const q=ht(H);q&&(N.push(H),L=Math.min(L,q.min),R=Math.max(R,q.max))}Number.isFinite(L)||(L=T.at[0]-ft/2,R=T.at[0]+ft/2),S.push({busId:O,min:L,max:R,members:N}),E+=R-L}if(S.some(O=>O.members.some(T=>u.has(T))))continue;let j=1/0,_=-1/0;for(const O of S)j=Math.min(j,O.min),_=Math.max(_,O.max);const M=_-j,z=E+hn*(S.length-1);if(!(M>z+hn))continue;S.sort((O,T)=>(O.min+O.max)/2-(T.min+T.max)/2);let C=j;for(const O of S){const T=pe(C-O.min);if(T!==0){const N=c.get(O.busId);c.set(O.busId,{...N,at:[N.at[0]+T,N.at[1]]});for(const L of O.members){const R=l.get(L);R&&l.set(L,{...R,at:[R.at[0]+T,R.at[1]]})}O.min+=T,O.max+=T}C=O.max+hn}for(const O of S){const T=c.get(O.busId),N=Math.max(ft,O.max-O.min);N<T.span&&c.set(O.busId,{...T,span:N})}}{const y=t.map(S=>S.id).filter(S=>l.has(S)),w=new Set(y);yo(y,w)}if(xo()>fv){l.clear();for(const[y,w]of bo)l.set(y,w);c.clear();for(const[y,w]of wo)c.set(y,w)}let pn=0;for(const y of t){if(l.has(y.id))continue;const w=pn%Fo,S=Math.floor(pn/Fo);l.set(y.id,{at:[pe(_2+w*S2),pe($2+S*j2)],rot:0,mirror:!1}),pn++}return{devices:l,buses:c,junctions:f}}function pe(e){return Math.round(e/Do)*Do}function N2(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=[Kt(f[0],p[0]-g,p[0]+g),p[1]];else{const $=Kt(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[Kt(t[0],i[0]-l,i[0]+l),i[1]];const c=Kt(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 Kt(e,t,n){return e<t?t:e>n?n:e}const fs="ammeter",ms="电流表 (A)",hs="measurement",ps="-22 -42 44 44",gs=44,ys=44,xs='<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>',bs=[{id:"t_top",x:0,y:-40,orientation:"n"}],ws={kind:"inline"},M2={id:fs,name:ms,category:hs,viewBox:ps,width:gs,height:ys,svg:xs,terminals:bs,source:ws},T2=Object.freeze(Object.defineProperty({__proto__:null,category:hs,default:M2,height:ys,id:fs,name:ms,source:ws,svg:xs,terminals:bs,viewBox:ps,width:gs},Symbol.toStringTag,{value:"Module"})),vs="arc-suppression-coil",ks="消弧线圈",_s="grounding",$s="中性点谐振接地:电感线圈连接到地",Ss="-12 -32 24 67",js=24,Es=67,Ns='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',Ms=[{id:"t_top",x:0,y:-30,orientation:"n"}],Ts={kind:"inline"},A2={id:vs,name:ks,category:_s,description:$s,viewBox:Ss,width:js,height:Es,svg:Ns,terminals:Ms,source:Ts},I2=Object.freeze(Object.defineProperty({__proto__:null,category:_s,default:A2,description:$s,height:Es,id:vs,name:ks,source:Ts,svg:Ns,terminals:Ms,viewBox:Ss,width:js},Symbol.toStringTag,{value:"Module"})),As="arrester",Is="避雷器 (FBL)",Cs="protection",Os="-7 -22 14 44",Ps=14,Bs=44,Ls='<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"/>',Rs=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],zs={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},C2={id:As,name:Is,category:Cs,viewBox:Os,width:Ps,height:Bs,svg:Ls,terminals:Rs,source:zs},O2=Object.freeze(Object.defineProperty({__proto__:null,category:Cs,default:C2,height:Bs,id:As,name:Is,source:zs,svg:Ls,terminals:Rs,viewBox:Os,width:Ps},Symbol.toStringTag,{value:"Module"})),Ds="async-motor",Fs="异步电动机",Hs="load",Ws="-62 -82 64 84",qs=64,Gs=84,Xs='<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"/>',Ys=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Ks={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},P2={id:Ds,name:Fs,category:Hs,viewBox:Ws,width:qs,height:Gs,svg:Xs,terminals:Ys,source:Ks},B2=Object.freeze(Object.defineProperty({__proto__:null,category:Hs,default:P2,height:Gs,id:Ds,name:Fs,source:Ks,svg:Xs,terminals:Ys,viewBox:Ws,width:qs},Symbol.toStringTag,{value:"Module"})),Vs="autotransformer",Us="自耦变压器",Js="transformer",Zs="-62 -112 64 144",Qs=64,ei=144,ti='<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"/>',ni=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],oi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},L2={id:Vs,name:Us,category:Js,viewBox:Zs,width:Qs,height:ei,svg:ti,terminals:ni,source:oi},R2=Object.freeze(Object.defineProperty({__proto__:null,category:Js,default:L2,height:ei,id:Vs,name:Us,source:oi,svg:ti,terminals:ni,viewBox:Zs,width:Qs},Symbol.toStringTag,{value:"Module"})),ri="battery",si="电池储能",ii="storage",ai="-12 -12 29 24",li=29,ci=24,di='<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"/>',ui=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],fi=[{name:"E",label:"容量",type:"number",unit:"kWh"}],mi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},z2={id:ri,name:si,category:ii,viewBox:ai,width:li,height:ci,svg:di,terminals:ui,params:fi,source:mi},D2=Object.freeze(Object.defineProperty({__proto__:null,category:ii,default:z2,height:ci,id:ri,name:si,params:fi,source:mi,svg:di,terminals:ui,viewBox:ai,width:li},Symbol.toStringTag,{value:"Module"})),hi="bell",pi="电铃 (HA)",gi="control",yi="信号电铃 / 警铃。",xi="-32 -32 44 44",bi=44,wi=44,vi='<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"/>',ki=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],_i={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},F2={id:hi,name:pi,category:gi,description:yi,viewBox:xi,width:bi,height:wi,svg:vi,terminals:ki,source:_i},H2=Object.freeze(Object.defineProperty({__proto__:null,category:gi,default:F2,description:yi,height:wi,id:hi,name:pi,source:_i,svg:vi,terminals:ki,viewBox:xi,width:bi},Symbol.toStringTag,{value:"Module"})),$i="break-contact",Si="常闭触点 (NC)",ji="control",Ei="常闭辅助触点 (break contact)。",Ni="-2 -42 14 64",Mi=14,Ti=64,Ai='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',Ii=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ci=[{name:"open",type:"boolean",default:!1,label:"断开"}],Oi={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},W2={id:$i,name:Si,category:ji,description:Ei,viewBox:Ni,width:Mi,height:Ti,svg:Ai,terminals:Ii,state:Ci,source:Oi},q2=Object.freeze(Object.defineProperty({__proto__:null,category:ji,default:W2,description:Ei,height:Ti,id:$i,name:Si,source:Oi,state:Ci,svg:Ai,terminals:Ii,viewBox:Ni,width:Mi},Symbol.toStringTag,{value:"Module"})),Pi="breaker",Bi="断路器 (QF)",Li="switching",Ri="-7 -22 15 46",zi=15,Di=46,Fi='<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"/>',Hi='<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>',Wi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],qi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Gi={x:6,y:-2,anchor:"start"},Xi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},G2={id:Pi,name:Bi,category:Li,viewBox:Ri,width:zi,height:Di,svg:Fi,terminalLabelsSvg:Hi,terminals:Wi,state:qi,label:Gi,source:Xi},X2=Object.freeze(Object.defineProperty({__proto__:null,category:Li,default:G2,height:Di,id:Pi,label:Gi,name:Bi,source:Xi,state:qi,svg:Fi,terminalLabelsSvg:Hi,terminals:Wi,viewBox:Ri,width:zi},Symbol.toStringTag,{value:"Module"})),Yi="buchholz-relay",Ki="瓦斯继电器 (63)",Vi="protection",Ui="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Ji="-22 -62 44 64",Zi=44,Qi=64,ea='<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"/>',ta=[{id:"t_top",x:0,y:-60,orientation:"n"}],na={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"},Y2={id:Yi,name:Ki,category:Vi,description:Ui,viewBox:Ji,width:Zi,height:Qi,svg:ea,terminals:ta,source:na},K2=Object.freeze(Object.defineProperty({__proto__:null,category:Vi,default:Y2,description:Ui,height:Qi,id:Yi,name:Ki,source:na,svg:ea,terminals:ta,viewBox:Ji,width:Zi},Symbol.toStringTag,{value:"Module"})),oa="busbar",ra="母线段",sa="busbar",ia="可拉伸单母线段,多设备挂接",aa="-42 -4 84 8",la=84,ca=8,da='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',ua=[{id:"tap",x:0,y:0,orientation:"n"}],fa={axis:"x",minLength:20,naturalSpan:80},ma=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],ha={x:0,y:-6,anchor:"middle"},pa={kind:"inline"},V2={id:oa,name:ra,category:sa,description:ia,viewBox:aa,width:la,height:ca,svg:da,terminals:ua,stretchable:fa,params:ma,label:ha,source:pa},U2=Object.freeze(Object.defineProperty({__proto__:null,category:sa,default:V2,description:ia,height:ca,id:oa,label:ha,name:ra,params:ma,source:pa,stretchable:fa,svg:da,terminals:ua,viewBox:aa,width:la},Symbol.toStringTag,{value:"Module"})),ga="buzzer",ya="蜂鸣器 (HA)",xa="control",ba="信号蜂鸣器。",wa="-32 -52 44 64",va=44,ka=64,_a='<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"/>',$a=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Sa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},J2={id:ga,name:ya,category:xa,description:ba,viewBox:wa,width:va,height:ka,svg:_a,terminals:$a,source:Sa},Z2=Object.freeze(Object.defineProperty({__proto__:null,category:xa,default:J2,description:ba,height:ka,id:ga,name:ya,source:Sa,svg:_a,terminals:$a,viewBox:wa,width:va},Symbol.toStringTag,{value:"Module"})),ja="capacitor",Ea="电容 (C)",Na="passive",Ma="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",Ta="-7 -23 14 27",Aa=14,Ia=27,Ca='<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"/>',Oa=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Pa=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Ba={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},Q2={id:ja,name:Ea,category:Na,description:Ma,viewBox:Ta,width:Aa,height:Ia,svg:Ca,terminals:Oa,params:Pa,source:Ba},ek=Object.freeze(Object.defineProperty({__proto__:null,category:Na,default:Q2,description:Ma,height:Ia,id:ja,name:Ea,params:Pa,source:Ba,svg:Ca,terminals:Oa,viewBox:Ta,width:Aa},Symbol.toStringTag,{value:"Module"})),La="contactor",Ra="接触器 (KM)",za="motor-control",Da="主回路接触器, 通常配热继电器和电机使用。",Fa="-10 -42 15 64",Ha=15,Wa=64,qa='<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"/>',Ga=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Xa=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ya={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"},tk={id:La,name:Ra,category:za,description:Da,viewBox:Fa,width:Ha,height:Wa,svg:qa,terminals:Ga,state:Xa,source:Ya},nk=Object.freeze(Object.defineProperty({__proto__:null,category:za,default:tk,description:Da,height:Wa,id:La,name:Ra,source:Ya,state:Xa,svg:qa,terminals:Ga,viewBox:Fa,width:Ha},Symbol.toStringTag,{value:"Module"})),Ka="converter-bidir",Va="双向变流器 (PCS)",Ua="renewable",Ja="储能变流器:双向 AC ↔ DC",Za="-42 -42 44 48",Qa=44,el=48,tl='<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"/>',nl=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],ol=[{name:"S",label:"容量",type:"number",unit:"MVA"}],rl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},ok={id:Ka,name:Va,category:Ua,description:Ja,viewBox:Za,width:Qa,height:el,svg:tl,terminals:nl,params:ol,source:rl},rk=Object.freeze(Object.defineProperty({__proto__:null,category:Ua,default:ok,description:Ja,height:el,id:Ka,name:Va,params:ol,source:rl,svg:tl,terminals:nl,viewBox:Za,width:Qa},Symbol.toStringTag,{value:"Module"})),sl="ct",il="电流互感器 (CT)",al="instrument-transformer",ll="-42 -62 54 64",cl=54,dl=64,ul='<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"/>',fl=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],ml={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},sk={id:sl,name:il,category:al,viewBox:ll,width:cl,height:dl,svg:ul,terminals:fl,source:ml},ik=Object.freeze(Object.defineProperty({__proto__:null,category:al,default:sk,height:dl,id:sl,name:il,source:ml,svg:ul,terminals:fl,viewBox:ll,width:cl},Symbol.toStringTag,{value:"Module"})),hl="dc-combiner",pl="直流汇流箱",gl="renewable",yl="光伏组串汇流箱 (4 路输入示例)。",xl="-27 -32 54 64",bl=54,wl=64,vl='<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>',kl=[{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"}],_l={kind:"inline"},ak={id:hl,name:pl,category:gl,description:yl,viewBox:xl,width:bl,height:wl,svg:vl,terminals:kl,source:_l},lk=Object.freeze(Object.defineProperty({__proto__:null,category:gl,default:ak,description:yl,height:wl,id:hl,name:pl,source:_l,svg:vl,terminals:kl,viewBox:xl,width:bl},Symbol.toStringTag,{value:"Module"})),$l="dc-disconnector",Sl="直流隔离开关",jl="switching",El="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",Nl="-12 -32 30 64",Ml=30,Tl=64,Al='<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"/>',Il=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Cl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ol={kind:"inline"},ck={id:$l,name:Sl,category:jl,description:El,viewBox:Nl,width:Ml,height:Tl,svg:Al,terminals:Il,state:Cl,source:Ol},dk=Object.freeze(Object.defineProperty({__proto__:null,category:jl,default:ck,description:El,height:Tl,id:$l,name:Sl,source:Ol,state:Cl,svg:Al,terminals:Il,viewBox:Nl,width:Ml},Symbol.toStringTag,{value:"Module"})),Pl="dc-motor",Bl="直流电机 (M)",Ll="load",Rl="直流电动机 (串励通用符号)。",zl="-72 -82 89 84",Dl=89,Fl=84,Hl='<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"/>',Wl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],ql={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},uk={id:Pl,name:Bl,category:Ll,description:Rl,viewBox:zl,width:Dl,height:Fl,svg:Hl,terminals:Wl,source:ql},fk=Object.freeze(Object.defineProperty({__proto__:null,category:Ll,default:uk,description:Rl,height:Fl,id:Pl,name:Bl,source:ql,svg:Hl,terminals:Wl,viewBox:zl,width:Dl},Symbol.toStringTag,{value:"Module"})),Gl="diode",Xl="二极管 (D)",Yl="passive",Kl="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Vl="-12 -42 24 44",Ul=24,Jl=44,Zl='<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"/>',Ql=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],ec={x:6,y:-20,anchor:"start"},tc={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},mk={id:Gl,name:Xl,category:Yl,description:Kl,viewBox:Vl,width:Ul,height:Jl,svg:Zl,terminals:Ql,label:ec,source:tc},hk=Object.freeze(Object.defineProperty({__proto__:null,category:Yl,default:mk,description:Kl,height:Jl,id:Gl,label:ec,name:Xl,source:tc,svg:Zl,terminals:Ql,viewBox:Vl,width:Ul},Symbol.toStringTag,{value:"Module"})),nc="disconnector",oc="隔离开关 (QS)",rc="switching",sc="-10 -42 15 64",ic=15,ac=64,lc='<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"/>',cc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],dc=[{name:"open",type:"boolean",default:!1,label:"断开"}],uc={x:6,y:-10,anchor:"start"},fc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},pk={id:nc,name:oc,category:rc,viewBox:sc,width:ic,height:ac,svg:lc,terminals:cc,state:dc,label:uc,source:fc},gk=Object.freeze(Object.defineProperty({__proto__:null,category:rc,default:pk,height:ac,id:nc,label:uc,name:oc,source:fc,state:dc,svg:lc,terminals:cc,viewBox:sc,width:ic},Symbol.toStringTag,{value:"Module"})),mc="distance-relay",hc="距离继电器 (21)",pc="protection",gc="距离 / 低阻抗保护继电器 (ANSI 21)。",yc="-62 -42 64 44",xc=64,bc=44,wc='<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>',vc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],kc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},yk={id:mc,name:hc,category:pc,description:gc,viewBox:yc,width:xc,height:bc,svg:wc,terminals:vc,source:kc},xk=Object.freeze(Object.defineProperty({__proto__:null,category:pc,default:yk,description:gc,height:bc,id:mc,name:hc,source:kc,svg:wc,terminals:vc,viewBox:yc,width:xc},Symbol.toStringTag,{value:"Module"})),_c="earth",$c="接地",Sc="busbar",jc="-12 -17 24 34",Ec=24,Nc=34,Mc='<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"/>',Tc=[{id:"t1",x:0,y:-15,orientation:"n"}],Ac={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"},bk={id:_c,name:$c,category:Sc,viewBox:jc,width:Ec,height:Nc,svg:Mc,terminals:Tc,source:Ac},wk=Object.freeze(Object.defineProperty({__proto__:null,category:Sc,default:bk,height:Nc,id:_c,name:$c,source:Ac,svg:Mc,terminals:Tc,viewBox:jc,width:Ec},Symbol.toStringTag,{value:"Module"})),Ic="earthing-switch",Cc="接地刀闸 (QE)",Oc="switching",Pc="隔离开关 + 接地连接,单端口",Bc="-12 -32 24 64",Lc=24,Rc=64,zc='<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"/>',Dc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Fc=[{name:"open",type:"boolean",default:!0,label:"断开"}],Hc={x:12,y:-8,anchor:"start"},Wc={kind:"inline"},vk={id:Ic,name:Cc,category:Oc,description:Pc,viewBox:Bc,width:Lc,height:Rc,svg:zc,terminals:Dc,state:Fc,label:Hc,source:Wc},kk=Object.freeze(Object.defineProperty({__proto__:null,category:Oc,default:vk,description:Pc,height:Rc,id:Ic,label:Hc,name:Cc,source:Wc,state:Fc,svg:zc,terminals:Dc,viewBox:Bc,width:Lc},Symbol.toStringTag,{value:"Module"})),qc="energy-meter",Gc="电能表 (Wh)",Xc="measurement",Yc="有功电能表 (kWh) — 服务入口 / 子表。",Kc="-22 -36 44 72",Vc=44,Uc=72,Jc='<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"/>',Zc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Qc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},_k={id:qc,name:Gc,category:Xc,description:Yc,viewBox:Kc,width:Vc,height:Uc,svg:Jc,terminals:Zc,source:Qc},$k=Object.freeze(Object.defineProperty({__proto__:null,category:Xc,default:_k,description:Yc,height:Uc,id:qc,name:Gc,source:Qc,svg:Jc,terminals:Zc,viewBox:Kc,width:Vc},Symbol.toStringTag,{value:"Module"})),ed="ev-charger",td="EV 充电桩",nd="load",od="电动汽车充电站 / 充电桩。",rd="-17 -27 34 49",sd=34,id=49,ad='<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>',ld=[{id:"t_top",x:0,y:-25,orientation:"n"}],cd={kind:"inline"},Sk={id:ed,name:td,category:nd,description:od,viewBox:rd,width:sd,height:id,svg:ad,terminals:ld,source:cd},jk=Object.freeze(Object.defineProperty({__proto__:null,category:nd,default:Sk,description:od,height:id,id:ed,name:td,source:cd,svg:ad,terminals:ld,viewBox:rd,width:sd},Symbol.toStringTag,{value:"Module"})),dd="frequency-meter",ud="频率表 (Hz)",fd="measurement",md="-22 -42 44 44",hd=44,pd=44,gd='<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>',yd=[{id:"t_top",x:0,y:-40,orientation:"n"}],xd={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},Ek={id:dd,name:ud,category:fd,viewBox:md,width:hd,height:pd,svg:gd,terminals:yd,source:xd},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:fd,default:Ek,height:pd,id:dd,name:ud,source:xd,svg:gd,terminals:yd,viewBox:md,width:hd},Symbol.toStringTag,{value:"Module"})),bd="fuse-switch-disconnector",wd="熔断器式隔离开关",vd="switching",kd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",_d="-8 -32 12 64",$d=12,Sd=64,jd='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',Ed=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Nd=[{name:"open",type:"boolean",default:!1,label:"断开"}],Md={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:bd,name:wd,category:vd,description:kd,viewBox:_d,width:$d,height:Sd,svg:jd,terminals:Ed,state:Nd,source:Md},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:vd,default:Mk,description:kd,height:Sd,id:bd,name:wd,source:Md,state:Nd,svg:jd,terminals:Ed,viewBox:_d,width:$d},Symbol.toStringTag,{value:"Module"})),Td="fuse",Ad="熔断器 (FU)",Id="switching",Cd="-7 -32 14 64",Od=14,Pd=64,Bd='<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"/>',Ld=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Rd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],zd={x:7,y:-2,anchor:"start"},Dd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},Ak={id:Td,name:Ad,category:Id,viewBox:Cd,width:Od,height:Pd,svg:Bd,terminals:Ld,state:Rd,label:zd,source:Dd},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:Id,default:Ak,height:Pd,id:Td,label:zd,name:Ad,source:Dd,state:Rd,svg:Bd,terminals:Ld,viewBox:Cd,width:Od},Symbol.toStringTag,{value:"Module"})),Fd="generator",Hd="发电机 (G)",Wd="source",qd="-42 -42 44 44",Gd=44,Xd=44,Yd='<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>',Kd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Vd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},Ck={id:Fd,name:Hd,category:Wd,viewBox:qd,width:Gd,height:Xd,svg:Yd,terminals:Kd,source:Vd},Ok=Object.freeze(Object.defineProperty({__proto__:null,category:Wd,default:Ck,height:Xd,id:Fd,name:Hd,source:Vd,svg:Yd,terminals:Kd,viewBox:qd,width:Gd},Symbol.toStringTag,{value:"Module"})),Ud="genset",Jd="发电机组 (G)",Zd="source",Qd="柴油 / 燃气发电机组。",eu="-28 -22 56 64",tu=56,nu=64,ou='<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"/>',ru=[{id:"t_out",x:0,y:40,orientation:"s"}],su=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],iu={kind:"inline"},Pk={id:Ud,name:Jd,category:Zd,description:Qd,viewBox:eu,width:tu,height:nu,svg:ou,terminals:ru,params:su,source:iu},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:Zd,default:Pk,description:Qd,height:nu,id:Ud,name:Jd,params:su,source:iu,svg:ou,terminals:ru,viewBox:eu,width:tu},Symbol.toStringTag,{value:"Module"})),au="gfci-breaker",lu="GFCI 断路器 (RCBO)",cu="protection",du="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",uu="-18 -22 22 44",fu=22,mu=44,hu='<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"/>',pu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],gu=[{name:"open",type:"boolean",default:!1,label:"断开"}],yu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],xu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Lk={id:au,name:lu,category:cu,description:du,viewBox:uu,width:fu,height:mu,svg:hu,terminals:pu,state:gu,params:yu,source:xu},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:cu,default:Lk,description:du,height:mu,id:au,name:lu,params:yu,source:xu,state:gu,svg:hu,terminals:pu,viewBox:uu,width:fu},Symbol.toStringTag,{value:"Module"})),bu="grid-source",wu="系统电源",vu="source",ku="无穷大母线 / 外部电网",_u="-16 -31 32 53",$u=32,Su=53,ju='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',Eu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Nu={kind:"inline"},zk={id:bu,name:wu,category:vu,description:ku,viewBox:_u,width:$u,height:Su,svg:ju,terminals:Eu,source:Nu},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:vu,default:zk,description:ku,height:Su,id:bu,name:wu,source:Nu,svg:ju,terminals:Eu,viewBox:_u,width:$u},Symbol.toStringTag,{value:"Module"})),Mu="grounding-transformer",Tu="接地变 (Z形)",Au="grounding",Iu="星-曲折接线变压器,中性点接地用",Cu="-62 -152 64 164",Ou=64,Pu=164,Bu='<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"/>',Lu=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Ru={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"},Fk={id:Mu,name:Tu,category:Au,description:Iu,viewBox:Cu,width:Ou,height:Pu,svg:Bu,terminals:Lu,source:Ru},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:Au,default:Fk,description:Iu,height:Pu,id:Mu,name:Tu,source:Ru,svg:Bu,terminals:Lu,viewBox:Cu,width:Ou},Symbol.toStringTag,{value:"Module"})),zu="heater",Du="电加热器 (EH)",Fu="load",Hu="电阻加热元件 / 电热负荷。",Wu="-22 -7 54 14",qu=54,Gu=14,Xu='<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"/>',Yu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Ku=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Vu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},Wk={id:zu,name:Du,category:Fu,description:Hu,viewBox:Wu,width:qu,height:Gu,svg:Xu,terminals:Yu,params:Ku,source:Vu},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Fu,default:Wk,description:Hu,height:Gu,id:zu,name:Du,params:Ku,source:Vu,svg:Xu,terminals:Yu,viewBox:Wu,width:qu},Symbol.toStringTag,{value:"Module"})),Uu="igbt",Ju="绝缘栅双极晶体管 (IGBT)",Zu="passive",Qu="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",ef="-32 -32 54 74",tf=54,nf=74,of='<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"/>',rf=[{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"}],sf={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"},Gk={id:Uu,name:Ju,category:Zu,description:Qu,viewBox:ef,width:tf,height:nf,svg:of,terminals:rf,source:sf},Xk=Object.freeze(Object.defineProperty({__proto__:null,category:Zu,default:Gk,description:Qu,height:nf,id:Uu,name:Ju,source:sf,svg:of,terminals:rf,viewBox:ef,width:tf},Symbol.toStringTag,{value:"Module"})),af="indicator-light",lf="指示灯 (HL)",cf="control",df="信号 / 状态指示灯。",uf="-12 -22 24 24",ff=24,mf=24,hf='<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"/>',pf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],gf=[{name:"color",label:"颜色",type:"string"}],yf={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},Yk={id:af,name:lf,category:cf,description:df,viewBox:uf,width:ff,height:mf,svg:hf,terminals:pf,params:gf,source:yf},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:cf,default:Yk,description:df,height:mf,id:af,name:lf,params:gf,source:yf,svg:hf,terminals:pf,viewBox:uf,width:ff},Symbol.toStringTag,{value:"Module"})),xf="inductor",bf="电感 (L)",wf="passive",vf="通用电感 / 线圈 / 扼流圈。",kf="-17 -32 34 64",_f=34,$f=64,Sf='<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"/>',jf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Ef=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],Nf={x:6,y:0,anchor:"start"},Mf={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Vk={id:xf,name:bf,category:wf,description:vf,viewBox:kf,width:_f,height:$f,svg:Sf,terminals:jf,params:Ef,label:Nf,source:Mf},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:wf,default:Vk,description:vf,height:$f,id:xf,label:Nf,name:bf,params:Ef,source:Mf,svg:Sf,terminals:jf,viewBox:kf,width:_f},Symbol.toStringTag,{value:"Module"})),Tf="inverter",Af="逆变器 (DC→AC)",If="renewable",Cf="-42 -42 44 44",Of=44,Pf=44,Bf='<g transform="matrix(1 0 0 -1 0 -40)"><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"/></g>',Lf=[{id:"t_dc",x:-20,y:0,orientation:"s"},{id:"t_ac",x:-20,y:-40,orientation:"n"}],Rf={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Jk={id:Tf,name:Af,category:If,viewBox:Cf,width:Of,height:Pf,svg:Bf,terminals:Lf,source:Rf},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:If,default:Jk,height:Pf,id:Tf,name:Af,source:Rf,svg:Bf,terminals:Lf,viewBox:Cf,width:Of},Symbol.toStringTag,{value:"Module"})),zf="limit-switch",Df="限位开关 (SQ)",Ff="control",Hf="行程 / 位置开关 (常开, 机械操作)。",Wf="-10 -42 12 64",qf=12,Gf=64,Xf='<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"/>',Yf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Kf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Vf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Qk={id:zf,name:Df,category:Ff,description:Hf,viewBox:Wf,width:qf,height:Gf,svg:Xf,terminals:Yf,state:Kf,source:Vf},e_=Object.freeze(Object.defineProperty({__proto__:null,category:Ff,default:Qk,description:Hf,height:Gf,id:zf,name:Df,source:Vf,state:Kf,svg:Xf,terminals:Yf,viewBox:Wf,width:qf},Symbol.toStringTag,{value:"Module"})),Uf="load-switch",Jf="负荷开关",Zf="switching",Qf="-10 -42 14 64",em=14,tm=64,nm='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',om=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],rm=[{name:"open",type:"boolean",default:!1,label:"断开"}],sm={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"},t_={id:Uf,name:Jf,category:Zf,viewBox:Qf,width:em,height:tm,svg:nm,terminals:om,state:rm,source:sm},n_=Object.freeze(Object.defineProperty({__proto__:null,category:Zf,default:t_,height:tm,id:Uf,name:Jf,source:sm,state:rm,svg:nm,terminals:om,viewBox:Qf,width:em},Symbol.toStringTag,{value:"Module"})),im="load",am="负荷",lm="load",cm="抽象负荷(电流流出箭头)",dm="-8 -22 16 46",um=16,fm=46,mm='<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"/>',hm=[{id:"t_top",x:0,y:-20,orientation:"n"}],pm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],gm={x:6,y:0,anchor:"start"},ym={kind:"inline"},o_={id:im,name:am,category:lm,description:cm,viewBox:dm,width:um,height:fm,svg:mm,terminals:hm,params:pm,label:gm,source:ym},r_=Object.freeze(Object.defineProperty({__proto__:null,category:lm,default:o_,description:cm,height:fm,id:im,label:gm,name:am,params:pm,source:ym,svg:mm,terminals:hm,viewBox:dm,width:um},Symbol.toStringTag,{value:"Module"})),xm="make-contact",bm="常开触点 (NO)",wm="control",vm="常开辅助触点 (make contact)。",km="-10 -42 12 64",_m=12,$m=64,Sm='<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"/>',jm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Em=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Nm={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"},s_={id:xm,name:bm,category:wm,description:vm,viewBox:km,width:_m,height:$m,svg:Sm,terminals:jm,state:Em,source:Nm},i_=Object.freeze(Object.defineProperty({__proto__:null,category:wm,default:s_,description:vm,height:$m,id:xm,name:bm,source:Nm,state:Em,svg:Sm,terminals:jm,viewBox:km,width:_m},Symbol.toStringTag,{value:"Module"})),Mm="motor-starter",Tm="电机启动器",Am="motor-control",Im="电机启动器 (IEC 60617 通用符号)。",Cm="-22 -27 44 54",Om=44,Pm=54,Bm='<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"/>',Lm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Rm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},a_={id:Mm,name:Tm,category:Am,description:Im,viewBox:Cm,width:Om,height:Pm,svg:Bm,terminals:Lm,source:Rm},l_=Object.freeze(Object.defineProperty({__proto__:null,category:Am,default:a_,description:Im,height:Pm,id:Mm,name:Tm,source:Rm,svg:Bm,terminals:Lm,viewBox:Cm,width:Om},Symbol.toStringTag,{value:"Module"})),zm="ngr",Dm="中性点电阻 (NGR)",Fm="grounding",Hm="小电阻接地:连接变压器中性点到地",Wm="-12 -32 24 62",qm=24,Gm=62,Xm='<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"/>',Ym=[{id:"t_top",x:0,y:-30,orientation:"n"}],Km=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Vm={kind:"inline"},c_={id:zm,name:Dm,category:Fm,description:Hm,viewBox:Wm,width:qm,height:Gm,svg:Xm,terminals:Ym,params:Km,source:Vm},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Fm,default:c_,description:Hm,height:Gm,id:zm,name:Dm,params:Km,source:Vm,svg:Xm,terminals:Ym,viewBox:Wm,width:qm},Symbol.toStringTag,{value:"Module"})),Um="overcurrent-relay",Jm="过流继电器 (50/51)",Zm="protection",Qm="过电流保护继电器 (ANSI 50/51)。",eh="-62 -62 64 64",th=64,nh=64,oh='<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>',rh=[{id:"t_top",x:-30,y:-60,orientation:"n"}],sh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},u_={id:Um,name:Jm,category:Zm,description:Qm,viewBox:eh,width:th,height:nh,svg:oh,terminals:rh,source:sh},f_=Object.freeze(Object.defineProperty({__proto__:null,category:Zm,default:u_,description:Qm,height:nh,id:Um,name:Jm,source:sh,svg:oh,terminals:rh,viewBox:eh,width:th},Symbol.toStringTag,{value:"Module"})),ih="panelboard",ah="配电箱",lh="load",ch="配电箱 / 负荷中心(IEC 60617 分配中心符号):底部进线,箱顶分路示意",dh="-52 -62 54 64",uh=54,fh=64,mh='<rect x="-50" y="-40" width="50" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-60" x2="-40" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-60" x2="-30" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-60" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-60" x2="-10" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-20" x2="-25" y2="0" fill="none" stroke="black" stroke-width="1"/>',hh=[{id:"t_in",x:-25,y:0,orientation:"s"}],ph={kind:"elmt",path:"91_en_60617/en_60617_11/en_60617_11_12/en_60617_11_12_07.elmt",qetEnglishName:"Distribution centre"},m_={id:ih,name:ah,category:lh,description:ch,viewBox:dh,width:uh,height:fh,svg:mh,terminals:hh,source:ph},h_=Object.freeze(Object.defineProperty({__proto__:null,category:lh,default:m_,description:ch,height:fh,id:ih,name:ah,source:ph,svg:mh,terminals:hh,viewBox:dh,width:uh},Symbol.toStringTag,{value:"Module"})),gh="phase-failure-relay",yh="断相继电器",xh="protection",bh="断相 / 缺相保护继电器。",wh="-62 -42 64 44",vh=64,kh=44,_h='<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>',$h=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Sh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},p_={id:gh,name:yh,category:xh,description:bh,viewBox:wh,width:vh,height:kh,svg:_h,terminals:$h,source:Sh},g_=Object.freeze(Object.defineProperty({__proto__:null,category:xh,default:p_,description:bh,height:kh,id:gh,name:yh,source:Sh,svg:_h,terminals:$h,viewBox:wh,width:vh},Symbol.toStringTag,{value:"Module"})),jh="plc",Eh="PLC / 控制器",Nh="control",Mh="可编程逻辑控制器 (PLC)。",Th="-24 -42 48 84",Ah=48,Ih=84,Ch='<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"/>',Oh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],Ph={kind:"inline"},y_={id:jh,name:Eh,category:Nh,description:Mh,viewBox:Th,width:Ah,height:Ih,svg:Ch,terminals:Oh,source:Ph},x_=Object.freeze(Object.defineProperty({__proto__:null,category:Nh,default:y_,description:Mh,height:Ih,id:jh,name:Eh,source:Ph,svg:Ch,terminals:Oh,viewBox:Th,width:Ah},Symbol.toStringTag,{value:"Module"})),Bh="power-factor-meter",Lh="功率因数表 (cosφ)",Rh="measurement",zh="功率因数表 (cosφ)。",Dh="-22 -42 44 44",Fh=44,Hh=44,Wh='<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>',qh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Gh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},b_={id:Bh,name:Lh,category:Rh,description:zh,viewBox:Dh,width:Fh,height:Hh,svg:Wh,terminals:qh,source:Gh},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Rh,default:b_,description:zh,height:Hh,id:Bh,name:Lh,source:Gh,svg:Wh,terminals:qh,viewBox:Dh,width:Fh},Symbol.toStringTag,{value:"Module"})),Xh="power-supply",Yh="开关电源 (PS)",Kh="source",Vh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Uh="-24 -42 48 84",Jh=48,Zh=84,Qh='<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"/>',e0=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],t0=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],n0={kind:"inline"},v_={id:Xh,name:Yh,category:Kh,description:Vh,viewBox:Uh,width:Jh,height:Zh,svg:Qh,terminals:e0,params:t0,source:n0},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Kh,default:v_,description:Vh,height:Zh,id:Xh,name:Yh,params:t0,source:n0,svg:Qh,terminals:e0,viewBox:Uh,width:Jh},Symbol.toStringTag,{value:"Module"})),o0="protective-relay",r0="保护继电器",s0="protection",i0="测量继电器 / 保护继电器通用符号 (IEC 60617)。",a0="-32 -42 64 44",l0=64,c0=44,d0='<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"/>',u0=[{id:"t_top",x:0,y:-40,orientation:"n"}],f0={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"},__={id:o0,name:r0,category:s0,description:i0,viewBox:a0,width:l0,height:c0,svg:d0,terminals:u0,source:f0},$_=Object.freeze(Object.defineProperty({__proto__:null,category:s0,default:__,description:i0,height:c0,id:o0,name:r0,source:f0,svg:d0,terminals:u0,viewBox:a0,width:l0},Symbol.toStringTag,{value:"Module"})),m0="proximity-switch",h0="接近开关 (SQ)",p0="control",g0="接近传感器 / 无触点接近开关。",y0="-12 -32 24 64",x0=24,b0=64,w0='<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"/>',v0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],k0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},S_={id:m0,name:h0,category:p0,description:g0,viewBox:y0,width:x0,height:b0,svg:w0,terminals:v0,source:k0},j_=Object.freeze(Object.defineProperty({__proto__:null,category:p0,default:S_,description:g0,height:b0,id:m0,name:h0,source:k0,svg:w0,terminals:v0,viewBox:y0,width:x0},Symbol.toStringTag,{value:"Module"})),_0="pt",$0="电压互感器 (PT)",S0="instrument-transformer",j0="-22 -42 44 115",E0=44,N0=115,M0='<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"/>',T0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],A0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},E_={id:_0,name:$0,category:S0,viewBox:j0,width:E0,height:N0,svg:M0,terminals:T0,source:A0},N_=Object.freeze(Object.defineProperty({__proto__:null,category:S0,default:E_,height:N0,id:_0,name:$0,source:A0,svg:M0,terminals:T0,viewBox:j0,width:E0},Symbol.toStringTag,{value:"Module"})),I0="push-button",C0="按钮 (SB)",O0="control",P0="手动按钮, 自动复位 (常开 make)。",B0="-37 -42 39 64",L0=39,R0=64,z0='<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"/>',D0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],F0={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"},M_={id:I0,name:C0,category:O0,description:P0,viewBox:B0,width:L0,height:R0,svg:z0,terminals:D0,source:F0},T_=Object.freeze(Object.defineProperty({__proto__:null,category:O0,default:M_,description:P0,height:R0,id:I0,name:C0,source:F0,svg:z0,terminals:D0,viewBox:B0,width:L0},Symbol.toStringTag,{value:"Module"})),H0="pv",W0="光伏组件",q0="renewable",G0="-33 -22 85 64",X0=85,Y0=64,K0='<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"/>',V0=[{id:"t_dc",x:50,y:10,orientation:"e"}],U0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},A_={id:H0,name:W0,category:q0,viewBox:G0,width:X0,height:Y0,svg:K0,terminals:V0,source:U0},I_=Object.freeze(Object.defineProperty({__proto__:null,category:q0,default:A_,height:Y0,id:H0,name:W0,source:U0,svg:K0,terminals:V0,viewBox:G0,width:X0},Symbol.toStringTag,{value:"Module"})),J0="rcd",Z0="剩余电流装置 (RCD)",Q0="protection",ep="不带过流保护的剩余电流断路器 (IEC 61008)。",tp="-12 -22 19 44",np=19,op=44,rp='<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"/>',sp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ip=[{name:"open",type:"boolean",default:!1,label:"断开"}],ap=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],lp={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},C_={id:J0,name:Z0,category:Q0,description:ep,viewBox:tp,width:np,height:op,svg:rp,terminals:sp,state:ip,params:ap,source:lp},O_=Object.freeze(Object.defineProperty({__proto__:null,category:Q0,default:C_,description:ep,height:op,id:J0,name:Z0,params:ap,source:lp,state:ip,svg:rp,terminals:sp,viewBox:tp,width:np},Symbol.toStringTag,{value:"Module"})),cp="recloser",dp="重合闸 (Recloser)",up="protection",fp="中压自动重合闸开关。",mp="-12 -32 36 64",hp=36,pp=64,gp='<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>',yp=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],xp=[{name:"open",type:"boolean",default:!1,label:"断开"}],bp={kind:"inline"},P_={id:cp,name:dp,category:up,description:fp,viewBox:mp,width:hp,height:pp,svg:gp,terminals:yp,state:xp,source:bp},B_=Object.freeze(Object.defineProperty({__proto__:null,category:up,default:P_,description:fp,height:pp,id:cp,name:dp,source:bp,state:xp,svg:gp,terminals:yp,viewBox:mp,width:hp},Symbol.toStringTag,{value:"Module"})),wp="rectifier",vp="整流器 (AC→DC)",kp="renewable",_p="-42 -42 44 44",$p=44,Sp=44,jp='<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"/>',Ep=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Np={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},L_={id:wp,name:vp,category:kp,viewBox:_p,width:$p,height:Sp,svg:jp,terminals:Ep,source:Np},R_=Object.freeze(Object.defineProperty({__proto__:null,category:kp,default:L_,height:Sp,id:wp,name:vp,source:Np,svg:jp,terminals:Ep,viewBox:_p,width:$p},Symbol.toStringTag,{value:"Module"})),Mp="relay-coil",Tp="继电器线圈 (KA)",Ap="control",Ip="继电器 / 接触器操作线圈 (方框)。",Cp="-22 -22 44 44",Op=44,Pp=44,Bp='<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"/>',Lp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Rp={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"},z_={id:Mp,name:Tp,category:Ap,description:Ip,viewBox:Cp,width:Op,height:Pp,svg:Bp,terminals:Lp,source:Rp},D_=Object.freeze(Object.defineProperty({__proto__:null,category:Ap,default:z_,description:Ip,height:Pp,id:Mp,name:Tp,source:Rp,svg:Bp,terminals:Lp,viewBox:Cp,width:Op},Symbol.toStringTag,{value:"Module"})),zp="resistor",Dp="电阻 (R)",Fp="passive",Hp="通用电阻 / 限流 / 制动电阻。",Wp="-6 -23 12 35",qp=12,Gp=35,Xp='<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"/>',Yp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Kp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Vp={x:6,y:0,anchor:"start"},Up={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},F_={id:zp,name:Dp,category:Fp,description:Hp,viewBox:Wp,width:qp,height:Gp,svg:Xp,terminals:Yp,params:Kp,label:Vp,source:Up},H_=Object.freeze(Object.defineProperty({__proto__:null,category:Fp,default:F_,description:Hp,height:Gp,id:zp,label:Vp,name:Dp,params:Kp,source:Up,svg:Xp,terminals:Yp,viewBox:Wp,width:qp},Symbol.toStringTag,{value:"Module"})),Jp="reverse-power-relay",Zp="逆功率继电器 (32)",Qp="protection",eg="逆功率 / 逆流保护继电器 (ANSI 32)。",tg="-62 -42 64 44",ng=64,og=44,rg='<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"/>',sg=[{id:"t_top",x:-30,y:-40,orientation:"n"}],ig={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},W_={id:Jp,name:Zp,category:Qp,description:eg,viewBox:tg,width:ng,height:og,svg:rg,terminals:sg,source:ig},q_=Object.freeze(Object.defineProperty({__proto__:null,category:Qp,default:W_,description:eg,height:og,id:Jp,name:Zp,source:ig,svg:rg,terminals:sg,viewBox:tg,width:ng},Symbol.toStringTag,{value:"Module"})),ag="selector-switch",lg="选择开关 (SA)",cg="switching",dg="转换 / 选择开关 (旋转操作, 保位)。",ug="-34 -42 36 64",fg=36,mg=64,hg='<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"/>',pg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],gg=[{name:"open",type:"boolean",default:!1,label:"断开"}],yg={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"},G_={id:ag,name:lg,category:cg,description:dg,viewBox:ug,width:fg,height:mg,svg:hg,terminals:pg,state:gg,source:yg},X_=Object.freeze(Object.defineProperty({__proto__:null,category:cg,default:G_,description:dg,height:mg,id:ag,name:lg,source:yg,state:gg,svg:hg,terminals:pg,viewBox:ug,width:fg},Symbol.toStringTag,{value:"Module"})),xg="series-reactor",bg="串联电抗器",wg="compensation",vg="与并联电抗器同符号;通过用法区分。",kg="-62 -82 64 104",_g=64,$g=104,Sg='<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"/>',jg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Eg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},Y_={id:xg,name:bg,category:wg,description:vg,viewBox:kg,width:_g,height:$g,svg:Sg,terminals:jg,source:Eg},K_=Object.freeze(Object.defineProperty({__proto__:null,category:wg,default:Y_,description:vg,height:$g,id:xg,name:bg,source:Eg,svg:Sg,terminals:jg,viewBox:kg,width:_g},Symbol.toStringTag,{value:"Module"})),Ng="shunt-capacitor",Mg="并联电容器",Tg="compensation",Ag="-7 -23 14 27",Ig=14,Cg=27,Og='<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"/>',Pg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Bg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],Lg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},V_={id:Ng,name:Mg,category:Tg,viewBox:Ag,width:Ig,height:Cg,svg:Og,terminals:Pg,params:Bg,source:Lg},U_=Object.freeze(Object.defineProperty({__proto__:null,category:Tg,default:V_,height:Cg,id:Ng,name:Mg,params:Bg,source:Lg,svg:Og,terminals:Pg,viewBox:Ag,width:Ig},Symbol.toStringTag,{value:"Module"})),Rg="shunt-reactor",zg="并联电抗器",Dg="compensation",Fg="-62 -82 64 104",Hg=64,Wg=104,qg='<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"/>',Gg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Xg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},J_={id:Rg,name:zg,category:Dg,viewBox:Fg,width:Hg,height:Wg,svg:qg,terminals:Gg,source:Xg},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:Dg,default:J_,height:Wg,id:Rg,name:zg,source:Xg,svg:qg,terminals:Gg,viewBox:Fg,width:Hg},Symbol.toStringTag,{value:"Module"})),Yg="siren",Kg="警笛 (HA)",Vg="control",Ug="声响警笛 / 报警器。",Jg="-32 -42 44 54",Zg=44,Qg=54,e1='<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"/>',t1=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],n1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},Q_={id:Yg,name:Kg,category:Vg,description:Ug,viewBox:Jg,width:Zg,height:Qg,svg:e1,terminals:t1,source:n1},e$=Object.freeze(Object.defineProperty({__proto__:null,category:Vg,default:Q_,description:Ug,height:Qg,id:Yg,name:Kg,source:n1,svg:e1,terminals:t1,viewBox:Jg,width:Zg},Symbol.toStringTag,{value:"Module"})),o1="socket-outlet",r1="插座 / 连接器",s1="load",i1="电源插座 / 多极连接器。",a1="-7 -2 13 34",l1=13,c1=34,d1='<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"/>',u1=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],f1={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
197
|
-
unifilar`},t$={id:o1,name:r1,category:s1,description:i1,viewBox:a1,width:l1,height:c1,svg:d1,terminals:u1,source:f1},n$=Object.freeze(Object.defineProperty({__proto__:null,category:s1,default:t$,description:i1,height:c1,id:o1,name:r1,source:f1,svg:d1,terminals:u1,viewBox:a1,width:l1},Symbol.toStringTag,{value:"Module"})),m1="soft-starter",h1="软启动器",p1="motor-control",g1="电机软启动器 (晶闸管降压启动)。",y1="-22 -42 44 84",x1=44,b1=84,w1='<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"/>',v1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],k1={kind:"inline"},o$={id:m1,name:h1,category:p1,description:g1,viewBox:y1,width:x1,height:b1,svg:w1,terminals:v1,source:k1},r$=Object.freeze(Object.defineProperty({__proto__:null,category:p1,default:o$,description:g1,height:b1,id:m1,name:h1,source:k1,svg:w1,terminals:v1,viewBox:y1,width:x1},Symbol.toStringTag,{value:"Module"})),_1="sync-motor",$1="同步电动机",S1="load",j1="-62 -82 64 114",E1=64,N1=114,M1='<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"/>',T1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],A1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},s$={id:_1,name:$1,category:S1,viewBox:j1,width:E1,height:N1,svg:M1,terminals:T1,source:A1},i$=Object.freeze(Object.defineProperty({__proto__:null,category:S1,default:s$,height:N1,id:_1,name:$1,source:A1,svg:M1,terminals:T1,viewBox:j1,width:E1},Symbol.toStringTag,{value:"Module"})),I1="synchronoscope",C1="同步表",O1="measurement",P1="同步指示器 / 同步表。",B1="-22 -42 44 44",L1=44,R1=44,z1='<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"/>',D1=[{id:"t_top",x:0,y:-40,orientation:"n"}],F1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},a$={id:I1,name:C1,category:O1,description:P1,viewBox:B1,width:L1,height:R1,svg:z1,terminals:D1,source:F1},l$=Object.freeze(Object.defineProperty({__proto__:null,category:O1,default:a$,description:P1,height:R1,id:I1,name:C1,source:F1,svg:z1,terminals:D1,viewBox:B1,width:L1},Symbol.toStringTag,{value:"Module"})),H1="terminal",W1="接线端子 / 节点 (X)",q1="busbar",G1="接线端子 / 接线盒 / 汇接节点。",X1="-5 -5 10 10",Y1=10,K1=10,V1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',U1=[{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"}],J1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},c$={id:H1,name:W1,category:q1,description:G1,viewBox:X1,width:Y1,height:K1,svg:V1,terminals:U1,source:J1},d$=Object.freeze(Object.defineProperty({__proto__:null,category:q1,default:c$,description:G1,height:K1,id:H1,name:W1,source:J1,svg:V1,terminals:U1,viewBox:X1,width:Y1},Symbol.toStringTag,{value:"Module"})),Z1="thermal-overload",Q1="热过载继电器",ey="motor-control",ty="电机热过载保护继电器, 通常串接在接触器和电机之间。",ny="-9 -32 19 64",oy=19,ry=64,sy='<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"/>',iy=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ay=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],ly={kind:"inline"},u$={id:Z1,name:Q1,category:ey,description:ty,viewBox:ny,width:oy,height:ry,svg:sy,terminals:iy,state:ay,source:ly},f$=Object.freeze(Object.defineProperty({__proto__:null,category:ey,default:u$,description:ty,height:ry,id:Z1,name:Q1,source:ly,state:ay,svg:sy,terminals:iy,viewBox:ny,width:oy},Symbol.toStringTag,{value:"Module"})),cy="thermocouple",dy="热电偶 (BT)",uy="measurement",fy="热电偶温度传感器。",my="-26 -42 52 46",hy=52,py=46,gy='<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"/>',yy=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],xy={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},m$={id:cy,name:dy,category:uy,description:fy,viewBox:my,width:hy,height:py,svg:gy,terminals:yy,source:xy},h$=Object.freeze(Object.defineProperty({__proto__:null,category:uy,default:m$,description:fy,height:py,id:cy,name:dy,source:xy,svg:gy,terminals:yy,viewBox:my,width:hy},Symbol.toStringTag,{value:"Module"})),by="thyristor",wy="晶闸管 (V)",vy="passive",ky="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",_y="-22 -42 34 44",$y=34,Sy=44,jy='<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"/>',Ey=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ny={x:6,y:-20,anchor:"start"},My={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)"},p$={id:by,name:wy,category:vy,description:ky,viewBox:_y,width:$y,height:Sy,svg:jy,terminals:Ey,label:Ny,source:My},g$=Object.freeze(Object.defineProperty({__proto__:null,category:vy,default:p$,description:ky,height:Sy,id:by,label:Ny,name:wy,source:My,svg:jy,terminals:Ey,viewBox:_y,width:$y},Symbol.toStringTag,{value:"Module"})),Ty="time-relay",Ay="时间继电器 (KT)",Iy="control",Cy="延时 (缓动) 继电器线圈。",Oy="-32 -22 54 44",Py=54,By=44,Ly='<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"/>',Ry=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],zy={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"},y$={id:Ty,name:Ay,category:Iy,description:Cy,viewBox:Oy,width:Py,height:By,svg:Ly,terminals:Ry,source:zy},x$=Object.freeze(Object.defineProperty({__proto__:null,category:Iy,default:y$,description:Cy,height:By,id:Ty,name:Ay,source:zy,svg:Ly,terminals:Ry,viewBox:Oy,width:Py},Symbol.toStringTag,{value:"Module"})),Dy="transfer-switch",Fy="切换开关 (ATS)",Hy="switching",Wy="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",qy="-27 -32 51 64",Gy=51,Xy=64,Yy='<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"/>',Ky=[{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"}],Vy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Uy={kind:"inline"},b$={id:Dy,name:Fy,category:Hy,description:Wy,viewBox:qy,width:Gy,height:Xy,svg:Yy,terminals:Ky,state:Vy,source:Uy},w$=Object.freeze(Object.defineProperty({__proto__:null,category:Hy,default:b$,description:Wy,height:Xy,id:Dy,name:Fy,source:Uy,state:Vy,svg:Yy,terminals:Ky,viewBox:qy,width:Gy},Symbol.toStringTag,{value:"Module"})),Jy="transformer-2w",Zy="双绕组变压器",Qy="transformer",ex="-62 -142 64 144",tx=64,nx=144,ox='<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"/>',rx=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],sx=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],ix={x:4,y:-68,anchor:"start"},ax={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"},v$={id:Jy,name:Zy,category:Qy,viewBox:ex,width:tx,height:nx,svg:ox,terminals:rx,params:sx,label:ix,source:ax},k$=Object.freeze(Object.defineProperty({__proto__:null,category:Qy,default:v$,height:nx,id:Jy,label:ix,name:Zy,params:sx,source:ax,svg:ox,terminals:rx,viewBox:ex,width:tx},Symbol.toStringTag,{value:"Module"})),lx="transformer-3w",cx="三绕组变压器",dx="transformer",ux="-82 -131 114 133",fx=114,mx=133,hx='<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"/>',px=[{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"}],gx={x:4,y:-64,anchor:"start"},yx={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"},_$={id:lx,name:cx,category:dx,viewBox:ux,width:fx,height:mx,svg:hx,terminals:px,label:gx,source:yx},$$=Object.freeze(Object.defineProperty({__proto__:null,category:dx,default:_$,height:mx,id:lx,label:gx,name:cx,source:yx,svg:hx,terminals:px,viewBox:ux,width:fx},Symbol.toStringTag,{value:"Module"})),xx="triac",bx="双向晶闸管 (V)",wx="passive",vx="双向三极晶闸管 (TRIAC)。",kx="-22 -42 44 44",_x=44,$x=44,Sx='<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"/>',jx=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ex={x:6,y:-20,anchor:"start"},Nx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},S$={id:xx,name:bx,category:wx,description:vx,viewBox:kx,width:_x,height:$x,svg:Sx,terminals:jx,label:Ex,source:Nx},j$=Object.freeze(Object.defineProperty({__proto__:null,category:wx,default:S$,description:vx,height:$x,id:xx,label:Ex,name:bx,source:Nx,svg:Sx,terminals:jx,viewBox:kx,width:_x},Symbol.toStringTag,{value:"Module"})),Mx="undervoltage-relay",Tx="欠压继电器 (27)",Ax="protection",Ix="欠电压保护继电器 (ANSI 27)。",Cx="-62 -82 64 84",Ox=64,Px=84,Bx='<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>',Lx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],Rx={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},E$={id:Mx,name:Tx,category:Ax,description:Ix,viewBox:Cx,width:Ox,height:Px,svg:Bx,terminals:Lx,source:Rx},N$=Object.freeze(Object.defineProperty({__proto__:null,category:Ax,default:E$,description:Ix,height:Px,id:Mx,name:Tx,source:Rx,svg:Bx,terminals:Lx,viewBox:Cx,width:Ox},Symbol.toStringTag,{value:"Module"})),zx="ups",Dx="不间断电源 (UPS)",Fx="source",Hx="在线 / 后备式不间断电源。",Wx="-26 -42 52 84",qx=52,Gx=84,Xx='<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"/>',Yx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Kx=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Vx={kind:"inline"},M$={id:zx,name:Dx,category:Fx,description:Hx,viewBox:Wx,width:qx,height:Gx,svg:Xx,terminals:Yx,params:Kx,source:Vx},T$=Object.freeze(Object.defineProperty({__proto__:null,category:Fx,default:M$,description:Hx,height:Gx,id:zx,name:Dx,params:Kx,source:Vx,svg:Xx,terminals:Yx,viewBox:Wx,width:qx},Symbol.toStringTag,{value:"Module"})),Ux="varmeter",Jx="无功功率表 (var)",Zx="measurement",Qx="无功功率表 (var)。",eb="-22 -42 44 44",tb=44,nb=44,ob='<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>',rb=[{id:"t_top",x:0,y:-40,orientation:"n"}],sb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},A$={id:Ux,name:Jx,category:Zx,description:Qx,viewBox:eb,width:tb,height:nb,svg:ob,terminals:rb,source:sb},I$=Object.freeze(Object.defineProperty({__proto__:null,category:Zx,default:A$,description:Qx,height:nb,id:Ux,name:Jx,source:sb,svg:ob,terminals:rb,viewBox:eb,width:tb},Symbol.toStringTag,{value:"Module"})),ib="vfd",ab="变频器 (VFD)",lb="motor-control",cb="Variable Frequency Drive — 异步电动机调速。",db="-24 -42 48 84",ub=48,fb=84,mb='<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"/>',hb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],pb={kind:"inline"},C$={id:ib,name:ab,category:lb,description:cb,viewBox:db,width:ub,height:fb,svg:mb,terminals:hb,source:pb},O$=Object.freeze(Object.defineProperty({__proto__:null,category:lb,default:C$,description:cb,height:fb,id:ib,name:ab,source:pb,svg:mb,terminals:hb,viewBox:db,width:ub},Symbol.toStringTag,{value:"Module"})),gb="voltage-regulator",yb="调压器 (T)",xb="transformer",bb="可调感应调压器 / 自耦调压器。",wb="-17 -32 38 64",vb=38,kb=64,_b='<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"/>',$b=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Sb=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],jb={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},P$={id:gb,name:yb,category:xb,description:bb,viewBox:wb,width:vb,height:kb,svg:_b,terminals:$b,params:Sb,source:jb},B$=Object.freeze(Object.defineProperty({__proto__:null,category:xb,default:P$,description:bb,height:kb,id:gb,name:yb,params:Sb,source:jb,svg:_b,terminals:$b,viewBox:wb,width:vb},Symbol.toStringTag,{value:"Module"})),Eb="voltmeter",Nb="电压表 (V)",Mb="measurement",Tb="-22 -42 44 44",Ab=44,Ib=44,Cb='<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>',Ob=[{id:"t_top",x:0,y:-40,orientation:"n"}],Pb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},L$={id:Eb,name:Nb,category:Mb,viewBox:Tb,width:Ab,height:Ib,svg:Cb,terminals:Ob,source:Pb},R$=Object.freeze(Object.defineProperty({__proto__:null,category:Mb,default:L$,height:Ib,id:Eb,name:Nb,source:Pb,svg:Cb,terminals:Ob,viewBox:Tb,width:Ab},Symbol.toStringTag,{value:"Module"})),Bb="wattmeter",Lb="功率表 (W)",Rb="measurement",zb="-22 -42 44 44",Db=44,Fb=44,Hb='<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>',Wb=[{id:"t_top",x:0,y:-40,orientation:"n"}],qb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},z$={id:Bb,name:Lb,category:Rb,viewBox:zb,width:Db,height:Fb,svg:Hb,terminals:Wb,source:qb},D$=Object.freeze(Object.defineProperty({__proto__:null,category:Rb,default:z$,height:Fb,id:Bb,name:Lb,source:qb,svg:Hb,terminals:Wb,viewBox:zb,width:Db},Symbol.toStringTag,{value:"Module"})),Gb="wind-turbine",Xb="风力发电机",Yb="renewable",Kb="风机:发电机 + 三叶轮标记",Vb="-22 -46 44 68",Ub=44,Jb=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"/>',Qb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],ew={kind:"inline"},F$={id:Gb,name:Xb,category:Yb,description:Kb,viewBox:Vb,width:Ub,height:Jb,svg:Zb,terminals:Qb,source:ew},H$=Object.freeze(Object.defineProperty({__proto__:null,category:Yb,default:F$,description:Kb,height:Jb,id:Gb,name:Xb,source:ew,svg:Zb,terminals:Qb,viewBox:Vb,width:Ub},Symbol.toStringTag,{value:"Module"})),tw="zener-diode",nw="稳压二极管 (D)",ow="passive",rw="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",sw="-12 -42 24 44",iw=24,aw=44,lw='<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"/>',cw=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],dw={x:6,y:-20,anchor:"start"},uw={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"},W$={id:tw,name:nw,category:ow,description:rw,viewBox:sw,width:iw,height:aw,svg:lw,terminals:cw,label:dw,source:uw},q$=Object.freeze(Object.defineProperty({__proto__:null,category:ow,default:W$,description:rw,height:aw,id:tw,label:dw,name:nw,source:uw,svg:lw,terminals:cw,viewBox:sw,width:iw},Symbol.toStringTag,{value:"Module"})),G$=Object.assign({"./ammeter.json":T2,"./arc-suppression-coil.json":I2,"./arrester.json":O2,"./async-motor.json":B2,"./autotransformer.json":R2,"./battery.json":D2,"./bell.json":H2,"./break-contact.json":q2,"./breaker.json":X2,"./buchholz-relay.json":K2,"./busbar.json":U2,"./buzzer.json":Z2,"./capacitor.json":ek,"./contactor.json":nk,"./converter-bidir.json":rk,"./ct.json":ik,"./dc-combiner.json":lk,"./dc-disconnector.json":dk,"./dc-motor.json":fk,"./diode.json":hk,"./disconnector.json":gk,"./distance-relay.json":xk,"./earth.json":wk,"./earthing-switch.json":kk,"./energy-meter.json":$k,"./ev-charger.json":jk,"./frequency-meter.json":Nk,"./fuse-switch-disconnector.json":Tk,"./fuse.json":Ik,"./generator.json":Ok,"./genset.json":Bk,"./gfci-breaker.json":Rk,"./grid-source.json":Dk,"./grounding-transformer.json":Hk,"./heater.json":qk,"./igbt.json":Xk,"./indicator-light.json":Kk,"./inductor.json":Uk,"./inverter.json":Zk,"./limit-switch.json":e_,"./load-switch.json":n_,"./load.json":r_,"./make-contact.json":i_,"./motor-starter.json":l_,"./ngr.json":d_,"./overcurrent-relay.json":f_,"./panelboard.json":h_,"./phase-failure-relay.json":g_,"./plc.json":x_,"./power-factor-meter.json":w_,"./power-supply.json":k_,"./protective-relay.json":$_,"./proximity-switch.json":j_,"./pt.json":N_,"./push-button.json":T_,"./pv.json":I_,"./rcd.json":O_,"./recloser.json":B_,"./rectifier.json":R_,"./relay-coil.json":D_,"./resistor.json":H_,"./reverse-power-relay.json":q_,"./selector-switch.json":X_,"./series-reactor.json":K_,"./shunt-capacitor.json":U_,"./shunt-reactor.json":Z_,"./siren.json":e$,"./socket-outlet.json":n$,"./soft-starter.json":r$,"./sync-motor.json":i$,"./synchronoscope.json":l$,"./terminal.json":d$,"./thermal-overload.json":f$,"./thermocouple.json":h$,"./thyristor.json":g$,"./time-relay.json":x$,"./transfer-switch.json":w$,"./transformer-2w.json":k$,"./transformer-3w.json":$$,"./triac.json":j$,"./undervoltage-relay.json":N$,"./ups.json":T$,"./varmeter.json":I$,"./vfd.json":O$,"./voltage-regulator.json":B$,"./voltmeter.json":R$,"./wattmeter.json":D$,"./wind-turbine.json":H$,"./zener-diode.json":q$}),fw=Object.values(G$).map(e=>e.default),Ke=Object.fromEntries(fw.map(e=>[e.id,e])),Xo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],X$=(()=>{var t;const e={};for(const n of fw)(e[t=n.category]??(e[t]=[])).push(n);return e})(),Bn=new Map(Object.entries(Ke));function mw(e){return Ke[e]}function Y$(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 K$=320;function Ge(e){var $,v,P,B,W;const t=cs(),n=new Map;e.elements.forEach((k,F)=>{if(n.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/elements/${F}`});return}n.set(k.id,k);const X=Bn.get(k.kind);X||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:k.kind})} (id=${k.id})`,pointer:`/elements/${F}`}),t.elements.set(k.id,{element:k,libraryDef:X})});const o=new Map,r=new Map;(e.buses??[]).forEach((k,F)=>{if(n.has(k.id)||o.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/buses/${F}`});return}if(o.set(k.id,k),k.layout){const X=k.layout.rot??0;r.set(k.id,{at:k.layout.at,span:k.layout.span,rot:X,axis:On(X)})}});const s=new Map;(e.junctions??[]).forEach((k,F)=>{if(n.has(k.id)||o.has(k.id)||s.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/junctions/${F}`});return}s.set(k.id,k)});const i=k=>!k.includes(".")&&o.has(k),a=k=>!k.includes(".")&&s.has(k),l=(k,F)=>{if(i(k)||a(k))return!0;const X=k.indexOf(".");if(X<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:k}),pointer:F}),!1;const Z=k.slice(0,X),G=k.slice(X+1),A=t.elements.get(Z);if(!A)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:Z}),pointer:F}),!1;if(!A.libraryDef)return!1;if(!A.libraryDef.terminals.find(D=>D.id===G)){const D=A.libraryDef.terminals.map(se=>se.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:Z,kind:A.element.kind,pin:G,available:D}),pointer:F}),!1}return!0},c=[];(e.wires??[]).forEach((k,F)=>{const X=`/wires/${F}`,Z=l(k.ends[0],X),G=l(k.ends[1],X);Z&&G&&c.push(k)});const f=new Map;if(e.layout)for(const[k,F]of Object.entries(e.layout))t.elements.has(k)?f.set(k,ds(F)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:k}),pointer:`/layout/${k}`});const u=E2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:Bn,userLayout:f,userBusLayout:r});t.layout=u.devices;for(const[k,F]of u.buses){const X=o.get(k);X&&t.buses.set(k,{bus:X,geometry:F})}for(const[k,F]of o)t.buses.has(k)||t.buses.set(k,{bus:F,geometry:{at:(($=F.layout)==null?void 0:$.at)??[0,0],span:((v=F.layout)==null?void 0:v.span)??K$,rot:((P=F.layout)==null?void 0:P.rot)??0,axis:On(((B=F.layout)==null?void 0:B.rot)??0)}});for(const k of t.elements.values()){if(!k.libraryDef)continue;const F=t.layout.get(k.element.id);if(!F)continue;const X=[];for(const Z of k.libraryDef.terminals){const G=`${k.element.id}.${Z.id}`,A=Oe([Z.x,Z.y],F),D=St(Z.orientation,F);t.terminals.set(G,{ref:G,elementId:k.element.id,pin:Z.id,world:A,orientation:D}),X.push(G)}t.elementToTerminals.set(k.element.id,X)}const m=new Map,p=new Set;for(const[k,F]of s)(W=F.layout)!=null&&W.at?(m.set(k,[F.layout.at[0],F.layout.at[1]]),p.add(k)):u.junctions.has(k)&&(m.set(k,u.junctions.get(k)),p.add(k));const h=k=>{if(!k.includes(".")){const X=t.buses.get(k);return X?X.geometry.at:m.get(k)??null}const F=t.terminals.get(k);return F?F.world:null},g=new Map;for(const[k]of s)p.has(k)||g.set(k,[]);for(const k of c){const[F,X]=k.ends;g.has(F)&&g.get(F).push(X),g.has(X)&&g.get(X).push(F)}for(let k=0;k<12;k++){let F=!1;for(const[X,Z]of g){let G=0,A=0,D=0;for(const oe of Z){const re=h(oe);re&&(G+=re[0],A+=re[1],D++)}if(!D)continue;const se=G/D,ie=A/D,de=m.get(X);(!de||Math.abs(de[0]-se)>.01||Math.abs(de[1]-ie)>.01)&&(m.set(X,[se,ie]),F=!0)}if(!F)break}for(const[k,F]of s)t.junctions.set(k,{junction:F,world:m.get(k)??[0,0]});const b=new us;for(const k of c)b.add(k.ends[0]),b.add(k.ends[1]),b.union(k.ends[0],k.ends[1]);for(const[,k]of b.groups()){const F=Y$(k);t.nodes.set(F,{id:F,terminals:k});for(const X of k)t.terminalToNode.set(X,F)}for(const k of t.elements.values()){const F=t.elementToTerminals.get(k.element.id)??[];if(F.length===0)continue;F.some(Z=>t.terminalToNode.has(Z))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k.element.id})})}for(const k of t.buses.keys())t.terminalToNode.has(k)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k})});for(const k of t.junctions.keys())t.terminalToNode.has(k)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k})});for(const k of c){if(k.path&&k.path.length>=2){const X=k.path,Z=X.length>=2?X[1]:null,G=X.length>=2?X[X.length-2]:null,A=qo(k.ends[0],Z,t),D=qo(k.ends[1],G,t);if(A&&D){const se=[[A[0],A[1]],...X.slice(1,-1).map(de=>[de[0],de[1]]),[D[0],D[1]]],ie=ls(se);if(ie.length>=2){t.wireRenders.set(k.id,{wireId:k.id,path:ie,userEdited:!0});continue}}}const F=N2(k,t);F&&t.wireRenders.set(k.id,F)}return t}const V$={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 Tt(e,t){const n=V$[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 Rn(e){const t=eo(e);let n=1;for(;t.has(`${Ko}${n}`);)n++;return`${Ko}${n}`}function hw(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:[]},U$=100,Uo=20;function J$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=tn()(w2((e,t)=>({diagram:Vo,internal:Ge(Vo),fileSession:null,activeTool:J$(),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,readOnly:!1,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}),setReadOnly:n=>e({readOnly: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>=U$?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:Z$(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]=Dt(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=Tt(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=Rn(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(v=>{const P=structuredClone(v);return P.id=l.get(v.id),P}),p=n.buses.map(v=>{const P=structuredClone(v);P.id=l.get(v.id);const B=n.busLayouts[v.id];return B&&(P.layout={...B,at:[B.at[0]+i,B.at[1]+a]}),P}),h=n.junctions.map(v=>{const P=structuredClone(v);return P.id=l.get(v.id),P.layout&&(P.layout={at:[P.layout.at[0]+i,P.layout.at[1]+a]}),P}),g={...u.layout??{}};for(const[v,P]of l){const B=n.placements[v];B&&(g[P]={...B,at:[B.at[0]+i,B.at[1]+a]})}const b=n.wires.map(v=>{const P=[f(v.ends[0]),f(v.ends[1])];return{id:Je(P[0],P[1]),ends:P}}),$=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]=Dt(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]=Dt(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?Dt(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),v=(((((u=(f=(c=s.buses)==null?void 0:c.find(P=>P.id===p))==null?void 0:f.layout)==null?void 0:u.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(p,v);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=Tt(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=Rn(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(P=>P.id===h.onWire),b=l(h.at);if(!g)return b;const $=(s.wires??[]).filter(P=>P.id!==h.onWire),v=(P,B)=>({id:Je(P,B),ends:[P,B]});return s={...s,wires:Jo($,[v(g.ends[0],b),v(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?ls(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=hw(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:as(()=>({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>{x.getState().readOnly||localStorage.setItem(e,t)},removeItem:e=>localStorage.removeItem(e)})),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 Z$(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 Dt(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 pw=null;function Zo(e){pw=e}function Ze(){return pw}const Vt=10;function gw(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function me(e){return gw()?Math.round(e/Vt)*Vt:e}const Q$=30,eS=144;function yw(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=tS(r,t);if(!s){const g=xw(n),b=g?[me(t[0])-g.x,me(t[1])-g.y]:[me(t[0]),me(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=nS(n,l),f=Tt(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?[me(m)-u.x,me(p)-u.y]:[me(t[0]),me(t[1])];return o.dispatch(g=>{const b={id:f,kind:e},$={at:h},v=`${f}.${c}`,P={id:Je(i,v),ends:[i,v]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],P],layout:{...g.layout??{},[f]:$}}}),o.setSelection([f]),{newElementId:f,attachedToBus:!0}}function tS(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<=Q$&&(!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 nS(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 xw(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function bw(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 oS={n:"s",s:"n",e:"w",w:"e"};function ww(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=oS[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 rS(e,t,n){const o=Ke[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=bw(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=eS,f=[me(n[0]),me(n[1])],u=ww(o,i,f),m=c?i.world:f,p=[me(m[0]-u.x),me(m[1]-u.y)],h=Tt(s,e);return r.dispatch(g=>{const b={id:h,kind:e},$={at:p},v=`${h}.${u.id}`,P=i.isBus&&i.busId?i.busId:t,B={id:Je(P,v),ends:[P,v]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],B],layout:{...g.layout??{},[h]:$}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const Ct=9,at=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=vw(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+t.h/2+at/3,anchor:"start"}:{x:0,y:0,anchor:"start"}}function sS(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 rn(e,t,n,o){const r=sS(e,n),s=e.anchor??"start",i=vw(t.viewBox);let a=e.x-(i?i.x+i.w/2:0),l=e.y-(i?i.y+i.h/2:0);switch(n.mirror&&(a=-a),n.rot){case 90:[a,l]=[-l,a];break;case 180:[a,l]=[-a,-l];break;case 270:[a,l]=[l,-a];break}return Math.abs(a)<1e-6&&Math.abs(l)<1e-6?{world:r,textAnchor:s,dy:0}:Math.abs(a)>=Math.abs(l)?{world:r,textAnchor:a>=0?"start":"end",dy:0}:l>0?{world:r,textAnchor:"middle",dy:at}:{world:r,textAnchor:"middle",dy:-(o-1)*Ct}}function vw(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 iS(){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=nn(r,n),{world:l,textAnchor:c,dy:f}=rn(i,r.libraryDef,s,Math.max(1,a.length));return o===r.element.id?d.jsx(aS,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:l,anchor:c},r.element.id):n==="off"||a.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${l[0]} ${l[1]})`,children:a.map((m,p)=>d.jsx("text",{x:0,y:f+p*Ct,textAnchor:c,className:"ole-annotation-text",children:m},p))},r.element.id)})})}const kn=200,_n=9;function aS({elementId:e,currentName:t,world:n,anchor:o}){const r=I.useRef(null);I.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const 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 kw=8,Ut=1.25;function lS(){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(dS,{ann:o},o.id):d.jsx(cS,{ann:o,isSelected:t===o.id},o.id))})}function cS({ann:e,isSelected:t}){const n=e.fontSize??kw,o=e.text===""?[""]:e.text.split(`
|
|
198
|
-
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Ut;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*Ut,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function dS({ann:e}){const t=I.useRef(null),n=e.fontSize??kw;I.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:Ut,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*Ut}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const uS=20;function fS(){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=I.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=gw()?Math.round(p/Vt)*Vt:p,g=u.startSpan+(o==="end"?h:-h);if(g<uS)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 zn=.5;function jt(e,t){return Math.abs(e[1]-t[1])<zn?"h":"v"}function mS(){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=jt(o[a-1],o[a]),c=jt(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(hS,{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(pS,{wireId:e,segIndex:a,axis:jt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function hS({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=I.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,v=g.index;if(v<=0||v>=$.length-1)return;const P=$[v],B=[g.xLocked?P[0]:me(P[0]+(b[0]-g.startSvg[0])),g.yLocked?P[1]:me(P[1]+(b[1]-g.startSvg[1]))];if(B[0]===P[0]&&B[1]===P[1])return;const W=$.map(X=>[X[0],X[1]]);W[v]=B;const k=jt($[v-1],$[v]);v-1>0&&(k==="h"?W[v-1]=[$[v-1][0],B[1]]:W[v-1]=[B[0],$[v-1][1]]);const F=jt($[v],$[v+1]);v+1<$.length-1&&(F==="h"?W[v+1]=[$[v+1][0],B[1]]:W[v+1]=[B[0],$[v+1][1]]),x.getState().updateWirePath(e,W)},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(($,v)=>v!==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 pS({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=I.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,v=g.segIndex;if(v>=$.length-1)return;const P=$[v],B=$[v+1],W=[];for(let k=0;k<=v;k++)W.push($[k]);if(g.axis==="h"){const k=me(P[1]+(b[1]-g.startSvg[1]));W.push([P[0],k]),W.push([B[0],k])}else{const k=me(P[0]+(b[0]-g.startSvg[0]));W.push([k,P[1]]),W.push([k,B[1]])}for(let k=v+1;k<$.length;k++)W.push($[k]);x.getState().updateWirePath(e,W)},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 gS=3,$n=12;function yS(){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),v=i.has(a.id),P=r.get(a.id)??void 0,B=$n/2,W=c==="x"?f[0]-m:f[0]-B,k=c==="x"?f[1]-B:f[1]-m,F=c==="x"?u:$n,X=c==="x"?$n:u;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":P,"data-selected":$?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:W,y:k,width:F,height:X,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:b,stroke:"currentColor",strokeWidth:gS,strokeLinecap:"round",fill:"none"})]},a.id)})})}function xS(){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 bS=2.5,wS=9,vS=13,kS=-13,_S=4.5,$S=8;function SS(){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]+vS,m=l[1]+kS;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:wS,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:bS,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:$S,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:u,cy:m,r:_S,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 jS(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 ES({lib:e}){const t=jS(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 NS(){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(ES,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}}),a.libraryDef.terminalLabelsSvg&&d.jsx("g",{className:"ole-terminal-labels",dangerouslySetInnerHTML:{__html:a.libraryDef.terminalLabelsSvg}})]},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 _w=null;const Dn=new Set;function Ft(e){_w=e;for(const t of Dn)t(e)}function MS(){return _w}function TS(e){return Dn.add(e),()=>{Dn.delete(e)}}function AS(){const[e,t]=I.useState(MS());return I.useEffect(()=>TS(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 IS(){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=mw(t);if(!r)return null;let s=null,i=null;if(o){const c=bw(o,n);c&&(s=ww(r,c,n),i={source:c.world,pin:n})}else s=xw(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 CS(){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=OS(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 OS(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 PS(){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 LS(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),v=Math.min(f,b+tr);o.push([s[0]+u*$,s[1]+m*$]),n.push(o),o=[[s[0]+u*v,s[1]+m*v]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function RS(){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(v=>`${v[0]},${v[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?LS(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((v,P)=>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:v.map(B=>`${B[0]},${B[1]}`).join(" ")},`${c.wireId}-${P}`))]})})}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 zS(){return Ue}function DS(e){return Fn.add(e),()=>{Fn.delete(e)}}function FS(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=I.useState(zS());if(I.useEffect(()=>DS(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 lt(e){var t;return((t=Qe(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function HS(e){var t;return((t=Qe(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function WS(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=WS(e);if(n)return n;const o=HS(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 Jt(e){var t;return((t=Qe(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function $w(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function qS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Sw(){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 GS(){I.useEffect(()=>{const e=t=>{if(qS(t.target)||x.getState().readOnly)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":Sw();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Wn=null;const qn=new Set;function XS(e){if(e!==Wn){Wn=e;for(const t of qn)t(e)}}function YS(){return Wn}function KS(e){return qn.add(e),()=>{qn.delete(e)}}const nr="ole-hover-element-host",VS="ole-hover-terminal-on",US="ole-hover-node-on";function JS(e){I.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="${Ht(n)}"]`))==null||p.classList.remove(nr)),u&&((h=t.querySelector(`[data-element-id="${Ht(u)}"]`))==null||h.classList.add(nr));const m=u?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Ht(u)}"]`)):[];i(r,m,VS),n=u,u?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),XS(u)},l=u=>{if(u===o)return;const m=u?Array.from(t.querySelectorAll(`[data-node-id="${Ht(u)}"]`)):[];i(s,m,US),o=u,u?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=u=>{a(lt(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 Ht(e){return e.replace(/(["\\])/g,"\\$1")}function ZS(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,Wt=e=>Math.round(e/or)*or,QS=16;function jw(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 Zt(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function ej(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=jw(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 Et(e,t,n){const o=e?sn(e):null;if(o){const a=ZS(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?jw(a.path,t):t}else{const a=ej(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[Wt(s[0]),Wt(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Wt(t[0]),Wt(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Nt(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+QS,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function Ew(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function Qt(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 fe=null,Me=null,je=null,ge=null;const tj={id:"select",cursor:"default",onPointerDown(e,t){var h,g,b,$,v,P,B,W,k,F,X,Z;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Jt(e.target);if(o){e.preventDefault(),e.stopPropagation();const G=(h=n.diagram.annotations)==null?void 0:h.find(A=>A.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 A=(v=n.internal.junctions.get(G))==null?void 0:v.world;A&&n.setWireDragFrom({spec:{end:G},world:A,ref:G}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:G};return}}const i=(e.target instanceof Element?(P=e.target.closest("[data-terminal-id]"))==null?void 0:P.getAttribute("data-terminal-id"):null)?sn(e.target):null;if(i){const G=i.indexOf("."),A=G>0?i.slice(0,G):"";if(A&&n.selection.includes(A)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((W=(B=e.target).hasPointerCapture)!=null&&W.call(B,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const D=(k=n.internal.terminals.get(i))==null?void 0:k.world;D&&n.setWireDragFrom({spec:{end:i},world:D,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:i};return}}let a=lt(e.target);if(!a){const G=Hn(e.target);if(G&&typeof document<"u"){const A=document.elementsFromPoint(e.clientX,e.clientY);for(const D of A){const se=(X=(F=D.closest)==null?void 0:F.call(D,"[data-bus-id]"))==null?void 0:X.getAttribute("data-bus-id");if(!se)continue;const ie=(Z=n.diagram.wires)==null?void 0:Z.find(de=>de.id===G);ie&&(ie.ends[0]===se||ie.ends[1]===se)&&(a=se);break}}}if(!a){const G=Hn(e.target);if(G){if(e.preventDefault(),e.altKey){const A=an(e.target);if(A){n.setSelectedNode(A);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 A=f.buses.get(G);if(A){m.set(G,[A.geometry.at[0],A.geometry.at[1]]);continue}const D=f.junctions.get(G);if(D){p.set(G,[D.world[0],D.world[1]]);continue}const se=f.layout.get(G);se&&u.set(G,{...se})}u.size===0&&m.size===0&&p.size===0||(fe={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=me(n[0]-ge.startSvg[0]),r=me(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=Zt(e.clientX,e.clientY),r=Et(o,n,Nt(t,e.clientX,e.clientY)),s={spec:{end:je.fromRef},world:[0,0],ref:je.fromRef};Xe(Qt(s,r)?null:Ew(r));return}if(fe&&e.pointerId===fe.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-fe.startSvg[0]),r=me(n[1]-fe.startSvg[1]);!fe.moved&&(o!==0||r!==0)&&(fe.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of fe.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 fe.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of fe.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);Ft(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=me(n[0]-ge.startSvg[0]),r=me(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=Zt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Et(s,r,Nt(t,e.clientX,e.clientY));if(Qt({world:[0,0],ref:o},i))return;n.connectWire({end:o},i.spec);return}if(fe&&e.pointerId===fe.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),fe.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-fe.startSvg[0]),r=me(n[1]-fe.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of fe.originals.keys())s.set(i,[o,r]);for(const i of fe.busOriginals.keys())s.set(i,[o,r]);for(const i of fe.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of fe.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}for(const s of fe.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}}fe=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=nj(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)}Ft(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(fe&&e.pointerId===fe.pointerId){for(const[l,c]of fe.originals){const f=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);f&&f.setAttribute("transform",Ye(c))}for(const l of fe.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of fe.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{}fe=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{}Ft(null),Me=null}},onDoubleClick(e){const t=x.getState(),n=Jt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=lt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(fe=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}Ft(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 nj(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=rj(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])=>oj([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 oj(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 rj(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 sj=4;let le=null;const ij={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=x.getState().readOnly?null:lt(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})}le={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(!le||e.pointerId!==le.pointerId)return;const n=e.clientX-le.startX,o=e.clientY-le.startY;if(!le.moved&&Math.hypot(n,o)>sj){le.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(le.moved){if(le.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=me(r[0]-le.elementDrag.startSvg[0]),i=me(r[1]-le.elementDrag.startSvg[1]);for(const[a,l]of le.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${vt(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 le.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:le.startTx+n,ty:le.startTy+o})}},onPointerUp(e,t){if(!(!le||e.pointerId!==le.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",le.elementDrag&&le.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-le.elementDrag.startSvg[0]),r=me(n[1]-le.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of le.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of le.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of le.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${vt(s)}"]`);i&&i.removeAttribute("transform")}}else!le.moved&&!x.getState().readOnly&&aj(le.startTarget);le=null}},onPointerCancel(e,t){if(le!=null&&le.elementDrag){for(const[n,o]of le.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);r&&r.setAttribute("transform",Ye(o))}for(const n of le.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);o&&o.removeAttribute("transform")}}le=null},onDeactivate(){le=null}};function aj(e){if(!e)return;const t=x.getState(),n=Jt(e);if(n){t.setSelectedAnnotation(n);return}const o=lt(e);if(o){t.setSelection([o]);return}const r=an(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function vt(e){return e.replace(/(["\\])/g,"\\$1")}const _t={tight:1024,compact:720,dense:520,mini:380},ir={full:0,tight:1,compact:2,dense:3,mini:4};function Pe(e,t){return ir[e]>=ir[t]}function lj(e){return e>=_t.tight?"full":e>=_t.compact?"tight":e>=_t.dense?"compact":e>=_t.mini?"dense":"mini"}const Nw=I.createContext("full");function Ve(){return I.useContext(Nw)}function cj(e){const[t,n]=I.useState(null);return I.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function Mw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<_t.dense}function ln(){Mw()&&x.getState().setActiveTool("pan")}function dj(){Mw()&&x.getState().setPlaceKind(null)}const uj={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=Nt(t,e.clientX,e.clientY),r=Et(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=Zt(e.clientX,e.clientY),i=Et(s,r,Nt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Xe(Qt(a,i)?null:Ew(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=Zt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Et(s,r,Nt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Qt(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 kt=!1;function lr(){setTimeout(()=>dj(),0)}const fj={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),kt=!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);yw(n,r),kt=!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);rS(r,o,s),lr();return}kt&&(kt=!1,lr())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),kt=!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 mj={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,hj={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()}},pj={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Jt(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()}},hr={select:tj,pan:ij,wire:uj,place:fj,busbar:mj,junction:hj,text:pj};function gj(e,t){const n=x(r=>r.activeTool),o=x(r=>r.readOnly);I.useEffect(()=>{var p;const r=e.current;if(!r)return;const s=o?hr.pan:hr[n],i={viewport:t,hostEl:r};(p=s.onActivate)==null||p.call(s,i),s.cursor&&(r.style.cursor=s.cursor);const a=h=>{var g;return(g=s.onPointerDown)==null?void 0:g.call(s,h,i)},l=h=>{var g;return(g=s.onPointerMove)==null?void 0:g.call(s,h,i)},c=h=>{var g;return(g=s.onPointerUp)==null?void 0:g.call(s,h,i)},f=h=>{var g;return s.onPointerCancel?s.onPointerCancel(h,i):(g=s.onPointerUp)==null?void 0:g.call(s,h,i)},u=h=>{var g;return(g=s.onPointerLeave)==null?void 0:g.call(s,h,i)},m=h=>{var g;return(g=s.onDoubleClick)==null?void 0:g.call(s,h,i)};return r.addEventListener("pointerdown",a),r.addEventListener("pointermove",l),r.addEventListener("pointerup",c),r.addEventListener("pointercancel",f),r.addEventListener("pointerleave",u),r.addEventListener("dblclick",m),()=>{var h;r.removeEventListener("pointerdown",a),r.removeEventListener("pointermove",l),r.removeEventListener("pointerup",c),r.removeEventListener("pointercancel",f),r.removeEventListener("pointerleave",u),r.removeEventListener("dblclick",m),(h=s.onDeactivate)==null||h.call(s,i),r.style.cursor=""}},[n,o,e,t])}let Gn=1;const Xn=new Set;function yj(e){if(e!==Gn){Gn=e;for(const t of Xn)t(e)}}function xj(){return Gn}function bj(e){return Xn.add(e),()=>{Xn.delete(e)}}const Sn=.1,jn=8,wj=1.0015,vj=1.02;function kj(e,t,n={tx:0,ty:0,scale:1}){const o=I.useRef({...n}),r=I.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),yj(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return I.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 A=[...h.values()],D=A[1].x-A[0].x,se=A[1].y-A[0].y,ie=Math.hypot(D,se)||1,de=i.getBoundingClientRect();g={startDist:ie,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(A[0].x+A[1].x)/2-de.left,startMidY:(A[0].y+A[1].y)/2-de.top}},v=A=>{if(A.pointerType==="touch"){if(h.set(A.pointerId,{x:A.clientX,y:A.clientY}),h.size>=2&&!b){b=!0;for(const D of h.keys())D!==A.pointerId&&$w(i,D);$()}if(b){A.stopPropagation(),A.preventDefault();try{i.setPointerCapture(A.pointerId)}catch{}}}},P=A=>{if(A.pointerType!=="touch"||!h.has(A.pointerId)||(h.set(A.pointerId,{x:A.clientX,y:A.clientY}),!b||!g))return;A.stopPropagation();const D=[...h.values()];if(D.length<2)return;const se=D[1].x-D[0].x,ie=D[1].y-D[0].y,de=Math.hypot(se,ie)||1,oe=i.getBoundingClientRect(),re=(D[0].x+D[1].x)/2-oe.left,ye=(D[0].y+D[1].y)/2-oe.top,xe=de/g.startDist,_e=En(g.startScale*xe,Sn,jn),Ne=_e/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*Ne+(re-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ne+(ye-g.startMidY),o.current.scale=_e,s()},B=A=>{var D;if(A.pointerType==="touch"&&h.has(A.pointerId)&&(h.delete(A.pointerId),b)){if(A.stopPropagation(),(D=i.hasPointerCapture)!=null&&D.call(i,A.pointerId))try{i.releasePointerCapture(A.pointerId)}catch{}h.size>=2?$():g=null,h.size===0&&(b=!1)}},W=A=>{A.preventDefault();const D=i.getBoundingClientRect(),se=A.clientX-D.left,ie=A.clientY-D.top,de=A.ctrlKey||A.metaKey;if(A.deltaX===0||de){const ye=Math.pow(de?vj:wj,-A.deltaY),xe=En(o.current.scale*ye,Sn,jn),_e=xe/o.current.scale;o.current.tx=se-(se-o.current.tx)*_e,o.current.ty=ie-(ie-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=A.deltaX,o.current.ty-=A.deltaY;s()},k=A=>{const D=A.button===1,se=p&&A.button===0;!D&&!se||(A.preventDefault(),a=!0,l=A.pointerId,c=A.clientX,f=A.clientY,u=o.current.tx,m=o.current.ty,i.setPointerCapture(A.pointerId),i.style.cursor="grabbing")},F=A=>{!a||A.pointerId!==l||(o.current.tx=u+(A.clientX-c),o.current.ty=m+(A.clientY-f),s())},X=A=>{a&&A.pointerId===l&&(a=!1,i.releasePointerCapture(A.pointerId),i.style.cursor=p?"grab":"")},Z=A=>{if(A.code==="Space"&&!p){const D=A.target;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"||D.isContentEditable))return;p=!0,i.style.cursor="grab",A.preventDefault()}},G=A=>{A.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",W,{passive:!1}),i.addEventListener("pointerdown",k),i.addEventListener("pointermove",F),i.addEventListener("pointerup",X),i.addEventListener("pointercancel",X),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",P,{capture:!0}),i.addEventListener("pointerup",B,{capture:!0}),i.addEventListener("pointercancel",B,{capture:!0}),window.addEventListener("keydown",Z),window.addEventListener("keyup",G),s(),()=>{i.removeEventListener("wheel",W),i.removeEventListener("pointerdown",k),i.removeEventListener("pointermove",F),i.removeEventListener("pointerup",X),i.removeEventListener("pointercancel",X),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",P,{capture:!0}),i.removeEventListener("pointerup",B,{capture:!0}),i.removeEventListener("pointercancel",B,{capture:!0}),window.removeEventListener("keydown",Z),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 Tw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ot=Tw?"⌘":"Ctrl+",_j=Tw?"⇧":"Shift+",Nn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],$j=18;function Sj(e){for(const t of Nn)if(t*e>=$j)return t;return Nn[Nn.length-1]}function jj(){const e=ce(),t=I.useRef(null),n=I.useRef(null),o=I.useRef(null),r=kj(t,n);gj(t,r),JS(t),I.useEffect(()=>(Zo(r),()=>Zo(null)),[r]),I.useEffect(()=>{const f=u=>{const m=o.current;if(!m)return;const h=Sj(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=m2(),i=I.useCallback((f,u,m)=>{const p=x.getState();if(p.readOnly)return;const h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){Sw();return}const g=lt(m);if(g)p.selection.includes(g)||p.setSelection([g]);else{const k=an(m);k&&p.selectedNode!==k&&p.setSelectedNode(k)}const b=x.getState(),$=b.selection.length>0,v=b.selectedNode!=null,P=!!b.clipboard,B=b.diagram.elements.length>0,W=[{label:e("menu.undo"),shortcut:`${ot}Z`,icon:Jn,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${ot}${_j}Z`,icon:Un,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ot}X`,icon:Xr,onSelect:()=>x.getState().cutSelection(),disabled:!$},{label:e("menu.copy"),shortcut:`${ot}C`,icon:Hr,onSelect:()=>x.getState().copySelection(),disabled:!$},{label:e("menu.paste"),shortcut:`${ot}V`,icon:Fr,onSelect:()=>x.getState().pasteClipboard(),disabled:!P},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Gr,onSelect:()=>x.getState().rotateSelection(90),disabled:!$},{label:e("menu.mirror"),shortcut:"M",icon:Wr,onSelect:()=>x.getState().mirrorSelection(),disabled:!$},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ot}A`,icon:Ov,onSelect:()=>{const k=x.getState();k.setSelection(k.diagram.elements.map(F=>F.id))},disabled:!B},{type:"separator"},{label:e(v&&!$?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Kr,destructive:!0,onSelect:()=>v&&!$?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!$&&!v}];s.open(f,u,W)},[s,e]);I.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=P=>{P.pointerType==="touch"&&(g(),h={pointerId:P.pointerId,x:P.clientX,y:P.clientY,target:P.target},p=window.setTimeout(()=>{const B=h;h=null,p=void 0,B&&($w(f,B.pointerId),i(B.x,B.y,B.target))},u))},$=P=>{if(!h||P.pointerId!==h.pointerId)return;const B=P.clientX-h.x,W=P.clientY-h.y;Math.hypot(B,W)>m&&g()},v=P=>{!h||P.pointerId!==h.pointerId||g()};return f.addEventListener("pointerdown",b),f.addEventListener("pointermove",$),f.addEventListener("pointerup",v),f.addEventListener("pointercancel",v),()=>{g(),f.removeEventListener("pointerdown",b),f.removeEventListener("pointermove",$),f.removeEventListener("pointerup",v),f.removeEventListener("pointercancel",v)}},[i]);const a=f=>{f.dataTransfer.types.includes("application/x-oneline-kind")&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},l=f=>{if(x.getState().readOnly)return;const u=f.dataTransfer.getData("application/x-oneline-kind");if(!u)return;f.preventDefault();const m=r.screenToSvg(f.clientX,f.clientY);yw(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(yS,{}),d.jsx(RS,{}),d.jsx(SS,{}),d.jsx(NS,{}),d.jsx(iS,{}),d.jsx(lS,{}),d.jsx(CS,{}),d.jsx(fS,{}),d.jsx(mS,{}),d.jsx(PS,{}),d.jsx(FS,{}),d.jsx(xS,{}),d.jsx(IS,{}),d.jsx(AS,{})]})]})})}const pr=60,Ej=.1,Nj=8,Mj=8;function Tj(e,t,n){return e<t?t:e>n?n:e}function Aj(){return document.querySelector(".ole-canvas-root")}function to(){const e=Ze(),t=Aj();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 v=$.getBoundingClientRect();v.width===0&&v.height===0||(v.left<r&&(r=v.left),v.top<s&&(s=v.top),v.right>i&&(i=v.right),v.bottom>a&&(a=v.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[f,u]=e.screenToSvg(i,a),m=Math.max(f-l,1),p=Math.max(u-c,1),h=Tj(Math.min((n.width-pr*2)/m,(n.height-pr*2)/p),Ej,Nj),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=Mj;const t=()=>{to()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const gr=10,Ij=100;function Cj(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function yr(){const[e,t]=I.useState(YS()),[n,o]=I.useState(!1),[r,s]=I.useState(null),i=I.useRef(null),a=I.useRef(void 0),[l]=I.useState(Cj);I.useEffect(()=>KS(h=>t(h)),[]),I.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),Ij),()=>window.clearTimeout(a.current)},[e]);const c=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(I.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,b=-1;const $=()=>{const v=document.querySelector(`[data-element-id="${Oj(e)}"]`),P=i.current;if(v&&P){const B=v.getBoundingClientRect();let W=B.bottom+gr;W+P.offsetHeight>window.innerHeight-4&&(W=B.top-P.offsetHeight-gr);let k=B.left+B.width/2-P.offsetWidth/2;k=Math.max(4,Math.min(k,window.innerWidth-P.offsetWidth-4)),(W!==g||k!==b)&&(s({top:W,left:k}),g=W,b=k)}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:Rr.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 Oj(e){return e.replace(/(["\\])/g,"\\$1")}function Pj({width:e,children:t}){const n=e==null?"full":lj(e);return d.jsx(Nw.Provider,{value:n,children:t})}function xr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Bj(...e){return t=>{let n=!1;const o=e.map(r=>{const s=xr(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():xr(e[r],null)}}}}var Lj=Symbol.for("react.lazy"),en=ke[" use ".trim().toString()];function Rj(e){return typeof e=="object"&&e!==null&&"then"in e}function Aw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Lj&&"_payload"in e&&Rj(e._payload)}function zj(e){const t=Fj(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;Aw(s)&&typeof en=="function"&&(s=en(s._payload));const a=ke.Children.toArray(s),l=a.find(Wj);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 Dj=zj("Slot");function Fj(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(Aw(r)&&typeof en=="function"&&(r=en(r._payload)),ke.isValidElement(r)){const i=Gj(r),a=qj(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?Bj(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 Hj=Symbol("radix.slottable");function Wj(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hj}function qj(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 Gj(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 br=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,wr=Jr,Xj=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return wr(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=br(f)||br(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 wr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},Yj=Xj("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?Dj:"button";return d.jsx(i,{className:Ee(Yj({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const Kj=350;function Ie({content:e,children:t,disabled:n,delayMs:o=Kj}){const r=I.useRef(null),s=I.useRef(null),[i,a]=I.useState(!1),[l,c]=I.useState(null),f=I.useId(),u=I.useRef(void 0),m=()=>{n||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(u.current),a(!1)};I.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const $=r.current.getBoundingClientRect(),v=s.current.getBoundingClientRect(),P=8;let B="top",W=$.top-v.height-P;W<4&&(B="bottom",W=$.bottom+P);let k=$.left+$.width/2-v.width/2;k=Math.max(4,Math.min(k,window.innerWidth-v.width-4)),c({top:W,left:k,side:B})},[i,e]),I.useEffect(()=>()=>window.clearTimeout(u.current),[]),I.useEffect(()=>{if(!i)return;const $=P=>{P.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",$),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",$),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const h=t,g=h.props,b=I.cloneElement(h,{ref:$=>{r.current=$;const v=h.ref;typeof v=="function"?v($):v&&typeof v=="object"&&(v.current=$)},onPointerEnter:$=>{var v;(v=g.onPointerEnter)==null||v.call(g,$),m()},onPointerLeave:$=>{var v;(v=g.onPointerLeave)==null||v.call(g,$),p()},onFocus:$=>{var v;(v=g.onFocus)==null||v.call(g,$),m()},onBlur:$=>{var v;(v=g.onBlur)==null||v.call(g,$),p()},"aria-describedby":i?f:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[b,i&&typeof document<"u"&&Rr.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 vr=12,Vj=56;function Uj(){var $;const e=ce(),t=x(v=>v.selection),n=x(v=>v.selectedNode),o=x(v=>v.selectedWire),r=x(v=>v.activeTool),s=x(v=>v.rotateSelection),i=x(v=>v.mirrorSelection),a=x(v=>v.deleteSelection),l=x(v=>v.deleteSelectedNode),c=x(v=>v.deleteSelectedWire),f=x(v=>v.resetWirePath),u=x(v=>v.internal.wireRenders),m=o!=null&&(($=u.get(o))==null?void 0:$.userEdited)===!0,p=I.useRef(null);I.useEffect(()=>{const v=p.current;if(!v)return;const P=t.length>0,B=!P&&o!=null,W=!P&&!B&&n!=null;if(!((P||B||W)&&(r==="select"||r==="pan"))){v.style.display="none";return}v.style.display="flex";let F=0,X="";const Z=()=>{let G=1/0,A=-1/0,D=1/0,se=-1/0,ie=!1;const de=oe=>{oe.width===0&&oe.height===0||(oe.left<G&&(G=oe.left),oe.right>A&&(A=oe.right),oe.top<D&&(D=oe.top),oe.bottom>se&&(se=oe.bottom),ie=!0)};if(P)for(const oe of t){const re=document.querySelector(`[data-element-id="${CSS.escape(oe)}"]`);re&&de(re.getBoundingClientRect())}else if(B&&o){const oe=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);oe&&de(oe.getBoundingClientRect())}else if(W&&n){const oe=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const re of oe)de(re.getBoundingClientRect())}if(ie){const oe=(G+A)/2;let re=D-vr,ye="-100%";re<Vj&&(re=se+vr,ye="0%");const xe=`translate3d(${oe}px, ${re}px, 0) translate(-50%, ${ye})`;xe!==X&&(v.style.transform=xe,X=xe)}F=requestAnimationFrame(Z)};return F=requestAnimationFrame(Z),()=>cancelAnimationFrame(F)},[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(Cv,{})})}),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(Gr,{})})}),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(Wr,{})})}),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(Kr,{})})})]})}function oo({open:e,onOpenChange:t,trigger:n,children:o}){const r=I.useRef(null);return I.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),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 Iw="ole-panel-open";function Jj(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Iw);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 kr(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Iw,JSON.stringify(t))}catch{}}const At=tn((e,t)=>({...Jj(),setOutlineOpen:n=>{e({outlineOpen:n}),kr(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),kr(t())}})),Xt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Cw=.1,Ow=8,Pw="ole-grid";function Zj(){try{const e=window.localStorage.getItem(Pw);return e==null?!0:e==="1"}catch{return!0}}function Qj(e){try{window.localStorage.setItem(Pw,e?"1":"0")}catch{}}function e4(e,t,n){return e<t?t:e>n?n:e}function Bw(){return document.querySelector(".ole-canvas-root")}function ro(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=e4(e,Cw,Ow),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function t4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=Xt.find(o=>o>t+1e-6)??Ow;ro(n)}function n4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=Cw;for(let o=Xt.length-1;o>=0;o--)if(Xt[o]<t-1e-6){n=Xt[o];break}ro(n)}const o4={off:"id",id:"all",all:"off"};function r4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=o4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Lw(){const[e,t]=I.useState(()=>Zj());return I.useEffect(()=>{const n=Bw();n==null||n.classList.toggle("hide-grid",!e),Qj(e)},[e]),I.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Rw(){const e=ce();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:n4,"aria-label":e("view.zoomOut"),children:d.jsx(Vn,{})})})}function zw(){const e=ce();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:t4,"aria-label":e("view.zoomIn"),children:d.jsx(Av,{})})})}function Dw(){const e=ce(),[t,n]=I.useState(xj);return I.useEffect(()=>bj(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 Fw(){const e=ce();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(Nv,{})})})}function Hw({grid:e,setGrid:t}){const n=ce();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(jv,{})})})}function Ww(){const e=ce(),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:r4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:Ee(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Vr,{})})})}function s4({stacked:e}={}){const t=ce(),[n,o]=I.useState(!1),[r,s]=Lw(),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(Dw,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Rw,{}),d.jsx(zw,{})]}),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(Fw,{}),d.jsx(Hw,{grid:r,setGrid:s}),d.jsx(Ww,{})]})]})})}function _r(){const e=Ve();return!x(n=>n.readOnly)&&Pe(e,"dense")?null:d.jsx(i4,{tier:e})}function i4({tier:e}){const t=Pe(e,"tight"),n=x(s=>s.readOnly),[o,r]=Lw();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(Rw,{}),!t&&d.jsx(Dw,{}),d.jsx(zw,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(Fw,{}),d.jsx(Hw,{grid:o,setGrid:r}),!n&&d.jsx(Ww,{})]})})}const $r=[{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:Ev,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:wv,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Yr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Dr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Vr,switchTo:"text",iconOnly:!0}];function a4(){const e=ce(),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 l4(){const e=ce(),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=Pe(l,"tight"),f=!Pe(l,"dense"),u=Pe(l,"dense"),m=u?$r.filter(h=>h.id!=="select"&&h.id!=="text"):$r,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(a4,{}),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(c4,{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(I.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(u4,{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(d4,{iconOnly:c})]}),u&&d.jsx(s4,{stacked:!0})]})]})}function c4({stacked:e}){const t=ce(),n=At(r=>r.outlineOpen),o=At(r=>r.toggleOutline);return d.jsx(it,{icon:qr,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 qw(){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 d4({iconOnly:e}){const t=ce(),[n,o]=I.useState(!1),r=qw(),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(Yt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Yt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function u4({stacked:e}){const t=ce(),[n,o]=I.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=qw(),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(Xr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Te,{onClick:u(()=>x.getState().copySelection()),icon:d.jsx(Hr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Te,{onClick:u(()=>x.getState().pasteClipboard()),icon:d.jsx(Fr,{}),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(Yt,{}),disabled:!f.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:u(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Yt,{}),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 f4(){const e=At(r=>r.outlineOpen),t=At(r=>r.setOutlineOpen),n=Ve();return Pe(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(Sr,{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(Sr,{onClose:()=>t(!1)}):d.jsx(m4,{onClick:()=>t(!0)})})}function m4({onClick:e}){const t=ce(),n=Ve(),o=Pe(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(qr,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function Sr({onClose:e,sheet:t}){const n=ce(),o=x(c=>c.diagram.elements),r=x(c=>c.activeTool==="place"),s=Ve(),i=Pe(s,"compact"),a=Pe(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(p4,{children:o.length}),d.jsx(Tv,{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(h4,{element:c},c.id))})})]})}function h4({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=!Pe(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 p4({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 g4={"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":"负荷","panelboard.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":"抽象负荷(电流流出箭头)","panelboard.desc":"配电箱 / 负荷中心(IEC 分配中心符号):底部进线,箱顶分路示意","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":"剩余动作电流"},y4={"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","panelboard.name":"Panelboard / load center","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"},jr={zh:g4,en:y4};function x4(e,t){return jr[e][t]??jr.zh[t]}function Ot(){const e=It(t=>t.locale);return(t,n)=>x4(e,t)??n??t}const Gw="ole-palette-collapsed",b4=new Set(["busbar"]),Mt=(()=>{const e={};for(const[t,n]of Object.entries(X$)){const o=n.filter(r=>!b4.has(r.id));o.length&&(e[t]=o)}return e})(),w4=(()=>{const e=new Set(Xo),t=Object.keys(Mt).filter(n=>!e.has(n));return[...Xo.filter(n=>{var o;return(o=Mt[n])==null?void 0:o.length}),...t]})();function v4(){try{const e=window.localStorage.getItem(Gw);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 k4(e){try{window.localStorage.setItem(Gw,JSON.stringify([...e]))}catch{}}function _4(){const e=ce(),t=x(u=>u.activeTool==="place"),n=x(u=>u.placeKind),o=x(u=>u.setActiveTool),r=At(u=>u.outlineOpen),s=Ve(),i=Pe(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($4,{sheet:i})]})})}function $4({sheet:e}){const t=ce(),n=Ot(),[o,r]=I.useState(""),[s,i]=I.useState(()=>v4()),a=I.useMemo(()=>{const u=o.trim().toLowerCase();if(!u)return Mt;const m={};for(const[p,h]of Object.entries(Mt)){const g=h.filter(b=>{const $=n(`${b.id}.name`,b.name).toLowerCase(),v=n(`${b.id}.desc`,b.description??"").toLowerCase();return $.includes(u)||b.id.toLowerCase().includes(u)||v.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=I.useCallback((u,m)=>{i(p=>{const h=new Set(p);return m?h.delete(u):h.add(u),k4(h),h})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(S4,{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")}):w4.map(u=>{var b;const m=a[u];if(!(m!=null&&m.length))return null;const p=((b=Mt[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(bv,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:h}),d.jsx(E4,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map($=>d.jsx(j4,{entry:$,sheet:e},$.id))})]},u)})})]})}function S4({value:e,onChange:t}){const n=ce();return d.jsxs("div",{className:"relative",children:[d.jsx(Iv,{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 j4({entry:e,sheet:t}){const n=ce(),o=Ot(),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=I.useRef(null);I.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 E4({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 N4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Yn)==="1"}catch{return!1}}function Er(e){try{e?window.localStorage.setItem(Yn,"1"):window.localStorage.removeItem(Yn)}catch{}}const Nr=tn(e=>({dismissed:N4(),dismiss:()=>{Er(!0),e({dismissed:!0})},reset:()=>{Er(!1),e({dismissed:!1})}}));function M4(){const e=ce(),t=Nr(o=>o.dismissed),n=Nr(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(Yr,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Mn,{n:2,icon:d.jsx(Dr,{}),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 T4(){const e=ce(),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(B4,{wireId:i});if(s)return d.jsx(R4,{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(O4,{bus:l});const c=(r??[]).find(m=>m.id===a);if(c)return d.jsx(L4,{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(ut,{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()})},a),(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(D4,{id:a,element:f,field:m},m.name))}),d.jsx(A4,{id:a,element:f,schema:(u==null?void 0:u.params)??[]})]})}function A4({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(I4,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(C4,{id:e,element:t,fieldKey:s,value:i},s))]})}function I4({id:e,element:t,field:n}){var l;const o=ce(),r=Ot(),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(dt,{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(ut,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function C4({id:e,element:t,fieldKey:n,value:o}){const r=ce(),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(dt,{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(ut,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function O4({bus:e}){const t=ce(),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(ut,{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()})},n),d.jsx(P4,{bus:e})]})}function P4({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 B4({wireId:e}){const t=ce(),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 W=u.get(b);if(W)return{id:b,label:W.name??b};const k=m.get(b);return{id:b,label:(k==null?void 0:k.name)??b}}const $=b.indexOf("."),v=b.slice(0,$),P=b.slice($+1),B=f.get(v);return{id:v,label:(B==null?void 0:B.name)??v,pin:P}},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 L4({junction:e}){var r;const t=ce(),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(ut,{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()})},e.id),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 R4({nodeId:e}){const t=ce(),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 dt({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 ut({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>i(t),[t]),d.jsx(dt,{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})]})})}const z4=350;function so({label:e,value:t,onCommit:n}){const[o,r]=I.useState(t),s=I.useRef(!1),i=I.useRef(null),a=I.useRef({local:o,value:t,onCommit:n});a.current={local:o,value:t,onCommit:n};const l=I.useRef(null);I.useEffect(()=>{s.current||(r(t),l.current=null)},[t]);const c=()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null);const u=a.current;u.local===u.value||u.local===l.current||(l.current=u.local,u.onCommit(u.local))},f=I.useRef(c);return f.current=c,I.useEffect(()=>()=>f.current(),[]),d.jsx(dt,{label:e,children:d.jsx("textarea",{rows:2,value:o,onFocus:()=>{s.current=!0},onChange:u=>{r(u.target.value),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,f.current()},z4)},onBlur:()=>{s.current=!1,c()},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]=I.useState(String(t)),a=I.useRef(null);return I.useEffect(()=>i(String(t)),[t]),d.jsx(dt,{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 D4({id:e,element:t,field:n}){var l;const o=ce(),s=Ot()(`${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(dt,{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(ut,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function F4(){const e=ce(),t=Ot(),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=Pe(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(T4,{})]})}function H4(){I.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function W4(){H4();const e=x(o=>o.readOnly),t=I.useRef(null),n=cj(t);return d.jsx(h2,{children:d.jsx("div",{ref:t,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(Pj,{width:n,children:[d.jsx(jj,{}),e?d.jsxs(d.Fragment,{children:[d.jsx(_r,{}),d.jsx(yr,{})]}):d.jsxs(d.Fragment,{children:[d.jsx(f4,{}),d.jsx(F4,{}),d.jsx(l4,{}),d.jsx(_r,{}),d.jsx(Uj,{}),d.jsx(_4,{}),d.jsx(M4,{}),d.jsx(yr,{})]})]})})})}const q4="ole-theme";function G4(){try{const e=window.localStorage.getItem(q4);return e==="light"||e==="dark"?e:null}catch{return null}}function X4(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function Y4(){return typeof window>"u"?"light":G4()??(X4()?"dark":"light")}function Xw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function K4({className:e,diagram:t,readOnly:n,locale:o,theme:r}){return I.useEffect(()=>{x.getState().setReadOnly(!!n)},[n]),I.useEffect(()=>{if(!t)return;if(n){x.getState().setDiagram(t),x.getState().setActiveTool("pan");return}x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t,n]),I.useEffect(()=>{o&&It.getState().setLocale(o)},[o]),I.useEffect(()=>{r&&Xw(r)},[r]),I.useEffect(()=>{no()},[]),GS(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(W4,{})})}const Yw={"application/json":[".json"]},Kw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Vw=e=>e instanceof DOMException&&e.name==="AbortError";function Mr(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 V4(e){return JSON.stringify(e,null,2)+`
|
|
199
|
-
`}async function
|
|
200
|
-
`);for(let
|
|
196
|
+
*/const to=ae("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Zr(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=Zr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Qr(){for(var e,t,n=0,o="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=Zr(e))&&(o&&(o+=" "),o+=t);return o}const no="-",Lv=e=>{const t=zv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(no);return a[0]===""&&a.length!==1&&a.shift(),es(a,t)||Rv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},es=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),s=o?es(e.slice(1),o):void 0;if(s)return s;if(t.validators.length===0)return;const r=e.join(no);return(i=t.validators.find(({validator:a})=>a(r)))==null?void 0:i.classGroupId},Oo=/^\[(.+)\]$/,Rv=e=>{if(Oo.test(e)){const t=Oo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},zv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return Fv(Object.entries(e.classGroups),n).forEach(([r,i])=>{Pn(i,o,r,t)}),o},Pn=(e,t,n,o)=>{e.forEach(s=>{if(typeof s=="string"){const r=s===""?t:Po(t,s);r.classGroupId=n;return}if(typeof s=="function"){if(Dv(s)){Pn(s(o),t,n,o);return}t.validators.push({validator:s,classGroupId:n});return}Object.entries(s).forEach(([r,i])=>{Pn(i,Po(t,r),n,o)})})},Po=(e,t)=>{let n=e;return t.split(no).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},Dv=e=>e.isThemeGetter,Fv=(e,t)=>t?e.map(([n,o])=>{const s=o.map(r=>typeof r=="string"?t+r:typeof r=="object"?Object.fromEntries(Object.entries(r).map(([i,a])=>[t+i,a])):r);return[n,s]}):e,Wv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const s=(r,i)=>{n.set(r,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(r){let i=n.get(r);if(i!==void 0)return i;if((i=o.get(r))!==void 0)return s(r,i),i},set(r,i){n.has(r)?n.set(r,i):s(r,i)}}},ts="!",Hv=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,s=t[0],r=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(_===s&&(o||a.slice(b,b+r)===t)){l.push(a.slice(f,b)),f=b+r;continue}if(_==="/"){u=b;continue}}_==="["?c++:_==="]"&&c--}const m=l.length===0?a:a.substring(f),p=m.startsWith(ts),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},qv=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},Gv=e=>({cache:Wv(e.cacheSize),parseClassName:Hv(e),...Lv(e)}),Xv=/\s+/,Yv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:s}=t,r=[],i=e.trim().split(Xv);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=qv(f).join(":"),_=u?b+ts:b,v=_+g;if(r.includes(v))continue;r.push(v);const O=s(g,h);for(let L=0;L<O.length;++L){const W=O[L];r.push(_+W)}a=c+(a.length>0?" "+a:a)}return a};function Kv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=ns(t))&&(o&&(o+=" "),o+=n);return o}const ns=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=ns(e[o]))&&(n&&(n+=" "),n+=t);return n};function Vv(e,...t){let n,o,s,r=i;function i(l){const c=t.reduce((f,u)=>u(f),e());return n=Gv(c),o=n.cache.get,s=n.cache.set,r=a,a(l)}function a(l){const c=o(l);if(c)return c;const f=Yv(l,n);return s(l,f),f}return function(){return r(Kv.apply(null,arguments))}}const he=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},os=/^\[(?:([a-z-]+):)?(.+)\]$/i,Uv=/^\d+\/\d+$/,Jv=new Set(["px","full","screen"]),Zv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Qv=/\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$/,e2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,t2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,n2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Re=e=>at(e)||Jv.has(e)||Uv.test(e),He=e=>dt(e,"length",d2),at=e=>!!e&&!Number.isNaN(Number(e)),yn=e=>dt(e,"number",at),yt=e=>!!e&&Number.isInteger(Number(e)),o2=e=>e.endsWith("%")&&at(e.slice(0,-1)),ne=e=>os.test(e),qe=e=>Zv.test(e),r2=new Set(["length","size","percentage"]),s2=e=>dt(e,r2,rs),i2=e=>dt(e,"position",rs),a2=new Set(["image","url"]),l2=e=>dt(e,a2,f2),c2=e=>dt(e,"",u2),xt=()=>!0,dt=(e,t,n)=>{const o=os.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},d2=e=>Qv.test(e)&&!e2.test(e),rs=()=>!1,u2=e=>t2.test(e),f2=e=>n2.test(e),m2=()=>{const e=he("colors"),t=he("spacing"),n=he("blur"),o=he("brightness"),s=he("borderColor"),r=he("borderRadius"),i=he("borderSpacing"),a=he("borderWidth"),l=he("contrast"),c=he("grayscale"),f=he("hueRotate"),u=he("invert"),m=he("gap"),p=he("gradientColorStops"),h=he("gradientColorStopPositions"),g=he("inset"),b=he("margin"),_=he("opacity"),v=he("padding"),O=he("saturate"),L=he("scale"),W=he("sepia"),k=he("skew"),F=he("space"),X=he("translate"),Z=()=>["auto","contain","none"],G=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",ne,t],D=()=>[ne,t],se=()=>["",Re,He],ie=()=>["auto",at,ne],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],re=()=>["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",ne],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ne=()=>[at,ne];return{cacheSize:500,separator:":",theme:{colors:[xt],spacing:[Re,He],blur:["none","",qe,ne],brightness:Ne(),borderColor:[e],borderRadius:["none","","full",qe,ne],borderSpacing:D(),borderWidth:se(),contrast:Ne(),grayscale:xe(),hueRotate:Ne(),invert:xe(),gap:D(),gradientColorStops:[e],gradientColorStopPositions:[o2,He],inset:A(),margin:A(),opacity:Ne(),padding:D(),saturate:Ne(),scale:Ne(),sepia:xe(),skew:Ne(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",ne]}],container:["container"],columns:[{columns:[qe]}],"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:[...de(),ne]}],overflow:[{overflow:G()}],"overflow-x":[{"overflow-x":G()}],"overflow-y":[{"overflow-y":G()}],overscroll:[{overscroll:Z()}],"overscroll-x":[{"overscroll-x":Z()}],"overscroll-y":[{"overscroll-y":Z()}],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",yt,ne]}],basis:[{basis:A()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ne]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",yt,ne]}],"grid-cols":[{"grid-cols":[xt]}],"col-start-end":[{col:["auto",{span:["full",yt,ne]},ne]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[xt]}],"row-start-end":[{row:["auto",{span:[yt,ne]},ne]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ne]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ne]}],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:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[F]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[F]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ne,t]}],"min-w":[{"min-w":[ne,t,"min","max","fit"]}],"max-w":[{"max-w":[ne,t,"none","full","min","max","fit","prose",{screen:[qe]},qe]}],h:[{h:[ne,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ne,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ne,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ne,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qe,He]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",yn]}],"font-family":[{font:[xt]}],"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",ne]}],"line-clamp":[{"line-clamp":["none",at,yn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Re,ne]}],"list-image":[{"list-image":["none",ne]}],"list-style-type":[{list:["none","disc","decimal",ne]}],"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",Re,He]}],"underline-offset":[{"underline-offset":["auto",Re,ne]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ne]}],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",ne]}],"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:[...de(),i2]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",s2]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},l2]}],"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:[r]}],"rounded-s":[{"rounded-s":[r]}],"rounded-e":[{"rounded-e":[r]}],"rounded-t":[{"rounded-t":[r]}],"rounded-r":[{"rounded-r":[r]}],"rounded-b":[{"rounded-b":[r]}],"rounded-l":[{"rounded-l":[r]}],"rounded-ss":[{"rounded-ss":[r]}],"rounded-se":[{"rounded-se":[r]}],"rounded-ee":[{"rounded-ee":[r]}],"rounded-es":[{"rounded-es":[r]}],"rounded-tl":[{"rounded-tl":[r]}],"rounded-tr":[{"rounded-tr":[r]}],"rounded-br":[{"rounded-br":[r]}],"rounded-bl":[{"rounded-bl":[r]}],"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:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...oe()]}],"outline-offset":[{"outline-offset":[Re,ne]}],"outline-w":[{outline:[Re,He]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:se()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[Re,He]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",qe,c2]}],"shadow-color":[{shadow:[xt]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",qe,ne]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[O]}],sepia:[{sepia:[W]}],"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":[O]}],"backdrop-sepia":[{"backdrop-sepia":[W]}],"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",ne]}],duration:[{duration:Ne()}],ease:[{ease:["linear","in","out","in-out",ne]}],delay:[{delay:Ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",ne]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[yt,ne]}],"translate-x":[{"translate-x":[X]}],"translate-y":[{"translate-y":[X]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ne]}],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",ne]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ne]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Re,He,yn]}],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"]}}},h2=Vv(m2);function Ee(...e){return h2(Qr(e))}const ss=I.createContext(null);function p2(){const e=I.useContext(ss);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Lt=8;function g2({children:e}){const[t,n]=I.useState({open:!1,x:0,y:0,items:[]}),[o,s]=I.useState(null),r=I.useRef(null),i=I.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=I.useCallback((c,f,u)=>{s(null),n({open:!0,x:c,y:f,items:u})},[]),l=I.useMemo(()=>({open:a,close:i}),[a,i]);return I.useLayoutEffect(()=>{if(!t.open||!r.current)return;const c=r.current.getBoundingClientRect();let f=t.x,u=t.y;f+c.width>window.innerWidth-Lt&&(f=Math.max(Lt,t.x-c.width)),u+c.height>window.innerHeight-Lt&&(u=Math.max(Lt,t.y-c.height)),s({left:f,top:u})},[t]),I.useEffect(()=>{if(!t.open)return;const c=p=>{r.current&&!r.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(ss.Provider,{value:l,children:[e,t.open&&d.jsx("div",{ref:r,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 Bo=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))}},s=()=>t,a={setState:o,getState:s,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,s,a);return a},y2=(e=>e?Bo(e):Bo),x2=e=>e;function b2(e,t=x2){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const Lo=e=>{const t=y2(e),n=o=>b2(t,o);return Object.assign(n,t),n},tn=(e=>e?Lo(e):Lo),Ro={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.label":"标注","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","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)。别拿母线连两个器件——点对点直接拉线(W)就行。","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.label":"Label","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","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":"A busbar is a shared rail, not a wire","onboard.step3.body":"Use the Busbar tool (B) only when several circuits share one rail. Don't use a bus to join two devices — just wire the pins (W).","onboard.dismiss":"Got it"}},is="ole-locale";function w2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(is);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 zo(e){try{window.localStorage.setItem(is,e)}catch{}}const It=tn((e,t)=>({locale:w2(),setLocale:n=>{zo(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";zo(n),e({locale:n})}}));function as(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function ls(e,t){return Ro[e][t]??Ro.zh[t]??t}function we(e,t){return as(ls(It.getState().locale,e),t)}function ce(){const e=It(t=>t.locale);return(t,n)=>as(ls(e,t),n)}function cs(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var r;const i=l=>l===null?null:JSON.parse(l,void 0),a=(r=n.getItem(s))!=null?r:null;return a instanceof Promise?a.then(i):i(a)},setItem:(s,r)=>n.setItem(s,JSON.stringify(r,void 0)),removeItem:s=>n.removeItem(s)}}const Bn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Bn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Bn(o)(n)}}}},v2=(e,t)=>(n,o,s)=>{let r={storage:cs(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,_)=>({..._,...b}),...t},i=!1,a=0;const l=new Set,c=new Set;let f=r.storage;if(!f)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${r.name}', the given storage is currently unavailable.`),n(...b)},o,s);const u=()=>{const b=r.partialize({...o()});return f.setItem(r.name,{state:b,version:r.version})},m=s.setState;s.setState=(b,_)=>(m(b,_),u());const p=e((...b)=>(n(...b),u()),o,s);s.getInitialState=()=>p;let h;const g=()=>{var b,_;if(!f)return;const v=++a;i=!1,l.forEach(L=>{var W;return L((W=o())!=null?W:p)});const O=((_=r.onRehydrateStorage)==null?void 0:_.call(r,(b=o())!=null?b:p))||void 0;return Bn(f.getItem.bind(f))(r.name).then(L=>{if(L)if(typeof L.version=="number"&&L.version!==r.version){if(r.migrate){const W=r.migrate(L.state,L.version);return W instanceof Promise?W.then(k=>[!0,k]):[!0,W]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,L.state];return[!1,void 0]}).then(L=>{var W;if(v!==a)return;const[k,F]=L;if(h=r.merge(F,(W=o())!=null?W:p),n(h,!0),k)return u()}).then(()=>{v===a&&(O==null||O(o(),void 0),h=o(),i=!0,c.forEach(L=>L(h)))}).catch(L=>{v===a&&(O==null||O(void 0,L))})};return s.persist={setOptions:b=>{r={...r,...b},b.storage&&(f=b.storage)},clearStorage:()=>{f==null||f.removeItem(r.name)},getOptions:()=>r,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},r.skipHydration||g(),h||p},k2=v2,ze=.5;function ds(e){if(e.length<2)return e.map(s=>[s[0],s[1]]);const t=[[e[0][0],e[0][1]]];for(let s=1;s<e.length;s++){const r=t[t.length-1];Math.abs(r[0]-e[s][0])<ze&&Math.abs(r[1]-e[s][1])<ze||t.push([e[s][0],e[s][1]])}if(t.length<2)return t;const n=[t[0]];for(let s=1;s<t.length;s++){const r=n[n.length-1],i=t[s],a=Math.abs(r[0]-i[0]),l=Math.abs(r[1]-i[1]);if(a>ze&&l>ze){const f=(n.length>=2?Math.abs(n[n.length-2][1]-r[1])<ze?"h":"v":null)==="h"?[i[0],r[1]]:[r[0],i[1]];n.push(f)}n.push(i)}const o=[n[0]];for(let s=1;s<n.length-1;s++){const r=o[o.length-1],i=n[s],a=n[s+1],l=Math.abs(r[0]-i[0])<ze&&Math.abs(i[0]-a[0])<ze,c=Math.abs(r[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 us(){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 fs(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 Ln(e){return e===90||e===270?"y":"x"}function Oe(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 _2={n:"e",e:"s",s:"w",w:"n"},$2={n:"n",s:"s",e:"w",w:"e"};function St(e,t){let n=t.mirror?$2[e]:e;const o=t.rot/90|0;for(let s=0;s<o;s++)n=_2[n];return n}function Rn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class ms{constructor(){gt(this,"parent",new Map);gt(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),s=this.parent.get(o);this.parent.set(n,s),n=s}return n}union(t,n){const o=this.find(t),s=this.find(n);if(o===s)return;const r=this.rank.get(o),i=this.rank.get(s);r<i?this.parent.set(o,s):r>i?this.parent.set(s,o):(this.parent.set(s,o),this.rank.set(o,r+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),s=t.get(o);s?s.push(n):t.set(o,[n])}return t}}const Do=["n","e","s","w"],Fo={n:"s",s:"n",e:"w",w:"e"};function Rt(e,t){const n=Do.indexOf(e),s=((Do.indexOf(t)-n)%4+4)%4;return[0,90,180,270][s]}const xn=320,zt=220,bt=260,bn=720,wt=30,Wo=30,Ge=80,Ho=10,S2=60,j2=520,E2=80,N2=80,qo=8,Go=new Set(["source","renewable"]);function M2(e){var So,jo,Eo,No,Mo,To;const{elements:t,buses:n,junctions:o,wires:s,library:r,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 w=p.get(y);if(w)return r.get(w.kind)},b=new Set(n.map(y=>y.id)),_=y=>b.has(y),v=new Set(o.map(y=>y.id)),O=new Set(o.filter(y=>{var w;return(w=y.layout)==null?void 0:w.at}).map(y=>y.id)),L=new ms;for(const y of s)L.add(y.ends[0]),L.add(y.ends[1]),L.union(y.ends[0],y.ends[1]);for(const y of t){const w=r.get(y.kind);if(w)for(const S of w.terminals)L.add(`${y.id}.${S.id}`)}for(const y of n)L.add(y.id);const W=[];for(const[,y]of L.groups())y.length>=2&&W.push(y);const k=new Map;for(const y of W)for(const w of y)k.set(w,[y]);const F=new Map;for(const y of W){const w=y.filter(_);if(w.length!==0)for(const S of w){const E=y.filter($=>$!==S),j=F.get(S)??[];j.push(...E),F.set(S,j)}}{const S=T=>p.has(T)&&!!g(T),E=T=>{if(_(T))return null;if(v.has(T))return T;const N=T.indexOf(".");return N>0?T.slice(0,N):null},j=new Map,$=new Set,M=(T,N)=>{j.has(T)||j.set(T,new Set),j.has(N)||j.set(N,new Set),T!==N&&(j.get(T).add(N),j.get(N).add(T))};for(const T of W){const N=[];let B=!1;for(const q of T){if(_(q)){B=!0;continue}const Q=E(q);Q&&N.push(Q)}const R=[...new Set(N)];for(const q of R)j.has(q)||j.set(q,new Set),B&&$.add(q);const H=R.filter(q=>v.has(q)),Y=R.filter(q=>!v.has(q));if(H.length>0){for(const q of H)for(const Q of Y)M(q,Q);for(let q=0;q<H.length;q++)for(let Q=q+1;Q<H.length;Q++)M(H[q],H[Q])}else for(let q=0;q<Y.length;q++)for(let Q=q+1;Q<Y.length;Q++)M(Y[q],Y[Q])}const z=(T,N)=>{const B=g(T);if(!B)return null;for(const R of B.terminals){const H=`${T}.${R.id}`;for(const Y of k.get(H)??[])for(const q of Y)if(E(q)===N)return R}return null},C=T=>{const N=U=>{var te;return((te=j.get(U))==null?void 0:te.size)??0},B=U=>{var te;return((te=g(U))==null?void 0:te.category)??""},R=U=>{const te=B(U);return te==="source"?0:te==="renewable"?1:2+Math.min(N(U),9)/10},H=T.filter(S).sort((U,te)=>R(U)-R(te)||U.localeCompare(te))[0];if(!H)return;const Y=new Map([[H,null]]),q=new Map([[H,0]]),Q=new Map,ee=[],K=[H],V=new Set([H]);for(;K.length;){const U=K.shift();ee.push(U);for(const te of[...j.get(U)??[]].sort(($e,Se)=>$e.localeCompare(Se)))V.has(te)||(V.add(te),Y.set(te,U),q.set(te,(q.get(U)??0)+1),Q.has(U)||Q.set(U,[]),Q.get(U).push(te),K.push(te))}let J=0;const ue=new Map,be=U=>{const te=Q.get(U)??[];if(te.length===0){ue.set(U,J++);return}for(const Se of te)be(Se);const $e=te.map(Se=>ue.get(Se));ue.set(U,$e.reduce((Se,Bt)=>Se+Bt,0)/$e.length)};be(H);for(const U of ee){const te=pe(xn+(ue.get(U)??0)*160),$e=pe(zt+(q.get(U)??0)*140);if(v.has(U)){f.set(U,[te,$e]);continue}let Se=0;const Bt=Y.get(U)??null;if(Bt){const pt=z(U,Bt);pt&&(Se=Rt(pt.orientation,"n"))}else{const pt=(Q.get(U)??[])[0],Ao=pt?z(U,pt):null;Ao&&(Se=Rt(Ao.orientation,"s"))}l.set(U,{at:[te,$e],rot:Se,mirror:!1}),u.add(U)}},P=new Set;for(const T of j.keys()){if(P.has(T))continue;const N=[],B=[T];for(P.add(T);B.length;){const R=B.pop();N.push(R);for(const H of j.get(R)??[])P.has(H)||(P.add(H),B.push(H))}N.length<2||N.some(R=>$.has(R))||N.some(R=>l.has(R)||O.has(R))||N.some(S)&&C(N)}}const X=new Map;for(const y of W){const w=y.filter(_);if(w.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),M=X.get(j)??[];for(const z of w)M.some(C=>C.busId===z&&C.pin===$)||M.push({busId:z,pin:$});X.set(j,M)}}const Z=[],G=new Set;for(const[y,w]of X)if(new Set(w.map(E=>E.busId)).size>=2){const E=((jo=r.get(((So=p.get(y))==null?void 0:So.kind)??""))==null?void 0:jo.category)==="transformer"?"vertical":"horizontal";Z.push({elementId:y,attachments:w,orientation:E}),E==="vertical"&&G.add(y)}const A=new Map,D=(y,w)=>{y!==w&&(A.has(y)||A.set(y,new Set),A.has(w)||A.set(w,new Set),A.get(y).add(w),A.get(w).add(y))};for(const y of s)D(y.ends[0],y.ends[1]);for(const y of t){const w=r.get(y.kind);if(!w||w.terminals.length<2)continue;const S=w.terminals.map(E=>`${y.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)D(S[E],S[j])}for(const y of t){if(G.has(y.id))continue;const w=r.get(y.kind);if(!w||w.category!=="transformer"||w.terminals.length<2)continue;const S=w.terminals.map($=>`${y.id}.${$.id}`),E=new Map;for(const $ of S){const M=$.slice(y.id.length+1);E.set(M,new Set);const z=new Set(S.filter(T=>T!==$)),C=new Set([$]),P=[$];for(;P.length>0;){const T=P.shift();if(_(T)){E.get(M).add(T);continue}const N=A.get(T);if(N)for(const B of N)C.has(B)||z.has(B)||(C.add(B),P.push(B))}}const j=new Set;for(const $ of E.values())for(const M of $)j.add(M);if(j.size>=2){const $=[];for(const[M,z]of E)for(const C of z)$.push({busId:C,pin:M});Z.push({elementId:y.id,attachments:$,orientation:"vertical"}),G.add(y.id)}}const se=(y,w)=>{var z;const S=g(w),E=S?S.terminals.map(C=>`${w}.${C.id}`):[],j=y,$=new Set([j,...E]),M=[j];for(;M.length>0;){const C=M.shift(),P=C.indexOf(".");if(P>0){const N=C.slice(0,P),B=p.get(N);if(B){const R=(z=r.get(B.kind))==null?void 0:z.category;if(R&&Go.has(R))return!0}}const T=A.get(C);if(T)for(const N of T)$.has(N)||($.add(N),M.push(N))}return!1};for(const y of Z){if(y.orientation!=="horizontal")continue;const w=new Set(y.attachments.map(E=>E.busId));let S=0;for(const E of w)se(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 w=r.get(y.kind);if(!w||w.terminals.length!==2)continue;const S=w.terminals.map($=>`${y.id}.${$.id}`),E=new Map;for(const $ of S){const M=$.slice(y.id.length+1),z=new Set(S.filter(T=>T!==$)),C=new Set([$]),P=[$];for(;P.length>0;){const T=P.shift();if(_(T)){E.set(M,T);break}const N=A.get(T);if(N)for(const B of N){if(C.has(B)||z.has(B))continue;const R=B.indexOf(".");if(R>0){const H=B.slice(0,R);if(H!==y.id){const Y=p.get(H),q=Y?r.get(Y.kind):void 0;if((q==null?void 0:q.category)==="transformer")continue}}C.add(B),P.push(B)}}}if(new Set(E.values()).size>=2){const $=[];for(const[M,z]of E)$.push({busId:z,pin:M});Z.push({elementId:y.id,attachments:$,orientation:"horizontal"})}}const ie=new Map;for(const y of n)ie.set(y.id,new Map);for(const y of Z){const w=Array.from(new Set(y.attachments.map(S=>S.busId)));for(const S of w)for(const E of w)S!==E&&((Eo=ie.get(S))==null||Eo.set(E,y))}const de=y=>{var S;const w=(S=r.get(y))==null?void 0:S.category;return w?Go.has(w):!1},oe=[];for(const y of n){const w=F.get(y.id);if(w)for(const S of w){if(_(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),$=p.get(j);if($&&de($.kind)){oe.push(y.id);break}}}oe.length===0&&n.length>0&&oe.push(n[0].id);const re=new Map;for(const y of oe)re.set(y,0);{const y=[...oe];for(;y.length>0;){const w=y.shift(),S=re.get(w),E=ie.get(w);if(E)for(const[j,$]of E){if(re.has(j))continue;const M=$.orientation==="horizontal"?S:S+1;re.set(j,M),y.push(j)}}}for(const y of n){if(re.has(y.id))continue;const w=re.size===0?-1:Math.max(...Array.from(re.values()));re.set(y.id,w+1)}const ye=new Map;for(const y of n){const w=re.get(y.id),S=ye.get(w)??[];S.push(y.id),ye.set(w,S)}const xe=[...ye.keys()].sort((y,w)=>y-w),_e=(y,w,S)=>{const E=`${y.elementId}.${S}`,j=w,$=g(y.elementId),M=new Set;if($)for(const N of $.terminals)N.id!==S&&M.add(`${y.elementId}.${N.id}`);const z=new Set([E]),C=[{ref:E,dist:0}],P=new Map,T=(N,B,R,H)=>{z.add(N),P.set(N,B),C.push({ref:N,dist:H+R})};for(;C.length>0;){const{ref:N,dist:B}=C.shift();if(N===j){const q=P.get(j);let Q;if(q){const ee=q.indexOf(".");if(ee>0){const K=q.slice(0,ee);K!==y.elementId&&(Q=K)}}return{extent:B,head:Q}}const R=N.indexOf(".");if(R<0)continue;const H=N.slice(0,R),Y=N.slice(R+1);if(!_(H)&&!G.has(H)){const q=g(H),Q=q==null?void 0:q.terminals.find(ee=>ee.id===Y);if(q&&Q)for(const ee of q.terminals){if(ee.id===Y)continue;const K=`${H}.${ee.id}`;z.has(K)||M.has(K)||T(K,N,Math.abs(Q.y-ee.y),B)}}for(const q of k.get(N)??[])for(const Q of q){if(Q===N||z.has(Q)||M.has(Q))continue;const ee=_(N)||_(Q);T(Q,N,ee?Wo:wt,B)}}return{extent:0}},Ne=(y,w)=>{var N,B,R;const S=(N=ie.get(y))==null?void 0:N.get(w);if(!S||S.orientation==="horizontal")return bt;const E=g(S.elementId);if(!E)return bt;const j=(B=S.attachments.find(H=>H.busId===y))==null?void 0:B.pin,$=(R=S.attachments.find(H=>H.busId===w))==null?void 0:R.pin;if(!j||!$)return bt;const M=E.terminals.find(H=>H.id===j),z=E.terminals.find(H=>H.id===$);if(!M||!z)return bt;const C=Math.abs(z.y-M.y),P=_e(S,y,j).extent,T=_e(S,w,$).extent;return P+C+T},un=new Map;for(const y of Z){if(y.orientation!=="vertical")continue;const w=y.attachments.slice().sort((z,C)=>(re.get(z.busId)??0)-(re.get(C.busId)??0));if(w.length<2)continue;const S=w[0].busId,E=w[1].busId,j=w[0].pin,M=_e(y,S,j).head??y.elementId;un.set(M,{lowerBusId:E})}const fo=30,mo=y=>{const w=g(y);return Math.max((w==null?void 0:w.width)??Ge,Ge)},sv=2,ho=(y,w,S,E=0)=>{const j=g(w);let $=mo(w);if(j&&!S.has(w)&&E<sv){S.add(w);let M=0;for(const z of j.terminals){const C=`${w}.${z.id}`;if(C!==y)for(const P of k.get(C)??[]){const T=new Set;let N=!1;for(const R of P){if(R===C)continue;if(_(R)){N=!0;continue}const H=R.indexOf(".");if(H<0)continue;const Y=R.slice(0,H);Y===w||S.has(Y)||G.has(Y)||T.add(Y)}if(N||T.size===0)continue;let B=0;for(const R of T){const H=[...P].find(Y=>Y.indexOf(".")>0&&Y.slice(0,Y.indexOf("."))===R);B+=(H?ho(H,R,S,E+1):mo(R))+fo}M=Math.max(M,B-fo)}}S.delete(w),$=Math.max($,M)}return $},ft=320,ot=new Map,po=(y,w)=>{if(!G.has(y))return!1;const S=Z.find(M=>M.elementId===y),E=S==null?void 0:S.attachments.find(M=>M.busId!==w);if(!E)return!1;const j=re.get(w)??0;return(re.get(E.busId)??0)<j},mt=(y,w,S)=>{const E=un.get(y);if(E){const $=ot.get(E.lowerBusId);if($!==void 0)return Math.max(w,$+Ge)}let j=0;return S&&(j=ho(S,y,new Set)),Math.max(w,Ge,j)},go=(y,w)=>{if(ot.has(y))return ot.get(y);if(w.has(y))return ft;w.add(y);const S=F.get(y)??[];let E=0,j=0;for(const M of S){if(_(M))continue;const z=M.indexOf(".");if(z<0)continue;const C=M.slice(0,z),P=M.slice(z+1);if(po(C,y))continue;const T=g(C);if(!T)continue;const N=T.terminals.find(H=>H.id===P);if(!N)continue;const B=un.get(C);B&&go(B.lowerBusId,w);const R=mt(C,T.width,`${C}.${P}`);N.y>0?E+=R:j+=R}const $=Math.max(ft,Math.max(E,j)+Ge);return ot.set(y,$),w.delete(y),$};for(const y of n)go(y.id,new Set);const We=new Map,iv=(y,w,S)=>{const E=g(w);if(!E)return;const j=`${w}.${S}`,$=E.terminals.filter(C=>C.id!==S).map(C=>`${w}.${C.id}`);if($.length===0)return;const M=new Set([j,...$]),z=$.slice();for(;z.length>0;){const C=z.shift();if(_(C)&&C!==y){const T=c.get(C);return T?T.at[0]:void 0}for(const T of k.get(C)??[])for(const N of T)N===C||M.has(N)||(M.add(N),z.push(N));const P=C.indexOf(".");if(P>0){const T=C.slice(0,P);if(!_(T)){const N=g(T);if(N)for(const B of N.terminals){const R=`${T}.${B.id}`;M.has(R)||(M.add(R),z.push(R))}}}}},av=y=>{const w=F.get(y);if(!w||w.length===0)return;const S=c.get(y);if(!S)return;const E=w.flatMap(N=>{if(_(N))return[];const B=N.indexOf(".");if(B<0)return[];const R=N.slice(0,B),H=N.slice(B+1);if(l.has(R))return[];if(po(R,y))return[];const Y=g(R);if(!Y)return[];const q=Y.terminals.find(Q=>Q.id===H);return q?[{elId:R,lib:Y,localTerm:q,isLinker:G.has(R),busFacingRef:`${R}.${H}`}]:[]});if(E.length===0)return;const j=[],$=[];for(const N of E)N.localTerm.y>0?j.push(N):$.push(N);const M=N=>N.reduce((B,R)=>B+mt(R.elId,R.lib.width,R.busFacingRef),0),z=Math.max(M(j),M($))+Ge,C=Math.max(S.span,z);C!==S.span&&!m.has(y)&&c.set(y,{...S,span:C});const P=c.get(y),T=(N,B)=>{if(N.length===0)return;const R=new Map;for(const V of N){const J=iv(y,V.elId,V.localTerm.id);J!==void 0&&R.set(V.elId,J)}N.sort((V,J)=>{const ue=R.get(V.elId)??P.at[0],be=R.get(J.elId)??P.at[0];if(ue!==be)return ue-be;const U=mt(V.elId,V.lib.width,V.busFacingRef);return mt(J.elId,J.lib.width,J.busFacingRef)-U});const H=N.map(V=>mt(V.elId,V.lib.width,V.busFacingRef)),Y=H.reduce((V,J)=>V+J,0),q=Math.max(C,Y),Q=(q-Y)/(N.length+1);let ee=P.at[0]-q/2+Q;const K=P.at[1]+B*Wo;for(let V=0;V<N.length;V++){const J=N[V],ue=H[V],be=ee+ue/2;J.isLinker?We.has(J.elId)||We.set(J.elId,be):l.set(J.elId,{at:[pe(be-J.localTerm.x),pe(K-J.localTerm.y)],rot:0,mirror:!1}),ee+=ue+Q}};T(j,-1),T($,1)},lv=y=>{if(l.has(y.elementId)||y.orientation==="horizontal")return;const w=g(y.elementId);if(!w)return;const S=y.attachments.filter(ee=>c.has(ee.busId));if(S.length<2)return;const E=S.slice().sort((ee,K)=>(re.get(ee.busId)??0)-(re.get(K.busId)??0)),j=E[0].busId,$=c.get(j),M=E[0].pin,z=E[E.length-1].pin,C=w.terminals.find(ee=>ee.id===M),P=w.terminals.find(ee=>ee.id===z);if(!C||!P)return;const T=C.y<=P.y?0:180,N=re.get(j)??0,B=S.filter(ee=>(re.get(ee.busId)??0)===N),R=[];let H=0;for(const ee of B){const K=_e(y,ee.busId,ee.pin);H=Math.max(H,K.extent);const V=K.head?l.get(K.head):void 0;V?R.push(V.at[0]):We.has(y.elementId)?R.push(We.get(y.elementId)):R.push(c.get(ee.busId).at[0])}let Y;R.length>0?Y=R.reduce((ee,K)=>ee+K,0)/R.length:We.has(y.elementId)?Y=We.get(y.elementId):Y=$.at[0];const q=$.at[1]+H,Q=T===0?[pe(Y-C.x),pe(q-C.y)]:[pe(Y+C.x),pe(q+C.y)];if(l.set(y.elementId,{at:Q,rot:T,mirror:!1}),B.length>1){const ee=l.get(y.elementId),K=Oe([C.x,C.y],ee),V=St(C.orientation,ee);cv(`${y.elementId}.${M}`,K,V,Y)}},cv=(y,w,S,E)=>{const j=new Set([y]);let $=y,M=w,z=S;for(;;){const C=k.get($)??[];let P,T=!1;for(const te of C){if(te.length>=3){T=!0;break}const $e=te.find(Se=>Se!==$);if(!(!$e||j.has($e))){if(_($e)){T=!0;break}P=$e;break}}if(T||!P)break;const N=P.indexOf(".");if(N<0)break;const B=P.slice(0,N),R=P.slice(N+1);if(_(B)||G.has(B)||l.has(B))break;const H=g(B);if(!H)break;const Y=H.terminals.find(te=>te.id===R);if(!Y)break;const q=Rn(z),Q=[M[0]+q[0]*wt,M[1]+q[1]*wt],ee=Fo[z],K=Rt(Y.orientation,ee),V=Oe([Y.x,Y.y],{at:[0,0],rot:K,mirror:!1}),J=[pe(E-V[0]),pe(Q[1]-V[1])];l.set(B,{at:J,rot:K,mirror:!1}),j.add(P);const ue=H.terminals.find(te=>te.id!==R);if(!ue)break;const be=`${B}.${ue.id}`;j.add(be);const U={at:J,rot:K,mirror:!1};M=Oe([ue.x,ue.y],U),z=St(ue.orientation,U),$=be}},dv=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const w=g(y.elementId);if(!w)return;const S=y.attachments.filter(B=>c.has(B.busId));if(S.length<2)return;const E=S.map(B=>{const R=_e(y,B.busId,B.pin),H=R.head?l.get(R.head):void 0,Y=H?H.at[0]:c.get(B.busId).at[0];return{att:B,x:Y,extent:R.extent}});E.sort((B,R)=>B.x-R.x);const j=E[0],$=E[E.length-1],M=w.terminals.find(B=>B.id===j.att.pin),z=w.terminals.find(B=>B.id===$.att.pin);if(!M||!z)return;const C=M.y<=z.y?270:90,P=(j.x+$.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,$.extent);l.set(y.elementId,{at:[pe(P),pe(N)],rot:C,mirror:!1})},yo=100;let Pt=zt;for(let y=0;y<xe.length;y++){const w=xe[y],S=ye.get(w);let E;if(y===0)E=zt;else{const $=ye.get(xe[y-1]);let M=0;for(const z of $)for(const C of S)(No=ie.get(z))!=null&&No.get(C)&&(M=Math.max(M,Ne(z,C)));M===0&&(M=bt),E=Pt+M}Pt=E;let j=xn;for(const $ of S){if(c.has($)){Pt=Math.max(Pt,c.get($).at[1]);continue}let M;if(y>0){const C=ye.get(xe[y-1]),P=[];for(const T of C){const N=(Mo=ie.get(T))==null?void 0:Mo.get($);if(!N||N.orientation!=="vertical")continue;const B=(To=N.attachments.find(H=>H.busId===T))==null?void 0:To.pin;if(!B)continue;const R=_e(N,T,B);R.head&&l.has(R.head)?P.push(l.get(R.head).at[0]):We.has(N.elementId)?P.push(We.get(N.elementId)):P.push(c.get(T).at[0])}P.length>0&&(M=P.reduce((T,N)=>T+N,0)/P.length)}if(M===void 0){const C=ot.get($)??bn;M=j+C/2,j+=C+yo}const z=ot.get($)??bn;c.set($,{at:[pe(M),pe(E)],rot:0,span:z,axis:Ln(0)})}for(const $ of S)av($);if(y>0)for(const $ of Z)l.has($.elementId)||!$.attachments.some(z=>S.includes(z.busId))||lv($);for(const $ of Z)$.orientation!=="horizontal"||l.has($.elementId)||!$.attachments.every(z=>S.includes(z.busId))||dv($)}if(n.length===0&&l.size<t.length){const y=j=>{const $=new Set,M=g(j);if(!M)return $;for(const z of M.terminals){const C=`${j}.${z.id}`;for(const P of k.get(C)??[])for(const T of P){if(T===C||_(T))continue;const N=T.indexOf(".");if(N<0)continue;const B=T.slice(0,N);B!==j&&$.add(B)}}return $},w=new Set,S=[];for(const j of t){if(w.has(j.id)||!g(j.id))continue;const $=[],M=[j.id];for(w.add(j.id);M.length>0;){const z=M.pop();$.push(z);for(const C of y(z))w.has(C)||(w.add(C),M.push(C))}$.length>=2&&S.push($)}let E=xn;for(const j of S){if(j.some(P=>l.has(P)))continue;j.sort((P,T)=>{var Y,q;const N=de(((Y=p.get(P))==null?void 0:Y.kind)??"")?0:1,B=de(((q=p.get(T))==null?void 0:q.kind)??"")?0:1;if(N!==B)return N-B;const R=y(P).size,H=y(T).size;return R!==H?R-H:P.localeCompare(T)});const $=j[0],M=g($);if(!M)continue;const z=M.terminals.slice().sort((P,T)=>T.y-P.y)[0],C=z?Oe([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set($,{at:[pe(E-C[0]),pe(zt-C[1])],rot:0,mirror:!1}),E+=Math.max(bn,j.length*Ge)+yo}}const uv=y=>{if(_(y))return c.has(y);const w=y.indexOf(".");return w<0?!1:l.has(y.slice(0,w))};let fn=!0,fv=t.length+4;for(;fn&&fv-- >0;){fn=!1;for(const y of W){if(y.length<2)continue;const w=[],S=new Map;for(const K of y){if(_(K))continue;const V=K.indexOf(".");if(V<0)continue;const J=K.slice(0,V),ue=K.slice(V+1);if(l.has(J)){w.push(K);continue}if(G.has(J)||S.has(J))continue;const be=g(J);if(!be)continue;const U=be.terminals.find(te=>te.id===ue);U&&S.set(J,{ref:K,elId:J,lib:be,localTerm:U})}if(S.size===0||w.length===0)continue;const E=[...S.values()],j=new Map;for(const K of E)for(const V of k.get(K.ref)??[])for(const J of V){if(J===K.ref||_(J)||!uv(J))continue;const ue=J;j.set(ue,(j.get(ue)??0)+1)}let $;if(j.size>0){let K=-1;for(const[V,J]of j)(J>K||J===K&&($===void 0||V<$))&&(K=J,$=V)}if($||($=[...w].sort()[0]),!$)continue;const M=$.indexOf("."),z=$.slice(0,M),C=$.slice(M+1),P=g(z),T=l.get(z);if(!P||!T)continue;const N=P.terminals.find(K=>K.id===C);if(!N)continue;const B=Oe([N.x,N.y],T),R=St(N.orientation,T),H=Rn(R),Y=[-H[1],H[0]];E.sort((K,V)=>K.elId.localeCompare(V.elId));const q=E.map(K=>Math.max(K.lib.width,Ge));let ee=-q.reduce((K,V)=>K+V,0)/2;for(let K=0;K<E.length;K++){const V=E[K],J=q[K],ue=ee+J/2;ee+=J;const be=Fo[R],U=Rt(V.localTerm.orientation,be),te=Oe([V.localTerm.x,V.localTerm.y],{at:[0,0],rot:U,mirror:!1}),$e=[B[0]+H[0]*wt+Y[0]*ue,B[1]+H[1]*wt+Y[1]*ue],Se=[pe($e[0]-te[0]),pe($e[1]-te[1])];l.set(V.elId,{at:Se,rot:U,mirror:!1}),fn=!0}}}const ht=y=>{const w=l.get(y),S=g(y);if(!w||!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:w.at[0]-N,max:w.at[0]+N}}const[j,$,M,z]=E,C=[[j,$],[j+M,$],[j,$+z],[j+M,$+z]];let P=1/0,T=-1/0;for(const N of C){const B=Oe(N,w);P=Math.min(P,B[0]),T=Math.max(T,B[0])}return{min:P,max:T}},mn=y=>{const w=new Set,S=g(y);if(!S)return w;for(const E of S.terminals){const j=`${y}.${E.id}`;for(const $ of k.get(j)??[])for(const M of $){if(M===j||_(M))continue;const z=M.indexOf(".");if(z<0)continue;const C=M.slice(0,z);C!==y&&w.add(C)}}return w},xo=40,hn=y=>{const w=l.get(y),S=g(y);if(!w||!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:w.at[1]-N,max:w.at[1]+N}}const[j,$,M,z]=E,C=[[j,$],[j+M,$],[j,$+z],[j+M,$+z]];let P=1/0,T=-1/0;for(const N of C){const B=Oe(N,w);P=Math.min(P,B[1]),T=Math.max(T,B[1])}return{min:P,max:T}},mv=(y,w)=>{const S=new Set,E=[];for(const j of F.get(y)??[]){if(_(j))continue;const $=j.indexOf(".");if($<0)continue;const M=j.slice(0,$),z=l.get(M);!z||z.at[1]>=w-1||S.has(M)||(S.add(M),E.push(M))}for(;E.length>0;){const j=E.pop();for(const $ of mn(j)){if(S.has($))continue;const M=l.get($);!M||M.at[1]>=w-1||(S.add($),E.push($))}}return S},bo=(y,w,S)=>{const E=new Set([y]),j=[y];for(;j.length>0;){const $=j.pop();for(const M of mn($))M===w||E.has(M)||!S.has(M)||(E.add(M),j.push(M))}return E},wo=(y,w)=>{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 M=$+1;M<y.length;M++){const z=y[$],C=y[M],P=ht(z),T=ht(C),N=hn(z),B=hn(C);if(!P||!T||!N||!B)continue;const R=Math.min(P.max,T.max)-Math.max(P.min,T.min),H=Math.min(N.max,B.max)-Math.max(N.min,B.min);if(R<=0||H<=0)continue;const Y=bo(z,C,w),q=bo(C,z,w);if(Y.has(C)||q.has(z))continue;const Q=![...Y].some(U=>u.has(U)),ee=![...q].some(U=>u.has(U));if(!Q&&!ee)continue;const K=(P.min+P.max)/2,V=(T.min+T.max)/2;let J,ue;Q&&(!ee||Y.size<=q.size)?(J=Y,ue=K<=V?-1:1):(J=q,ue=V<=K?-1:1);const be=pe(ue*(R+xo));if(be!==0){for(const U of J){const te=l.get(U);te&&l.set(U,{...te,at:[te.at[0]+be,te.at[1]]})}E=!0,j=!0;break}}}return E};for(const y of n){const w=c.get(y.id);if(!w)continue;const S=mv(y.id,w.at[1]);if(S.size<2)continue;const E=[...S];if(wo(E,S)){let $=1/0,M=-1/0;for(const z of E){const C=ht(z);C&&($=Math.min($,C.min),M=Math.max(M,C.max))}if(Number.isFinite($)){const C=E.some(T=>u.has(T))?0:pe(w.at[0]-($+M)/2);if(C!==0)for(const T of E){const N=l.get(T);N&&l.set(T,{...N,at:[N.at[0]+C,N.at[1]]})}const P=M-$+xo;if(P>w.span&&!m.has(y.id)){const T=c.get(y.id);c.set(y.id,{...T,span:P})}}}}const vo=()=>{const w=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:ht(E),y:hn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<w.length;E++)for(let j=E+1;j<w.length;j++){const $=Math.min(w[E].x.max,w[j].x.max)-Math.max(w[E].x.min,w[j].x.min),M=Math.min(w[E].y.max,w[j].y.max)-Math.max(w[E].y.min,w[j].y.min);$>1&&M>1&&S++}return S},hv=vo(),ko=new Map;for(const[y,w]of l)ko.set(y,{...w,at:[...w.at]});const _o=new Map;for(const[y,w]of c)_o.set(y,{...w,at:[...w.at]});const pn=120,$o=new Map;{const y=new Map,w=new Map,S=[];for(const j of n)for(const $ of F.get(j.id)??[]){if(_($))continue;const M=$.indexOf(".");if(M<0)continue;const z=$.slice(0,M);l.has(z)&&S.push({el:z,bus:j.id,d:1})}S.sort((j,$)=>j.d-$.d);let E=0;for(;E<S.length;){const{el:j,bus:$,d:M}=S[E++],z=y.get(j);if(z===void 0)y.set(j,M),w.set(j,$);else if(M===z&&w.get(j)!==$){w.set(j,null);continue}else continue;for(const C of mn(j))l.has(C)&&(y.has(C)||S.push({el:C,bus:$,d:M+1}))}for(const[j,$]of w)$&&$o.set(j,$)}for(const y of xe){const w=(ye.get(y)??[]).filter(P=>c.has(P));if(w.length<2||w.some(P=>m.has(P)))continue;const S=[];let E=0;for(const P of w){const T=c.get(P),N=[];let B=1/0,R=-1/0;for(const[H,Y]of $o){if(Y!==P)continue;const q=ht(H);q&&(N.push(H),B=Math.min(B,q.min),R=Math.max(R,q.max))}Number.isFinite(B)||(B=T.at[0]-ft/2,R=T.at[0]+ft/2),S.push({busId:P,min:B,max:R,members:N}),E+=R-B}if(S.some(P=>P.members.some(T=>u.has(T))))continue;let j=1/0,$=-1/0;for(const P of S)j=Math.min(j,P.min),$=Math.max($,P.max);const M=$-j,z=E+pn*(S.length-1);if(!(M>z+pn))continue;S.sort((P,T)=>(P.min+P.max)/2-(T.min+T.max)/2);let C=j;for(const P of S){const T=pe(C-P.min);if(T!==0){const N=c.get(P.busId);c.set(P.busId,{...N,at:[N.at[0]+T,N.at[1]]});for(const B of P.members){const R=l.get(B);R&&l.set(B,{...R,at:[R.at[0]+T,R.at[1]]})}P.min+=T,P.max+=T}C=P.max+pn}for(const P of S){const T=c.get(P.busId),N=Math.max(ft,P.max-P.min);N<T.span&&c.set(P.busId,{...T,span:N})}}{const y=t.map(S=>S.id).filter(S=>l.has(S)),w=new Set(y);wo(y,w)}if(vo()>hv){l.clear();for(const[y,w]of ko)l.set(y,w);c.clear();for(const[y,w]of _o)c.set(y,w)}let gn=0;for(const y of t){if(l.has(y.id))continue;const w=gn%qo,S=Math.floor(gn/qo);l.set(y.id,{at:[pe(S2+w*E2),pe(j2+S*N2)],rot:0,mirror:!1}),gn++}return{devices:l,buses:c,junctions:f}}function pe(e){return Math.round(e/Ho)*Ho}function T2(e,t){const n=e.ends[0],o=e.ends[1],s=Xo(n,t),r=Xo(o,t);if(s||r){const l=s?n:o,f=wn(s?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=[Kt(f[0],p[0]-g,p[0]+g),p[1]];else{const _=Kt(f[1],p[1]-g,p[1]+g);b=[p[0],_]}return{wireId:e.id,path:Ko(f,b)}}const i=wn(n,t),a=wn(o,t);return!i||!a?null:{wireId:e.id,path:Ko(i,a)}}function Xo(e,t){return!e.includes(".")&&t.buses.has(e)}function wn(e,t){if(!e.includes(".")){const o=t.buses.get(e);if(o)return o.geometry.at;const s=t.junctions.get(e);return s?s.world:null}const n=t.terminals.get(e);return n?n.world:null}function Yo(e,t,n){if(!e.includes(".")){const s=n.buses.get(e);if(!s){const f=n.junctions.get(e);return f?[f.world[0],f.world[1]]:null}const{axis:r,at:i,span:a}=s.geometry;if(!t)return[i[0],i[1]];const l=a/2;if(r==="x")return[Kt(t[0],i[0]-l,i[0]+l),i[1]];const c=Kt(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 Ko(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Kt(e,t,n){return e<t?t:e>n?n:e}const hs="ammeter",ps="电流表 (A)",gs="measurement",ys="-22 -42 44 44",xs=44,bs=44,ws='<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>',vs=[{id:"t_top",x:0,y:-40,orientation:"n"}],ks={kind:"inline"},A2={id:hs,name:ps,category:gs,viewBox:ys,width:xs,height:bs,svg:ws,terminals:vs,source:ks},I2=Object.freeze(Object.defineProperty({__proto__:null,category:gs,default:A2,height:bs,id:hs,name:ps,source:ks,svg:ws,terminals:vs,viewBox:ys,width:xs},Symbol.toStringTag,{value:"Module"})),_s="arc-suppression-coil",$s="消弧线圈",Ss="grounding",js="中性点谐振接地:电感线圈连接到地",Es="-12 -32 24 67",Ns=24,Ms=67,Ts='<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"/>',As=[{id:"t_top",x:0,y:-30,orientation:"n"}],Is={kind:"inline"},C2={id:_s,name:$s,category:Ss,description:js,viewBox:Es,width:Ns,height:Ms,svg:Ts,terminals:As,source:Is},O2=Object.freeze(Object.defineProperty({__proto__:null,category:Ss,default:C2,description:js,height:Ms,id:_s,name:$s,source:Is,svg:Ts,terminals:As,viewBox:Es,width:Ns},Symbol.toStringTag,{value:"Module"})),Cs="arrester",Os="避雷器 (FBL)",Ps="protection",Bs="-7 -22 14 44",Ls=14,Rs=44,zs='<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"/>',Ds=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Fs={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},P2={id:Cs,name:Os,category:Ps,viewBox:Bs,width:Ls,height:Rs,svg:zs,terminals:Ds,source:Fs},B2=Object.freeze(Object.defineProperty({__proto__:null,category:Ps,default:P2,height:Rs,id:Cs,name:Os,source:Fs,svg:zs,terminals:Ds,viewBox:Bs,width:Ls},Symbol.toStringTag,{value:"Module"})),Ws="async-motor",Hs="异步电动机",qs="load",Gs="-62 -82 64 84",Xs=64,Ys=84,Ks='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',Vs=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Us={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"},L2={id:Ws,name:Hs,category:qs,viewBox:Gs,width:Xs,height:Ys,svg:Ks,terminals:Vs,source:Us},R2=Object.freeze(Object.defineProperty({__proto__:null,category:qs,default:L2,height:Ys,id:Ws,name:Hs,source:Us,svg:Ks,terminals:Vs,viewBox:Gs,width:Xs},Symbol.toStringTag,{value:"Module"})),Js="autotransformer",Zs="自耦变压器",Qs="transformer",ei="-62 -112 64 144",ti=64,ni=144,oi='<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"/>',ri=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],si={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},z2={id:Js,name:Zs,category:Qs,viewBox:ei,width:ti,height:ni,svg:oi,terminals:ri,source:si},D2=Object.freeze(Object.defineProperty({__proto__:null,category:Qs,default:z2,height:ni,id:Js,name:Zs,source:si,svg:oi,terminals:ri,viewBox:ei,width:ti},Symbol.toStringTag,{value:"Module"})),ii="battery",ai="电池储能",li="storage",ci="-12 -12 29 24",di=29,ui=24,fi='<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"/>',mi=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],hi=[{name:"E",label:"容量",type:"number",unit:"kWh"}],pi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},F2={id:ii,name:ai,category:li,viewBox:ci,width:di,height:ui,svg:fi,terminals:mi,params:hi,source:pi},W2=Object.freeze(Object.defineProperty({__proto__:null,category:li,default:F2,height:ui,id:ii,name:ai,params:hi,source:pi,svg:fi,terminals:mi,viewBox:ci,width:di},Symbol.toStringTag,{value:"Module"})),gi="bell",yi="电铃 (HA)",xi="control",bi="信号电铃 / 警铃。",wi="-32 -32 44 44",vi=44,ki=44,_i='<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"/>',$i=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Si={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},H2={id:gi,name:yi,category:xi,description:bi,viewBox:wi,width:vi,height:ki,svg:_i,terminals:$i,source:Si},q2=Object.freeze(Object.defineProperty({__proto__:null,category:xi,default:H2,description:bi,height:ki,id:gi,name:yi,source:Si,svg:_i,terminals:$i,viewBox:wi,width:vi},Symbol.toStringTag,{value:"Module"})),ji="break-contact",Ei="常闭触点 (NC)",Ni="control",Mi="常闭辅助触点 (break contact)。",Ti="-2 -42 14 64",Ai=14,Ii=64,Ci='<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"/>',Oi=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Pi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Bi={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},G2={id:ji,name:Ei,category:Ni,description:Mi,viewBox:Ti,width:Ai,height:Ii,svg:Ci,terminals:Oi,state:Pi,source:Bi},X2=Object.freeze(Object.defineProperty({__proto__:null,category:Ni,default:G2,description:Mi,height:Ii,id:ji,name:Ei,source:Bi,state:Pi,svg:Ci,terminals:Oi,viewBox:Ti,width:Ai},Symbol.toStringTag,{value:"Module"})),Li="breaker",Ri="断路器 (QF)",zi="switching",Di="-7 -22 15 46",Fi=15,Wi=46,Hi='<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"/>',qi='<text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',Gi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Xi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Yi={x:6,y:-2,anchor:"start"},Ki={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},Y2={id:Li,name:Ri,category:zi,viewBox:Di,width:Fi,height:Wi,svg:Hi,terminalLabelsSvg:qi,terminals:Gi,state:Xi,label:Yi,source:Ki},K2=Object.freeze(Object.defineProperty({__proto__:null,category:zi,default:Y2,height:Wi,id:Li,label:Yi,name:Ri,source:Ki,state:Xi,svg:Hi,terminalLabelsSvg:qi,terminals:Gi,viewBox:Di,width:Fi},Symbol.toStringTag,{value:"Module"})),Vi="buchholz-relay",Ui="瓦斯继电器 (63)",Ji="protection",Zi="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Qi="-22 -62 44 64",ea=44,ta=64,na='<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"/>',oa=[{id:"t_top",x:0,y:-60,orientation:"n"}],ra={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"},V2={id:Vi,name:Ui,category:Ji,description:Zi,viewBox:Qi,width:ea,height:ta,svg:na,terminals:oa,source:ra},U2=Object.freeze(Object.defineProperty({__proto__:null,category:Ji,default:V2,description:Zi,height:ta,id:Vi,name:Ui,source:ra,svg:na,terminals:oa,viewBox:Qi,width:ea},Symbol.toStringTag,{value:"Module"})),sa="busbar",ia="母线段",aa="busbar",la="可拉伸单母线段,多设备挂接",ca="-42 -4 84 8",da=84,ua=8,fa='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',ma=[{id:"tap",x:0,y:0,orientation:"n"}],ha={axis:"x",minLength:20,naturalSpan:80},pa=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],ga={x:0,y:-6,anchor:"middle"},ya={kind:"inline"},J2={id:sa,name:ia,category:aa,description:la,viewBox:ca,width:da,height:ua,svg:fa,terminals:ma,stretchable:ha,params:pa,label:ga,source:ya},Z2=Object.freeze(Object.defineProperty({__proto__:null,category:aa,default:J2,description:la,height:ua,id:sa,label:ga,name:ia,params:pa,source:ya,stretchable:ha,svg:fa,terminals:ma,viewBox:ca,width:da},Symbol.toStringTag,{value:"Module"})),xa="buzzer",ba="蜂鸣器 (HA)",wa="control",va="信号蜂鸣器。",ka="-32 -52 44 64",_a=44,$a=64,Sa='<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"/>',ja=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Ea={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},Q2={id:xa,name:ba,category:wa,description:va,viewBox:ka,width:_a,height:$a,svg:Sa,terminals:ja,source:Ea},ek=Object.freeze(Object.defineProperty({__proto__:null,category:wa,default:Q2,description:va,height:$a,id:xa,name:ba,source:Ea,svg:Sa,terminals:ja,viewBox:ka,width:_a},Symbol.toStringTag,{value:"Module"})),Na="capacitor",Ma="电容 (C)",Ta="passive",Aa="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",Ia="-7 -23 14 27",Ca=14,Oa=27,Pa='<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"/>',Ba=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],La=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Ra={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},tk={id:Na,name:Ma,category:Ta,description:Aa,viewBox:Ia,width:Ca,height:Oa,svg:Pa,terminals:Ba,params:La,source:Ra},nk=Object.freeze(Object.defineProperty({__proto__:null,category:Ta,default:tk,description:Aa,height:Oa,id:Na,name:Ma,params:La,source:Ra,svg:Pa,terminals:Ba,viewBox:Ia,width:Ca},Symbol.toStringTag,{value:"Module"})),za="contactor",Da="接触器 (KM)",Fa="motor-control",Wa="主回路接触器, 通常配热继电器和电机使用。",Ha="-10 -42 15 64",qa=15,Ga=64,Xa='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',Ya=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ka=[{name:"open",type:"boolean",default:!0,label:"断开"}],Va={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"},ok={id:za,name:Da,category:Fa,description:Wa,viewBox:Ha,width:qa,height:Ga,svg:Xa,terminals:Ya,state:Ka,source:Va},rk=Object.freeze(Object.defineProperty({__proto__:null,category:Fa,default:ok,description:Wa,height:Ga,id:za,name:Da,source:Va,state:Ka,svg:Xa,terminals:Ya,viewBox:Ha,width:qa},Symbol.toStringTag,{value:"Module"})),Ua="converter-bidir",Ja="双向变流器 (PCS)",Za="renewable",Qa="储能变流器:双向 AC ↔ DC",el="-42 -42 44 48",tl=44,nl=48,ol='<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"/>',rl=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],sl=[{name:"S",label:"容量",type:"number",unit:"MVA"}],il={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},sk={id:Ua,name:Ja,category:Za,description:Qa,viewBox:el,width:tl,height:nl,svg:ol,terminals:rl,params:sl,source:il},ik=Object.freeze(Object.defineProperty({__proto__:null,category:Za,default:sk,description:Qa,height:nl,id:Ua,name:Ja,params:sl,source:il,svg:ol,terminals:rl,viewBox:el,width:tl},Symbol.toStringTag,{value:"Module"})),al="ct",ll="电流互感器 (CT)",cl="instrument-transformer",dl="-42 -62 54 64",ul=54,fl=64,ml='<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"/>',hl=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],pl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},ak={id:al,name:ll,category:cl,viewBox:dl,width:ul,height:fl,svg:ml,terminals:hl,source:pl},lk=Object.freeze(Object.defineProperty({__proto__:null,category:cl,default:ak,height:fl,id:al,name:ll,source:pl,svg:ml,terminals:hl,viewBox:dl,width:ul},Symbol.toStringTag,{value:"Module"})),gl="dc-combiner",yl="直流汇流箱",xl="renewable",bl="光伏组串汇流箱 (4 路输入示例)。",wl="-27 -32 54 64",vl=54,kl=64,_l='<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>',$l=[{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"}],Sl={kind:"inline"},ck={id:gl,name:yl,category:xl,description:bl,viewBox:wl,width:vl,height:kl,svg:_l,terminals:$l,source:Sl},dk=Object.freeze(Object.defineProperty({__proto__:null,category:xl,default:ck,description:bl,height:kl,id:gl,name:yl,source:Sl,svg:_l,terminals:$l,viewBox:wl,width:vl},Symbol.toStringTag,{value:"Module"})),jl="dc-disconnector",El="直流隔离开关",Nl="switching",Ml="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",Tl="-12 -32 30 64",Al=30,Il=64,Cl='<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"/>',Ol=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Pl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Bl={kind:"inline"},uk={id:jl,name:El,category:Nl,description:Ml,viewBox:Tl,width:Al,height:Il,svg:Cl,terminals:Ol,state:Pl,source:Bl},fk=Object.freeze(Object.defineProperty({__proto__:null,category:Nl,default:uk,description:Ml,height:Il,id:jl,name:El,source:Bl,state:Pl,svg:Cl,terminals:Ol,viewBox:Tl,width:Al},Symbol.toStringTag,{value:"Module"})),Ll="dc-motor",Rl="直流电机 (M)",zl="load",Dl="直流电动机 (串励通用符号)。",Fl="-72 -82 89 84",Wl=89,Hl=84,ql='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',Gl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Xl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},mk={id:Ll,name:Rl,category:zl,description:Dl,viewBox:Fl,width:Wl,height:Hl,svg:ql,terminals:Gl,source:Xl},hk=Object.freeze(Object.defineProperty({__proto__:null,category:zl,default:mk,description:Dl,height:Hl,id:Ll,name:Rl,source:Xl,svg:ql,terminals:Gl,viewBox:Fl,width:Wl},Symbol.toStringTag,{value:"Module"})),Yl="diode",Kl="二极管 (D)",Vl="passive",Ul="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Jl="-12 -42 24 44",Zl=24,Ql=44,ec='<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"/>',tc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],nc={x:6,y:-20,anchor:"start"},oc={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},pk={id:Yl,name:Kl,category:Vl,description:Ul,viewBox:Jl,width:Zl,height:Ql,svg:ec,terminals:tc,label:nc,source:oc},gk=Object.freeze(Object.defineProperty({__proto__:null,category:Vl,default:pk,description:Ul,height:Ql,id:Yl,label:nc,name:Kl,source:oc,svg:ec,terminals:tc,viewBox:Jl,width:Zl},Symbol.toStringTag,{value:"Module"})),rc="disconnector",sc="隔离开关 (QS)",ic="switching",ac="-10 -42 15 64",lc=15,cc=64,dc='<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"/>',uc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],fc=[{name:"open",type:"boolean",default:!1,label:"断开"}],mc={x:6,y:-10,anchor:"start"},hc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},yk={id:rc,name:sc,category:ic,viewBox:ac,width:lc,height:cc,svg:dc,terminals:uc,state:fc,label:mc,source:hc},xk=Object.freeze(Object.defineProperty({__proto__:null,category:ic,default:yk,height:cc,id:rc,label:mc,name:sc,source:hc,state:fc,svg:dc,terminals:uc,viewBox:ac,width:lc},Symbol.toStringTag,{value:"Module"})),pc="distance-relay",gc="距离继电器 (21)",yc="protection",xc="距离 / 低阻抗保护继电器 (ANSI 21)。",bc="-62 -42 64 44",wc=64,vc=44,kc='<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>',_c=[{id:"t_top",x:-30,y:-40,orientation:"n"}],$c={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},bk={id:pc,name:gc,category:yc,description:xc,viewBox:bc,width:wc,height:vc,svg:kc,terminals:_c,source:$c},wk=Object.freeze(Object.defineProperty({__proto__:null,category:yc,default:bk,description:xc,height:vc,id:pc,name:gc,source:$c,svg:kc,terminals:_c,viewBox:bc,width:wc},Symbol.toStringTag,{value:"Module"})),Sc="earth",jc="接地",Ec="busbar",Nc="-12 -17 24 34",Mc=24,Tc=34,Ac='<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"/>',Ic=[{id:"t1",x:0,y:-15,orientation:"n"}],Cc={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"},vk={id:Sc,name:jc,category:Ec,viewBox:Nc,width:Mc,height:Tc,svg:Ac,terminals:Ic,source:Cc},kk=Object.freeze(Object.defineProperty({__proto__:null,category:Ec,default:vk,height:Tc,id:Sc,name:jc,source:Cc,svg:Ac,terminals:Ic,viewBox:Nc,width:Mc},Symbol.toStringTag,{value:"Module"})),Oc="earthing-switch",Pc="接地刀闸 (QE)",Bc="switching",Lc="隔离开关 + 接地连接,单端口",Rc="-12 -32 24 64",zc=24,Dc=64,Fc='<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"/>',Wc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Hc=[{name:"open",type:"boolean",default:!0,label:"断开"}],qc={x:12,y:-8,anchor:"start"},Gc={kind:"inline"},_k={id:Oc,name:Pc,category:Bc,description:Lc,viewBox:Rc,width:zc,height:Dc,svg:Fc,terminals:Wc,state:Hc,label:qc,source:Gc},$k=Object.freeze(Object.defineProperty({__proto__:null,category:Bc,default:_k,description:Lc,height:Dc,id:Oc,label:qc,name:Pc,source:Gc,state:Hc,svg:Fc,terminals:Wc,viewBox:Rc,width:zc},Symbol.toStringTag,{value:"Module"})),Xc="energy-meter",Yc="电能表 (Wh)",Kc="measurement",Vc="有功电能表 (kWh) — 服务入口 / 子表。",Uc="-22 -36 44 72",Jc=44,Zc=72,Qc='<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"/>',ed=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],td={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},Sk={id:Xc,name:Yc,category:Kc,description:Vc,viewBox:Uc,width:Jc,height:Zc,svg:Qc,terminals:ed,source:td},jk=Object.freeze(Object.defineProperty({__proto__:null,category:Kc,default:Sk,description:Vc,height:Zc,id:Xc,name:Yc,source:td,svg:Qc,terminals:ed,viewBox:Uc,width:Jc},Symbol.toStringTag,{value:"Module"})),nd="ev-charger",od="EV 充电桩",rd="load",sd="电动汽车充电站 / 充电桩。",id="-17 -27 34 49",ad=34,ld=49,cd='<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>',dd=[{id:"t_top",x:0,y:-25,orientation:"n"}],ud={kind:"inline"},Ek={id:nd,name:od,category:rd,description:sd,viewBox:id,width:ad,height:ld,svg:cd,terminals:dd,source:ud},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:rd,default:Ek,description:sd,height:ld,id:nd,name:od,source:ud,svg:cd,terminals:dd,viewBox:id,width:ad},Symbol.toStringTag,{value:"Module"})),fd="frequency-meter",md="频率表 (Hz)",hd="measurement",pd="-22 -42 44 44",gd=44,yd=44,xd='<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>',bd=[{id:"t_top",x:0,y:-40,orientation:"n"}],wd={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},Mk={id:fd,name:md,category:hd,viewBox:pd,width:gd,height:yd,svg:xd,terminals:bd,source:wd},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:hd,default:Mk,height:yd,id:fd,name:md,source:wd,svg:xd,terminals:bd,viewBox:pd,width:gd},Symbol.toStringTag,{value:"Module"})),vd="fuse-switch-disconnector",kd="熔断器式隔离开关",_d="switching",$d="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",Sd="-8 -32 12 64",jd=12,Ed=64,Nd='<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"/>',Md=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Td=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ad={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"},Ak={id:vd,name:kd,category:_d,description:$d,viewBox:Sd,width:jd,height:Ed,svg:Nd,terminals:Md,state:Td,source:Ad},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:_d,default:Ak,description:$d,height:Ed,id:vd,name:kd,source:Ad,state:Td,svg:Nd,terminals:Md,viewBox:Sd,width:jd},Symbol.toStringTag,{value:"Module"})),Id="fuse",Cd="熔断器 (FU)",Od="switching",Pd="-7 -32 14 64",Bd=14,Ld=64,Rd='<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"/>',zd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Dd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Fd={x:7,y:-2,anchor:"start"},Wd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},Ck={id:Id,name:Cd,category:Od,viewBox:Pd,width:Bd,height:Ld,svg:Rd,terminals:zd,state:Dd,label:Fd,source:Wd},Ok=Object.freeze(Object.defineProperty({__proto__:null,category:Od,default:Ck,height:Ld,id:Id,label:Fd,name:Cd,source:Wd,state:Dd,svg:Rd,terminals:zd,viewBox:Pd,width:Bd},Symbol.toStringTag,{value:"Module"})),Hd="generator",qd="发电机 (G)",Gd="source",Xd="-42 -42 44 44",Yd=44,Kd=44,Vd='<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>',Ud=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Jd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},Pk={id:Hd,name:qd,category:Gd,viewBox:Xd,width:Yd,height:Kd,svg:Vd,terminals:Ud,source:Jd},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:Gd,default:Pk,height:Kd,id:Hd,name:qd,source:Jd,svg:Vd,terminals:Ud,viewBox:Xd,width:Yd},Symbol.toStringTag,{value:"Module"})),Zd="genset",Qd="发电机组 (G)",eu="source",tu="柴油 / 燃气发电机组。",nu="-28 -22 56 64",ou=56,ru=64,su='<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"/>',iu=[{id:"t_out",x:0,y:40,orientation:"s"}],au=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],lu={kind:"inline"},Lk={id:Zd,name:Qd,category:eu,description:tu,viewBox:nu,width:ou,height:ru,svg:su,terminals:iu,params:au,source:lu},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:eu,default:Lk,description:tu,height:ru,id:Zd,name:Qd,params:au,source:lu,svg:su,terminals:iu,viewBox:nu,width:ou},Symbol.toStringTag,{value:"Module"})),cu="gfci-breaker",du="GFCI 断路器 (RCBO)",uu="protection",fu="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",mu="-18 -22 22 44",hu=22,pu=44,gu='<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"/>',yu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],xu=[{name:"open",type:"boolean",default:!1,label:"断开"}],bu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],wu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},zk={id:cu,name:du,category:uu,description:fu,viewBox:mu,width:hu,height:pu,svg:gu,terminals:yu,state:xu,params:bu,source:wu},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:uu,default:zk,description:fu,height:pu,id:cu,name:du,params:bu,source:wu,state:xu,svg:gu,terminals:yu,viewBox:mu,width:hu},Symbol.toStringTag,{value:"Module"})),vu="grid-source",ku="系统电源",_u="source",$u="无穷大母线 / 外部电网",Su="-16 -31 32 53",ju=32,Eu=53,Nu='<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"/>',Mu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Tu={kind:"inline"},Fk={id:vu,name:ku,category:_u,description:$u,viewBox:Su,width:ju,height:Eu,svg:Nu,terminals:Mu,source:Tu},Wk=Object.freeze(Object.defineProperty({__proto__:null,category:_u,default:Fk,description:$u,height:Eu,id:vu,name:ku,source:Tu,svg:Nu,terminals:Mu,viewBox:Su,width:ju},Symbol.toStringTag,{value:"Module"})),Au="grounding-transformer",Iu="接地变 (Z形)",Cu="grounding",Ou="星-曲折接线变压器,中性点接地用",Pu="-62 -152 64 164",Bu=64,Lu=164,Ru='<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"/>',zu=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Du={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"},Hk={id:Au,name:Iu,category:Cu,description:Ou,viewBox:Pu,width:Bu,height:Lu,svg:Ru,terminals:zu,source:Du},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Cu,default:Hk,description:Ou,height:Lu,id:Au,name:Iu,source:Du,svg:Ru,terminals:zu,viewBox:Pu,width:Bu},Symbol.toStringTag,{value:"Module"})),Fu="heater",Wu="电加热器 (EH)",Hu="load",qu="电阻加热元件 / 电热负荷。",Gu="-22 -7 54 14",Xu=54,Yu=14,Ku='<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"/>',Vu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Uu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Ju={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},Gk={id:Fu,name:Wu,category:Hu,description:qu,viewBox:Gu,width:Xu,height:Yu,svg:Ku,terminals:Vu,params:Uu,source:Ju},Xk=Object.freeze(Object.defineProperty({__proto__:null,category:Hu,default:Gk,description:qu,height:Yu,id:Fu,name:Wu,params:Uu,source:Ju,svg:Ku,terminals:Vu,viewBox:Gu,width:Xu},Symbol.toStringTag,{value:"Module"})),Zu="igbt",Qu="绝缘栅双极晶体管 (IGBT)",ef="passive",tf="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",nf="-32 -32 54 74",of=54,rf=74,sf='<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"/>',af=[{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"}],lf={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"},Yk={id:Zu,name:Qu,category:ef,description:tf,viewBox:nf,width:of,height:rf,svg:sf,terminals:af,source:lf},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:ef,default:Yk,description:tf,height:rf,id:Zu,name:Qu,source:lf,svg:sf,terminals:af,viewBox:nf,width:of},Symbol.toStringTag,{value:"Module"})),cf="indicator-light",df="指示灯 (HL)",uf="control",ff="信号 / 状态指示灯。",mf="-12 -22 24 24",hf=24,pf=24,gf='<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"/>',yf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],xf=[{name:"color",label:"颜色",type:"string"}],bf={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},Vk={id:cf,name:df,category:uf,description:ff,viewBox:mf,width:hf,height:pf,svg:gf,terminals:yf,params:xf,source:bf},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:uf,default:Vk,description:ff,height:pf,id:cf,name:df,params:xf,source:bf,svg:gf,terminals:yf,viewBox:mf,width:hf},Symbol.toStringTag,{value:"Module"})),wf="inductor",vf="电感 (L)",kf="passive",_f="通用电感 / 线圈 / 扼流圈。",$f="-17 -32 34 64",Sf=34,jf=64,Ef='<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"/>',Nf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Mf=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],Tf={x:6,y:0,anchor:"start"},Af={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Jk={id:wf,name:vf,category:kf,description:_f,viewBox:$f,width:Sf,height:jf,svg:Ef,terminals:Nf,params:Mf,label:Tf,source:Af},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:kf,default:Jk,description:_f,height:jf,id:wf,label:Tf,name:vf,params:Mf,source:Af,svg:Ef,terminals:Nf,viewBox:$f,width:Sf},Symbol.toStringTag,{value:"Module"})),If="inverter",Cf="逆变器 (DC→AC)",Of="renewable",Pf="-42 -42 44 44",Bf=44,Lf=44,Rf='<g transform="matrix(1 0 0 -1 0 -40)"><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"/></g>',zf=[{id:"t_dc",x:-20,y:0,orientation:"s"},{id:"t_ac",x:-20,y:-40,orientation:"n"}],Df={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Qk={id:If,name:Cf,category:Of,viewBox:Pf,width:Bf,height:Lf,svg:Rf,terminals:zf,source:Df},e_=Object.freeze(Object.defineProperty({__proto__:null,category:Of,default:Qk,height:Lf,id:If,name:Cf,source:Df,svg:Rf,terminals:zf,viewBox:Pf,width:Bf},Symbol.toStringTag,{value:"Module"})),Ff="limit-switch",Wf="限位开关 (SQ)",Hf="control",qf="行程 / 位置开关 (常开, 机械操作)。",Gf="-10 -42 12 64",Xf=12,Yf=64,Kf='<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"/>',Vf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Uf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Jf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},t_={id:Ff,name:Wf,category:Hf,description:qf,viewBox:Gf,width:Xf,height:Yf,svg:Kf,terminals:Vf,state:Uf,source:Jf},n_=Object.freeze(Object.defineProperty({__proto__:null,category:Hf,default:t_,description:qf,height:Yf,id:Ff,name:Wf,source:Jf,state:Uf,svg:Kf,terminals:Vf,viewBox:Gf,width:Xf},Symbol.toStringTag,{value:"Module"})),Zf="load-switch",Qf="负荷开关",em="switching",tm="-10 -42 14 64",nm=14,om=64,rm='<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"/>',sm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],im=[{name:"open",type:"boolean",default:!1,label:"断开"}],am={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},o_={id:Zf,name:Qf,category:em,viewBox:tm,width:nm,height:om,svg:rm,terminals:sm,state:im,source:am},r_=Object.freeze(Object.defineProperty({__proto__:null,category:em,default:o_,height:om,id:Zf,name:Qf,source:am,state:im,svg:rm,terminals:sm,viewBox:tm,width:nm},Symbol.toStringTag,{value:"Module"})),lm="load",cm="负荷",dm="load",um="抽象负荷(电流流出箭头)",fm="-8 -22 16 46",mm=16,hm=46,pm='<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"/>',gm=[{id:"t_top",x:0,y:-20,orientation:"n"}],ym=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],xm={x:6,y:0,anchor:"start"},bm={kind:"inline"},s_={id:lm,name:cm,category:dm,description:um,viewBox:fm,width:mm,height:hm,svg:pm,terminals:gm,params:ym,label:xm,source:bm},i_=Object.freeze(Object.defineProperty({__proto__:null,category:dm,default:s_,description:um,height:hm,id:lm,label:xm,name:cm,params:ym,source:bm,svg:pm,terminals:gm,viewBox:fm,width:mm},Symbol.toStringTag,{value:"Module"})),wm="make-contact",vm="常开触点 (NO)",km="control",_m="常开辅助触点 (make contact)。",$m="-10 -42 12 64",Sm=12,jm=64,Em='<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"/>',Nm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Mm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Tm={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"},a_={id:wm,name:vm,category:km,description:_m,viewBox:$m,width:Sm,height:jm,svg:Em,terminals:Nm,state:Mm,source:Tm},l_=Object.freeze(Object.defineProperty({__proto__:null,category:km,default:a_,description:_m,height:jm,id:wm,name:vm,source:Tm,state:Mm,svg:Em,terminals:Nm,viewBox:$m,width:Sm},Symbol.toStringTag,{value:"Module"})),Am="motor-starter",Im="电机启动器",Cm="motor-control",Om="电机启动器 (IEC 60617 通用符号)。",Pm="-22 -27 44 54",Bm=44,Lm=54,Rm='<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"/>',zm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Dm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},c_={id:Am,name:Im,category:Cm,description:Om,viewBox:Pm,width:Bm,height:Lm,svg:Rm,terminals:zm,source:Dm},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Cm,default:c_,description:Om,height:Lm,id:Am,name:Im,source:Dm,svg:Rm,terminals:zm,viewBox:Pm,width:Bm},Symbol.toStringTag,{value:"Module"})),Fm="ngr",Wm="中性点电阻 (NGR)",Hm="grounding",qm="小电阻接地:连接变压器中性点到地",Gm="-12 -32 24 62",Xm=24,Ym=62,Km='<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"/>',Vm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Um=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Jm={kind:"inline"},u_={id:Fm,name:Wm,category:Hm,description:qm,viewBox:Gm,width:Xm,height:Ym,svg:Km,terminals:Vm,params:Um,source:Jm},f_=Object.freeze(Object.defineProperty({__proto__:null,category:Hm,default:u_,description:qm,height:Ym,id:Fm,name:Wm,params:Um,source:Jm,svg:Km,terminals:Vm,viewBox:Gm,width:Xm},Symbol.toStringTag,{value:"Module"})),Zm="overcurrent-relay",Qm="过流继电器 (50/51)",eh="protection",th="过电流保护继电器 (ANSI 50/51)。",nh="-62 -62 64 64",oh=64,rh=64,sh='<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>',ih=[{id:"t_top",x:-30,y:-60,orientation:"n"}],ah={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},m_={id:Zm,name:Qm,category:eh,description:th,viewBox:nh,width:oh,height:rh,svg:sh,terminals:ih,source:ah},h_=Object.freeze(Object.defineProperty({__proto__:null,category:eh,default:m_,description:th,height:rh,id:Zm,name:Qm,source:ah,svg:sh,terminals:ih,viewBox:nh,width:oh},Symbol.toStringTag,{value:"Module"})),lh="panelboard",ch="配电箱",dh="load",uh="配电箱 / 负荷中心(IEC 60617 分配中心符号):顶部进线,底部分路示意",fh="-52 -62 54 64",mh=54,hh=64,ph='<g transform="matrix(1 0 0 -1 0 -60)"><rect x="-50" y="-40" width="50" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-60" x2="-40" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-60" x2="-30" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-60" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-60" x2="-10" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-20" x2="-25" y2="0" fill="none" stroke="black" stroke-width="1"/></g>',gh=[{id:"t_in",x:-25,y:-60,orientation:"n"}],yh={kind:"elmt",path:"91_en_60617/en_60617_11/en_60617_11_12/en_60617_11_12_07.elmt",qetEnglishName:"Distribution centre"},p_={id:lh,name:ch,category:dh,description:uh,viewBox:fh,width:mh,height:hh,svg:ph,terminals:gh,source:yh},g_=Object.freeze(Object.defineProperty({__proto__:null,category:dh,default:p_,description:uh,height:hh,id:lh,name:ch,source:yh,svg:ph,terminals:gh,viewBox:fh,width:mh},Symbol.toStringTag,{value:"Module"})),xh="phase-failure-relay",bh="断相继电器",wh="protection",vh="断相 / 缺相保护继电器。",kh="-62 -42 64 44",_h=64,$h=44,Sh='<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>',jh=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Eh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},y_={id:xh,name:bh,category:wh,description:vh,viewBox:kh,width:_h,height:$h,svg:Sh,terminals:jh,source:Eh},x_=Object.freeze(Object.defineProperty({__proto__:null,category:wh,default:y_,description:vh,height:$h,id:xh,name:bh,source:Eh,svg:Sh,terminals:jh,viewBox:kh,width:_h},Symbol.toStringTag,{value:"Module"})),Nh="plc",Mh="PLC / 控制器",Th="control",Ah="可编程逻辑控制器 (PLC)。",Ih="-24 -42 48 84",Ch=48,Oh=84,Ph='<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"}],Lh={kind:"inline"},b_={id:Nh,name:Mh,category:Th,description:Ah,viewBox:Ih,width:Ch,height:Oh,svg:Ph,terminals:Bh,source:Lh},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Th,default:b_,description:Ah,height:Oh,id:Nh,name:Mh,source:Lh,svg:Ph,terminals:Bh,viewBox:Ih,width:Ch},Symbol.toStringTag,{value:"Module"})),Rh="power-factor-meter",zh="功率因数表 (cosφ)",Dh="measurement",Fh="功率因数表 (cosφ)。",Wh="-22 -42 44 44",Hh=44,qh=44,Gh='<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>',Xh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Yh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},v_={id:Rh,name:zh,category:Dh,description:Fh,viewBox:Wh,width:Hh,height:qh,svg:Gh,terminals:Xh,source:Yh},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Dh,default:v_,description:Fh,height:qh,id:Rh,name:zh,source:Yh,svg:Gh,terminals:Xh,viewBox:Wh,width:Hh},Symbol.toStringTag,{value:"Module"})),Kh="power-supply",Vh="开关电源 (PS)",Uh="source",Jh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Zh="-24 -42 48 84",Qh=48,e0=84,t0='<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"/>',n0=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],o0=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],r0={kind:"inline"},__={id:Kh,name:Vh,category:Uh,description:Jh,viewBox:Zh,width:Qh,height:e0,svg:t0,terminals:n0,params:o0,source:r0},$_=Object.freeze(Object.defineProperty({__proto__:null,category:Uh,default:__,description:Jh,height:e0,id:Kh,name:Vh,params:o0,source:r0,svg:t0,terminals:n0,viewBox:Zh,width:Qh},Symbol.toStringTag,{value:"Module"})),s0="protective-relay",i0="保护继电器",a0="protection",l0="测量继电器 / 保护继电器通用符号 (IEC 60617)。",c0="-32 -42 64 44",d0=64,u0=44,f0='<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"/>',m0=[{id:"t_top",x:0,y:-40,orientation:"n"}],h0={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:s0,name:i0,category:a0,description:l0,viewBox:c0,width:d0,height:u0,svg:f0,terminals:m0,source:h0},j_=Object.freeze(Object.defineProperty({__proto__:null,category:a0,default:S_,description:l0,height:u0,id:s0,name:i0,source:h0,svg:f0,terminals:m0,viewBox:c0,width:d0},Symbol.toStringTag,{value:"Module"})),p0="proximity-switch",g0="接近开关 (SQ)",y0="control",x0="接近传感器 / 无触点接近开关。",b0="-12 -32 24 64",w0=24,v0=64,k0='<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"/>',_0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],$0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},E_={id:p0,name:g0,category:y0,description:x0,viewBox:b0,width:w0,height:v0,svg:k0,terminals:_0,source:$0},N_=Object.freeze(Object.defineProperty({__proto__:null,category:y0,default:E_,description:x0,height:v0,id:p0,name:g0,source:$0,svg:k0,terminals:_0,viewBox:b0,width:w0},Symbol.toStringTag,{value:"Module"})),S0="pt",j0="电压互感器 (PT)",E0="instrument-transformer",N0="-22 -42 44 115",M0=44,T0=115,A0='<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"/>',I0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],C0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},M_={id:S0,name:j0,category:E0,viewBox:N0,width:M0,height:T0,svg:A0,terminals:I0,source:C0},T_=Object.freeze(Object.defineProperty({__proto__:null,category:E0,default:M_,height:T0,id:S0,name:j0,source:C0,svg:A0,terminals:I0,viewBox:N0,width:M0},Symbol.toStringTag,{value:"Module"})),O0="push-button",P0="按钮 (SB)",B0="control",L0="手动按钮, 自动复位 (常开 make)。",R0="-37 -42 39 64",z0=39,D0=64,F0='<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"/>',W0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],H0={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"},A_={id:O0,name:P0,category:B0,description:L0,viewBox:R0,width:z0,height:D0,svg:F0,terminals:W0,source:H0},I_=Object.freeze(Object.defineProperty({__proto__:null,category:B0,default:A_,description:L0,height:D0,id:O0,name:P0,source:H0,svg:F0,terminals:W0,viewBox:R0,width:z0},Symbol.toStringTag,{value:"Module"})),q0="pv",G0="光伏组件",X0="renewable",Y0="-33 -22 85 64",K0=85,V0=64,U0='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',J0=[{id:"t_dc",x:0,y:40,orientation:"s"}],Z0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},C_={id:q0,name:G0,category:X0,viewBox:Y0,width:K0,height:V0,svg:U0,terminals:J0,source:Z0},O_=Object.freeze(Object.defineProperty({__proto__:null,category:X0,default:C_,height:V0,id:q0,name:G0,source:Z0,svg:U0,terminals:J0,viewBox:Y0,width:K0},Symbol.toStringTag,{value:"Module"})),Q0="rcd",ep="剩余电流装置 (RCD)",tp="protection",np="不带过流保护的剩余电流断路器 (IEC 61008)。",op="-12 -22 19 44",rp=19,sp=44,ip='<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"/>',ap=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],lp=[{name:"open",type:"boolean",default:!1,label:"断开"}],cp=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],dp={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},P_={id:Q0,name:ep,category:tp,description:np,viewBox:op,width:rp,height:sp,svg:ip,terminals:ap,state:lp,params:cp,source:dp},B_=Object.freeze(Object.defineProperty({__proto__:null,category:tp,default:P_,description:np,height:sp,id:Q0,name:ep,params:cp,source:dp,state:lp,svg:ip,terminals:ap,viewBox:op,width:rp},Symbol.toStringTag,{value:"Module"})),up="recloser",fp="重合闸 (Recloser)",mp="protection",hp="中压自动重合闸开关。",pp="-12 -32 36 64",gp=36,yp=64,xp='<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>',bp=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],wp=[{name:"open",type:"boolean",default:!1,label:"断开"}],vp={kind:"inline"},L_={id:up,name:fp,category:mp,description:hp,viewBox:pp,width:gp,height:yp,svg:xp,terminals:bp,state:wp,source:vp},R_=Object.freeze(Object.defineProperty({__proto__:null,category:mp,default:L_,description:hp,height:yp,id:up,name:fp,source:vp,state:wp,svg:xp,terminals:bp,viewBox:pp,width:gp},Symbol.toStringTag,{value:"Module"})),kp="rectifier",_p="整流器 (AC→DC)",$p="renewable",Sp="-42 -42 44 44",jp=44,Ep=44,Np='<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"}],Tp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},z_={id:kp,name:_p,category:$p,viewBox:Sp,width:jp,height:Ep,svg:Np,terminals:Mp,source:Tp},D_=Object.freeze(Object.defineProperty({__proto__:null,category:$p,default:z_,height:Ep,id:kp,name:_p,source:Tp,svg:Np,terminals:Mp,viewBox:Sp,width:jp},Symbol.toStringTag,{value:"Module"})),Ap="relay-coil",Ip="继电器线圈 (KA)",Cp="control",Op="继电器 / 接触器操作线圈 (方框)。",Pp="-22 -22 44 44",Bp=44,Lp=44,Rp='<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"/>',zp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Dp={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"},F_={id:Ap,name:Ip,category:Cp,description:Op,viewBox:Pp,width:Bp,height:Lp,svg:Rp,terminals:zp,source:Dp},W_=Object.freeze(Object.defineProperty({__proto__:null,category:Cp,default:F_,description:Op,height:Lp,id:Ap,name:Ip,source:Dp,svg:Rp,terminals:zp,viewBox:Pp,width:Bp},Symbol.toStringTag,{value:"Module"})),Fp="resistor",Wp="电阻 (R)",Hp="passive",qp="通用电阻 / 限流 / 制动电阻。",Gp="-6 -23 12 35",Xp=12,Yp=35,Kp='<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"/>',Vp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Up=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Jp={x:6,y:0,anchor:"start"},Zp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},H_={id:Fp,name:Wp,category:Hp,description:qp,viewBox:Gp,width:Xp,height:Yp,svg:Kp,terminals:Vp,params:Up,label:Jp,source:Zp},q_=Object.freeze(Object.defineProperty({__proto__:null,category:Hp,default:H_,description:qp,height:Yp,id:Fp,label:Jp,name:Wp,params:Up,source:Zp,svg:Kp,terminals:Vp,viewBox:Gp,width:Xp},Symbol.toStringTag,{value:"Module"})),Qp="reverse-power-relay",eg="逆功率继电器 (32)",tg="protection",ng="逆功率 / 逆流保护继电器 (ANSI 32)。",og="-62 -42 64 44",rg=64,sg=44,ig='<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"/>',ag=[{id:"t_top",x:-30,y:-40,orientation:"n"}],lg={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},G_={id:Qp,name:eg,category:tg,description:ng,viewBox:og,width:rg,height:sg,svg:ig,terminals:ag,source:lg},X_=Object.freeze(Object.defineProperty({__proto__:null,category:tg,default:G_,description:ng,height:sg,id:Qp,name:eg,source:lg,svg:ig,terminals:ag,viewBox:og,width:rg},Symbol.toStringTag,{value:"Module"})),cg="selector-switch",dg="选择开关 (SA)",ug="switching",fg="转换 / 选择开关 (旋转操作, 保位)。",mg="-34 -42 36 64",hg=36,pg=64,gg='<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"/>',yg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],xg=[{name:"open",type:"boolean",default:!1,label:"断开"}],bg={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"},Y_={id:cg,name:dg,category:ug,description:fg,viewBox:mg,width:hg,height:pg,svg:gg,terminals:yg,state:xg,source:bg},K_=Object.freeze(Object.defineProperty({__proto__:null,category:ug,default:Y_,description:fg,height:pg,id:cg,name:dg,source:bg,state:xg,svg:gg,terminals:yg,viewBox:mg,width:hg},Symbol.toStringTag,{value:"Module"})),wg="series-reactor",vg="串联电抗器",kg="compensation",_g="与并联电抗器同符号;通过用法区分。",$g="-62 -82 64 104",Sg=64,jg=104,Eg='<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"/>',Ng=[{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"},V_={id:wg,name:vg,category:kg,description:_g,viewBox:$g,width:Sg,height:jg,svg:Eg,terminals:Ng,source:Mg},U_=Object.freeze(Object.defineProperty({__proto__:null,category:kg,default:V_,description:_g,height:jg,id:wg,name:vg,source:Mg,svg:Eg,terminals:Ng,viewBox:$g,width:Sg},Symbol.toStringTag,{value:"Module"})),Tg="shunt-capacitor",Ag="并联电容器",Ig="compensation",Cg="-7 -23 14 27",Og=14,Pg=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"/>',Lg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Rg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],zg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},J_={id:Tg,name:Ag,category:Ig,viewBox:Cg,width:Og,height:Pg,svg:Bg,terminals:Lg,params:Rg,source:zg},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:Ig,default:J_,height:Pg,id:Tg,name:Ag,params:Rg,source:zg,svg:Bg,terminals:Lg,viewBox:Cg,width:Og},Symbol.toStringTag,{value:"Module"})),Dg="shunt-reactor",Fg="并联电抗器",Wg="compensation",Hg="-62 -82 64 104",qg=64,Gg=104,Xg='<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"/>',Yg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Kg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},Q_={id:Dg,name:Fg,category:Wg,viewBox:Hg,width:qg,height:Gg,svg:Xg,terminals:Yg,source:Kg},e$=Object.freeze(Object.defineProperty({__proto__:null,category:Wg,default:Q_,height:Gg,id:Dg,name:Fg,source:Kg,svg:Xg,terminals:Yg,viewBox:Hg,width:qg},Symbol.toStringTag,{value:"Module"})),Vg="siren",Ug="警笛 (HA)",Jg="control",Zg="声响警笛 / 报警器。",Qg="-32 -42 44 54",e1=44,t1=54,n1='<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"/>',o1=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],r1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},t$={id:Vg,name:Ug,category:Jg,description:Zg,viewBox:Qg,width:e1,height:t1,svg:n1,terminals:o1,source:r1},n$=Object.freeze(Object.defineProperty({__proto__:null,category:Jg,default:t$,description:Zg,height:t1,id:Vg,name:Ug,source:r1,svg:n1,terminals:o1,viewBox:Qg,width:e1},Symbol.toStringTag,{value:"Module"})),s1="socket-outlet",i1="插座 / 连接器",a1="load",l1="电源插座 / 多极连接器。",c1="-7 -2 13 34",d1=13,u1=34,f1='<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"/>',m1=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],h1={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
197
|
+
unifilar`},o$={id:s1,name:i1,category:a1,description:l1,viewBox:c1,width:d1,height:u1,svg:f1,terminals:m1,source:h1},r$=Object.freeze(Object.defineProperty({__proto__:null,category:a1,default:o$,description:l1,height:u1,id:s1,name:i1,source:h1,svg:f1,terminals:m1,viewBox:c1,width:d1},Symbol.toStringTag,{value:"Module"})),p1="soft-starter",g1="软启动器",y1="motor-control",x1="电机软启动器 (晶闸管降压启动)。",b1="-22 -42 44 84",w1=44,v1=84,k1='<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"/>',_1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],$1={kind:"inline"},s$={id:p1,name:g1,category:y1,description:x1,viewBox:b1,width:w1,height:v1,svg:k1,terminals:_1,source:$1},i$=Object.freeze(Object.defineProperty({__proto__:null,category:y1,default:s$,description:x1,height:v1,id:p1,name:g1,source:$1,svg:k1,terminals:_1,viewBox:b1,width:w1},Symbol.toStringTag,{value:"Module"})),S1="sync-motor",j1="同步电动机",E1="load",N1="-62 -82 64 114",M1=64,T1=114,A1='<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"/>',I1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],C1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},a$={id:S1,name:j1,category:E1,viewBox:N1,width:M1,height:T1,svg:A1,terminals:I1,source:C1},l$=Object.freeze(Object.defineProperty({__proto__:null,category:E1,default:a$,height:T1,id:S1,name:j1,source:C1,svg:A1,terminals:I1,viewBox:N1,width:M1},Symbol.toStringTag,{value:"Module"})),O1="synchronoscope",P1="同步表",B1="measurement",L1="同步指示器 / 同步表。",R1="-22 -42 44 44",z1=44,D1=44,F1='<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"/>',W1=[{id:"t_top",x:0,y:-40,orientation:"n"}],H1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},c$={id:O1,name:P1,category:B1,description:L1,viewBox:R1,width:z1,height:D1,svg:F1,terminals:W1,source:H1},d$=Object.freeze(Object.defineProperty({__proto__:null,category:B1,default:c$,description:L1,height:D1,id:O1,name:P1,source:H1,svg:F1,terminals:W1,viewBox:R1,width:z1},Symbol.toStringTag,{value:"Module"})),q1="terminal",G1="接线端子 / 节点 (X)",X1="busbar",Y1="接线端子 / 接线盒 / 汇接节点。",K1="-5 -5 10 10",V1=10,U1=10,J1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',Z1=[{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"}],Q1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},u$={id:q1,name:G1,category:X1,description:Y1,viewBox:K1,width:V1,height:U1,svg:J1,terminals:Z1,source:Q1},f$=Object.freeze(Object.defineProperty({__proto__:null,category:X1,default:u$,description:Y1,height:U1,id:q1,name:G1,source:Q1,svg:J1,terminals:Z1,viewBox:K1,width:V1},Symbol.toStringTag,{value:"Module"})),ey="thermal-overload",ty="热过载继电器",ny="motor-control",oy="电机热过载保护继电器, 通常串接在接触器和电机之间。",ry="-9 -32 19 64",sy=19,iy=64,ay='<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"/>',ly=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],cy=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],dy={kind:"inline"},m$={id:ey,name:ty,category:ny,description:oy,viewBox:ry,width:sy,height:iy,svg:ay,terminals:ly,state:cy,source:dy},h$=Object.freeze(Object.defineProperty({__proto__:null,category:ny,default:m$,description:oy,height:iy,id:ey,name:ty,source:dy,state:cy,svg:ay,terminals:ly,viewBox:ry,width:sy},Symbol.toStringTag,{value:"Module"})),uy="thermocouple",fy="热电偶 (BT)",my="measurement",hy="热电偶温度传感器。",py="-26 -42 52 46",gy=52,yy=46,xy='<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"/>',by=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],wy={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},p$={id:uy,name:fy,category:my,description:hy,viewBox:py,width:gy,height:yy,svg:xy,terminals:by,source:wy},g$=Object.freeze(Object.defineProperty({__proto__:null,category:my,default:p$,description:hy,height:yy,id:uy,name:fy,source:wy,svg:xy,terminals:by,viewBox:py,width:gy},Symbol.toStringTag,{value:"Module"})),vy="thyristor",ky="晶闸管 (V)",_y="passive",$y="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",Sy="-22 -42 34 44",jy=34,Ey=44,Ny='<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"}],Ty={x:6,y:-20,anchor:"start"},Ay={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)"},y$={id:vy,name:ky,category:_y,description:$y,viewBox:Sy,width:jy,height:Ey,svg:Ny,terminals:My,label:Ty,source:Ay},x$=Object.freeze(Object.defineProperty({__proto__:null,category:_y,default:y$,description:$y,height:Ey,id:vy,label:Ty,name:ky,source:Ay,svg:Ny,terminals:My,viewBox:Sy,width:jy},Symbol.toStringTag,{value:"Module"})),Iy="time-relay",Cy="时间继电器 (KT)",Oy="control",Py="延时 (缓动) 继电器线圈。",By="-32 -22 54 44",Ly=54,Ry=44,zy='<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"/>',Dy=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Fy={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"},b$={id:Iy,name:Cy,category:Oy,description:Py,viewBox:By,width:Ly,height:Ry,svg:zy,terminals:Dy,source:Fy},w$=Object.freeze(Object.defineProperty({__proto__:null,category:Oy,default:b$,description:Py,height:Ry,id:Iy,name:Cy,source:Fy,svg:zy,terminals:Dy,viewBox:By,width:Ly},Symbol.toStringTag,{value:"Module"})),Wy="transfer-switch",Hy="切换开关 (ATS)",qy="switching",Gy="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Xy="-27 -32 51 64",Yy=51,Ky=64,Vy='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',Uy=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],Jy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Zy={kind:"inline"},v$={id:Wy,name:Hy,category:qy,description:Gy,viewBox:Xy,width:Yy,height:Ky,svg:Vy,terminals:Uy,state:Jy,source:Zy},k$=Object.freeze(Object.defineProperty({__proto__:null,category:qy,default:v$,description:Gy,height:Ky,id:Wy,name:Hy,source:Zy,state:Jy,svg:Vy,terminals:Uy,viewBox:Xy,width:Yy},Symbol.toStringTag,{value:"Module"})),Qy="transformer-2w",ex="双绕组变压器",tx="transformer",nx="-62 -142 64 144",ox=64,rx=144,sx='<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"/>',ix=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],ax=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],lx={x:4,y:-68,anchor:"start"},cx={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"},_$={id:Qy,name:ex,category:tx,viewBox:nx,width:ox,height:rx,svg:sx,terminals:ix,params:ax,label:lx,source:cx},$$=Object.freeze(Object.defineProperty({__proto__:null,category:tx,default:_$,height:rx,id:Qy,label:lx,name:ex,params:ax,source:cx,svg:sx,terminals:ix,viewBox:nx,width:ox},Symbol.toStringTag,{value:"Module"})),dx="transformer-3w",ux="三绕组变压器",fx="transformer",mx="-82 -131 114 133",hx=114,px=133,gx='<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"/>',yx=[{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"}],xx={x:4,y:-64,anchor:"start"},bx={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:dx,name:ux,category:fx,viewBox:mx,width:hx,height:px,svg:gx,terminals:yx,label:xx,source:bx},j$=Object.freeze(Object.defineProperty({__proto__:null,category:fx,default:S$,height:px,id:dx,label:xx,name:ux,source:bx,svg:gx,terminals:yx,viewBox:mx,width:hx},Symbol.toStringTag,{value:"Module"})),wx="triac",vx="双向晶闸管 (V)",kx="passive",_x="双向三极晶闸管 (TRIAC)。",$x="-22 -42 44 44",Sx=44,jx=44,Ex='<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"/>',Nx=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Mx={x:6,y:-20,anchor:"start"},Tx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},E$={id:wx,name:vx,category:kx,description:_x,viewBox:$x,width:Sx,height:jx,svg:Ex,terminals:Nx,label:Mx,source:Tx},N$=Object.freeze(Object.defineProperty({__proto__:null,category:kx,default:E$,description:_x,height:jx,id:wx,label:Mx,name:vx,source:Tx,svg:Ex,terminals:Nx,viewBox:$x,width:Sx},Symbol.toStringTag,{value:"Module"})),Ax="undervoltage-relay",Ix="欠压继电器 (27)",Cx="protection",Ox="欠电压保护继电器 (ANSI 27)。",Px="-62 -82 64 84",Bx=64,Lx=84,Rx='<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>',zx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],Dx={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},M$={id:Ax,name:Ix,category:Cx,description:Ox,viewBox:Px,width:Bx,height:Lx,svg:Rx,terminals:zx,source:Dx},T$=Object.freeze(Object.defineProperty({__proto__:null,category:Cx,default:M$,description:Ox,height:Lx,id:Ax,name:Ix,source:Dx,svg:Rx,terminals:zx,viewBox:Px,width:Bx},Symbol.toStringTag,{value:"Module"})),Fx="ups",Wx="不间断电源 (UPS)",Hx="source",qx="在线 / 后备式不间断电源。",Gx="-26 -42 52 84",Xx=52,Yx=84,Kx='<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"/>',Vx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Ux=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Jx={kind:"inline"},A$={id:Fx,name:Wx,category:Hx,description:qx,viewBox:Gx,width:Xx,height:Yx,svg:Kx,terminals:Vx,params:Ux,source:Jx},I$=Object.freeze(Object.defineProperty({__proto__:null,category:Hx,default:A$,description:qx,height:Yx,id:Fx,name:Wx,params:Ux,source:Jx,svg:Kx,terminals:Vx,viewBox:Gx,width:Xx},Symbol.toStringTag,{value:"Module"})),Zx="varmeter",Qx="无功功率表 (var)",eb="measurement",tb="无功功率表 (var)。",nb="-22 -42 44 44",ob=44,rb=44,sb='<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>',ib=[{id:"t_top",x:0,y:-40,orientation:"n"}],ab={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},C$={id:Zx,name:Qx,category:eb,description:tb,viewBox:nb,width:ob,height:rb,svg:sb,terminals:ib,source:ab},O$=Object.freeze(Object.defineProperty({__proto__:null,category:eb,default:C$,description:tb,height:rb,id:Zx,name:Qx,source:ab,svg:sb,terminals:ib,viewBox:nb,width:ob},Symbol.toStringTag,{value:"Module"})),lb="vfd",cb="变频器 (VFD)",db="motor-control",ub="Variable Frequency Drive — 异步电动机调速。",fb="-24 -42 48 84",mb=48,hb=84,pb='<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"/>',gb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],yb={kind:"inline"},P$={id:lb,name:cb,category:db,description:ub,viewBox:fb,width:mb,height:hb,svg:pb,terminals:gb,source:yb},B$=Object.freeze(Object.defineProperty({__proto__:null,category:db,default:P$,description:ub,height:hb,id:lb,name:cb,source:yb,svg:pb,terminals:gb,viewBox:fb,width:mb},Symbol.toStringTag,{value:"Module"})),xb="voltage-regulator",bb="调压器 (T)",wb="transformer",vb="可调感应调压器 / 自耦调压器。",kb="-17 -32 38 64",_b=38,$b=64,Sb='<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"/>',jb=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Eb=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],Nb={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},L$={id:xb,name:bb,category:wb,description:vb,viewBox:kb,width:_b,height:$b,svg:Sb,terminals:jb,params:Eb,source:Nb},R$=Object.freeze(Object.defineProperty({__proto__:null,category:wb,default:L$,description:vb,height:$b,id:xb,name:bb,params:Eb,source:Nb,svg:Sb,terminals:jb,viewBox:kb,width:_b},Symbol.toStringTag,{value:"Module"})),Mb="voltmeter",Tb="电压表 (V)",Ab="measurement",Ib="-22 -42 44 44",Cb=44,Ob=44,Pb='<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"}],Lb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},z$={id:Mb,name:Tb,category:Ab,viewBox:Ib,width:Cb,height:Ob,svg:Pb,terminals:Bb,source:Lb},D$=Object.freeze(Object.defineProperty({__proto__:null,category:Ab,default:z$,height:Ob,id:Mb,name:Tb,source:Lb,svg:Pb,terminals:Bb,viewBox:Ib,width:Cb},Symbol.toStringTag,{value:"Module"})),Rb="wattmeter",zb="功率表 (W)",Db="measurement",Fb="-22 -42 44 44",Wb=44,Hb=44,qb='<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>',Gb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Xb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},F$={id:Rb,name:zb,category:Db,viewBox:Fb,width:Wb,height:Hb,svg:qb,terminals:Gb,source:Xb},W$=Object.freeze(Object.defineProperty({__proto__:null,category:Db,default:F$,height:Hb,id:Rb,name:zb,source:Xb,svg:qb,terminals:Gb,viewBox:Fb,width:Wb},Symbol.toStringTag,{value:"Module"})),Yb="wind-turbine",Kb="风力发电机",Vb="renewable",Ub="风机:发电机 + 三叶轮标记",Jb="-22 -46 44 68",Zb=44,Qb=68,ew='<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"/>',tw=[{id:"t_bottom",x:0,y:20,orientation:"s"}],nw={kind:"inline"},H$={id:Yb,name:Kb,category:Vb,description:Ub,viewBox:Jb,width:Zb,height:Qb,svg:ew,terminals:tw,source:nw},q$=Object.freeze(Object.defineProperty({__proto__:null,category:Vb,default:H$,description:Ub,height:Qb,id:Yb,name:Kb,source:nw,svg:ew,terminals:tw,viewBox:Jb,width:Zb},Symbol.toStringTag,{value:"Module"})),ow="zener-diode",rw="稳压二极管 (D)",sw="passive",iw="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",aw="-12 -42 24 44",lw=24,cw=44,dw='<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"/>',uw=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fw={x:6,y:-20,anchor:"start"},mw={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"},G$={id:ow,name:rw,category:sw,description:iw,viewBox:aw,width:lw,height:cw,svg:dw,terminals:uw,label:fw,source:mw},X$=Object.freeze(Object.defineProperty({__proto__:null,category:sw,default:G$,description:iw,height:cw,id:ow,label:fw,name:rw,source:mw,svg:dw,terminals:uw,viewBox:aw,width:lw},Symbol.toStringTag,{value:"Module"})),Y$=Object.assign({"./ammeter.json":I2,"./arc-suppression-coil.json":O2,"./arrester.json":B2,"./async-motor.json":R2,"./autotransformer.json":D2,"./battery.json":W2,"./bell.json":q2,"./break-contact.json":X2,"./breaker.json":K2,"./buchholz-relay.json":U2,"./busbar.json":Z2,"./buzzer.json":ek,"./capacitor.json":nk,"./contactor.json":rk,"./converter-bidir.json":ik,"./ct.json":lk,"./dc-combiner.json":dk,"./dc-disconnector.json":fk,"./dc-motor.json":hk,"./diode.json":gk,"./disconnector.json":xk,"./distance-relay.json":wk,"./earth.json":kk,"./earthing-switch.json":$k,"./energy-meter.json":jk,"./ev-charger.json":Nk,"./frequency-meter.json":Tk,"./fuse-switch-disconnector.json":Ik,"./fuse.json":Ok,"./generator.json":Bk,"./genset.json":Rk,"./gfci-breaker.json":Dk,"./grid-source.json":Wk,"./grounding-transformer.json":qk,"./heater.json":Xk,"./igbt.json":Kk,"./indicator-light.json":Uk,"./inductor.json":Zk,"./inverter.json":e_,"./limit-switch.json":n_,"./load-switch.json":r_,"./load.json":i_,"./make-contact.json":l_,"./motor-starter.json":d_,"./ngr.json":f_,"./overcurrent-relay.json":h_,"./panelboard.json":g_,"./phase-failure-relay.json":x_,"./plc.json":w_,"./power-factor-meter.json":k_,"./power-supply.json":$_,"./protective-relay.json":j_,"./proximity-switch.json":N_,"./pt.json":T_,"./push-button.json":I_,"./pv.json":O_,"./rcd.json":B_,"./recloser.json":R_,"./rectifier.json":D_,"./relay-coil.json":W_,"./resistor.json":q_,"./reverse-power-relay.json":X_,"./selector-switch.json":K_,"./series-reactor.json":U_,"./shunt-capacitor.json":Z_,"./shunt-reactor.json":e$,"./siren.json":n$,"./socket-outlet.json":r$,"./soft-starter.json":i$,"./sync-motor.json":l$,"./synchronoscope.json":d$,"./terminal.json":f$,"./thermal-overload.json":h$,"./thermocouple.json":g$,"./thyristor.json":x$,"./time-relay.json":w$,"./transfer-switch.json":k$,"./transformer-2w.json":$$,"./transformer-3w.json":j$,"./triac.json":N$,"./undervoltage-relay.json":T$,"./ups.json":I$,"./varmeter.json":O$,"./vfd.json":B$,"./voltage-regulator.json":R$,"./voltmeter.json":D$,"./wattmeter.json":W$,"./wind-turbine.json":q$,"./zener-diode.json":X$}),hw=Object.values(Y$).map(e=>e.default),Ve=Object.fromEntries(hw.map(e=>[e.id,e])),Vo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],K$=(()=>{var t;const e={};for(const n of hw)(e[t=n.category]??(e[t]=[])).push(n);return e})(),zn=new Map(Object.entries(Ve));function pw(e){return Ve[e]}function V$(e){const n=[...e].sort().join("|");let o=2166136261;for(let s=0;s<n.length;s++)o^=n.charCodeAt(s),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const U$=320;function Xe(e){var _,v,O,L,W;const t=us(),n=new Map;e.elements.forEach((k,F)=>{if(n.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/elements/${F}`});return}n.set(k.id,k);const X=zn.get(k.kind);X||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:k.kind})} (id=${k.id})`,pointer:`/elements/${F}`}),t.elements.set(k.id,{element:k,libraryDef:X})});const o=new Map,s=new Map;(e.buses??[]).forEach((k,F)=>{if(n.has(k.id)||o.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/buses/${F}`});return}if(o.set(k.id,k),k.layout){const X=k.layout.rot??0;s.set(k.id,{at:k.layout.at,span:k.layout.span,rot:X,axis:Ln(X)})}});const r=new Map;(e.junctions??[]).forEach((k,F)=>{if(n.has(k.id)||o.has(k.id)||r.has(k.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:k.id}),pointer:`/junctions/${F}`});return}r.set(k.id,k)});const i=k=>!k.includes(".")&&o.has(k),a=k=>!k.includes(".")&&r.has(k),l=(k,F)=>{if(i(k)||a(k))return!0;const X=k.indexOf(".");if(X<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:k}),pointer:F}),!1;const Z=k.slice(0,X),G=k.slice(X+1),A=t.elements.get(Z);if(!A)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:Z}),pointer:F}),!1;if(!A.libraryDef)return!1;if(!A.libraryDef.terminals.find(D=>D.id===G)){const D=A.libraryDef.terminals.map(se=>se.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:Z,kind:A.element.kind,pin:G,available:D}),pointer:F}),!1}return!0},c=[];(e.wires??[]).forEach((k,F)=>{const X=`/wires/${F}`,Z=l(k.ends[0],X),G=l(k.ends[1],X);Z&&G&&c.push(k)});const f=new Map;if(e.layout)for(const[k,F]of Object.entries(e.layout))t.elements.has(k)?f.set(k,fs(F)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:k}),pointer:`/layout/${k}`});const u=M2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:zn,userLayout:f,userBusLayout:s});t.layout=u.devices;for(const[k,F]of u.buses){const X=o.get(k);X&&t.buses.set(k,{bus:X,geometry:F})}for(const[k,F]of o)t.buses.has(k)||t.buses.set(k,{bus:F,geometry:{at:((_=F.layout)==null?void 0:_.at)??[0,0],span:((v=F.layout)==null?void 0:v.span)??U$,rot:((O=F.layout)==null?void 0:O.rot)??0,axis:Ln(((L=F.layout)==null?void 0:L.rot)??0)}});for(const k of t.elements.values()){if(!k.libraryDef)continue;const F=t.layout.get(k.element.id);if(!F)continue;const X=[];for(const Z of k.libraryDef.terminals){const G=`${k.element.id}.${Z.id}`,A=Oe([Z.x,Z.y],F),D=St(Z.orientation,F);t.terminals.set(G,{ref:G,elementId:k.element.id,pin:Z.id,world:A,orientation:D}),X.push(G)}t.elementToTerminals.set(k.element.id,X)}const m=new Map,p=new Set;for(const[k,F]of r)(W=F.layout)!=null&&W.at?(m.set(k,[F.layout.at[0],F.layout.at[1]]),p.add(k)):u.junctions.has(k)&&(m.set(k,u.junctions.get(k)),p.add(k));const h=k=>{if(!k.includes(".")){const X=t.buses.get(k);return X?X.geometry.at:m.get(k)??null}const F=t.terminals.get(k);return F?F.world:null},g=new Map;for(const[k]of r)p.has(k)||g.set(k,[]);for(const k of c){const[F,X]=k.ends;g.has(F)&&g.get(F).push(X),g.has(X)&&g.get(X).push(F)}for(let k=0;k<12;k++){let F=!1;for(const[X,Z]of g){let G=0,A=0,D=0;for(const oe of Z){const re=h(oe);re&&(G+=re[0],A+=re[1],D++)}if(!D)continue;const se=G/D,ie=A/D,de=m.get(X);(!de||Math.abs(de[0]-se)>.01||Math.abs(de[1]-ie)>.01)&&(m.set(X,[se,ie]),F=!0)}if(!F)break}for(const[k,F]of r)t.junctions.set(k,{junction:F,world:m.get(k)??[0,0]});const b=new ms;for(const k of c)b.add(k.ends[0]),b.add(k.ends[1]),b.union(k.ends[0],k.ends[1]);for(const[,k]of b.groups()){const F=V$(k);t.nodes.set(F,{id:F,terminals:k});for(const X of k)t.terminalToNode.set(X,F)}for(const k of t.elements.values()){const F=t.elementToTerminals.get(k.element.id)??[];if(F.length===0)continue;F.some(Z=>t.terminalToNode.has(Z))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k.element.id})})}for(const k of t.buses.keys())t.terminalToNode.has(k)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k})});for(const k of t.junctions.keys())t.terminalToNode.has(k)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:k})});for(const k of c){if(k.path&&k.path.length>=2){const X=k.path,Z=X.length>=2?X[1]:null,G=X.length>=2?X[X.length-2]:null,A=Yo(k.ends[0],Z,t),D=Yo(k.ends[1],G,t);if(A&&D){const se=[[A[0],A[1]],...X.slice(1,-1).map(de=>[de[0],de[1]]),[D[0],D[1]]],ie=ds(se);if(ie.length>=2){t.wireRenders.set(k.id,{wireId:k.id,path:ie,userEdited:!0,...k.label?{label:k.label}:{}});continue}}}const F=T2(k,t);F&&t.wireRenders.set(k.id,k.label?{...F,label:k.label}:F)}return t}const J$={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"},Uo="B",Jo="J";function oo(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Tt(e,t){const n=J$[t]??t,o=oo(e);let s=1;for(;o.has(`${n}${s}`);)s++;return`${n}${s}`}function Dn(e){const t=oo(e);let n=1;for(;t.has(`${Uo}${n}`);)n++;return`${Uo}${n}`}function Fn(e){const t=oo(e);let n=1;for(;t.has(`${Jo}${n}`);)n++;return`${Jo}${n}`}function gw(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Qe(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let s=2166136261;for(let r=0;r<o.length;r++)s^=o.charCodeAt(r),s=Math.imul(s,16777619);return`w_${(s>>>0).toString(36)}`}function vn(e,t,n){if(n.length===0)return n;const o=new Set(n.map(a=>a.id)),s=new Set(t.map(a=>a.id)),r=new Set;for(const a of e)if(!s.has(a.id))for(const l of a.ends)o.has(l)&&r.add(l);if(r.size===0)return n;const i=new Set;for(const a of t)for(const l of a.ends)r.has(l)&&i.add(l);return n.filter(a=>!r.has(a.id)||i.has(a.id))}const Zo={version:"1",elements:[]},Z$=100,Qo=20;function Q$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=tn()(k2((e,t)=>({diagram:Zo,internal:Xe(Zo),fileSession:null,activeTool:Q$(),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,readOnly:!1,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:Xe(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}),setReadOnly:n=>e({readOnly:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:Xe(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:s}=t(),r=n(o);if(r===o)return;const i=s.length>=Z$?s.slice(1):s;e({diagram:r,internal:Xe(r),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:s}=t();if(n.length===0)return;const r=n[n.length-1];e({diagram:r,internal:Xe(r),past:n.slice(0,-1),future:[...o,s],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},redo:()=>{const{past:n,future:o,diagram:s}=t();if(o.length===0)return;const r=o[o.length-1];e({diagram:r,internal:Xe(r),past:[...n,s],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},setActiveTool:(n,o)=>{const s=t();let r;(o==null?void 0:o.placeKind)!==void 0?r=o.placeKind:n==="place"?r=s.placeKind??s.lastPlaceKind:r=null,e({activeTool:n,placeKind:r,lastPlaceKind:r??s.lastPlaceKind,wireFromTerminal:n==="wire"?s.wireFromTerminal:null,wireDragFrom:n==="wire"?s.wireDragFrom:null,placeFromTerminal:n==="place"?s.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:eS(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(s=>s!==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:s}=t();if(n.length===0)return;const r=new Set(n),i=o.elements.filter(p=>r.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>r.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>r.has(p.id)).map(p=>{var g;const h=structuredClone(p);if(!h.layout){const b=(g=s.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(r.has(p)&&!s.buses.has(p)){const h=(m=o.layout)==null?void 0:m[p];if(h){c[p]=structuredClone(h);continue}const g=s.layout.get(p);g&&(c[p]=Dt(g))}const f={};for(const p of n){const h=s.buses.get(p);h&&(f[p]=rt(h.geometry))}const u=(o.wires??[]).filter(p=>p.ends.every(h=>r.has(kn(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:s}=t();if(!n||n.elements.length===0&&n.buses.length===0&&n.junctions.length===0)return;const r=o+1,i=Qo*r,a=Qo*r,l=new Map;let c=s;for(const u of n.elements){const m=Tt(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=Dn(c);l.set(u.id,m),c={...c,buses:[...c.buses??[],{id:m}]}}for(const u of n.junctions){const m=Fn(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(v=>{const O=structuredClone(v);return O.id=l.get(v.id),O}),p=n.buses.map(v=>{const O=structuredClone(v);O.id=l.get(v.id);const L=n.busLayouts[v.id];return L&&(O.layout={...L,at:[L.at[0]+i,L.at[1]+a]}),O}),h=n.junctions.map(v=>{const O=structuredClone(v);return O.id=l.get(v.id),O.layout&&(O.layout={at:[O.layout.at[0]+i,O.layout.at[1]+a]}),O}),g={...u.layout??{}};for(const[v,O]of l){const L=n.placements[v];L&&(g[O]={...L,at:[L.at[0]+i,L.at[1]+a]})}const b=n.wires.map(v=>{const O=[f(v.ends[0]),f(v.ends[1])];return{id:Qe(O[0],O[1]),ends:O,...v.label?{label:v.label}:{}}}),_=er(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:r})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,s=(n.buses??[]).some(c=>c.layout);if(!o&&!s)return n;const{layout:r,...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(s=>{let r=!1,i=s.layout;if(i){const l={};for(const[c,f]of Object.entries(i)){if(o.has(c)){r=!0;continue}l[c]=f}r&&(i=Object.keys(l).length?l:void 0)}let a=s.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){r=!0;const{layout:f,...u}=c;return u}return c});r&&(a=l)}return r?{...s,layout:i,buses:a}:s})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const s=o.layout??{},r={};for(const l of o.elements){if(s[l.id])continue;const c=n.layout.get(l.id);c&&(r[l.id]=Dt(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,bus:l})}),Object.keys(r).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:rt(c.geometry)}:l})),{...o,layout:{...s,...r},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(s=>{var c;const r=s.layout??{},i={},a=new Map;for(const f of n)if(o.buses.has(f)){const u=o.buses.get(f);(c=s.buses)!=null&&c.find(m=>m.id===f&&m.layout)||a.set(f,rt(u.geometry))}else{if(r[f])continue;const u=o.layout.get(f);u&&(i[f]=Dt(u))}if(Object.keys(i).length===0&&a.size===0)return s;let l=s.buses;return a.size>0&&l&&(l=l.map(f=>a.has(f.id)?{...f,layout:a.get(f.id)}:f)),{...s,layout:{...r,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(s=>{const r={...s.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=r[f]??(m?Dt(m):{at:[0,0]});r[f]={...p,at:[p.at[0]+u[0],p.at[1]+u[1]]}}let l=s.buses;i.size>0&&(l=(s.buses??[]).map(f=>{const u=i.get(f.id);if(!u)return f;const m=f.layout??rt(o.buses.get(f.id).geometry);return{...f,layout:{...m,at:[m.at[0]+u[0],m.at[1]+u[1]]}}}));let c=s.junctions;return a.size>0&&(c=(s.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]]}}})),{...s,layout:r,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(s=>{const r=s.elements.filter(u=>!o.has(u.id)),i=(s.buses??[]).filter(u=>!o.has(u.id)),a=(s.junctions??[]).filter(u=>!o.has(u.id)),l=(s.wires??[]).filter(u=>!o.has(kn(u.ends[0]))&&!o.has(kn(u.ends[1]))),c=vn(s.wires??[],l,a),f=s.layout?Object.fromEntries(Object.entries(s.layout).filter(([u])=>!o.has(u))):void 0;return{...s,elements:r,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 s=(t().diagram.wires??[]).find(i=>i.id===n),r=new Set;if(s)for(const i of s.ends){const a=i.indexOf(".");a>0&&r.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 r){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=vn(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 s=o.nodes.get(n);if(!s)return;const r=new Set(s.terminals),i=new Set;for(const a of s.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=>!r.has(m.ends[0])&&!r.has(m.ends[1])),u=vn(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:s}=t();o.length!==0&&t().dispatch(r=>{var c,f,u,m;const i={...r.layout??{}},a=new Map;for(const p of o){if(s.junctions.has(p))continue;if(s.buses.has(p)){const b=s.buses.get(p),v=(((((u=(f=(c=r.buses)==null?void 0:c.find(O=>O.id===p))==null?void 0:f.layout)==null?void 0:u.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(p,v);continue}const h=i[p]??{at:((m=s.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=r.buses;return a.size>0&&(l=(r.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??rt(s.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.id)}}})),{...r,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(s=>{var i;const r={...s.layout??{}};for(const a of n){if(o.buses.has(a)||o.junctions.has(a))continue;const l=r[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};r[a]={...l,mirror:!(l.mirror??!1)}}return{...s,layout:r}})},addElement:(n,o,s)=>{if(n==="busbar")return t().addBus(o,320);const r=Tt(t().diagram,n);return t().dispatch(i=>{const a={id:r,kind:n,...s??{}};return{...i,elements:[...i.elements,a],layout:{...i.layout??{},[r]:{at:o}}}}),e({selection:[r]}),r},addBus:(n,o,s)=>{const r=Dn(t().diagram);return t().dispatch(i=>{const a={id:r,layout:s!==void 0?{at:n,span:o,rot:s}:{at:n,span:o}};return{...i,buses:[...i.buses??[],a]}}),e({selection:[r]}),r},addJunction:n=>{const o=Fn(t().diagram);return t().dispatch(s=>{const r={id:o,layout:{at:n}};return{...s,junctions:[...s.junctions??[],r]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(s=>({...s,junctions:(s.junctions??[]).map(r=>r.id===n?{...r,...o}:r)}))},addWire:(n,o)=>{if(n===o)return;const s=Qe(n,o);t().dispatch(r=>{const i=r.wires??[];return i.some(a=>a.id===s)?r:{...r,wires:[...i,{id:s,ends:[n,o]}]}})},connectWire:(n,o)=>{t().dispatch(s=>{let r=s;const i=new Set([...r.elements.map(h=>h.id),...(r.buses??[]).map(h=>h.id),...(r.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 r={...r,junctions:[...r.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=(r.wires??[]).find(O=>O.id===h.onWire),b=l(h.at);if(!g)return b;const _=(r.wires??[]).filter(O=>O.id!==h.onWire),v=(O,L)=>({id:Qe(O,L),ends:[O,L],...g.label?{label:g.label}:{}});return r={...r,wires:er(_,[v(g.ends[0],b),v(b,g.ends[1])])},b},f=c(n),u=c(o);if(f===null||u===null||f===u)return r;const m=Qe(f,u),p=r.wires??[];return p.some(h=>h.id===m)?r:{...r,wires:[...p,{id:m,ends:[f,u]}]}})},updateWirePath:(n,o)=>{t().dispatch(s=>{const r=s.wires??[];if(!r.some(c=>c.id===n))return s;const i=o&&o.length>=2?ds(o):null,a=i&&i.length>=2?i:null,l=r.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:f,...u}=c;return u});return{...s,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateWire:(n,o)=>{t().dispatch(s=>{const r=s.wires??[];return r.some(i=>i.id===n)?{...s,wires:r.map(i=>i.id===n?{...i,...o}:i)}:s})},updateElement:(n,o)=>{t().dispatch(s=>({...s,elements:s.elements.map(r=>r.id===n?{...r,...o}:r)}))},updatePlacement:(n,o)=>{t().dispatch(s=>{var a;const r=((a=s.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(r==null?void 0:r.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:r!=null&&r.rot?{rot:r.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:r!=null&&r.mirror?{mirror:r.mirror}:{}};return{...s,layout:{...s.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(s=>{const r=(s.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?rt(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{...s,buses:r}})},addAnnotation:(n,o="")=>{const s=gw(t().diagram);return t().dispatch(r=>{const i={id:s,at:n,text:o};return{...r,annotations:[...r.annotations??[],i]}}),s},updateAnnotation:(n,o)=>{t().dispatch(s=>{const r=s.annotations??[];let i=!1;const a=r.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...s,annotations:a}:s})},deleteAnnotation:n=>{t().dispatch(o=>{const s=o.annotations??[],r=s.filter(i=>i.id!==n);return r.length===s.length?o:{...o,annotations:r.length?r:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:cs(()=>({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>{x.getState().readOnly||localStorage.setItem(e,t)},removeItem:e=>localStorage.removeItem(e)})),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=Xe(e.diagram))}}));function eS(e){return Array.from(new Set(e))}function kn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function er(e,t){const n=new Set(e.map(s=>s.id)),o=e.slice();for(const s of t)n.has(s.id)||(n.add(s.id),o.push(s));return o}function Dt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function rt(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let yw=null;function tr(e){yw=e}function et(){return yw}const Vt=10;function xw(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function me(e){return xw()?Math.round(e/Vt)*Vt:e}const tS=30,nS=144;function bw(e,t){const n=Ve[e],o=x.getState(),s=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const r=oS(s,t);if(!r){const g=ww(n),b=g?[me(t[0])-g.x,me(t[1])-g.y]:[me(t[0]),me(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=r,c=rS(n,l),f=Tt(s,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?[me(m)-u.x,me(p)-u.y]:[me(t[0]),me(t[1])];return o.dispatch(g=>{const b={id:f,kind:e},_={at:h},v=`${f}.${c}`,O={id:Qe(i,v),ends:[i,v]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],O],layout:{...g.layout??{},[f]:_}}}),o.setSelection([f]),{newElementId:f,attachedToBus:!0}}function oS(e,t){const n=x.getState().internal;let o=null;for(const s of e.buses??[]){const r=n.buses.get(s.id);if(!r)continue;const{axis:i,at:a,span:l}=r.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<=tS&&(!o||c<o.dist)&&(o={busId:s.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function rS(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,s)=>t==="x"?o.y-s.y:o.x-s.x)[0].id}function ww(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function vw(e,t){const n=x.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const s=n.buses.get(e),{axis:r,at:i,span:a}=s.geometry;if(r==="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 s=n.junctions.get(e),[r,i]=s.world,a=t[0]-r,l=t[1]-i,c=Math.abs(a)>=Math.abs(l)?a>=0?"e":"w":l>=0?"s":"n";return{ref:e,world:[r,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 sS={n:"s",s:"n",e:"w",w:"e"};function kw(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=sS[t.orientation],s=e.terminals.filter(l=>l.orientation===o),r=s.length>0?s:e.terminals;let i=r[0],a=nr(i,n,t.world);for(let l=1;l<r.length;l++){const c=r[l],f=nr(c,n,t.world);f<a&&(a=f,i=c)}return i}function nr(e,t,n){const o=t[0]+e.x-n[0],s=t[1]+e.y-n[1];return o*o+s*s}function iS(e,t,n){const o=Ve[e],s=x.getState(),r=s.diagram;if(!o)return null;const i=vw(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=nS,f=[me(n[0]),me(n[1])],u=kw(o,i,f),m=c?i.world:f,p=[me(m[0]-u.x),me(m[1]-u.y)],h=Tt(r,e);return s.dispatch(g=>{const b={id:h,kind:e},_={at:p},v=`${h}.${u.id}`,O=i.isBus&&i.busId?i.busId:t,L={id:Qe(O,v),ends:[O,v]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],L],layout:{...g.layout??{},[h]:_}}}),s.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const Ct=9,Le=7;function nn(e,t){var r,i;const n=[],o=((r=e.element.name)==null?void 0:r.trim())||e.element.id;if(o&&n.push(o),t!=="all"||!((i=e.libraryDef)!=null&&i.params))return n;const s=e.element.params??{};for(const a of e.libraryDef.params){if(!a.showOnCanvas)continue;const l=s[a.name];l==null||l===""||n.push(`${l}${a.unit??""}`)}return n}function on(e){const t=_w(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+t.h/2+Le/3,anchor:"start"}:{x:0,y:0,anchor:"start"}}function aS(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 rn(e,t,n,o){const s=aS(e,n),r=e.anchor??"start",i=_w(t.viewBox);let a=e.x-(i?i.x+i.w/2:0),l=e.y-(i?i.y+i.h/2:0);switch(n.mirror&&(a=-a),n.rot){case 90:[a,l]=[-l,a];break;case 180:[a,l]=[-a,-l];break;case 270:[a,l]=[l,-a];break}return Math.abs(a)<1e-6&&Math.abs(l)<1e-6?{world:s,textAnchor:r,dy:0}:Math.abs(a)>=Math.abs(l)?{world:s,textAnchor:a>=0?"start":"end",dy:0}:l>0?{world:s,textAnchor:"middle",dy:Le}:{world:s,textAnchor:"middle",dy:-(o-1)*Ct}}function _w(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]}}const or=8;function sn(e){if(e.length<2)return null;let t=-1,n=0;for(let c=0;c<e.length-1;c++){const f=Math.hypot(e[c+1][0]-e[c][0],e[c+1][1]-e[c][1]);f>n&&(n=f,t=c)}if(t<0||n<=0)return null;const[o,s]=e[t],[r,i]=e[t+1],a=(o+r)/2,l=(s+i)/2;return Math.abs(r-o)>=Math.abs(i-s)?{world:[a,l-or],textAnchor:"middle"}:{world:[a+or,l+Le/3],textAnchor:"start"}}function lS(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>r.internal.wireRenders),o=x(r=>{var i;return((i=r.diagram.meta)==null?void 0:i.labelMode)??"all"}),s=x(r=>r.editingElement);return d.jsxs("g",{className:"ole-annotation-layer",pointerEvents:"none",children:[Array.from(e.values()).map(r=>{var m;const i=t.get(r.element.id);if(!i||!r.libraryDef)return null;const a=r.libraryDef.label??on(r.libraryDef),l=nn(r,o),{world:c,textAnchor:f,dy:u}=rn(a,r.libraryDef,i,Math.max(1,l.length));return s===r.element.id?d.jsx(cS,{elementId:r.element.id,currentName:((m=r.element.name)==null?void 0:m.trim())||r.element.id,world:c,anchor:f},r.element.id):o==="off"||l.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${c[0]} ${c[1]})`,children:l.map((p,h)=>d.jsx("text",{x:0,y:u+h*Ct,textAnchor:f,className:"ole-annotation-text",children:p},h))},r.element.id)}),o!=="off"&&Array.from(n.values()).map(r=>{var l;const i=(l=r.label)==null?void 0:l.trim();if(!i)return null;const a=sn(r.path);return a?d.jsx("text",{x:a.world[0],y:a.world[1],textAnchor:a.textAnchor,className:"ole-annotation-text",children:i},`wire-${r.wireId}`):null})]})}const _n=200,$n=9;function cS({elementId:e,currentName:t,world:n,anchor:o}){const s=I.useRef(null);I.useEffect(()=>{const l=s.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 r(){var m;const l=x.getState(),c=l.diagram.elements.find(p=>p.id===e);if(!c){l.setEditingElement(null);return}const f=(((m=s.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(),r();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=_n/2:o==="end"&&(a-=_n),d.jsx("foreignObject",{x:a,y:n[1]-$n,width:_n,height:$n*2.2,className:"ole-element-name-editor",children:d.jsx("div",{ref:s,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:r,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 $w=8,Ut=1.25;function dS(){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(fS,{ann:o},o.id):d.jsx(uS,{ann:o,isSelected:t===o.id},o.id))})}function uS({ann:e,isSelected:t}){const n=e.fontSize??$w,o=e.text===""?[""]:e.text.split(`
|
|
198
|
+
`),s=Math.max(20,...o.map(i=>i.length*n*.55)),r=o.length*n*Ut;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:s+2,height:r+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&d.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:s+2,height:r+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*Ut,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function fS({ann:e}){const t=I.useRef(null),n=e.fontSize??$w;I.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 s(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:s,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:Ut,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*Ut}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const mS=20;function hS(){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:s,at:r,span:i}=o.geometry,a=i/2,l=s==="x"?[r[0]-a,r[1]]:[r[0],r[1]-a],c=s==="x"?[r[0]+a,r[1]]:[r[0],r[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(rr,{x:l[0],y:l[1],busId:n,side:"start",axis:s}),d.jsx(rr,{x:c[0],y:c[1],busId:n,side:"end",axis:s})]})}function rr({x:e,y:t,busId:n,side:o,axis:s}){const r=et(),i=I.useRef(null),a=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!r))return;const u=x.getState().internal.buses.get(n);u&&(i.current={pointerId:f.pointerId,startSpan:u.geometry.span,startAt:[...u.geometry.at],startSvg:r.screenToSvg(f.clientX,f.clientY)},f.target.setPointerCapture(f.pointerId))},l=f=>{const u=i.current;if(!u||f.pointerId!==u.pointerId||!r)return;const m=r.screenToSvg(f.clientX,f.clientY),p=s==="x"?m[0]-u.startSvg[0]:m[1]-u.startSvg[1],h=xw()?Math.round(p/Vt)*Vt:p,g=u.startSpan+(o==="end"?h:-h);if(g<mS)return;const b=s==="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 Wn=.5;function jt(e,t){return Math.abs(e[1]-t[1])<Wn?"h":"v"}function pS(){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,s=o.length,r=[];for(let a=1;a<s-1;a++){const l=jt(o[a-1],o[a]),c=jt(o[a],o[a+1]),f=a-1===0,u=a+1===s-1,m=f&&l==="v"||u&&c==="v",p=f&&l==="h"||u&&c==="h";m&&p||r.push(d.jsx(gS,{wireId:e,index:a,xLocked:m,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<s-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<Wn&&Math.abs(l[1]-c[1])<Wn||i.push(d.jsx(yS,{wireId:e,segIndex:a,axis:jt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,r]})}function gS({wireId:e,index:t,xLocked:n,yLocked:o}){const s=et(),r=I.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(),!s))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:s.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=r.current;if(!g||h.pointerId!==g.pointerId||!s)return;const b=s.screenToSvg(h.clientX,h.clientY),_=g.startPath,v=g.index;if(v<=0||v>=_.length-1)return;const O=_[v],L=[g.xLocked?O[0]:me(O[0]+(b[0]-g.startSvg[0])),g.yLocked?O[1]:me(O[1]+(b[1]-g.startSvg[1]))];if(L[0]===O[0]&&L[1]===O[1])return;const W=_.map(X=>[X[0],X[1]]);W[v]=L;const k=jt(_[v-1],_[v]);v-1>0&&(k==="h"?W[v-1]=[_[v-1][0],L[1]]:W[v-1]=[L[0],_[v-1][1]]);const F=jt(_[v],_[v+1]);v+1<_.length-1&&(F==="h"?W[v+1]=[_[v+1][0],L[1]]:W[v+1]=[L[0],_[v+1][1]]),x.getState().updateWirePath(e,W)},m=h=>{const g=r.current;!g||h.pointerId!==g.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),r.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((_,v)=>v!==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 yS({wireId:e,segIndex:t,axis:n}){const o=et(),s=I.useRef(null),r=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!r||t<0||t>=r.length-1)return null;const i=r[t],a=r[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&&(s.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=s.current;if(!g||h.pointerId!==g.pointerId||!o)return;const b=o.screenToSvg(h.clientX,h.clientY),_=g.startPath,v=g.segIndex;if(v>=_.length-1)return;const O=_[v],L=_[v+1],W=[];for(let k=0;k<=v;k++)W.push(_[k]);if(g.axis==="h"){const k=me(O[1]+(b[1]-g.startSvg[1]));W.push([O[0],k]),W.push([L[0],k])}else{const k=me(O[0]+(b[0]-g.startSvg[0]));W.push([k,O[1]]),W.push([k,L[1]])}for(let k=v+1;k<_.length;k++)W.push(_[k]);x.getState().updateWirePath(e,W)},p=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId)return;const b=h.currentTarget;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),s.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 xS=3,Sn=12;function bS(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),s=x(a=>a.internal.terminalToNode),r=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,_=r.has(a.id),v=i.has(a.id),O=s.get(a.id)??void 0,L=Sn/2,W=c==="x"?f[0]-m:f[0]-L,k=c==="x"?f[1]-L:f[1]-m,F=c==="x"?u:Sn,X=c==="x"?Sn:u;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":O,"data-selected":_?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:W,y:k,width:F,height:X,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:b,stroke:"currentColor",strokeWidth:xS,strokeLinecap:"round",fill:"none"})]},a.id)})})}function wS(){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],s=Math.abs(n)>=Math.abs(o),r=s?t[0]:e[0],i=s?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:r,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:r,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const vS=2.5,kS=9,_S=13,$S=-13,SS=4.5,jS=8;function ES(){const e=x(a=>a.internal.junctions),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),s=x(a=>a.internal.terminalToNode),r=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=s.get(a.id)??void 0,f=t.length===1&&t[0]===a.id,u=l[0]+_S,m=l[1]+$S;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":c,"data-selected":r.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:kS,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:vS,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:jS,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:u,cy:m,r:SS,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function Ke(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function NS(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 MS({lib:e}){const t=NS(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 TS(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),s=x(a=>a.internal.nodes),r=new Set(n),i=new Set;if(o){const a=s.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=r.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:Ke(l),className:"ole-element",children:[d.jsx(MS,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}}),a.libraryDef.terminalLabelsSvg&&d.jsx("g",{className:"ole-terminal-labels",dangerouslySetInnerHTML:{__html:a.libraryDef.terminalLabelsSvg}})]},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:Ke(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 Sw=null;const Hn=new Set;function Ft(e){Sw=e;for(const t of Hn)t(e)}function AS(){return Sw}function IS(e){return Hn.add(e),()=>{Hn.delete(e)}}function CS(){const[e,t]=I.useState(AS());return I.useEffect(()=>IS(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 OS(){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 s=pw(t);if(!s)return null;let r=null,i=null;if(o){const c=vw(o,n);c&&(r=kw(s,c,n),i={source:c.world,pin:n})}else r=ww(s);const a=n[0]-((r==null?void 0:r.x)??0),l=n[1]-((r==null?void 0:r.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:s.svg}})})]})}function PS(){const e=x(s=>s.selection),t=x(s=>s.internal.elements),n=x(s=>s.internal.layout),o=x(s=>s.internal.buses);return e.length===0?null:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(s=>{const r=o.get(s);if(r){const{axis:c,at:f,span:u}=r.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"},s)}const i=t.get(s),a=n.get(s);if(!(i!=null&&i.libraryDef)||!a)return null;const l=BS(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:Ke(a)},s):null})})}function BS(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 LS(){const e=x(r=>r.internal.terminals),t=x(r=>r.internal.terminalToNode),n=x(r=>r.wireFromTerminal),o=x(r=>r.selection),s=new Set(o);return d.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(r=>{const i=t.get(r.ref),a=i!==void 0,l=n===r.ref,c=s.has(r.elementId);return d.jsx("circle",{cx:r.world[0],cy:r.world[1],r:3,"data-element-id":r.elementId,"data-terminal-id":r.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"},r.ref)})})}const sr=4;function RS(e,t,n,o){const s=t[0]-e[0],r=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=s*a-r*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])*r-(n[1]-e[1])*s)/l,u=1e-6;return c<=u||c>=1-u||f<=u||f>=1-u?null:[e[0]+c*s,e[1]+c*r]}function zS(e,t){const n=[];let o=[e[0]];for(let s=0;s<e.length-1;s++){const r=e[s],i=e[s+1],a=t.get(s);if(!a||a.length===0){o.push(i);continue}const l=i[0]-r[0],c=i[1]-r[1],f=Math.hypot(l,c)||1,u=l/f,m=c/f,p=g=>(g[0]-r[0])*u+(g[1]-r[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-sr),v=Math.min(f,b+sr);o.push([r[0]+u*_,r[1]+m*_]),n.push(o),o=[[r[0]+u*v,r[1]+m*v]]}o.push(i)}return n.push(o),n.filter(s=>s.length>=2)}function DS(){const e=x(c=>c.internal.wireRenders),t=x(c=>c.internal.terminalToNode),n=x(c=>c.diagram.wires),o=x(c=>c.selectedWire),s=x(c=>c.selectedNode),r=new Map;for(const c of n??[]){const f=t.get(c.ends[0]);f&&r.set(c.id,f)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const f=r.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=RS(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(v=>`${v[0]},${v[1]}`).join(" "),m=r.get(c.wireId),p=o===c.wireId,h=s!=null&&s===m,g=p||h?"true":void 0,b=l.get(c.wireId),_=b?zS(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((v,O)=>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:v.map(L=>`${L[0]},${L[1]}`).join(" ")},`${c.wireId}-${O}`))]})})}let Ze=null;const qn=new Set;function Ye(e){if(!(e===null&&Ze===null||e&&Ze&&e.ref===Ze.ref&&e.world[0]===Ze.world[0]&&e.world[1]===Ze.world[1])){Ze=e;for(const t of qn)t(e)}}function FS(){return Ze}function WS(e){return qn.add(e),()=>{qn.delete(e)}}function HS(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=I.useState(FS());if(I.useEffect(()=>WS(o),[]),!e||!t)return null;const s=e.world,r=(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:s[0],y1:s[1],x2:r,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:s[0],cy:s[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 tt(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function ct(e){var t;return((t=tt(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function qS(e){var t;return((t=tt(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function GS(e){var t;return((t=tt(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function an(e){var s;const t=(s=tt(e,"data-terminal-id"))==null?void 0:s.getAttribute("data-terminal-id");if(t)return t;const n=GS(e);if(n)return n;const o=qS(e);return o||null}function ln(e){var t;return((t=tt(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Gn(e){var t;return((t=tt(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Jt(e){var t;return((t=tt(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function jw(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function XS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Ew(){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 YS(){I.useEffect(()=>{const e=t=>{if(XS(t.target)||x.getState().readOnly)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 s=x.getState().diagram.elements.map(r=>r.id);o.setSelection(s);return}if(n&&!t.shiftKey&&!t.altKey){const s=t.key.toLowerCase();if(s==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(s==="x"){if(o.selection.length===0)return;t.preventDefault(),o.cutSelection();return}if(s==="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":Ew();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Xn=null;const Yn=new Set;function KS(e){if(e!==Xn){Xn=e;for(const t of Yn)t(e)}}function VS(){return Xn}function US(e){return Yn.add(e),()=>{Yn.delete(e)}}const ir="ole-hover-element-host",JS="ole-hover-terminal-on",ZS="ole-hover-node-on";function QS(e){I.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const s=new Set,r=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="${Wt(n)}"]`))==null||p.classList.remove(ir)),u&&((h=t.querySelector(`[data-element-id="${Wt(u)}"]`))==null||h.classList.add(ir));const m=u?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Wt(u)}"]`)):[];i(s,m,JS),n=u,u?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),KS(u)},l=u=>{if(u===o)return;const m=u?Array.from(t.querySelectorAll(`[data-node-id="${Wt(u)}"]`)):[];i(r,m,ZS),o=u,u?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=u=>{a(ct(u.target));const m=an(u.target);let p=null;m?p=x.getState().internal.terminalToNode.get(m)??null:p=ln(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 Wt(e){return e.replace(/(["\\])/g,"\\$1")}function ej(e,t){const n=x.getState().internal;if(!e.includes(".")){const s=n.buses.get(e);if(s){const{axis:i,at:a,span:l}=s.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 r=n.junctions.get(e);return r?{ref:e,world:[r.world[0],r.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const ar=10,Ht=e=>Math.round(e/ar)*ar,tj=16;function Nw(e,t){let n=e[0],o=1/0;for(let s=0;s<e.length-1;s++){const[r,i]=e[s],[a,l]=e[s+1],c=a-r,f=l-i,u=c*c+f*f,m=u===0?0:Math.max(0,Math.min(1,((t[0]-r)*c+(t[1]-i)*f)/u)),p=r+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 Zt(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function nj(e,t){const n=x.getState().internal.wireRenders;let o=null,s=t;for(const r of n.values()){if(r.path.length<2)continue;const i=Nw(r.path,e),a=Math.hypot(i[0]-e[0],i[1]-e[1]);a<=s&&(s=a,o={wireId:r.wireId,at:i})}return o}function Et(e,t,n){const o=e?an(e):null;if(o){const a=ej(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let s=e?Gn(e):null,r=null;if(s){const a=x.getState().internal.wireRenders.get(s);r=a?Nw(a.path,t):t}else{const a=nj(t,n);a&&(s=a.wireId,r=a.at)}if(s&&r){const a=[Ht(r[0]),Ht(r[1])];return{spec:{onWire:s,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Ht(t[0]),Ht(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Nt(e,t,n){const o=e.viewport.screenToSvg(t,n),s=e.viewport.screenToSvg(t+tj,n);return Math.hypot(s[0]-o[0],s[1]-o[1])}function Mw(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function Qt(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 lr=3;let fe=null,Me=null,je=null,ge=null;const oj={id:"select",cursor:"default",onPointerDown(e,t){var h,g,b,_,v,O,L,W,k,F,X,Z;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Jt(e.target);if(o){e.preventDefault(),e.stopPropagation();const G=(h=n.diagram.annotations)==null?void 0:h.find(A=>A.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 s=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(s){const G=(g=s.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 A=(v=n.internal.junctions.get(G))==null?void 0:v.world;A&&n.setWireDragFrom({spec:{end:G},world:A,ref:G}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:G};return}}const i=(e.target instanceof Element?(O=e.target.closest("[data-terminal-id]"))==null?void 0:O.getAttribute("data-terminal-id"):null)?an(e.target):null;if(i){const G=i.indexOf("."),A=G>0?i.slice(0,G):"";if(A&&n.selection.includes(A)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((W=(L=e.target).hasPointerCapture)!=null&&W.call(L,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const D=(k=n.internal.terminals.get(i))==null?void 0:k.world;D&&n.setWireDragFrom({spec:{end:i},world:D,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:i};return}}let a=ct(e.target);if(!a){const G=Gn(e.target);if(G&&typeof document<"u"){const A=document.elementsFromPoint(e.clientX,e.clientY);for(const D of A){const se=(X=(F=D.closest)==null?void 0:F.call(D,"[data-bus-id]"))==null?void 0:X.getAttribute("data-bus-id");if(!se)continue;const ie=(Z=n.diagram.wires)==null?void 0:Z.find(de=>de.id===G);ie&&(ie.ends[0]===se||ie.ends[1]===se)&&(a=se);break}}}if(!a){const G=Gn(e.target);if(G){if(e.preventDefault(),e.altKey){const A=ln(e.target);if(A){n.setSelectedNode(A);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 A=f.buses.get(G);if(A){m.set(G,[A.geometry.at[0],A.geometry.at[1]]);continue}const D=f.junctions.get(G);if(D){p.set(G,[D.world[0],D.world[1]]);continue}const se=f.layout.get(G);se&&u.set(G,{...se})}u.size===0&&m.size===0&&p.size===0||(fe={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=me(n[0]-ge.startSvg[0]),s=me(n[1]-ge.startSvg[1]);!ge.moved&&(o!==0||s!==0)&&(ge.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const r=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);r&&r.setAttribute("transform",`translate(${o} ${s})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=Zt(e.clientX,e.clientY),s=Et(o,n,Nt(t,e.clientX,e.clientY)),r={spec:{end:je.fromRef},world:[0,0],ref:je.fromRef};Ye(Qt(r,s)?null:Mw(s));return}if(fe&&e.pointerId===fe.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-fe.startSvg[0]),s=me(n[1]-fe.startSvg[1]);!fe.moved&&(o!==0||s!==0)&&(fe.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[r,i]of fe.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(r)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+s]};a.setAttribute("transform",Ke(l))}for(const r of fe.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(r)}"]`);i&&i.setAttribute("transform",`translate(${o} ${s})`)}for(const r of fe.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(r)}"]`);i&&i.setAttribute("transform",`translate(${o} ${s})`)}return}if(Me&&e.pointerId===Me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);Ft(cr(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=me(n[0]-ge.startSvg[0]),s=me(n[1]-ge.startSvg[1]),r=t.hostEl.querySelector(`[data-annotation-id="${Be(ge.id)}"]`);r&&r.removeAttribute("transform"),ge.moved&&(o!==0||s!==0)&&x.getState().updateAnnotation(ge.id,{at:[ge.origin[0]+o,ge.origin[1]+s]}),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),Ye(null);const s=t.viewport.screenToSvg(e.clientX,e.clientY),r=Zt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Et(r,s,Nt(t,e.clientX,e.clientY));if(Qt({world:[0,0],ref:o},i))return;n.connectWire({end:o},i.spec);return}if(fe&&e.pointerId===fe.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),fe.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-fe.startSvg[0]),s=me(n[1]-fe.startSvg[1]);if(o!==0||s!==0){const r=new Map;for(const i of fe.originals.keys())r.set(i,[o,s]);for(const i of fe.busOriginals.keys())r.set(i,[o,s]);for(const i of fe.junctionOriginals.keys())r.set(i,[o,s]);x.getState().moveElements(r)}for(const r of fe.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(r)}"]`);i&&i.removeAttribute("transform")}for(const r of fe.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(r)}"]`);i&&i.removeAttribute("transform")}}fe=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=cr(Me.startSvg,n);if(o.w>=lr||o.h>=lr){const s=rj(o);if(Me.shiftKey){const r=new Set(Me.baseSelection);for(const i of s)r.has(i)?r.delete(i):r.add(i);x.getState().setSelection([...r])}else x.getState().setSelection(s)}Ft(null),Me=null}},onPointerCancel(e,t){var n,o,s,r,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(fe&&e.pointerId===fe.pointerId){for(const[l,c]of fe.originals){const f=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);f&&f.setAttribute("transform",Ke(c))}for(const l of fe.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of fe.junctionOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}if((r=(s=t.hostEl).hasPointerCapture)!=null&&r.call(s,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}fe=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),Ye(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{}Ft(null),Me=null}},onDoubleClick(e){const t=x.getState(),n=Jt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=ct(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(fe=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),Ye(null),je=null}Ft(null)}};function cr(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),s=Math.abs(t[0]-e[0]),r=Math.abs(t[1]-e[1]);return{x:n,y:o,w:s,h:r}}function rj(e){const{internal:t}=x.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const s=t.layout.get(o.element.id);if(!s)continue;const r=ij(o.libraryDef.viewBox);if(!r)continue;const i=[[r.x,r.y],[r.x+r.w,r.y],[r.x,r.y+r.h],[r.x+r.w,r.y+r.h]].map(([u,m])=>sj([u,m],s));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:s}of t.buses.values()){const{axis:r,at:i,span:a}=s,l=a/2,c=r==="x"?i[0]-l:i[0],f=r==="x"?i[0]+l:i[0],u=r==="x"?i[1]:i[1]-l,m=r==="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:s}of t.junctions.values())s[0]>=e.x&&s[0]<=e.x+e.w&&s[1]>=e.y&&s[1]<=e.y+e.h&&n.push(o.id);return n}function sj(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 ij(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 aj=4;let le=null;const lj={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=x.getState().readOnly?null:ct(e.target);let s=null;if(o){const r=x.getState();r.selection.includes(o)||r.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)&&(s={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}le={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTx:n.tx,startTy:n.ty,startTarget:e.target,moved:!1,elementDrag:s},t.hostEl.style.cursor="grabbing",e.preventDefault()},onPointerMove(e,t){if(!le||e.pointerId!==le.pointerId)return;const n=e.clientX-le.startX,o=e.clientY-le.startY;if(!le.moved&&Math.hypot(n,o)>aj){le.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(le.moved){if(le.elementDrag){const s=t.viewport.screenToSvg(e.clientX,e.clientY),r=me(s[0]-le.elementDrag.startSvg[0]),i=me(s[1]-le.elementDrag.startSvg[1]);for(const[a,l]of le.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);if(!c)continue;const f={...l,at:[l.at[0]+r,l.at[1]+i]};c.setAttribute("transform",Ke(f))}for(const a of le.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);l&&l.setAttribute("transform",`translate(${r} ${i})`)}return}t.viewport.setViewport({tx:le.startTx+n,ty:le.startTy+o})}},onPointerUp(e,t){if(!(!le||e.pointerId!==le.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",le.elementDrag&&le.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-le.elementDrag.startSvg[0]),s=me(n[1]-le.elementDrag.startSvg[1]);if(o!==0||s!==0){const r=new Map;for(const i of le.elementDrag.originals.keys())r.set(i,[o,s]);for(const i of le.elementDrag.busOriginals.keys())r.set(i,[o,s]);x.getState().moveElements(r)}for(const r of le.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${vt(r)}"]`);i&&i.removeAttribute("transform")}}else!le.moved&&!x.getState().readOnly&&cj(le.startTarget);le=null}},onPointerCancel(e,t){if(le!=null&&le.elementDrag){for(const[n,o]of le.elementDrag.originals){const s=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);s&&s.setAttribute("transform",Ke(o))}for(const n of le.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);o&&o.removeAttribute("transform")}}le=null},onDeactivate(){le=null}};function cj(e){if(!e)return;const t=x.getState(),n=Jt(e);if(n){t.setSelectedAnnotation(n);return}const o=ct(e);if(o){t.setSelection([o]);return}const s=ln(e);if(s){t.setSelectedNode(s);return}t.clearSelection()}function vt(e){return e.replace(/(["\\])/g,"\\$1")}const _t={tight:1024,compact:720,dense:520,mini:380},dr={full:0,tight:1,compact:2,dense:3,mini:4};function Pe(e,t){return dr[e]>=dr[t]}function dj(e){return e>=_t.tight?"full":e>=_t.compact?"tight":e>=_t.dense?"compact":e>=_t.mini?"dense":"mini"}const Tw=I.createContext("full");function Ue(){return I.useContext(Tw)}function uj(e){const[t,n]=I.useState(null);return I.useLayoutEffect(()=>{const o=e.current;if(!o)return;const s=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(s(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(s);return r.observe(o),()=>r.disconnect()},[e]),t}function Aw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<_t.dense}function cn(){Aw()&&x.getState().setActiveTool("pan")}function fj(){Aw()&&x.getState().setPlaceKind(null)}const mj={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),Ye(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=Nt(t,e.clientX,e.clientY),s=Et(e.target instanceof Element?e.target:null,n,o),r=x.getState();r.setWireDragFrom({spec:s.spec,world:s.world,ref:s.ref}),r.setWireFromTerminal(s.ref),r.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(s);const r=Zt(e.clientX,e.clientY),i=Et(r,s,Nt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Ye(Qt(a,i)?null:Mw(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Ye(null),!o)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY),r=Zt(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Et(r,s,Nt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Qt(a,i)||(n.connectWire(o.spec,i.spec),cn())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Ye(null)}},ur=10;let kt=!1;function fr(){setTimeout(()=>fj(),0)}const hj={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),kt=!1},onPointerDown(e,t){var r,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=an(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(r=e.target).hasPointerCapture)!=null&&i.call(r,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 s=t.viewport.screenToSvg(e.clientX,e.clientY);bw(n,s),kt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([mr(n[0]),mr(n[1])])},onPointerUp(e,t){const n=x.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:s}=n;if(!s)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);iS(s,o,r),fr();return}kt&&(kt=!1,fr())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),kt=!1}};function mr(e){return Math.round(e/ur)*ur}const hr=10,pr=20;function st(e){return Math.round(e/hr)*hr}const pj={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[st(n[0]),st(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([st(n[0]),st(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),s=st(o[0]),r=st(o[1]),i=s-n[0],a=r-n[1],l=Math.abs(i)>=Math.abs(a);let c,f,u;if(l){if(f=Math.abs(i),f<pr)return;c=0,u=[(n[0]+s)/2,n[1]]}else{if(f=Math.abs(a),f<pr)return;c=90,u=[n[0],(n[1]+r)/2]}x.getState().addBus(u,f,c),cn()},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)}},gr=10,yr=e=>Math.round(e/gr)*gr,gj={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([yr(n[0]),yr(n[1])]),cn()}},yj={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Jt(e.target);if(o){e.preventDefault(),e.stopPropagation(),n.setActiveTool("select"),n.setSelectedAnnotation(o);return}e.preventDefault();const s=t.viewport.screenToSvg(e.clientX,e.clientY),r=n.addAnnotation([s[0],s[1]],"");n.setEditingAnnotation(r),cn()}},xr={select:oj,pan:lj,wire:mj,place:hj,busbar:pj,junction:gj,text:yj};function xj(e,t){const n=x(s=>s.activeTool),o=x(s=>s.readOnly);I.useEffect(()=>{var p;const s=e.current;if(!s)return;const r=o?xr.pan:xr[n],i={viewport:t,hostEl:s};(p=r.onActivate)==null||p.call(r,i),r.cursor&&(s.style.cursor=r.cursor);const a=h=>{var g;return(g=r.onPointerDown)==null?void 0:g.call(r,h,i)},l=h=>{var g;return(g=r.onPointerMove)==null?void 0:g.call(r,h,i)},c=h=>{var g;return(g=r.onPointerUp)==null?void 0:g.call(r,h,i)},f=h=>{var g;return r.onPointerCancel?r.onPointerCancel(h,i):(g=r.onPointerUp)==null?void 0:g.call(r,h,i)},u=h=>{var g;return(g=r.onPointerLeave)==null?void 0:g.call(r,h,i)},m=h=>{var g;return(g=r.onDoubleClick)==null?void 0:g.call(r,h,i)};return s.addEventListener("pointerdown",a),s.addEventListener("pointermove",l),s.addEventListener("pointerup",c),s.addEventListener("pointercancel",f),s.addEventListener("pointerleave",u),s.addEventListener("dblclick",m),()=>{var h;s.removeEventListener("pointerdown",a),s.removeEventListener("pointermove",l),s.removeEventListener("pointerup",c),s.removeEventListener("pointercancel",f),s.removeEventListener("pointerleave",u),s.removeEventListener("dblclick",m),(h=r.onDeactivate)==null||h.call(r,i),s.style.cursor=""}},[n,o,e,t])}let Kn=1;const Vn=new Set;function bj(e){if(e!==Kn){Kn=e;for(const t of Vn)t(e)}}function wj(){return Kn}function vj(e){return Vn.add(e),()=>{Vn.delete(e)}}const jn=.1,En=8,kj=1.0015,_j=1.02;function $j(e,t,n={tx:0,ty:0,scale:1}){const o=I.useRef({...n}),s=I.useRef(new Set),r=()=>{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)),bj(o.current.scale),s.current.size>0){const l={...o.current};for(const c of s.current)c(l)}};return I.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 A=[...h.values()],D=A[1].x-A[0].x,se=A[1].y-A[0].y,ie=Math.hypot(D,se)||1,de=i.getBoundingClientRect();g={startDist:ie,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(A[0].x+A[1].x)/2-de.left,startMidY:(A[0].y+A[1].y)/2-de.top}},v=A=>{if(A.pointerType==="touch"){if(h.set(A.pointerId,{x:A.clientX,y:A.clientY}),h.size>=2&&!b){b=!0;for(const D of h.keys())D!==A.pointerId&&jw(i,D);_()}if(b){A.stopPropagation(),A.preventDefault();try{i.setPointerCapture(A.pointerId)}catch{}}}},O=A=>{if(A.pointerType!=="touch"||!h.has(A.pointerId)||(h.set(A.pointerId,{x:A.clientX,y:A.clientY}),!b||!g))return;A.stopPropagation();const D=[...h.values()];if(D.length<2)return;const se=D[1].x-D[0].x,ie=D[1].y-D[0].y,de=Math.hypot(se,ie)||1,oe=i.getBoundingClientRect(),re=(D[0].x+D[1].x)/2-oe.left,ye=(D[0].y+D[1].y)/2-oe.top,xe=de/g.startDist,_e=Nn(g.startScale*xe,jn,En),Ne=_e/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*Ne+(re-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ne+(ye-g.startMidY),o.current.scale=_e,r()},L=A=>{var D;if(A.pointerType==="touch"&&h.has(A.pointerId)&&(h.delete(A.pointerId),b)){if(A.stopPropagation(),(D=i.hasPointerCapture)!=null&&D.call(i,A.pointerId))try{i.releasePointerCapture(A.pointerId)}catch{}h.size>=2?_():g=null,h.size===0&&(b=!1)}},W=A=>{A.preventDefault();const D=i.getBoundingClientRect(),se=A.clientX-D.left,ie=A.clientY-D.top,de=A.ctrlKey||A.metaKey;if(A.deltaX===0||de){const ye=Math.pow(de?_j:kj,-A.deltaY),xe=Nn(o.current.scale*ye,jn,En),_e=xe/o.current.scale;o.current.tx=se-(se-o.current.tx)*_e,o.current.ty=ie-(ie-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=A.deltaX,o.current.ty-=A.deltaY;r()},k=A=>{const D=A.button===1,se=p&&A.button===0;!D&&!se||(A.preventDefault(),a=!0,l=A.pointerId,c=A.clientX,f=A.clientY,u=o.current.tx,m=o.current.ty,i.setPointerCapture(A.pointerId),i.style.cursor="grabbing")},F=A=>{!a||A.pointerId!==l||(o.current.tx=u+(A.clientX-c),o.current.ty=m+(A.clientY-f),r())},X=A=>{a&&A.pointerId===l&&(a=!1,i.releasePointerCapture(A.pointerId),i.style.cursor=p?"grab":"")},Z=A=>{if(A.code==="Space"&&!p){const D=A.target;if(D&&(D.tagName==="INPUT"||D.tagName==="TEXTAREA"||D.isContentEditable))return;p=!0,i.style.cursor="grab",A.preventDefault()}},G=A=>{A.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",W,{passive:!1}),i.addEventListener("pointerdown",k),i.addEventListener("pointermove",F),i.addEventListener("pointerup",X),i.addEventListener("pointercancel",X),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",O,{capture:!0}),i.addEventListener("pointerup",L,{capture:!0}),i.addEventListener("pointercancel",L,{capture:!0}),window.addEventListener("keydown",Z),window.addEventListener("keyup",G),r(),()=>{i.removeEventListener("wheel",W),i.removeEventListener("pointerdown",k),i.removeEventListener("pointermove",F),i.removeEventListener("pointerup",X),i.removeEventListener("pointercancel",X),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",O,{capture:!0}),i.removeEventListener("pointerup",L,{capture:!0}),i.removeEventListener("pointercancel",L,{capture:!0}),window.removeEventListener("keydown",Z),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=Nn(i.scale,jn,En)),r()},subscribe(i){return s.current.add(i),()=>{s.current.delete(i)}}}}function Nn(e,t,n){return e<t?t:e>n?n:e}const Iw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),it=Iw?"⌘":"Ctrl+",Sj=Iw?"⇧":"Shift+",Mn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],jj=18;function Ej(e){for(const t of Mn)if(t*e>=jj)return t;return Mn[Mn.length-1]}function Nj(){const e=ce(),t=I.useRef(null),n=I.useRef(null),o=I.useRef(null),s=$j(t,n);xj(t,s),QS(t),I.useEffect(()=>(tr(s),()=>tr(null)),[s]),I.useEffect(()=>{const f=u=>{const m=o.current;if(!m)return;const h=Ej(u.scale)*u.scale;m.setAttribute("width",String(h)),m.setAttribute("height",String(h)),m.setAttribute("patternTransform",`translate(${u.tx} ${u.ty})`)};return f(s.getViewport()),s.subscribe(f)},[s]);const r=p2(),i=I.useCallback((f,u,m)=>{const p=x.getState();if(p.readOnly)return;const h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){Ew();return}const g=ct(m);if(g)p.selection.includes(g)||p.setSelection([g]);else{const k=ln(m);k&&p.selectedNode!==k&&p.setSelectedNode(k)}const b=x.getState(),_=b.selection.length>0,v=b.selectedNode!=null,O=!!b.clipboard,L=b.diagram.elements.length>0,W=[{label:e("menu.undo"),shortcut:`${it}Z`,icon:eo,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${it}${Sj}Z`,icon:Qn,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${it}X`,icon:Kr,onSelect:()=>x.getState().cutSelection(),disabled:!_},{label:e("menu.copy"),shortcut:`${it}C`,icon:qr,onSelect:()=>x.getState().copySelection(),disabled:!_},{label:e("menu.paste"),shortcut:`${it}V`,icon:Hr,onSelect:()=>x.getState().pasteClipboard(),disabled:!O},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Yr,onSelect:()=>x.getState().rotateSelection(90),disabled:!_},{label:e("menu.mirror"),shortcut:"M",icon:Gr,onSelect:()=>x.getState().mirrorSelection(),disabled:!_},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${it}A`,icon:Bv,onSelect:()=>{const k=x.getState();k.setSelection(k.diagram.elements.map(F=>F.id))},disabled:!L},{type:"separator"},{label:e(v&&!_?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Ur,destructive:!0,onSelect:()=>v&&!_?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!_&&!v}];r.open(f,u,W)},[r,e]);I.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=O=>{O.pointerType==="touch"&&(g(),h={pointerId:O.pointerId,x:O.clientX,y:O.clientY,target:O.target},p=window.setTimeout(()=>{const L=h;h=null,p=void 0,L&&(jw(f,L.pointerId),i(L.x,L.y,L.target))},u))},_=O=>{if(!h||O.pointerId!==h.pointerId)return;const L=O.clientX-h.x,W=O.clientY-h.y;Math.hypot(L,W)>m&&g()},v=O=>{!h||O.pointerId!==h.pointerId||g()};return f.addEventListener("pointerdown",b),f.addEventListener("pointermove",_),f.addEventListener("pointerup",v),f.addEventListener("pointercancel",v),()=>{g(),f.removeEventListener("pointerdown",b),f.removeEventListener("pointermove",_),f.removeEventListener("pointerup",v),f.removeEventListener("pointercancel",v)}},[i]);const a=f=>{f.dataTransfer.types.includes("application/x-oneline-kind")&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},l=f=>{if(x.getState().readOnly)return;const u=f.dataTransfer.getData("application/x-oneline-kind");if(!u)return;f.preventDefault();const m=s.screenToSvg(f.clientX,f.clientY);bw(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(bS,{}),d.jsx(DS,{}),d.jsx(ES,{}),d.jsx(TS,{}),d.jsx(lS,{}),d.jsx(dS,{}),d.jsx(PS,{}),d.jsx(hS,{}),d.jsx(pS,{}),d.jsx(LS,{}),d.jsx(HS,{}),d.jsx(wS,{}),d.jsx(OS,{}),d.jsx(CS,{})]})]})})}const br=60,Mj=.1,Tj=8,Aj=8;function Ij(e,t,n){return e<t?t:e>n?n:e}function Cj(){return document.querySelector(".ole-canvas-root")}function ro(){const e=et(),t=Cj();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 s=1/0,r=1/0,i=-1/0,a=-1/0;for(const _ of o){const v=_.getBoundingClientRect();v.width===0&&v.height===0||(v.left<s&&(s=v.left),v.top<r&&(r=v.top),v.right>i&&(i=v.right),v.bottom>a&&(a=v.bottom))}if(s===1/0)return!1;const[l,c]=e.screenToSvg(s,r),[f,u]=e.screenToSvg(i,a),m=Math.max(f-l,1),p=Math.max(u-c,1),h=Ij(Math.min((n.width-br*2)/m,(n.height-br*2)/p),Mj,Tj),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 so(){let e=Aj;const t=()=>{ro()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const wr=10,Oj=100;function Pj(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function vr(){const[e,t]=I.useState(VS()),[n,o]=I.useState(!1),[s,r]=I.useState(null),i=I.useRef(null),a=I.useRef(void 0),[l]=I.useState(Pj);I.useEffect(()=>US(h=>t(h)),[]),I.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),r(null),!!e)return a.current=window.setTimeout(()=>o(!0),Oj),()=>window.clearTimeout(a.current)},[e]);const c=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(I.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,b=-1;const _=()=>{const v=document.querySelector(`[data-element-id="${Bj(e)}"]`),O=i.current;if(v&&O){const L=v.getBoundingClientRect();let W=L.bottom+wr;W+O.offsetHeight>window.innerHeight-4&&(W=L.top-O.offsetHeight-wr);let k=L.left+L.width/2-O.offsetWidth/2;k=Math.max(4,Math.min(k,window.innerWidth-O.offsetWidth-4)),(W!==g||k!==b)&&(r({top:W,left:k}),g=W,b=k)}h=requestAnimationFrame(_)};return h=requestAnimationFrame(_),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!c)return null;const f=Ve[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:Dr.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:(s==null?void 0:s.top)??-9999,left:(s==null?void 0:s.left)??-9999,opacity:s?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 Bj(e){return e.replace(/(["\\])/g,"\\$1")}function Lj({width:e,children:t}){const n=e==null?"full":dj(e);return d.jsx(Tw.Provider,{value:n,children:t})}function kr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Rj(...e){return t=>{let n=!1;const o=e.map(s=>{const r=kr(s,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let s=0;s<o.length;s++){const r=o[s];typeof r=="function"?r():kr(e[s],null)}}}}var zj=Symbol.for("react.lazy"),en=ke[" use ".trim().toString()];function Dj(e){return typeof e=="object"&&e!==null&&"then"in e}function Cw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===zj&&"_payload"in e&&Dj(e._payload)}function Fj(e){const t=Hj(e),n=ke.forwardRef((o,s)=>{let{children:r,...i}=o;Cw(r)&&typeof en=="function"&&(r=en(r._payload));const a=ke.Children.toArray(r),l=a.find(Gj);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:s,children:ke.isValidElement(c)?ke.cloneElement(c,void 0,f):null})}return d.jsx(t,{...i,ref:s,children:r})});return n.displayName=`${e}.Slot`,n}var Wj=Fj("Slot");function Hj(e){const t=ke.forwardRef((n,o)=>{let{children:s,...r}=n;if(Cw(s)&&typeof en=="function"&&(s=en(s._payload)),ke.isValidElement(s)){const i=Yj(s),a=Xj(r,s.props);return s.type!==ke.Fragment&&(a.ref=o?Rj(o,i):i),ke.cloneElement(s,a)}return ke.Children.count(s)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var qj=Symbol("radix.slottable");function Gj(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qj}function Xj(e,t){const n={...t};for(const o in t){const s=e[o],r=t[o];/^on[A-Z]/.test(o)?s&&r?n[o]=(...a)=>{const l=r(...a);return s(...a),l}:s&&(n[o]=s):o==="style"?n[o]={...s,...r}:o==="className"&&(n[o]=[s,r].filter(Boolean).join(" "))}return{...e,...n}}function Yj(e){var o,s;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=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const _r=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,$r=Qr,Kj=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return $r(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:s,defaultVariants:r}=t,i=Object.keys(s).map(c=>{const f=n==null?void 0:n[c],u=r==null?void 0:r[c];if(f===null)return null;const m=_r(f)||_r(u);return s[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({...r,...a}[g]):{...r,...a}[g]===b})?[...c,u,m]:c},[]);return $r(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},Vj=Kj("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"}}),Ie=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...s},r)=>{const i=o?Wj:"button";return d.jsx(i,{className:Ee(Vj({variant:t,size:n,className:e})),ref:r,...s})});Ie.displayName="Button";const Uj=350;function Ce({content:e,children:t,disabled:n,delayMs:o=Uj}){const s=I.useRef(null),r=I.useRef(null),[i,a]=I.useState(!1),[l,c]=I.useState(null),f=I.useId(),u=I.useRef(void 0),m=()=>{n||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(u.current),a(!1)};I.useLayoutEffect(()=>{if(!i||!s.current||!r.current)return;const _=s.current.getBoundingClientRect(),v=r.current.getBoundingClientRect(),O=8;let L="top",W=_.top-v.height-O;W<4&&(L="bottom",W=_.bottom+O);let k=_.left+_.width/2-v.width/2;k=Math.max(4,Math.min(k,window.innerWidth-v.width-4)),c({top:W,left:k,side:L})},[i,e]),I.useEffect(()=>()=>window.clearTimeout(u.current),[]),I.useEffect(()=>{if(!i)return;const _=O=>{O.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",_),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",_),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const h=t,g=h.props,b=I.cloneElement(h,{ref:_=>{s.current=_;const v=h.ref;typeof v=="function"?v(_):v&&typeof v=="object"&&(v.current=_)},onPointerEnter:_=>{var v;(v=g.onPointerEnter)==null||v.call(g,_),m()},onPointerLeave:_=>{var v;(v=g.onPointerLeave)==null||v.call(g,_),p()},onFocus:_=>{var v;(v=g.onFocus)==null||v.call(g,_),m()},onBlur:_=>{var v;(v=g.onBlur)==null||v.call(g,_),p()},"aria-describedby":i?f:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[b,i&&typeof document<"u"&&Dr.createPortal(d.jsx("div",{ref:r,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 Sr=12,Jj=56;function Zj(){var _;const e=ce(),t=x(v=>v.selection),n=x(v=>v.selectedNode),o=x(v=>v.selectedWire),s=x(v=>v.activeTool),r=x(v=>v.rotateSelection),i=x(v=>v.mirrorSelection),a=x(v=>v.deleteSelection),l=x(v=>v.deleteSelectedNode),c=x(v=>v.deleteSelectedWire),f=x(v=>v.resetWirePath),u=x(v=>v.internal.wireRenders),m=o!=null&&((_=u.get(o))==null?void 0:_.userEdited)===!0,p=I.useRef(null);I.useEffect(()=>{const v=p.current;if(!v)return;const O=t.length>0,L=!O&&o!=null,W=!O&&!L&&n!=null;if(!((O||L||W)&&(s==="select"||s==="pan"))){v.style.display="none";return}v.style.display="flex";let F=0,X="";const Z=()=>{let G=1/0,A=-1/0,D=1/0,se=-1/0,ie=!1;const de=oe=>{oe.width===0&&oe.height===0||(oe.left<G&&(G=oe.left),oe.right>A&&(A=oe.right),oe.top<D&&(D=oe.top),oe.bottom>se&&(se=oe.bottom),ie=!0)};if(O)for(const oe of t){const re=document.querySelector(`[data-element-id="${CSS.escape(oe)}"]`);re&&de(re.getBoundingClientRect())}else if(L&&o){const oe=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);oe&&de(oe.getBoundingClientRect())}else if(W&&n){const oe=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const re of oe)de(re.getBoundingClientRect())}if(ie){const oe=(G+A)/2;let re=D-Sr,ye="-100%";re<Jj&&(re=se+Sr,ye="0%");const xe=`translate3d(${oe}px, ${re}px, 0) translate(-50%, ${ye})`;xe!==X&&(v.style.transform=xe,X=xe)}F=requestAnimationFrame(Z)};return F=requestAnimationFrame(Z),()=>cancelAnimationFrame(F)},[t,n,o,s]);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(Ce,{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(Ie,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>f(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx(Pv,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&d.jsxs(d.Fragment,{children:[d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>r(90),"aria-label":e("ctx.rotate"),children:d.jsx(Yr,{})})}),d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Gr,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Ce,{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(Ie,{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(Ur,{})})})]})}function io({open:e,onOpenChange:t,trigger:n,children:o}){const s=I.useRef(null);return I.useEffect(()=>{if(!e)return;const r=a=>{s.current&&!s.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",r),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",i)}},[e,t]),d.jsxs("div",{ref:s,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 Ow="ole-panel-open";function Qj(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Ow);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 jr(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Ow,JSON.stringify(t))}catch{}}const At=tn((e,t)=>({...Qj(),setOutlineOpen:n=>{e({outlineOpen:n}),jr(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),jr(t())}})),Xt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Pw=.1,Bw=8,Lw="ole-grid";function e4(){try{const e=window.localStorage.getItem(Lw);return e==null?!0:e==="1"}catch{return!0}}function t4(e){try{window.localStorage.setItem(Lw,e?"1":"0")}catch{}}function n4(e,t,n){return e<t?t:e>n?n:e}function Rw(){return document.querySelector(".ole-canvas-root")}function ao(e){const t=et(),n=Rw();if(!t||!n)return;const o=n.getBoundingClientRect(),s=o.width/2,r=o.height/2,i=t.getViewport(),a=n4(e,Pw,Bw),l=a/i.scale;t.setViewport({tx:s-(s-i.tx)*l,ty:r-(r-i.ty)*l,scale:a})}function o4(){const e=et();if(!e)return;const t=e.getViewport().scale,n=Xt.find(o=>o>t+1e-6)??Bw;ao(n)}function r4(){const e=et();if(!e)return;const t=e.getViewport().scale;let n=Pw;for(let o=Xt.length-1;o>=0;o--)if(Xt[o]<t-1e-6){n=Xt[o];break}ao(n)}const s4={off:"id",id:"all",all:"off"};function i4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=s4[t];e.dispatch(s=>{const r={...s.meta??{},labelMode:n};return{...s,meta:r}})}function zw(){const[e,t]=I.useState(()=>e4());return I.useEffect(()=>{const n=Rw();n==null||n.classList.toggle("hide-grid",!e),t4(e)},[e]),I.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const s=o.target;s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable)||(o.preventDefault(),t(r=>!r))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Dw(){const e=ce();return d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",onClick:r4,"aria-label":e("view.zoomOut"),children:d.jsx(Zn,{})})})}function Fw(){const e=ce();return d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",onClick:o4,"aria-label":e("view.zoomIn"),children:d.jsx(Cv,{})})})}function Ww(){const e=ce(),[t,n]=I.useState(wj);return I.useEffect(()=>vj(n),[]),d.jsx(Ce,{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:()=>ao(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 Hw(){const e=ce();return d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",onClick:ro,"aria-label":e("view.fit"),children:d.jsx(Tv,{})})})}function qw({grid:e,setGrid:t}){const n=ce();return d.jsx(Ce,{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(Ie,{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(Nv,{})})})}function Gw(){const e=ce(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Ce,{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(Ie,{variant:"ghost",size:"icon",onClick:i4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:Ee(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Jr,{})})})}function a4({stacked:e}={}){const t=ce(),[n,o]=I.useState(!1),[s,r]=zw(),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(Ce,{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(On,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Ce,{content:i,children:d.jsx(Ie,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:d.jsx(On,{})})});return d.jsx(io,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(Ww,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Dw,{}),d.jsx(Fw,{})]}),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(Hw,{}),d.jsx(qw,{grid:s,setGrid:r}),d.jsx(Gw,{})]})]})})}function Er(){const e=Ue();return!x(n=>n.readOnly)&&Pe(e,"dense")?null:d.jsx(l4,{tier:e})}function l4({tier:e}){const t=Pe(e,"tight"),n=x(r=>r.readOnly),[o,s]=zw();return d.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 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(Dw,{}),!t&&d.jsx(Ww,{}),d.jsx(Fw,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(Hw,{}),d.jsx(qw,{grid:o,setGrid:s}),!n&&d.jsx(Gw,{})]})})}const Nr=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:Av,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:Mv,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Zn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:kv,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Vr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Wr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Jr,switchTo:"text",iconOnly:!0}];function c4(){const e=ce(),t=x(f=>f.activeTool),n=x(f=>f.placeKind),o=x(f=>f.placeFromTerminal),s=x(f=>f.wireDragFrom),r=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(s?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(r?"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 d4(){const e=ce(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),s=x(h=>h.past.length),r=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ue(),c=Pe(l,"tight"),f=!Pe(l,"dense"),u=Pe(l,"dense"),m=u?Nr.filter(h=>h.id!=="select"&&h.id!=="text"):Nr,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) + var(--ole-safe-bottom, 0px))"},children:[f&&d.jsx(c4,{}),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(u4,{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(I.Fragment,{children:[d.jsx(lt,{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(m4,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(lt,{icon:eo,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:s===0,onClick:i}),d.jsx(lt,{icon:Qn,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:r===0,onClick:a}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),d.jsx(f4,{iconOnly:c})]}),u&&d.jsx(a4,{stacked:!0})]})]})}function u4({stacked:e}){const t=ce(),n=At(s=>s.outlineOpen),o=At(s=>s.toggleOutline);return d.jsx(lt,{icon:Xr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function lt({icon:e,label:t,hotkey:n,active:o,disabled:s,iconOnly:r,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(Ce,{content:c,disabled:s,children:d.jsxs("button",{type:"button",onClick:a,disabled:s,"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&&(r?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",s&&"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}):!r&&d.jsx("span",{children:t})]})})}function Xw(){const e=x(s=>s.diagram.elements),t=x(s=>s.diagram.layout),n=x(s=>s.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(s=>!o[s.id]),hasSelection:n.length>0,selectionHasArranged:n.some(s=>!!o[s]),selectionHasGaps:n.some(s=>!o[s])}}function f4({iconOnly:e}){const t=ce(),[n,o]=I.useState(!1),s=Xw(),r=i=>()=>{o(!1),i()};return d.jsxs(io,{open:n,onOpenChange:o,trigger:d.jsx(lt,{icon:$t,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Ae,{onClick:r(()=>x.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!s.hasAnyElement||!s.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Ae,{onClick:r(()=>x.getState().autoArrangeSelection()),icon:d.jsx($t,{}),disabled:!s.hasSelection||!s.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Ae,{onClick:r(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Yt,{}),disabled:!s.hasGapsAll,children:t("layout.allFill")}),d.jsx(Ae,{onClick:r(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Yt,{}),disabled:!s.hasSelection||!s.selectionHasGaps,children:t("layout.selFill")})]})}function m4({stacked:e}){const t=ce(),[n,o]=I.useState(!1),s=x(m=>m.past.length),r=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=Xw(),u=m=>()=>{o(!1),m()};return d.jsxs(io,{open:n,onOpenChange:o,trigger:d.jsx(lt,{icon:On,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[d.jsx(Ae,{onClick:u(i),icon:d.jsx(eo,{}),disabled:s===0,children:t("tool.undo")}),d.jsx(Ae,{onClick:u(a),icon:d.jsx(Qn,{}),disabled:r===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Ae,{onClick:u(()=>x.getState().cutSelection()),icon:d.jsx(Kr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Ae,{onClick:u(()=>x.getState().copySelection()),icon:d.jsx(qr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Ae,{onClick:u(()=>x.getState().pasteClipboard()),icon:d.jsx(Hr,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Ae,{onClick:u(()=>x.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!f.hasAnyElement||!f.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Ae,{onClick:u(()=>x.getState().autoArrangeSelection()),icon:d.jsx($t,{}),disabled:!f.hasSelection||!f.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Ae,{onClick:u(()=>x.getState().fillUnplacedAll()),icon:d.jsx(Yt,{}),disabled:!f.hasGapsAll,children:t("layout.allFill")}),d.jsx(Ae,{onClick:u(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(Yt,{}),disabled:!f.hasSelection||!f.selectionHasGaps,children:t("layout.selFill")})]})}function Ae({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 h4(){const e=At(s=>s.outlineOpen),t=At(s=>s.setOutlineOpen),n=Ue();return Pe(n,"dense")?e?d.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px) + 0.75rem)"},children:d.jsx(Mr,{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) + var(--ole-safe-bottom, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?d.jsx(Mr,{onClose:()=>t(!1)}):d.jsx(p4,{onClick:()=>t(!0)})})}function p4({onClick:e}){const t=ce(),n=Ue(),o=Pe(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(Xr,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function Mr({onClose:e,sheet:t}){const n=ce(),o=x(c=>c.diagram.elements),s=x(c=>c.activeTool==="place"),r=Ue(),i=Pe(r,"compact"),a=Pe(r,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":s?"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(y4,{children:o.length}),d.jsx(Iv,{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(g4,{element:c},c.id))})})]})}function g4({element:e}){const t=Ve[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),s=x(l=>l.toggleInSelection),r=Ue(),i=!Pe(r,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?s(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 y4({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 x4={"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":"负荷","panelboard.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":"抽象负荷(电流流出箭头)","panelboard.desc":"配电箱 / 负荷中心(IEC 分配中心符号):底部进线,箱顶分路示意","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":"剩余动作电流"},b4={"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","panelboard.name":"Panelboard / load center","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"},Tr={zh:x4,en:b4};function w4(e,t){return Tr[e][t]??Tr.zh[t]}function Ot(){const e=It(t=>t.locale);return(t,n)=>w4(e,t)??n??t}const Yw="ole-palette-collapsed",v4=new Set(["busbar"]),Mt=(()=>{const e={};for(const[t,n]of Object.entries(K$)){const o=n.filter(s=>!v4.has(s.id));o.length&&(e[t]=o)}return e})(),k4=(()=>{const e=new Set(Vo),t=Object.keys(Mt).filter(n=>!e.has(n));return[...Vo.filter(n=>{var o;return(o=Mt[n])==null?void 0:o.length}),...t]})();function _4(){try{const e=window.localStorage.getItem(Yw);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 $4(e){try{window.localStorage.setItem(Yw,JSON.stringify([...e]))}catch{}}function S4(){const e=ce(),t=x(u=>u.activeTool==="place"),n=x(u=>u.placeKind),o=x(u=>u.setActiveTool),s=At(u=>u.outlineOpen),r=Ue(),i=Pe(r,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${s?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const f=i?{top:`calc(${a}px + var(--ole-top-inset, 0px) + var(--ole-safe-top, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 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(to,{className:"size-3.5"})})]}),d.jsx(j4,{sheet:i})]})})}function j4({sheet:e}){const t=ce(),n=Ot(),[o,s]=I.useState(""),[r,i]=I.useState(()=>_4()),a=I.useMemo(()=>{const u=o.trim().toLowerCase();if(!u)return Mt;const m={};for(const[p,h]of Object.entries(Mt)){const g=h.filter(b=>{const _=n(`${b.id}.name`,b.name).toLowerCase(),v=n(`${b.id}.desc`,b.description??"").toLowerCase();return _.includes(u)||b.id.toLowerCase().includes(u)||v.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=I.useCallback((u,m)=>{i(p=>{const h=new Set(p);return m?h.delete(u):h.add(u),$4(h),h})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(E4,{value:o,onChange:s})}),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")}):k4.map(u=>{var b;const m=a[u];if(!(m!=null&&m.length))return null;const p=((b=Mt[u])==null?void 0:b.length)??m.length,h=t(`cat.${u}`),g=l||!r.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(vv,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:h}),d.jsx(M4,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map(_=>d.jsx(N4,{entry:_,sheet:e},_.id))})]},u)})})]})}function E4({value:e,onChange:t}){const n=ce();return d.jsxs("div",{className:"relative",children:[d.jsx(Ov,{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(to,{className:"size-3"})})]})}function N4({entry:e,sheet:t}){const n=ce(),o=Ot(),s=o(`${e.id}.name`,e.name),r=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=I.useRef(null);I.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:r?`${s} — ${r}`:`${s} — ${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:s})]})}function M4({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 Un="ole-onboarding-dismissed";function T4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(Un)==="1"}catch{return!1}}function Ar(e){try{e?window.localStorage.setItem(Un,"1"):window.localStorage.removeItem(Un)}catch{}}const Ir=tn(e=>({dismissed:T4(),dismiss:()=>{Ar(!0),e({dismissed:!0})},reset:()=>{Ar(!1),e({dismissed:!1})}}));function A4(){const e=ce(),t=Ir(o=>o.dismissed),n=Ir(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(to,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Tn,{n:1,icon:d.jsx(Vr,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Tn,{n:2,icon:d.jsx(Wr,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Tn,{n:3,icon:d.jsx(Zn,{}),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 Tn({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 I4(){const e=ce(),t=x(m=>m.selection),n=x(m=>m.diagram.elements),o=x(m=>m.diagram.buses),s=x(m=>m.diagram.junctions),r=x(m=>m.selectedNode),i=x(m=>m.selectedWire);if(i)return d.jsx(R4,{wireId:i});if(r)return d.jsx(D4,{nodeId:r});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(B4,{bus:l});const c=(s??[]).find(m=>m.id===a);if(c)return d.jsx(z4,{junction:c});const f=n.find(m=>m.id===a);if(!f)return null;const u=Ve[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(nt,{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(lo,{label:e("props.note"),value:f.note??"",onCommit:m=>x.getState().updateElement(a,{note:m.trim()===""?void 0:m.trim()})},a),(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(W4,{id:a,element:f,field:m},m.name))}),d.jsx(C4,{id:a,element:f,schema:(u==null?void 0:u.params)??[]})]})}function C4({id:e,element:t,schema:n}){const o=new Set(n.map(r=>r.name)),s=t.params?Object.entries(t.params).filter(([r])=>!o.has(r)):[];return n.length===0&&s.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(r=>d.jsx(O4,{id:e,element:t,field:r},r.name)),s.map(([r,i])=>d.jsx(P4,{id:e,element:t,fieldKey:r,value:i},r))]})}function O4({id:e,element:t,field:n}){var l;const o=ce(),s=Ot(),r=((l=t.params)==null?void 0:l[n.name])??n.default,i=s(`${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(ut,{label:i,children:d.jsx(co,{active:!!r,onClick:()=>a(!r),children:o(r?"common.yes":"common.no")})}):n.type==="number"?d.jsx(dn,{label:i,value:typeof r=="number"?r:0,unit:n.unit,onCommit:a}):d.jsx(nt,{label:i,value:typeof r=="string"?r:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function P4({id:e,element:t,fieldKey:n,value:o}){const s=ce(),r=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(ut,{label:n,children:d.jsx(co,{active:o,onClick:()=>r(!o),children:s(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(dn,{label:n,value:o,onCommit:r}):d.jsx(nt,{label:n,value:o,onCommit:i=>r(i.trim()===""?void 0:i)})}function B4({bus:e}){const t=ce(),n=e.id,o=s=>{const r=s.trim();Jn(n,{name:r===""?void 0:r})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(nt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(lo,{label:t("props.note"),value:e.note??"",onCommit:s=>Jn(n,{note:s.trim()===""?void 0:s.trim()})},n),d.jsx(L4,{bus:e})]})}function L4({bus:e}){const t=(o,s)=>{const r={...e.params??{}};s===void 0||s===""?delete r[o]:r[o]=s,Jn(e.id,{params:Object.keys(r).length>0?r: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(dn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Jn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(s=>s.id===e?{...s,...t}:s);return{...n,buses:o}})}function R4({wireId:e}){const t=ce(),n=x(b=>b.diagram.wires),o=x(b=>b.diagram.elements),s=x(b=>b.diagram.buses),r=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((s??[]).map(b=>[b.id,b])),m=new Map((r??[]).map(b=>[b.id,b])),p=b=>{if(!b.includes(".")){const W=u.get(b);if(W)return{id:b,label:W.name??b};const k=m.get(b);return{id:b,label:(k==null?void 0:k.name)??b}}const _=b.indexOf("."),v=b.slice(0,_),O=b.slice(_+1),L=f.get(v);return{id:v,label:(L==null?void 0:L.name)??v,pin:O}},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(nt,{label:t("props.label"),value:l.label??"",placeholder:t("props.labelPlaceholder"),onCommit:b=>x.getState().updateWire(e,{label:b.trim()===""?void 0:b.trim()})}),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 z4({junction:e}){var s;const t=ce(),n=x(r=>{var i;return(i=r.internal.junctions.get(e.id))==null?void 0:i.world}),o=((s=e.layout)==null?void 0:s.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(nt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:r=>x.getState().updateJunction(e.id,{name:r.trim()===""?void 0:r.trim()})}),d.jsx(lo,{label:t("props.note"),value:e.note??"",onCommit:r=>x.getState().updateJunction(e.id,{note:r.trim()===""?void 0:r.trim()})},e.id),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 D4({nodeId:e}){const t=ce(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),s=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 r=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=r.get(c)??[];u.push(f),r.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:r.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...r.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:()=>s([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 ut({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 nt({label:e,value:t,placeholder:n,unit:o,onCommit:s}){const[r,i]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>i(t),[t]),d.jsx(ut,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:r,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{r!==t&&s(r)},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})]})})}const F4=350;function lo({label:e,value:t,onCommit:n}){const[o,s]=I.useState(t),r=I.useRef(!1),i=I.useRef(null),a=I.useRef({local:o,value:t,onCommit:n});a.current={local:o,value:t,onCommit:n};const l=I.useRef(null);I.useEffect(()=>{r.current||(s(t),l.current=null)},[t]);const c=()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null);const u=a.current;u.local===u.value||u.local===l.current||(l.current=u.local,u.onCommit(u.local))},f=I.useRef(c);return f.current=c,I.useEffect(()=>()=>f.current(),[]),d.jsx(ut,{label:e,children:d.jsx("textarea",{rows:2,value:o,onFocus:()=>{r.current=!0},onChange:u=>{s(u.target.value),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,f.current()},F4)},onBlur:()=>{r.current=!1,c()},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 dn({label:e,value:t,min:n,unit:o,onCommit:s}){const[r,i]=I.useState(String(t)),a=I.useRef(null);return I.useEffect(()=>i(String(t)),[t]),d.jsx(ut,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"number",value:r,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(r);Number.isFinite(l)&&l!==t?s(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 co({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 W4({id:e,element:t,field:n}){var l;const o=ce(),r=Ot()(`${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(ut,{label:r,children:d.jsx(co,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(dn,{label:r,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(nt,{label:r,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function H4(){const e=ce(),t=Ot(),n=x(u=>u.selection),o=x(u=>u.selectedNode),s=x(u=>u.selectedWire),r=x(u=>u.diagram.elements),i=x(u=>u.diagram.buses),a=Ue(),l=Pe(a,"dense");if(n.length===0&&!o&&!s)return null;let c=e("props.title"),f=null;if(s)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=r.find(h=>h.id===u);if(p){const h=Ve[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) + var(--ole-safe-top, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-safe-top, 0px) - var(--ole-bottom-inset, 0px) - var(--ole-safe-bottom, 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(I4,{})]})}function q4(){I.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const s=o.closest("button");s&&s.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const s=document.activeElement;!s||s===document.body||s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable||s.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function G4(){q4();const e=x(o=>o.readOnly),t=I.useRef(null),n=uj(t);return d.jsx(g2,{children:d.jsx("div",{ref:t,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(Lj,{width:n,children:[d.jsx(Nj,{}),e?d.jsxs(d.Fragment,{children:[d.jsx(Er,{}),d.jsx(vr,{})]}):d.jsxs(d.Fragment,{children:[d.jsx(h4,{}),d.jsx(H4,{}),d.jsx(d4,{}),d.jsx(Er,{}),d.jsx(Zj,{}),d.jsx(S4,{}),d.jsx(A4,{}),d.jsx(vr,{})]})]})})})}const X4="ole-theme";function Y4(){try{const e=window.localStorage.getItem(X4);return e==="light"||e==="dark"?e:null}catch{return null}}function K4(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function V4(){return typeof window>"u"?"light":Y4()??(K4()?"dark":"light")}function Kw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function U4({className:e,diagram:t,readOnly:n,locale:o,theme:s}){return I.useEffect(()=>{x.getState().setReadOnly(!!n)},[n]),I.useEffect(()=>{if(!t)return;if(n){x.getState().setDiagram(t),x.getState().setActiveTool("pan");return}x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t,n]),I.useEffect(()=>{o&&It.getState().setLocale(o)},[o]),I.useEffect(()=>{s&&Kw(s)},[s]),I.useEffect(()=>{so()},[]),YS(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(G4,{})})}const Vw={"application/json":[".json"]},Uw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Jw=e=>e instanceof DOMException&&e.name==="AbortError";function Cr(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 J4(e){return JSON.stringify(e,null,2)+`
|
|
199
|
+
`}async function Z4(){if(Uw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:we("topbar.file.fileDescription"),accept:Vw}]})}catch(n){if(Jw(n))return null;throw n}const t=await e.getFile();return{diagram:Cr(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 s;const o=(s=n.files)==null?void 0:s[0];if(!o)return e(null);try{e({diagram:Cr(await o.text()),session:{name:o.name}})}catch(r){t(r)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function Or(e,t,n={}){const o=J4(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Uw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:we("topbar.file.fileDescription"),accept:Vw}]})}catch(l){if(Jw(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const s=URL.createObjectURL(new Blob([o],{type:"application/json"})),r=document.createElement("a");return r.href=s,r.download=(t==null?void 0:t.name)??"diagram.json",r.click(),URL.revokeObjectURL(s),t??{name:"diagram.json"}}function Q4(){const e=ce(),t=x(u=>u.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:s,onSave:r,onSaveAs:i}=e6(),[a,l]=I.useState(!1),c=I.useRef(null);I.useEffect(()=>{const u=m=>{if(!(m.metaKey||m.ctrlKey))return;const p=m.key.toLowerCase();p==="o"?(m.preventDefault(),s()):p==="s"&&(m.preventDefault(),m.shiftKey?i():r())};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[s,r,i]),I.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(Ie,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(u=>!u),children:[d.jsx(Io,{}),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(qt,{onClick:f(o),icon:d.jsx(jv,{}),children:e("topbar.file.new")}),d.jsx(qt,{onClick:f(s),icon:d.jsx(Io,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(qt,{onClick:f(r),icon:d.jsx(Co,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(qt,{onClick:f(i),icon:d.jsx(Co,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function qt({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 e6(){const e=ce(),t=x(l=>l.loadDiagramFromFile),n=x(l=>l.setFileSession),o=x(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=x.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await Z4();l&&(t(l.diagram,l.session),so())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=x.getState(),f=await Or(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 Or(l,c,{saveAs:!0});f&&n(f)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const An="WIRES",Fe="ELEMENTS",In="LABELS",Pr="ANNOTATIONS",Br=32,Lr=64,t6=8,n6=1.25,o6=6;function Zw(e,t={}){var s;const n=new g6(t.precision??6);n.header(t.title),n.tables([{name:An,color:7},{name:Fe,color:7},{name:In,color:8},{name:Pr,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(An,r.path.map(Te),!1);for(const{geometry:r}of e.buses.values()){const{axis:i,at:a,span:l}=r,c=l/2,f=i==="x"?[a[0]-c,a[1]]:[a[0],a[1]-c],u=i==="x"?[a[0]+c,a[1]]:[a[0],a[1]+c];n.lwpolyline(An,[f,u].map(Te),!1)}for(const r of e.elements.values()){const i=e.layout.get(r.element.id),a=r.libraryDef;!i||!a||r6(n,a.svg,i)}const o=t.labelMode??"all";if(o!=="off"){for(const r of e.elements.values()){const i=e.layout.get(r.element.id);if(!i||!r.libraryDef)continue;const a=nn(r,o);if(a.length===0)continue;const l=r.libraryDef.label??on(r.libraryDef),{world:[c,f],textAnchor:u,dy:m}=rn(l,r.libraryDef,i,a.length);for(let p=0;p<a.length;p++){const[h,g]=Te([c,f+m+p*Ct]);n.text(In,[h,g],a[p],Le,0,!1,u)}}for(const r of e.wireRenders.values()){const i=(s=r.label)==null?void 0:s.trim();if(!i)continue;const a=sn(r.path);if(!a)continue;const l=Te(a.world);n.text(In,l,i,Le,0,!1,a.textAnchor)}}for(const r of t.annotations??[]){if(!r.text)continue;const i=r.fontSize??t6,a=r.text.split(`
|
|
200
|
+
`);for(let l=0;l<a.length;l++){const[c,f]=Te([r.at[0],r.at[1]+(l+1)*i*n6]);n.text(Pr,[c,f],a[l],i,0,!1)}}return n.endEntities(),n.toString()}async function Qw(e,t="diagram.dxf",n){const o=Zw(e,n),s=URL.createObjectURL(new Blob([o],{type:"application/dxf;charset=utf-8"})),r=document.createElement("a");r.href=s,r.download=t,r.click(),URL.revokeObjectURL(s)}function r6(e,t,n){const o=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,r=new DOMParser().parseFromString(o,"image/svg+xml").documentElement;if(!(!r||r.querySelector("parsererror")))for(const i of Array.from(r.children))switch(i.tagName.toLowerCase()){case"line":s6(e,i,n);break;case"polyline":Rr(e,i,n,!1);break;case"polygon":Rr(e,i,n,!0);break;case"rect":i6(e,i,n);break;case"circle":a6(e,i,n);break;case"ellipse":l6(e,i,n);break;case"path":f6(e,i,n);break;case"text":u6(e,i,n);break}}function s6(e,t,n){const o=ve(t,"x1"),s=ve(t,"y1"),r=ve(t,"x2"),i=ve(t,"y2"),a=Te(De([o,s],n)),l=Te(De([r,i],n));e.line(Fe,a,l)}function Rr(e,t,n,o){const s=p6(t.getAttribute("points")??"");if(s.length<2)return;const r=s.map(i=>Te(De(i,n)));e.lwpolyline(Fe,r,o)}function i6(e,t,n){const o=ve(t,"x"),s=ve(t,"y"),r=ve(t,"width"),i=ve(t,"height"),l=[[o,s],[o+r,s],[o+r,s+i],[o,s+i]].map(c=>Te(De(c,n)));e.lwpolyline(Fe,l,!0)}function a6(e,t,n){const o=ve(t,"cx"),s=ve(t,"cy"),r=ve(t,"r"),i=Te(De([o,s],n));e.circle(Fe,i,r)}function l6(e,t,n){const o=ve(t,"cx"),s=ve(t,"cy"),r=ve(t,"rx"),i=ve(t,"ry");if(Math.abs(r-i)<1e-6){c6(e,o,s,r,n);return}d6(e,o,s,r,i,n)}function c6(e,t,n,o,s){const r=Te(De([t,n],s));e.circle(Fe,r,o)}function d6(e,t,n,o,s,r){const i=[];for(let a=0;a<Lr;a++){const l=a/Lr*Math.PI*2;i.push(Te(De([t+o*Math.cos(l),n+s*Math.sin(l)],r)))}e.lwpolyline(Fe,i,!0)}function u6(e,t,n){const o=ve(t,"x"),s=ve(t,"y"),r=parseFloat(t.getAttribute("font-size")??"")||o6,i=(t.textContent??"").trim();if(!i)return;const a=Te(De([o,s],n));e.text(Fe,a,i,r,n.rot,n.mirror)}function f6(e,t,n){const o=t.getAttribute("d")??"",s=m6(o);if(s.length===0)return;let r=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Fe,i.map(l=>Te(De(l,n))),!1),i=[]};for(const l of s)if(l.cmd==="M")a(),r=[l.args[0],l.args[1]],i.push(r);else if(l.cmd==="A"&&r){const[c,f,,u,m,p,h]=l.args,g=h6(r,[p,h],c,f,u!==0,m!==0);if(g)for(let b=1;b<=Br;b++){const _=g.theta1+g.delta*b/Br;i.push([g.cx+c*Math.cos(_),g.cy+f*Math.sin(_)])}else i.push([p,h]);r=[p,h]}a()}function m6(e){const t=[],n=/([MmAa])([^MmAa]*)/g;let o;for(;(o=n.exec(e))!==null;){const s=o[1].toUpperCase(),r=o[2].trim().split(/[\s,]+/).filter(i=>i.length>0).map(Number);t.push({cmd:s,args:r})}return t}function h6(e,t,n,o,s,r){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 D=Math.sqrt(b);m*=D,p*=D}const _=s===r?-1:1,v=m*m*p*p-m*m*u*u-p*p*f*f,O=m*m*u*u+p*p*f*f,L=_*Math.sqrt(Math.max(0,v/O)),W=L*(m*u)/p,k=L*-(p*f)/m,F=W+(i+l)/2,X=k+(a+c)/2,Z=(D,se,ie,de)=>{const oe=D*ie+se*de,re=Math.hypot(D,se)*Math.hypot(ie,de);let ye=Math.acos(Math.max(-1,Math.min(1,oe/re)));return D*de-se*ie<0&&(ye=-ye),ye},G=Z(1,0,(f-W)/m,(u-k)/p);let A=Z((f-W)/m,(u-k)/p,(-f-W)/m,(-u-k)/p);return!r&&A>0?A-=2*Math.PI:r&&A<0&&(A+=2*Math.PI),{cx:F,cy:X,theta1:G,delta:A}}function De(e,t){return Oe(e,t)}function Te(e){return[e[0],-e[1]]}function ve(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function p6(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 g6{constructor(t){gt(this,"out",[]);gt(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
|
|
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,zr(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[s,r]of n)this.g(10,s),this.g(20,r)}}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,s,r,i,a="start"){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,s),this.g(1,zr(o)),r!==0&&this.g(50,r),i&&this.g(71,2),a!=="start"&&(this.g(72,a==="middle"?1:2),this.g(11,n[0]),this.g(21,n[1]),this.g(31,0))}}function zr(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const y6="http://www.w3.org/2000/svg",Gt=24,ev=8,tv=1.25;function uo(e,t={}){var u;const n=x6(e,t),o=Math.floor(n.minX-Gt),s=Math.floor(n.minY-Gt),r=Math.ceil(n.maxX+Gt)-o,i=Math.ceil(n.maxY+Gt)-s,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${y6}" viewBox="${o} ${s} ${r} ${i}" width="${r}" height="${i}">`),t.title&&l.push(` <title>${Je(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${s}" width="${r}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const m of e.wireRenders.values()){if(m.path.length<2)continue;const p=m.path.map(([h,g])=>`${h},${g}`).join(" ");l.push(` <polyline points="${p}"/>`)}l.push(" </g>");for(const{bus:m,geometry:p}of e.buses.values()){const{axis:h,at:g,span:b}=p,_=b/2,v=h==="x"?g[0]-_:g[0],O=h==="x"?g[1]:g[1]-_,L=h==="x"?g[0]+_:g[0],W=h==="x"?g[1]:g[1]+_;l.push(` <line id="${Je(m.id)}" x1="${v}" y1="${O}" x2="${L}" y2="${W}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:m,world:p}of e.junctions.values())l.push(` <circle id="${Je(m.id)}" cx="${p[0]}" cy="${p[1]}" r="3.5" fill="black"/>`);for(const m of e.elements.values()){if(!m.libraryDef)continue;const p=e.layout.get(m.element.id);p&&(l.push(` <g id="${Je(m.element.id)}" transform="${Ke(p)}">`),l.push(` ${m.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Le}" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const p of e.elements.values()){const h=e.layout.get(p.element.id);if(!h||!p.libraryDef)continue;const g=nn(p,c);if(g.length===0)continue;const b=p.libraryDef.label??on(p.libraryDef),{world:[_,v],textAnchor:O,dy:L}=rn(b,p.libraryDef,h,g.length);for(let W=0;W<g.length;W++)l.push(` <text x="${_}" y="${v+L+W*Ct}" text-anchor="${O}">${Je(g[W])}</text>`)}for(const p of e.wireRenders.values()){const h=(u=p.label)==null?void 0:u.trim();if(!h)continue;const g=sn(p.path);g&&l.push(` <text x="${g.world[0]}" y="${g.world[1]}" text-anchor="${g.textAnchor}">${Je(h)}</text>`)}l.push(" </g>")}const f=t.annotations??[];if(f.length>0){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const p of f){if(!p.text)continue;const h=p.fontSize??ev,g=p.text.split(`
|
|
203
|
+
`);for(let b=0;b<g.length;b++){const _=p.at[1]+h*.85+b*h*tv;l.push(` <text x="${p.at[0]}" y="${_}" font-size="${h}">${Je(g[b])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
|
|
204
|
+
`)}function x6(e,t){var l;let n=1/0,o=1/0,s=-1/0,r=-1/0;const i=(c,f)=>{c<n&&(n=c),c>s&&(s=c),f<o&&(o=f),f>r&&(r=f)};for(const c of e.terminals.values())i(c.world[0],c.world[1]);for(const c of e.junctions.values())i(c.world[0],c.world[1]);for(const c of e.elements.values()){const f=e.layout.get(c.element.id),u=c.libraryDef;if(!f||!u)continue;const m=b6(u.viewBox);if(!m){i(f.at[0],f.at[1]);continue}const p=[[m.x,m.y],[m.x+m.w,m.y],[m.x,m.y+m.h],[m.x+m.w,m.y+m.h]];for(const h of p){const[g,b]=Oe(h,f);i(g,b)}}for(const{geometry:c}of e.buses.values()){const{axis:f,at:u,span:m}=c,p=m/2;f==="x"?(i(u[0]-p,u[1]),i(u[0]+p,u[1])):(i(u[0],u[1]-p),i(u[0],u[1]+p))}for(const c of e.wireRenders.values())for(const[f,u]of c.path)i(f,u);const a=t.labelMode??"all";if(a!=="off"){for(const c of e.elements.values()){const f=e.layout.get(c.element.id);if(!f||!c.libraryDef)continue;const u=nn(c,a);if(u.length===0)continue;const m=c.libraryDef.label??on(c.libraryDef),{world:[p,h],textAnchor:g,dy:b}=rn(m,c.libraryDef,f,u.length),_=Cn(u,Le),v=u.length*Ct,O=g==="middle"?p-_/2:g==="end"?p-_:p;i(O,h+b-Le),i(O+_,h+b+v)}for(const c of e.wireRenders.values()){const f=(l=c.label)==null?void 0:l.trim();if(!f)continue;const u=sn(c.path);if(!u)continue;const[m,p]=u.world,h=Cn([f],Le),g=u.textAnchor==="middle"?m-h/2:m;i(g,p-Le),i(g+h,p)}}for(const c of t.annotations??[]){if(!c.text)continue;const f=c.fontSize??ev,u=c.text.split(`
|
|
205
|
+
`),m=Cn(u,f),p=u.length*f*tv;i(c.at[0],c.at[1]),i(c.at[0]+m,c.at[1]+p)}return n===1/0&&(n=0,o=0,s=0,r=0),{minX:n,minY:o,maxX:s,maxY:r}}function Cn(e,t){let n=0;for(const o of e){const s=o.length*t*.55;s>n&&(n=s)}return Math.max(20,n)}function b6(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 Je(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function nv(e,t="diagram.svg",n){const o=uo(e,n);rv(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function ov(e,t="diagram.png",n){const o=uo(e,n),s=(n==null?void 0:n.scale)??2,r=URL.createObjectURL(new Blob([o],{type:"image/svg+xml;charset=utf-8"}));try{const i=await w6(r),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*s),a.height=Math.round(i.naturalHeight*s);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")});rv(c,t)}finally{URL.revokeObjectURL(r)}}function w6(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 rv(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function v6(){const e=ce(),[t,n]=I.useState(!1),o=I.useRef(null);I.useEffect(()=>{if(!t)return;const r=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",r),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",r),window.removeEventListener("keydown",i)}},[t]);const s=r=>()=>{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};r==="svg"?nv(i,`${c}.svg`,f):r==="png"?ov(i,`${c}.png`,{...f,scale:2}).catch(g=>{console.error(g),alert(e("topbar.export.pngFailed",{err:g.message}))}):Qw(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(Ie,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(r=>!r),children:[d.jsx(_v,{}),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:s("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(Ev,{}),d.jsx("span",{className:"flex-1",children:"SVG"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:s("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(Sv,{}),d.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:s("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($v,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=v6;exports.FileMenu=Q4;exports.LIBRARY=zn;exports.OneLineEditor=U4;exports.applyTheme=Kw;exports.buildExportDxf=Zw;exports.buildExportSvg=uo;exports.compile=Xe;exports.downloadDxf=Qw;exports.downloadPng=ov;exports.downloadSvg=nv;exports.emptyInternalModel=us;exports.fitToContent=ro;exports.fitToContentSoon=so;exports.getInitialTheme=V4;exports.getLibraryEntry=pw;exports.newAnnotationId=gw;exports.newBusId=Dn;exports.newElementId=Tt;exports.newJunctionId=Fn;exports.orientationVec=Rn;exports.resolvePlacement=fs;exports.transformOrientation=St;exports.transformPoint=Oe;exports.useEditorStore=x;exports.useLocale=It;exports.wireIdFromEnds=Qe;
|
|
206
206
|
//# sourceMappingURL=sldeditor.cjs.map
|