sldeditor 0.14.0 → 0.15.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/AnnotationDraftPreview.d.ts +11 -0
- package/dist/canvas/AnnotationDraftPreview.d.ts.map +1 -0
- package/dist/canvas/AnnotationHandles.d.ts +17 -0
- package/dist/canvas/AnnotationHandles.d.ts.map +1 -0
- package/dist/canvas/CanvasSvg.d.ts.map +1 -1
- package/dist/canvas/FreeAnnotationLayer.d.ts +16 -12
- package/dist/canvas/FreeAnnotationLayer.d.ts.map +1 -1
- package/dist/canvas/tools/LineTool.d.ts +3 -0
- package/dist/canvas/tools/LineTool.d.ts.map +1 -0
- package/dist/canvas/tools/RectTool.d.ts +3 -0
- package/dist/canvas/tools/RectTool.d.ts.map +1 -0
- package/dist/canvas/tools/SelectTool.d.ts.map +1 -1
- package/dist/canvas/tools/TableTool.d.ts +3 -0
- package/dist/canvas/tools/TableTool.d.ts.map +1 -0
- package/dist/canvas/tools/index.d.ts.map +1 -1
- package/dist/canvas/useKeyboardShortcuts.d.ts.map +1 -1
- package/dist/components/AnnotationEditToolbar.d.ts +15 -0
- package/dist/components/AnnotationEditToolbar.d.ts.map +1 -0
- package/dist/components/EditorShell.d.ts.map +1 -1
- package/dist/components/FloatingToolbar.d.ts.map +1 -1
- package/dist/components/PropertyPanel.d.ts.map +1 -1
- package/dist/components/RightPanel.d.ts.map +1 -1
- package/dist/i18n/messages.d.ts +72 -0
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/annotation-geom.d.ts +77 -0
- package/dist/lib/annotation-geom.d.ts.map +1 -0
- package/dist/lib/export-dxf.d.ts +3 -3
- package/dist/lib/export-dxf.d.ts.map +1 -1
- package/dist/lib/export-image.d.ts +3 -3
- package/dist/lib/export-image.d.ts.map +1 -1
- package/dist/model/index.d.ts +2 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/types.d.ts +68 -1
- package/dist/model/types.d.ts.map +1 -1
- package/dist/sldeditor.cjs +68 -48
- package/dist/sldeditor.cjs.map +1 -1
- package/dist/sldeditor.js +7926 -6344
- package/dist/sldeditor.js.map +1 -1
- package/dist/store/store.d.ts +24 -3
- 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,206 +1,226 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o2=Object.defineProperty;var r2=(e,t,n)=>t in e?o2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>r2(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),C=require("react"),ks=require("react-dom");function s2(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 Se=s2(C);/**
|
|
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 i2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_s=(...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 a2={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 l2=C.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>C.createElement("svg",{ref:l,...a2,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:_s("lucide",r),...a},[...i.map(([c,u])=>C.createElement(c,u)),...Array.isArray(s)?s:[s]]));/**
|
|
17
17
|
* @license lucide-react v0.469.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const se=(e,t)=>{const n=C.forwardRef(({className:o,...r},s)=>C.createElement(l2,{ref:s,iconNode:t,className:_s(`lucide-${i2(e)}`,o),...r}));return n.displayName=`${e}`,n};/**
|
|
22
22
|
* @license lucide-react v0.469.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Ss=se("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 c2=se("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
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 d2=se("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
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 u2=se("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
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 $s=se("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"}]]);/**
|
|
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 js=se("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"}]]);/**
|
|
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 f2=se("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"}]]);/**
|
|
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 no=se("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"}]]);/**
|
|
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 h2=se("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"}]]);/**
|
|
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 m2=se("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"}]]);/**
|
|
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 p2=se("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"}]]);/**
|
|
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 g2=se("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"}]]);/**
|
|
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 Es=se("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"}]]);/**
|
|
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 rr=se("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"}]]);/**
|
|
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 y2=se("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"}]]);/**
|
|
97
97
|
* @license lucide-react v0.469.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const x2=se("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"}]]);/**
|
|
102
102
|
* @license lucide-react v0.469.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const pn=se("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
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 Ns=se("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"}]]);/**
|
|
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 b2=se("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"}]]);/**
|
|
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 $o=se("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
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 w2=se("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"}]]);/**
|
|
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 v2=se("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"}]]);/**
|
|
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 k2=se("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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 jo=se("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"}]]);/**
|
|
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 As=se("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"}]]);/**
|
|
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 sr=se("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"}]]);/**
|
|
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 Ts=se("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"}]]);/**
|
|
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 _2=se("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
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 Ms=se("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"}]]);/**
|
|
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 S2=se("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/**
|
|
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 $2=se("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"}]]);/**
|
|
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 j2=se("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"}]]);/**
|
|
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 E2=se("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
187
187
|
* @license lucide-react v0.469.0 - ISC
|
|
188
188
|
*
|
|
189
189
|
* This source code is licensed under the ISC license.
|
|
190
190
|
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const
|
|
191
|
+
*/const N2=se("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
|
|
192
192
|
* @license lucide-react v0.469.0 - ISC
|
|
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 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 x=0;x<a.length;x++){let k=a[x];if(c===0){if(k===s&&(o||a.slice(x,x+r)===t)){l.push(a.slice(f,x)),f=x+r;continue}if(k==="/"){u=x;continue}}k==="["?c++:k==="]"&&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 x=qv(f).join(":"),k=u?x+ts:x,v=k+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(k+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 pe=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)),re=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=pe("colors"),t=pe("spacing"),n=pe("blur"),o=pe("brightness"),s=pe("borderColor"),r=pe("borderRadius"),i=pe("borderSpacing"),a=pe("borderWidth"),l=pe("contrast"),c=pe("grayscale"),f=pe("hueRotate"),u=pe("invert"),m=pe("gap"),p=pe("gradientColorStops"),h=pe("gradientColorStopPositions"),g=pe("inset"),x=pe("margin"),k=pe("opacity"),v=pe("padding"),O=pe("saturate"),L=pe("scale"),W=pe("sepia"),G=pe("skew"),S=pe("space"),F=pe("translate"),Y=()=>["auto","contain","none"],X=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto",re,t],D=()=>[re,t],Z=()=>["",Re,He],se=()=>["auto",at,re],de=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ee=()=>["solid","dashed","dotted","double","none"],ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],he=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",re],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ne=()=>[at,re];return{cacheSize:500,separator:":",theme:{colors:[xt],spacing:[Re,He],blur:["none","",qe,re],brightness:Ne(),borderColor:[e],borderRadius:["none","","full",qe,re],borderSpacing:D(),borderWidth:Z(),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",re]}],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(),re]}],overflow:[{overflow:X()}],"overflow-x":[{"overflow-x":X()}],"overflow-y":[{"overflow-y":X()}],overscroll:[{overscroll:Y()}],"overscroll-x":[{"overscroll-x":Y()}],"overscroll-y":[{"overscroll-y":Y()}],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,re]}],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",re]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",yt,re]}],"grid-cols":[{"grid-cols":[xt]}],"col-start-end":[{col:["auto",{span:["full",yt,re]},re]}],"col-start":[{"col-start":se()}],"col-end":[{"col-end":se()}],"grid-rows":[{"grid-rows":[xt]}],"row-start-end":[{row:["auto",{span:[yt,re]},re]}],"row-start":[{"row-start":se()}],"row-end":[{"row-end":se()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",re]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",re]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...he()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...he(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...he(),"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:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",re,t]}],"min-w":[{"min-w":[re,t,"min","max","fit"]}],"max-w":[{"max-w":[re,t,"none","full","min","max","fit","prose",{screen:[qe]},qe]}],h:[{h:[re,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[re,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",re]}],"line-clamp":[{"line-clamp":["none",at,yn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Re,re]}],"list-image":[{"list-image":["none",re]}],"list-style-type":[{list:["none","disc","decimal",re]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Re,He]}],"underline-offset":[{"underline-offset":["auto",Re,re]}],"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",re]}],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",re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...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":[k]}],"border-style":[{border:[...ee(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:ee()}],"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:["",...ee()]}],"outline-offset":[{"outline-offset":[Re,re]}],"outline-w":[{outline:[Re,He]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"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:[k]}],"mix-blend":[{"mix-blend":[...ie(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ie()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",qe,re]}],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":[k]}],"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",re]}],duration:[{duration:Ne()}],ease:[{ease:["linear","in","out","in-out",re]}],delay:[{delay:Ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",re]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[L]}],"scale-x":[{"scale-x":[L]}],"scale-y":[{"scale-y":[L]}],rotate:[{rotate:[yt,re]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[G]}],"skew-y":[{"skew-y":[G]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",re]}],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",re]}],"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",re]}],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:x=>x,version:0,merge:(x,k)=>({...k,...x}),...t},i=!1,a=0;const l=new Set,c=new Set;let f=r.storage;if(!f)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${r.name}', the given storage is currently unavailable.`),n(...x)},o,s);const u=()=>{const x=r.partialize({...o()});return f.setItem(r.name,{state:x,version:r.version})},m=s.setState;s.setState=(x,k)=>(m(x,k),u());const p=e((...x)=>(n(...x),u()),o,s);s.getInitialState=()=>p;let h;const g=()=>{var x,k;if(!f)return;const v=++a;i=!1,l.forEach(L=>{var W;return L((W=o())!=null?W:p)});const O=((k=r.onRehydrateStorage)==null?void 0:k.call(r,(x=o())!=null?x: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(G=>[!0,G]):[!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[G,S]=L;if(h=r.merge(S,(W=o())!=null?W:p),n(h,!0),G)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:x=>{r={...r,...x},x.storage&&(f=x.storage)},clearStorage:()=>{f==null||f.removeItem(r.name)},getOptions:()=>r,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:x=>(l.add(x),()=>{l.delete(x)}),onFinishHydration:x=>(c.add(x),()=>{c.delete(x)})},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)},x=new Set(n.map(y=>y.id)),k=y=>x.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 $ of w.terminals)L.add(`${y.id}.${$.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 G=new Map;for(const y of W)for(const w of y)G.set(w,[y]);const S=new Map;for(const y of W){const w=y.filter(k);if(w.length!==0)for(const $ of w){const E=y.filter(_=>_!==$),j=S.get($)??[];j.push(...E),S.set($,j)}}{const $=T=>p.has(T)&&!!g(T),E=T=>{if(k(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(k(q)){B=!0;continue}const te=E(q);te&&N.push(te)}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)),K=R.filter(q=>!v.has(q));if(H.length>0){for(const q of H)for(const te of K)M(q,te);for(let q=0;q<H.length;q++)for(let te=q+1;te<H.length;te++)M(H[q],H[te])}else for(let q=0;q<K.length;q++)for(let te=q+1;te<K.length;te++)M(K[q],K[te])}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 K of G.get(H)??[])for(const q of K)if(E(q)===N)return R}return null},C=T=>{const N=J=>{var oe;return((oe=j.get(J))==null?void 0:oe.size)??0},B=J=>{var oe;return((oe=g(J))==null?void 0:oe.category)??""},R=J=>{const oe=B(J);return oe==="source"?0:oe==="renewable"?1:2+Math.min(N(J),9)/10},H=T.filter($).sort((J,oe)=>R(J)-R(oe)||J.localeCompare(oe))[0];if(!H)return;const K=new Map([[H,null]]),q=new Map([[H,0]]),te=new Map,ne=[],V=[H],U=new Set([H]);for(;V.length;){const J=V.shift();ne.push(J);for(const oe of[...j.get(J)??[]].sort(($e,Se)=>$e.localeCompare(Se)))U.has(oe)||(U.add(oe),K.set(oe,J),q.set(oe,(q.get(J)??0)+1),te.has(J)||te.set(J,[]),te.get(J).push(oe),V.push(oe))}let Q=0;const ue=new Map,be=J=>{const oe=te.get(J)??[];if(oe.length===0){ue.set(J,Q++);return}for(const Se of oe)be(Se);const $e=oe.map(Se=>ue.get(Se));ue.set(J,$e.reduce((Se,Bt)=>Se+Bt,0)/$e.length)};be(H);for(const J of ne){const oe=ge(xn+(ue.get(J)??0)*160),$e=ge(zt+(q.get(J)??0)*140);if(v.has(J)){f.set(J,[oe,$e]);continue}let Se=0;const Bt=K.get(J)??null;if(Bt){const pt=z(J,Bt);pt&&(Se=Rt(pt.orientation,"n"))}else{const pt=(te.get(J)??[])[0],Ao=pt?z(J,pt):null;Ao&&(Se=Rt(Ao.orientation,"s"))}l.set(J,{at:[oe,$e],rot:Se,mirror:!1}),u.add(J)}},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($)&&C(N)}}const F=new Map;for(const y of W){const w=y.filter(k);if(w.length!==0)for(const $ of y){if(k($))continue;const E=$.indexOf(".");if(E<0)continue;const j=$.slice(0,E),_=$.slice(E+1),M=F.get(j)??[];for(const z of w)M.some(C=>C.busId===z&&C.pin===_)||M.push({busId:z,pin:_});F.set(j,M)}}const Y=[],X=new Set;for(const[y,w]of F)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";Y.push({elementId:y,attachments:w,orientation:E}),E==="vertical"&&X.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 $=w.terminals.map(E=>`${y.id}.${E.id}`);for(let E=0;E<$.length;E++)for(let j=E+1;j<$.length;j++)D($[E],$[j])}for(const y of t){if(X.has(y.id))continue;const w=r.get(y.kind);if(!w||w.category!=="transformer"||w.terminals.length<2)continue;const $=w.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of $){const M=_.slice(y.id.length+1);E.set(M,new Set);const z=new Set($.filter(T=>T!==_)),C=new Set([_]),P=[_];for(;P.length>0;){const T=P.shift();if(k(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});Y.push({elementId:y.id,attachments:_,orientation:"vertical"}),X.add(y.id)}}const Z=(y,w)=>{var z;const $=g(w),E=$?$.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 Y){if(y.orientation!=="horizontal")continue;const w=new Set(y.attachments.map(E=>E.busId));let $=0;for(const E of w)Z(E,y.elementId)&&$++;$===1&&(y.orientation="vertical",X.add(y.elementId))}for(const y of t){if(X.has(y.id)||y.kind!=="breaker")continue;const w=r.get(y.kind);if(!w||w.terminals.length!==2)continue;const $=w.terminals.map(_=>`${y.id}.${_.id}`),E=new Map;for(const _ of $){const M=_.slice(y.id.length+1),z=new Set($.filter(T=>T!==_)),C=new Set([_]),P=[_];for(;P.length>0;){const T=P.shift();if(k(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 K=p.get(H),q=K?r.get(K.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});Y.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const se=new Map;for(const y of n)se.set(y.id,new Map);for(const y of Y){const w=Array.from(new Set(y.attachments.map($=>$.busId)));for(const $ of w)for(const E of w)$!==E&&((Eo=se.get($))==null||Eo.set(E,y))}const de=y=>{var $;const w=($=r.get(y))==null?void 0:$.category;return w?Go.has(w):!1},ee=[];for(const y of n){const w=S.get(y.id);if(w)for(const $ of w){if(k($))continue;const E=$.indexOf(".");if(E<0)continue;const j=$.slice(0,E),_=p.get(j);if(_&&de(_.kind)){ee.push(y.id);break}}}ee.length===0&&n.length>0&&ee.push(n[0].id);const ie=new Map;for(const y of ee)ie.set(y,0);{const y=[...ee];for(;y.length>0;){const w=y.shift(),$=ie.get(w),E=se.get(w);if(E)for(const[j,_]of E){if(ie.has(j))continue;const M=_.orientation==="horizontal"?$:$+1;ie.set(j,M),y.push(j)}}}for(const y of n){if(ie.has(y.id))continue;const w=ie.size===0?-1:Math.max(...Array.from(ie.values()));ie.set(y.id,w+1)}const he=new Map;for(const y of n){const w=ie.get(y.id),$=he.get(w)??[];$.push(y.id),he.set(w,$)}const xe=[...he.keys()].sort((y,w)=>y-w),_e=(y,w,$)=>{const E=`${y.elementId}.${$}`,j=w,_=g(y.elementId),M=new Set;if(_)for(const N of _.terminals)N.id!==$&&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 te;if(q){const ne=q.indexOf(".");if(ne>0){const V=q.slice(0,ne);V!==y.elementId&&(te=V)}}return{extent:B,head:te}}const R=N.indexOf(".");if(R<0)continue;const H=N.slice(0,R),K=N.slice(R+1);if(!k(H)&&!X.has(H)){const q=g(H),te=q==null?void 0:q.terminals.find(ne=>ne.id===K);if(q&&te)for(const ne of q.terminals){if(ne.id===K)continue;const V=`${H}.${ne.id}`;z.has(V)||M.has(V)||T(V,N,Math.abs(te.y-ne.y),B)}}for(const q of G.get(N)??[])for(const te of q){if(te===N||z.has(te)||M.has(te))continue;const ne=k(N)||k(te);T(te,N,ne?Wo:wt,B)}}return{extent:0}},Ne=(y,w)=>{var N,B,R;const $=(N=se.get(y))==null?void 0:N.get(w);if(!$||$.orientation==="horizontal")return bt;const E=g($.elementId);if(!E)return bt;const j=(B=$.attachments.find(H=>H.busId===y))==null?void 0:B.pin,_=(R=$.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($,y,j).extent,T=_e($,w,_).extent;return P+C+T},un=new Map;for(const y of Y){if(y.orientation!=="vertical")continue;const w=y.attachments.slice().sort((z,C)=>(ie.get(z.busId)??0)-(ie.get(C.busId)??0));if(w.length<2)continue;const $=w[0].busId,E=w[1].busId,j=w[0].pin,M=_e(y,$,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,$,E=0)=>{const j=g(w);let _=mo(w);if(j&&!$.has(w)&&E<sv){$.add(w);let M=0;for(const z of j.terminals){const C=`${w}.${z.id}`;if(C!==y)for(const P of G.get(C)??[]){const T=new Set;let N=!1;for(const R of P){if(R===C)continue;if(k(R)){N=!0;continue}const H=R.indexOf(".");if(H<0)continue;const K=R.slice(0,H);K===w||$.has(K)||X.has(K)||T.add(K)}if(N||T.size===0)continue;let B=0;for(const R of T){const H=[...P].find(K=>K.indexOf(".")>0&&K.slice(0,K.indexOf("."))===R);B+=(H?ho(H,R,$,E+1):mo(R))+fo}M=Math.max(M,B-fo)}}$.delete(w),_=Math.max(_,M)}return _},ft=320,ot=new Map,po=(y,w)=>{if(!X.has(y))return!1;const $=Y.find(M=>M.elementId===y),E=$==null?void 0:$.attachments.find(M=>M.busId!==w);if(!E)return!1;const j=ie.get(w)??0;return(ie.get(E.busId)??0)<j},mt=(y,w,$)=>{const E=un.get(y);if(E){const _=ot.get(E.lowerBusId);if(_!==void 0)return Math.max(w,_+Ge)}let j=0;return $&&(j=ho($,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.get(y)??[];let E=0,j=0;for(const M of $){if(k(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,$)=>{const E=g(w);if(!E)return;const j=`${w}.${$}`,_=E.terminals.filter(C=>C.id!==$).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(k(C)&&C!==y){const T=c.get(C);return T?T.at[0]:void 0}for(const T of G.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(!k(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=S.get(y);if(!w||w.length===0)return;const $=c.get(y);if(!$)return;const E=w.flatMap(N=>{if(k(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 K=g(R);if(!K)return[];const q=K.terminals.find(te=>te.id===H);return q?[{elId:R,lib:K,localTerm:q,isLinker:X.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($.span,z);C!==$.span&&!m.has(y)&&c.set(y,{...$,span:C});const P=c.get(y),T=(N,B)=>{if(N.length===0)return;const R=new Map;for(const U of N){const Q=iv(y,U.elId,U.localTerm.id);Q!==void 0&&R.set(U.elId,Q)}N.sort((U,Q)=>{const ue=R.get(U.elId)??P.at[0],be=R.get(Q.elId)??P.at[0];if(ue!==be)return ue-be;const J=mt(U.elId,U.lib.width,U.busFacingRef);return mt(Q.elId,Q.lib.width,Q.busFacingRef)-J});const H=N.map(U=>mt(U.elId,U.lib.width,U.busFacingRef)),K=H.reduce((U,Q)=>U+Q,0),q=Math.max(C,K),te=(q-K)/(N.length+1);let ne=P.at[0]-q/2+te;const V=P.at[1]+B*Wo;for(let U=0;U<N.length;U++){const Q=N[U],ue=H[U],be=ne+ue/2;Q.isLinker?We.has(Q.elId)||We.set(Q.elId,be):l.set(Q.elId,{at:[ge(be-Q.localTerm.x),ge(V-Q.localTerm.y)],rot:0,mirror:!1}),ne+=ue+te}};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 $=y.attachments.filter(ne=>c.has(ne.busId));if($.length<2)return;const E=$.slice().sort((ne,V)=>(ie.get(ne.busId)??0)-(ie.get(V.busId)??0)),j=E[0].busId,_=c.get(j),M=E[0].pin,z=E[E.length-1].pin,C=w.terminals.find(ne=>ne.id===M),P=w.terminals.find(ne=>ne.id===z);if(!C||!P)return;const T=C.y<=P.y?0:180,N=ie.get(j)??0,B=$.filter(ne=>(ie.get(ne.busId)??0)===N),R=[];let H=0;for(const ne of B){const V=_e(y,ne.busId,ne.pin);H=Math.max(H,V.extent);const U=V.head?l.get(V.head):void 0;U?R.push(U.at[0]):We.has(y.elementId)?R.push(We.get(y.elementId)):R.push(c.get(ne.busId).at[0])}let K;R.length>0?K=R.reduce((ne,V)=>ne+V,0)/R.length:We.has(y.elementId)?K=We.get(y.elementId):K=_.at[0];const q=_.at[1]+H,te=T===0?[ge(K-C.x),ge(q-C.y)]:[ge(K+C.x),ge(q+C.y)];if(l.set(y.elementId,{at:te,rot:T,mirror:!1}),B.length>1){const ne=l.get(y.elementId),V=Oe([C.x,C.y],ne),U=St(C.orientation,ne);cv(`${y.elementId}.${M}`,V,U,K)}},cv=(y,w,$,E)=>{const j=new Set([y]);let _=y,M=w,z=$;for(;;){const C=G.get(_)??[];let P,T=!1;for(const oe of C){if(oe.length>=3){T=!0;break}const $e=oe.find(Se=>Se!==_);if(!(!$e||j.has($e))){if(k($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(k(B)||X.has(B)||l.has(B))break;const H=g(B);if(!H)break;const K=H.terminals.find(oe=>oe.id===R);if(!K)break;const q=Rn(z),te=[M[0]+q[0]*wt,M[1]+q[1]*wt],ne=Fo[z],V=Rt(K.orientation,ne),U=Oe([K.x,K.y],{at:[0,0],rot:V,mirror:!1}),Q=[ge(E-U[0]),ge(te[1]-U[1])];l.set(B,{at:Q,rot:V,mirror:!1}),j.add(P);const ue=H.terminals.find(oe=>oe.id!==R);if(!ue)break;const be=`${B}.${ue.id}`;j.add(be);const J={at:Q,rot:V,mirror:!1};M=Oe([ue.x,ue.y],J),z=St(ue.orientation,J),_=be}},dv=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const w=g(y.elementId);if(!w)return;const $=y.attachments.filter(B=>c.has(B.busId));if($.length<2)return;const E=$.map(B=>{const R=_e(y,B.busId,B.pin),H=R.head?l.get(R.head):void 0,K=H?H.at[0]:c.get(B.busId).at[0];return{att:B,x:K,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:[ge(P),ge(N)],rot:C,mirror:!1})},yo=100;let Pt=zt;for(let y=0;y<xe.length;y++){const w=xe[y],$=he.get(w);let E;if(y===0)E=zt;else{const _=he.get(xe[y-1]);let M=0;for(const z of _)for(const C of $)(No=se.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 $){if(c.has(_)){Pt=Math.max(Pt,c.get(_).at[1]);continue}let M;if(y>0){const C=he.get(xe[y-1]),P=[];for(const T of C){const N=(Mo=se.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:[ge(M),ge(E)],rot:0,span:z,axis:Ln(0)})}for(const _ of $)av(_);if(y>0)for(const _ of Y)l.has(_.elementId)||!_.attachments.some(z=>$.includes(z.busId))||lv(_);for(const _ of Y)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>$.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 G.get(C)??[])for(const T of P){if(T===C||k(T))continue;const N=T.indexOf(".");if(N<0)continue;const B=T.slice(0,N);B!==j&&_.add(B)}}return _},w=new Set,$=[];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&&$.push(_)}let E=xn;for(const j of $){if(j.some(P=>l.has(P)))continue;j.sort((P,T)=>{var K,q;const N=de(((K=p.get(P))==null?void 0:K.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:[ge(E-C[0]),ge(zt-C[1])],rot:0,mirror:!1}),E+=Math.max(bn,j.length*Ge)+yo}}const uv=y=>{if(k(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=[],$=new Map;for(const V of y){if(k(V))continue;const U=V.indexOf(".");if(U<0)continue;const Q=V.slice(0,U),ue=V.slice(U+1);if(l.has(Q)){w.push(V);continue}if(X.has(Q)||$.has(Q))continue;const be=g(Q);if(!be)continue;const J=be.terminals.find(oe=>oe.id===ue);J&&$.set(Q,{ref:V,elId:Q,lib:be,localTerm:J})}if($.size===0||w.length===0)continue;const E=[...$.values()],j=new Map;for(const V of E)for(const U of G.get(V.ref)??[])for(const Q of U){if(Q===V.ref||k(Q)||!uv(Q))continue;const ue=Q;j.set(ue,(j.get(ue)??0)+1)}let _;if(j.size>0){let V=-1;for(const[U,Q]of j)(Q>V||Q===V&&(_===void 0||U<_))&&(V=Q,_=U)}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(V=>V.id===C);if(!N)continue;const B=Oe([N.x,N.y],T),R=St(N.orientation,T),H=Rn(R),K=[-H[1],H[0]];E.sort((V,U)=>V.elId.localeCompare(U.elId));const q=E.map(V=>Math.max(V.lib.width,Ge));let ne=-q.reduce((V,U)=>V+U,0)/2;for(let V=0;V<E.length;V++){const U=E[V],Q=q[V],ue=ne+Q/2;ne+=Q;const be=Fo[R],J=Rt(U.localTerm.orientation,be),oe=Oe([U.localTerm.x,U.localTerm.y],{at:[0,0],rot:J,mirror:!1}),$e=[B[0]+H[0]*wt+K[0]*ue,B[1]+H[1]*wt+K[1]*ue],Se=[ge($e[0]-oe[0]),ge($e[1]-oe[1])];l.set(U.elId,{at:Se,rot:J,mirror:!1}),fn=!0}}}const ht=y=>{const w=l.get(y),$=g(y);if(!w||!$)return null;const E=$.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=$.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,$=g(y);if(!$)return w;for(const E of $.terminals){const j=`${y}.${E.id}`;for(const _ of G.get(j)??[])for(const M of _){if(M===j||k(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),$=g(y);if(!w||!$)return null;const E=$.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=$.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 $=new Set,E=[];for(const j of S.get(y)??[]){if(k(j))continue;const _=j.indexOf(".");if(_<0)continue;const M=j.slice(0,_),z=l.get(M);!z||z.at[1]>=w-1||$.has(M)||($.add(M),E.push(M))}for(;E.length>0;){const j=E.pop();for(const _ of mn(j)){if($.has(_))continue;const M=l.get(_);!M||M.at[1]>=w-1||($.add(_),E.push(_))}}return $},bo=(y,w,$)=>{const E=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const M of mn(_))M===w||E.has(M)||!$.has(M)||(E.add(M),j.push(M))}return E},wo=(y,w)=>{let $=y.length*y.length+8,E=!1,j=!0;for(;j&&$-- >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 K=bo(z,C,w),q=bo(C,z,w);if(K.has(C)||q.has(z))continue;const te=![...K].some(J=>u.has(J)),ne=![...q].some(J=>u.has(J));if(!te&&!ne)continue;const V=(P.min+P.max)/2,U=(T.min+T.max)/2;let Q,ue;te&&(!ne||K.size<=q.size)?(Q=K,ue=V<=U?-1:1):(Q=q,ue=U<=V?-1:1);const be=ge(ue*(R+xo));if(be!==0){for(const J of Q){const oe=l.get(J);oe&&l.set(J,{...oe,at:[oe.at[0]+be,oe.at[1]]})}E=!0,j=!0;break}}}return E};for(const y of n){const w=c.get(y.id);if(!w)continue;const $=mv(y.id,w.at[1]);if($.size<2)continue;const E=[...$];if(wo(E,$)){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:ge(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 $=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&&$++}return $},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,$=[];for(const j of n)for(const _ of S.get(j.id)??[]){if(k(_))continue;const M=_.indexOf(".");if(M<0)continue;const z=_.slice(0,M);l.has(z)&&$.push({el:z,bus:j.id,d:1})}$.sort((j,_)=>j.d-_.d);let E=0;for(;E<$.length;){const{el:j,bus:_,d:M}=$[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)||$.push({el:C,bus:_,d:M+1}))}for(const[j,_]of w)_&&$o.set(j,_)}for(const y of xe){const w=(he.get(y)??[]).filter(P=>c.has(P));if(w.length<2||w.some(P=>m.has(P)))continue;const $=[];let E=0;for(const P of w){const T=c.get(P),N=[];let B=1/0,R=-1/0;for(const[H,K]of $o){if(K!==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),$.push({busId:P,min:B,max:R,members:N}),E+=R-B}if($.some(P=>P.members.some(T=>u.has(T))))continue;let j=1/0,_=-1/0;for(const P of $)j=Math.min(j,P.min),_=Math.max(_,P.max);const M=_-j,z=E+pn*($.length-1);if(!(M>z+pn))continue;$.sort((P,T)=>(P.min+P.max)/2-(T.min+T.max)/2);let C=j;for(const P of $){const T=ge(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 $){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($=>$.id).filter($=>l.has($)),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,$=Math.floor(gn/qo);l.set(y.id,{at:[ge(S2+w*E2),ge(j2+$*N2)],rot:0,mirror:!1}),gn++}return{devices:l,buses:c,junctions:f}}function ge(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 x;if(m==="x")x=[Kt(f[0],p[0]-g,p[0]+g),p[1]];else{const k=Kt(f[1],p[1]-g,p[1]+g);x=[p[0],k]}return{wireId:e.id,path:Ko(f,x)}}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,G;const t=us(),n=new Map;e.elements.forEach((S,F)=>{if(n.has(S.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:S.id}),pointer:`/elements/${F}`});return}n.set(S.id,S);const Y=zn.get(S.kind);Y||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:S.kind})} (id=${S.id})`,pointer:`/elements/${F}`}),t.elements.set(S.id,{element:S,libraryDef:Y})});const o=new Map,s=new Map;(e.buses??[]).forEach((S,F)=>{if(n.has(S.id)||o.has(S.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:S.id}),pointer:`/buses/${F}`});return}if(o.set(S.id,S),S.layout){const Y=S.layout.rot??0;s.set(S.id,{at:S.layout.at,span:S.layout.span,rot:Y,axis:Ln(Y)})}});const r=new Map;(e.junctions??[]).forEach((S,F)=>{if(n.has(S.id)||o.has(S.id)||r.has(S.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:S.id}),pointer:`/junctions/${F}`});return}r.set(S.id,S)});const i=S=>!S.includes(".")&&o.has(S),a=S=>!S.includes(".")&&r.has(S),l=(S,F)=>{if(i(S)||a(S))return!0;const Y=S.indexOf(".");if(Y<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:S}),pointer:F}),!1;const X=S.slice(0,Y),A=S.slice(Y+1),D=t.elements.get(X);if(!D)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:X}),pointer:F}),!1;if(!D.libraryDef)return!1;if(!D.libraryDef.terminals.find(Z=>Z.id===A)){const Z=D.libraryDef.terminals.map(se=>se.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:X,kind:D.element.kind,pin:A,available:Z}),pointer:F}),!1}return!0},c=[];(e.wires??[]).forEach((S,F)=>{const Y=`/wires/${F}`,X=l(S.ends[0],Y),A=l(S.ends[1],Y);X&&A&&c.push(S)});const f=new Map;if(e.layout)for(const[S,F]of Object.entries(e.layout))t.elements.has(S)?f.set(S,fs(F)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:S}),pointer:`/layout/${S}`});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[S,F]of u.buses){const Y=o.get(S);Y&&t.buses.set(S,{bus:Y,geometry:F})}for(const[S,F]of o)t.buses.has(S)||t.buses.set(S,{bus:F,geometry:{at:((v=F.layout)==null?void 0:v.at)??[0,0],span:((O=F.layout)==null?void 0:O.span)??U$,rot:((L=F.layout)==null?void 0:L.rot)??0,axis:Ln(((W=F.layout)==null?void 0:W.rot)??0)}});for(const S of t.elements.values()){if(!S.libraryDef)continue;const F=t.layout.get(S.element.id);if(!F)continue;const Y=[];for(const X of S.libraryDef.terminals){const A=`${S.element.id}.${X.id}`,D=Oe([X.x,X.y],F),Z=St(X.orientation,F);t.terminals.set(A,{ref:A,elementId:S.element.id,pin:X.id,world:D,orientation:Z}),Y.push(A)}t.elementToTerminals.set(S.element.id,Y)}const m=new Map,p=new Set;for(const[S,F]of r)(G=F.layout)!=null&&G.at?(m.set(S,[F.layout.at[0],F.layout.at[1]]),p.add(S)):u.junctions.has(S)&&(m.set(S,u.junctions.get(S)),p.add(S));const h=S=>{if(!S.includes(".")){const Y=t.buses.get(S);return Y?Y.geometry.at:m.get(S)??null}const F=t.terminals.get(S);return F?F.world:null},g=new Map;for(const[S]of r)p.has(S)||g.set(S,[]);for(const S of c){const[F,Y]=S.ends;g.has(F)&&g.get(F).push(Y),g.has(Y)&&g.get(Y).push(F)}for(let S=0;S<12;S++){let F=!1;for(const[Y,X]of g){let A=0,D=0,Z=0;for(const ie of X){const he=h(ie);he&&(A+=he[0],D+=he[1],Z++)}if(!Z)continue;const se=A/Z,de=D/Z,ee=m.get(Y);(!ee||Math.abs(ee[0]-se)>.01||Math.abs(ee[1]-de)>.01)&&(m.set(Y,[se,de]),F=!0)}if(!F)break}const x=new Map;for(const[S]of r)x.set(S,0);for(const S of c)for(const F of S.ends){const Y=x.get(F);Y!==void 0&&x.set(F,Y+1)}for(const[S,F]of r)t.junctions.set(S,{junction:F,world:m.get(S)??[0,0],degree:x.get(S)??0});const k=new ms;for(const S of c)k.add(S.ends[0]),k.add(S.ends[1]),k.union(S.ends[0],S.ends[1]);for(const[,S]of k.groups()){const F=V$(S);t.nodes.set(F,{id:F,terminals:S});for(const Y of S)t.terminalToNode.set(Y,F)}for(const S of t.elements.values()){const F=t.elementToTerminals.get(S.element.id)??[];if(F.length===0)continue;F.some(X=>t.terminalToNode.has(X))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:S.element.id})})}for(const S of t.buses.keys())t.terminalToNode.has(S)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:S})});for(const S of t.junctions.keys())t.terminalToNode.has(S)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:S})});for(const S of c){if(S.path&&S.path.length>=2){const Y=S.path,X=Y.length>=2?Y[1]:null,A=Y.length>=2?Y[Y.length-2]:null,D=Yo(S.ends[0],X,t),Z=Yo(S.ends[1],A,t);if(D&&Z){const se=[[D[0],D[1]],...Y.slice(1,-1).map(ee=>[ee[0],ee[1]]),[Z[0],Z[1]]],de=ds(se);if(de.length>=2){t.wireRenders.set(S.id,{wireId:S.id,path:de,userEdited:!0,...S.label?{label:S.label}:{}});continue}}}const F=T2(S,t);F&&t.wireRenders.set(S.id,S.label?{...F,label:S.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 b=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 x=(g=s.junctions.get(p.id))==null?void 0:g.world;x&&(h.layout={at:[x[0],x[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 x=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}:{}}}),k=er(u.wires??[],x);return{...u,elements:[...u.elements,...m],buses:p.length?[...u.buses??[],...p]:u.buses,junctions:h.length?[...u.junctions??[],...h]:u.junctions,wires:k.length?k: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 x=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)??x.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),x=l(h.at);if(!g)return x;const k=(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(k,[v(g.ends[0],x),v(x,g.ends[1])])},x},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)=>{b.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=b.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),x=g?[me(t[0])-g.x,me(t[1])-g.y]:[me(t[0]),me(t[1])];return{newElementId:o.addElement(e,x),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 x={id:f,kind:e},k={at:h},v=`${f}.${c}`,O={id:Qe(i,v),ends:[i,v]};return{...g,elements:[...g.elements,x],wires:[...g.wires??[],O],layout:{...g.layout??{},[f]:k}}}),o.setSelection([f]),{newElementId:f,attachedToBus:!0}}function oS(e,t){const n=b.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=b.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])),x=i[1],k=t[1]>=x?"s":"n";return{ref:e,world:[g,x],orientation:k,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=b.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 x={id:h,kind:e},k={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,x],wires:[...g.wires??[],L],layout:{...g.layout??{},[h]:k}}}),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=b(r=>r.internal.elements),t=b(r=>r.internal.layout),n=b(r=>r.internal.wireRenders),o=b(r=>{var i;return((i=r.diagram.meta)==null?void 0:i.labelMode)??"all"}),s=b(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=b.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=b(o=>o.diagram.annotations),t=b(o=>o.selectedAnnotation),n=b(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=b.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=b(f=>f.selection),t=b(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=b.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 x=s==="x"?[u.startAt[0]+h/2,u.startAt[1]]:[u.startAt[0],u.startAt[1]+h/2];b.getState().updateBus(n,{span:g,at:x})},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=b(a=>a.selectedWire),t=b(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=b(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=b.getState().internal.wireRenders.get(e);g&&(r.current={pointerId:h.pointerId,startPath:g.path.map(x=>[x[0],x[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 x=s.screenToSvg(h.clientX,h.clientY),k=g.startPath,v=g.index;if(v<=0||v>=k.length-1)return;const O=k[v],L=[g.xLocked?O[0]:me(O[0]+(x[0]-g.startSvg[0])),g.yLocked?O[1]:me(O[1]+(x[1]-g.startSvg[1]))];if(L[0]===O[0]&&L[1]===O[1])return;const W=k.map(F=>[F[0],F[1]]);W[v]=L;const G=jt(k[v-1],k[v]);v-1>0&&(G==="h"?W[v-1]=[k[v-1][0],L[1]]:W[v-1]=[L[0],k[v-1][1]]);const S=jt(k[v],k[v+1]);v+1<k.length-1&&(S==="h"?W[v+1]=[k[v+1][0],L[1]]:W[v+1]=[L[0],k[v+1][1]]),b.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=b.getState().internal.wireRenders.get(e);if(!g||g.path.length<=2||t<=0||t>=g.path.length-1)return;const x=g.path.filter((k,v)=>v!==t);b.getState().updateWirePath(e,x)};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=b(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=b.getState().internal.wireRenders.get(e);g&&(s.current={pointerId:h.pointerId,startPath:g.path.map(x=>[x[0],x[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 x=o.screenToSvg(h.clientX,h.clientY),k=g.startPath,v=g.segIndex;if(v>=k.length-1)return;const O=k[v],L=k[v+1],W=[];for(let G=0;G<=v;G++)W.push(k[G]);if(g.axis==="h"){const G=me(O[1]+(x[1]-g.startSvg[1]));W.push([O[0],G]),W.push([L[0],G])}else{const G=me(O[0]+(x[0]-g.startSvg[0]));W.push([G,O[1]]),W.push([G,L[1]])}for(let G=v+1;G<k.length;G++)W.push(k[G]);b.getState().updateWirePath(e,W)},p=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId)return;const x=h.currentTarget;x.hasPointerCapture(h.pointerId)&&x.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=b(a=>a.internal.buses),t=b(a=>a.selection),n=b(a=>a.selectedNode),o=b(a=>a.internal.nodes),s=b(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],x=c==="x"?f[1]:f[1]+m,k=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,G=c==="x"?f[1]-L:f[1]-m,S=c==="x"?u:Sn,F=c==="x"?Sn:u;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":O,"data-selected":k?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:W,y:G,width:S,height:F,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:x,stroke:"currentColor",strokeWidth:xS,strokeLinecap:"round",fill:"none"})]},a.id)})})}function wS(){const e=b(a=>a.busbarDrawStart),t=b(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=b(a=>a.internal.junctions),t=b(a=>a.selection),n=b(a=>a.selectedNode),o=b(a=>a.internal.nodes),s=b(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,degree:c})=>{const f=s.get(a.id)??void 0,u=t.length===1&&t[0]===a.id,m=l[0]+_S,p=l[1]+$S;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":f,"data-solder":c>=3?"true":void 0,"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"}),u&&d.jsxs("g",{className:"ole-junction-wire-handle-group",children:[d.jsx("line",{x1:l[0],y1:l[1],x2:m,y2:p,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:m,cy:p,r:jS,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:m,cy:p,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=b(a=>a.internal.elements),t=b(a=>a.internal.layout),n=b(a=>a.selection),o=b(a=>a.selectedNode),s=b(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=b(c=>c.activeTool),t=b(c=>c.placeKind),n=b(c=>c.cursorSvg),o=b(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=b(s=>s.selection),t=b(s=>s.internal.elements),n=b(s=>s.internal.layout),o=b(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,x=c==="x"?8:u;return d.jsx("rect",{x:p,y:h,width:g,height:x,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=b(r=>r.internal.terminals),t=b(r=>r.internal.terminalToNode),n=b(r=>r.wireFromTerminal),o=b(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,x)=>p(g)-p(x));for(const g of h){const x=p(g),k=Math.max(0,x-sr),v=Math.min(f,x+sr);o.push([r[0]+u*k,r[1]+m*k]),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=b(c=>c.internal.wireRenders),t=b(c=>c.internal.terminalToNode),n=b(c=>c.diagram.wires),o=b(c=>c.selectedWire),s=b(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 x=g.get(h.i)??[];x.push(p),g.set(h.i,x)}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,x=l.get(c.wireId),k=x?zS(f,x):[f];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,className:"ole-wire-hit",points:u},`hit-${c.wireId}`),...k.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=b(l=>l.wireDragFrom),t=b(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=b.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)||b.getState().readOnly)return;const n=t.metaKey||t.ctrlKey,o=b.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=b.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=b.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=b.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=b.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=b.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,ye=null;const oj={id:"select",cursor:"default",onPointerDown(e,t){var h,g,x,k,v,O,L,W,G,S,F,Y;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=b.getState(),o=Jt(e.target);if(o){e.preventDefault(),e.stopPropagation();const X=(h=n.diagram.annotations)==null?void 0:h.find(A=>A.id===o);if(!X)return;n.setSelectedAnnotation(o),ye={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[X.at[0],X.at[1]],moved:!1};return}const s=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(s){const X=(g=s.closest("[data-junction-id]"))==null?void 0:g.getAttribute("data-junction-id");if(X){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((k=(x=e.target).hasPointerCapture)!=null&&k.call(x,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(X);const A=(v=n.internal.junctions.get(X))==null?void 0:v.world;A&&n.setWireDragFrom({spec:{end:X},world:A,ref:X}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:X};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 X=i.indexOf("."),A=X>0?i.slice(0,X):"";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=(G=n.internal.terminals.get(i))==null?void 0:G.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 X=Gn(e.target);if(X&&typeof document<"u"){const A=document.elementsFromPoint(e.clientX,e.clientY);for(const D of A){const Z=(F=(S=D.closest)==null?void 0:S.call(D,"[data-bus-id]"))==null?void 0:F.getAttribute("data-bus-id");if(!Z)continue;const se=(Y=n.diagram.wires)==null?void 0:Y.find(de=>de.id===X);se&&(se.ends[0]===Z||se.ends[1]===Z)&&(a=Z);break}}}if(!a){const X=Gn(e.target);if(X){if(e.preventDefault(),e.altKey){const A=ln(e.target);if(A){n.setSelectedNode(A);return}}n.setSelectedWire(X);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?b.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const f=b.getState().internal,u=new Map,m=new Map,p=new Map;for(const X of c){const A=f.buses.get(X);if(A){m.set(X,[A.geometry.at[0],A.geometry.at[1]]);continue}const D=f.junctions.get(X);if(D){p.set(X,[D.world[0],D.world[1]]);continue}const Z=f.layout.get(X);Z&&u.set(X,{...Z})}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(ye&&e.pointerId===ye.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-ye.startSvg[0]),s=me(n[1]-ye.startSvg[1]);!ye.moved&&(o!==0||s!==0)&&(ye.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const r=t.hostEl.querySelector(`[data-annotation-id="${Be(ye.id)}"]`);r&&r.setAttribute("transform",`translate(${o} ${s})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);b.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(ye&&e.pointerId===ye.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=me(n[0]-ye.startSvg[0]),s=me(n[1]-ye.startSvg[1]),r=t.hostEl.querySelector(`[data-annotation-id="${Be(ye.id)}"]`);r&&r.removeAttribute("transform"),ye.moved&&(o!==0||s!==0)&&b.getState().updateAnnotation(ye.id,{at:[ye.origin[0]+o,ye.origin[1]+s]}),ye=null;return}if(je&&e.pointerId===je.pointerId){const n=b.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]);b.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);b.getState().setSelection([...r])}else b.getState().setSelection(s)}Ft(null),Me=null}},onPointerCancel(e,t){var n,o,s,r,i,a;if(ye&&e.pointerId===ye.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(ye.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ye=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=b.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=b.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,ye=null,je){e.hostEl.classList.remove("tool-wire");const t=b.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}=b.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=b.getState().readOnly?null:ct(e.target);let s=null;if(o){const r=b.getState();r.selection.includes(o)||r.setSelection([o]);const i=b.getState().selection,a=b.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]);b.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&&!b.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=b.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()&&b.getState().setActiveTool("pan")}function fj(){Aw()&&b.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=b.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=b.getState();r.setWireDragFrom({spec:s.spec,world:s.world,ref:s.ref}),r.setWireFromTerminal(s.ref),r.setCursorSvg(n)},onPointerMove(e,t){const n=b.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=b.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=b.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=b.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),kt=!1},onPointerDown(e,t){var r,i;if(e.button!==0)return;const{placeKind:n}=b.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=b.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);b.getState().setCursorSvg([mr(n[0]),mr(n[1])])},onPointerUp(e,t){const n=b.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=b.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=b.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])];b.getState().setBusbarDrawStart(o),b.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);b.getState().setCursorSvg([st(n[0]),st(n[1])])},onPointerUp(e,t){const n=b.getState().busbarDrawStart;if(b.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]}b.getState().addBus(u,f,c),cn()},onPointerLeave(){const e=b.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=b.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=b.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);b.getState().addJunction([yr(n[0]),yr(n[1])]),cn()}},yj={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=b.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=b(s=>s.activeTool),o=b(s=>s.readOnly);I.useEffect(()=>{var h;const s=e.current;if(!s)return;const r=o?"pan":n,i=o?xr.pan:xr[n],a={viewport:t,hostEl:s};s.dataset.tool=r,(h=i.onActivate)==null||h.call(i,a),i.cursor&&(s.style.cursor=i.cursor);const l=g=>{var x;return(x=i.onPointerDown)==null?void 0:x.call(i,g,a)},c=g=>{var x;return(x=i.onPointerMove)==null?void 0:x.call(i,g,a)},f=g=>{var x;return(x=i.onPointerUp)==null?void 0:x.call(i,g,a)},u=g=>{var x;return i.onPointerCancel?i.onPointerCancel(g,a):(x=i.onPointerUp)==null?void 0:x.call(i,g,a)},m=g=>{var x;return(x=i.onPointerLeave)==null?void 0:x.call(i,g,a)},p=g=>{var x;return(x=i.onDoubleClick)==null?void 0:x.call(i,g,a)};return s.addEventListener("pointerdown",l),s.addEventListener("pointermove",c),s.addEventListener("pointerup",f),s.addEventListener("pointercancel",u),s.addEventListener("pointerleave",m),s.addEventListener("dblclick",p),()=>{var g;s.removeEventListener("pointerdown",l),s.removeEventListener("pointermove",c),s.removeEventListener("pointerup",f),s.removeEventListener("pointercancel",u),s.removeEventListener("pointerleave",m),s.removeEventListener("dblclick",p),(g=i.onDeactivate)==null||g.call(i,a),s.style.cursor="",delete s.dataset.tool}},[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,x=!1;const k=()=>{if(h.size<2){g=null;return}const A=[...h.values()],D=A[1].x-A[0].x,Z=A[1].y-A[0].y,se=Math.hypot(D,Z)||1,de=i.getBoundingClientRect();g={startDist:se,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&&!x){x=!0;for(const D of h.keys())D!==A.pointerId&&jw(i,D);k()}if(x){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}),!x||!g))return;A.stopPropagation();const D=[...h.values()];if(D.length<2)return;const Z=D[1].x-D[0].x,se=D[1].y-D[0].y,de=Math.hypot(Z,se)||1,ee=i.getBoundingClientRect(),ie=(D[0].x+D[1].x)/2-ee.left,he=(D[0].y+D[1].y)/2-ee.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+(ie-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ne+(he-g.startMidY),o.current.scale=_e,r()},L=A=>{var D;if(A.pointerType==="touch"&&h.has(A.pointerId)&&(h.delete(A.pointerId),x)){if(A.stopPropagation(),(D=i.hasPointerCapture)!=null&&D.call(i,A.pointerId))try{i.releasePointerCapture(A.pointerId)}catch{}h.size>=2?k():g=null,h.size===0&&(x=!1)}},W=A=>{A.preventDefault();const D=i.getBoundingClientRect(),Z=A.clientX-D.left,se=A.clientY-D.top,de=A.ctrlKey||A.metaKey;if(A.deltaX===0||de){const he=Math.pow(de?_j:kj,-A.deltaY),xe=Nn(o.current.scale*he,jn,En),_e=xe/o.current.scale;o.current.tx=Z-(Z-o.current.tx)*_e,o.current.ty=se-(se-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=A.deltaX,o.current.ty-=A.deltaY;r()},G=A=>{const D=A.button===1,Z=p&&A.button===0;!D&&!Z||(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")},S=A=>{!a||A.pointerId!==l||(o.current.tx=u+(A.clientX-c),o.current.ty=m+(A.clientY-f),r())},F=A=>{a&&A.pointerId===l&&(a=!1,i.releasePointerCapture(A.pointerId),i.style.cursor=p?"grab":"")},Y=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()}},X=A=>{A.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",W,{passive:!1}),i.addEventListener("pointerdown",G),i.addEventListener("pointermove",S),i.addEventListener("pointerup",F),i.addEventListener("pointercancel",F),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",Y),window.addEventListener("keyup",X),r(),()=>{i.removeEventListener("wheel",W),i.removeEventListener("pointerdown",G),i.removeEventListener("pointermove",S),i.removeEventListener("pointerup",F),i.removeEventListener("pointercancel",F),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",Y),window.removeEventListener("keyup",X)}},[]),{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=b.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 G=ln(m);G&&p.selectedNode!==G&&p.setSelectedNode(G)}const x=b.getState(),k=x.selection.length>0,v=x.selectedNode!=null,O=!!x.clipboard,L=x.diagram.elements.length>0,W=[{label:e("menu.undo"),shortcut:`${it}Z`,icon:eo,onSelect:()=>b.getState().undo(),disabled:x.past.length===0},{label:e("menu.redo"),shortcut:`${it}${Sj}Z`,icon:Qn,onSelect:()=>b.getState().redo(),disabled:x.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${it}X`,icon:Kr,onSelect:()=>b.getState().cutSelection(),disabled:!k},{label:e("menu.copy"),shortcut:`${it}C`,icon:qr,onSelect:()=>b.getState().copySelection(),disabled:!k},{label:e("menu.paste"),shortcut:`${it}V`,icon:Hr,onSelect:()=>b.getState().pasteClipboard(),disabled:!O},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Yr,onSelect:()=>b.getState().rotateSelection(90),disabled:!k},{label:e("menu.mirror"),shortcut:"M",icon:Gr,onSelect:()=>b.getState().mirrorSelection(),disabled:!k},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${it}A`,icon:Bv,onSelect:()=>{const G=b.getState();G.setSelection(G.diagram.elements.map(S=>S.id))},disabled:!L},{type:"separator"},{label:e(v&&!k?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Ur,destructive:!0,onSelect:()=>v&&!k?b.getState().deleteSelectedNode():b.getState().deleteSelection(),disabled:!k&&!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},x=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))},k=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",x),f.addEventListener("pointermove",k),f.addEventListener("pointerup",v),f.addEventListener("pointercancel",v),()=>{g(),f.removeEventListener("pointerdown",x),f.removeEventListener("pointermove",k),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(b.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 k of o){const v=k.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,x=(c+u)/2;return e.setViewport({tx:n.width/2-h*g,ty:n.height/2-h*x,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=b(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(I.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,x=-1;const k=()=>{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 G=L.left+L.width/2-O.offsetWidth/2;G=Math.max(4,Math.min(G,window.innerWidth-O.offsetWidth-4)),(W!==g||G!==x)&&(r({top:W,left:G}),g=W,x=G)}h=requestAnimationFrame(k)};return h=requestAnimationFrame(k),()=>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,x]=h;return Array.isArray(x)?x.includes({...r,...a}[g]):{...r,...a}[g]===x})?[...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 k=s.current.getBoundingClientRect(),v=r.current.getBoundingClientRect(),O=8;let L="top",W=k.top-v.height-O;W<4&&(L="bottom",W=k.bottom+O);let G=k.left+k.width/2-v.width/2;G=Math.max(4,Math.min(G,window.innerWidth-v.width-4)),c({top:W,left:G,side:L})},[i,e]),I.useEffect(()=>()=>window.clearTimeout(u.current),[]),I.useEffect(()=>{if(!i)return;const k=O=>{O.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",k),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",k),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const h=t,g=h.props,x=I.cloneElement(h,{ref:k=>{s.current=k;const v=h.ref;typeof v=="function"?v(k):v&&typeof v=="object"&&(v.current=k)},onPointerEnter:k=>{var v;(v=g.onPointerEnter)==null||v.call(g,k),m()},onPointerLeave:k=>{var v;(v=g.onPointerLeave)==null||v.call(g,k),p()},onFocus:k=>{var v;(v=g.onFocus)==null||v.call(g,k),m()},onBlur:k=>{var v;(v=g.onBlur)==null||v.call(g,k),p()},"aria-describedby":i?f:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[x,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 k;const e=ce(),t=b(v=>v.selection),n=b(v=>v.selectedNode),o=b(v=>v.selectedWire),s=b(v=>v.activeTool),r=b(v=>v.rotateSelection),i=b(v=>v.mirrorSelection),a=b(v=>v.deleteSelection),l=b(v=>v.deleteSelectedNode),c=b(v=>v.deleteSelectedWire),f=b(v=>v.resetWirePath),u=b(v=>v.internal.wireRenders),m=o!=null&&((k=u.get(o))==null?void 0:k.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 S=0,F="";const Y=()=>{let X=1/0,A=-1/0,D=1/0,Z=-1/0,se=!1;const de=ee=>{ee.width===0&&ee.height===0||(ee.left<X&&(X=ee.left),ee.right>A&&(A=ee.right),ee.top<D&&(D=ee.top),ee.bottom>Z&&(Z=ee.bottom),se=!0)};if(O)for(const ee of t){const ie=document.querySelector(`[data-element-id="${CSS.escape(ee)}"]`);ie&&de(ie.getBoundingClientRect())}else if(L&&o){const ee=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ee&&de(ee.getBoundingClientRect())}else if(W&&n){const ee=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const ie of ee)de(ie.getBoundingClientRect())}if(se){const ee=(X+A)/2;let ie=D-Sr,he="-100%";ie<Jj&&(ie=Z+Sr,he="0%");const xe=`translate3d(${ee}px, ${ie}px, 0) translate(-50%, ${he})`;xe!==F&&(v.style.transform=xe,F=xe)}S=requestAnimationFrame(Y)};return S=requestAnimationFrame(Y),()=>cancelAnimationFrame(S)},[t,n,o,s]);const h=t.length===0&&o!=null,g=t.length===0&&!h&&n!=null,x=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"})]}),!x&&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=b.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=b(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!b(n=>n.readOnly)&&Pe(e,"dense")?null:d.jsx(l4,{tier:e})}function l4({tier:e}){const t=Pe(e,"tight"),n=b(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=b(f=>f.activeTool),n=b(f=>f.placeKind),o=b(f=>f.placeFromTerminal),s=b(f=>f.wireDragFrom),r=b(f=>f.busbarDrawStart),i=b(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=b(h=>h.activeTool),n=b(h=>h.placeKind),o=b(h=>h.setActiveTool),s=b(h=>h.past.length),r=b(h=>h.future.length),i=b(h=>h.undo),a=b(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,x=p(h),k=h.id==="place"&&x&&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:x,iconOnly:!u&&(h.iconOnly||c),stacked:u,description:k,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=b(s=>s.diagram.elements),t=b(s=>s.diagram.layout),n=b(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(()=>b.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!s.hasAnyElement||!s.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Ae,{onClick:r(()=>b.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(()=>b.getState().fillUnplacedAll()),icon:d.jsx(Yt,{}),disabled:!s.hasGapsAll,children:t("layout.allFill")}),d.jsx(Ae,{onClick:r(()=>b.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=b(m=>m.past.length),r=b(m=>m.future.length),i=b(m=>m.undo),a=b(m=>m.redo),l=b(m=>m.selection.length>0),c=b(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(()=>b.getState().cutSelection()),icon:d.jsx(Kr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Ae,{onClick:u(()=>b.getState().copySelection()),icon:d.jsx(qr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Ae,{onClick:u(()=>b.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(()=>b.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!f.hasAnyElement||!f.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Ae,{onClick:u(()=>b.getState().autoArrangeSelection()),icon:d.jsx($t,{}),disabled:!f.hasSelection||!f.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Ae,{onClick:u(()=>b.getState().fillUnplacedAll()),icon:d.jsx(Yt,{}),disabled:!f.hasGapsAll,children:t("layout.allFill")}),d.jsx(Ae,{onClick:u(()=>b.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=b(c=>c.diagram.elements),s=b(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=b(l=>l.selection.includes(e.id)),o=b(l=>l.setSelection),s=b(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=b(u=>u.activeTool==="place"),n=b(u=>u.placeKind),o=b(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(x=>{const k=n(`${x.id}.name`,x.name).toLowerCase(),v=n(`${x.id}.desc`,x.description??"").toLowerCase();return k.includes(u)||x.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 x;const m=a[u];if(!(m!=null&&m.length))return null;const p=((x=Mt[u])==null?void 0:x.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:k=>{l||f(u,k.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(k=>d.jsx(N4,{entry:k,sheet:e},k.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=b(u=>u.setActiveTool),a=b(u=>u.activeTool==="place"&&u.placeKind===e.id),l=b(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=b(m=>m.selection),n=b(m=>m.diagram.elements),o=b(m=>m.diagram.buses),s=b(m=>m.diagram.junctions),r=b(m=>m.selectedNode),i=b(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=>b.getState().updateElement(a,{name:m.trim()===""?void 0:m.trim()})}),d.jsx(lo,{label:e("props.note"),value:f.note??"",onCommit:m=>b.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,b.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,b.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){b.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=b(x=>x.diagram.wires),o=b(x=>x.diagram.elements),s=b(x=>x.diagram.buses),r=b(x=>x.diagram.junctions),i=b(x=>x.internal.terminalToNode),a=b(x=>x.setSelectedNode),l=(n??[]).find(x=>x.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(x=>[x.id,x])),u=new Map((s??[]).map(x=>[x.id,x])),m=new Map((r??[]).map(x=>[x.id,x])),p=x=>{if(!x.includes(".")){const W=u.get(x);if(W)return{id:x,label:W.name??x};const G=m.get(x);return{id:x,label:(G==null?void 0:G.name)??x}}const k=x.indexOf("."),v=x.slice(0,k),O=x.slice(k+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:x=>b.getState().updateWire(e,{label:x.trim()===""?void 0:x.trim()})}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((x,k)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>b.getState().setSelection([x.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:x.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:x.label}),x.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:x.pin})]},k))}),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=b(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=>b.getState().updateJunction(e.id,{name:r.trim()===""?void 0:r.trim()})}),d.jsx(lo,{label:t("props.note"),value:e.note??"",onCommit:r=>b.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=b(a=>a.internal.nodes.get(e)),o=b(a=>a.diagram.elements),s=b(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,b.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=b(u=>u.selection),o=b(u=>u.selectedNode),s=b(u=>u.selectedWire),r=b(u=>u.diagram.elements),i=b(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=b(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(()=>{b.getState().setReadOnly(!!n)},[n]),I.useEffect(()=>{if(!t)return;if(n){b.getState().setDiagram(t),b.getState().setActiveTool("pan");return}b.getState().diagram.elements.length===0&&b.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
|
-
|
|
200
|
-
|
|
196
|
+
*/const Cs=se("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"}]]);/**
|
|
197
|
+
* @license lucide-react v0.469.0 - ISC
|
|
198
|
+
*
|
|
199
|
+
* This source code is licensed under the ISC license.
|
|
200
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
+
*/const Ps=se("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"}]]);/**
|
|
202
|
+
* @license lucide-react v0.469.0 - ISC
|
|
203
|
+
*
|
|
204
|
+
* This source code is licensed under the ISC license.
|
|
205
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
+
*/const Eo=se("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"}]]);/**
|
|
207
|
+
* @license lucide-react v0.469.0 - ISC
|
|
208
|
+
*
|
|
209
|
+
* This source code is licensed under the ISC license.
|
|
210
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
+
*/const It=se("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
|
|
212
|
+
* @license lucide-react v0.469.0 - ISC
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the ISC license.
|
|
215
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/const Sn=se("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Is(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=Is(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Os(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Is(e))&&(o&&(o+=" "),o+=t);return o}const No="-",A2=e=>{const t=M2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(No);return a[0]===""&&a.length!==1&&a.shift(),Bs(a,t)||T2(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Bs=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Bs(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(No);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},ir=/^\[(.+)\]$/,T2=e=>{if(ir.test(e)){const t=ir.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},M2=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return P2(Object.entries(e.classGroups),n).forEach(([s,i])=>{oo(i,o,s,t)}),o},oo=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:ar(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(C2(r)){oo(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{oo(i,ar(t,s),n,o)})})},ar=(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},C2=e=>e.isThemeGetter,P2=(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,I2=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)}}},Ls="!",O2=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,u=0,f;for(let x=0;x<a.length;x++){let w=a[x];if(c===0){if(w===r&&(o||a.slice(x,x+s)===t)){l.push(a.slice(u,x)),u=x+s;continue}if(w==="/"){f=x;continue}}w==="["?c++:w==="]"&&c--}const h=l.length===0?a:a.substring(u),g=h.startsWith(Ls),m=g?h.substring(1):h,p=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:i}):i},B2=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},L2=e=>({cache:I2(e.cacheSize),parseClassName:O2(e),...A2(e)}),D2=/\s+/,z2=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(D2);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:g}=n(c);let m=!!g,p=o(m?h.substring(0,g):h);if(!p){if(!m){a=c+(a.length>0?" "+a:a);continue}if(p=o(h),!p){a=c+(a.length>0?" "+a:a);continue}m=!1}const x=B2(u).join(":"),w=f?x+Ls:x,v=w+p;if(s.includes(v))continue;s.push(v);const M=r(p,m);for(let I=0;I<M.length;++I){const F=M[I];s.push(w+F)}a=c+(a.length>0?" "+a:a)}return a};function R2(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ds(t))&&(o&&(o+=" "),o+=n);return o}const Ds=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Ds(e[o]))&&(n&&(n+=" "),n+=t);return n};function F2(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((u,f)=>f(u),e());return n=L2(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const u=z2(l,n);return r(l,u),u}return function(){return s(R2.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},zs=/^\[(?:([a-z-]+):)?(.+)\]$/i,H2=/^\d+\/\d+$/,W2=new Set(["px","full","screen"]),q2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,X2=/\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$/,Y2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,G2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,K2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Re=e=>mt(e)||W2.has(e)||H2.test(e),Je=e=>bt(e,"length",nk),mt=e=>!!e&&!Number.isNaN(Number(e)),zn=e=>bt(e,"number",mt),Et=e=>!!e&&Number.isInteger(Number(e)),U2=e=>e.endsWith("%")&&mt(e.slice(0,-1)),re=e=>zs.test(e),Ze=e=>q2.test(e),V2=new Set(["length","size","percentage"]),J2=e=>bt(e,V2,Rs),Z2=e=>bt(e,"position",Rs),Q2=new Set(["image","url"]),ek=e=>bt(e,Q2,rk),tk=e=>bt(e,"",ok),Nt=()=>!0,bt=(e,t,n)=>{const o=zs.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},nk=e=>X2.test(e)&&!Y2.test(e),Rs=()=>!1,ok=e=>G2.test(e),rk=e=>K2.test(e),sk=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),o=ge("brightness"),r=ge("borderColor"),s=ge("borderRadius"),i=ge("borderSpacing"),a=ge("borderWidth"),l=ge("contrast"),c=ge("grayscale"),u=ge("hueRotate"),f=ge("invert"),h=ge("gap"),g=ge("gradientColorStops"),m=ge("gradientColorStopPositions"),p=ge("inset"),x=ge("margin"),w=ge("opacity"),v=ge("padding"),M=ge("saturate"),I=ge("scale"),F=ge("sepia"),G=ge("skew"),$=ge("space"),H=ge("translate"),W=()=>["auto","contain","none"],X=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",re,t],R=()=>[re,t],Z=()=>["",Re,Je],ie=()=>["auto",mt,re],ue=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ee=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],be=()=>["","0",re],$e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Me=()=>[mt,re];return{cacheSize:500,separator:":",theme:{colors:[Nt],spacing:[Re,Je],blur:["none","",Ze,re],brightness:Me(),borderColor:[e],borderRadius:["none","","full",Ze,re],borderSpacing:R(),borderWidth:Z(),contrast:Me(),grayscale:be(),hueRotate:Me(),invert:be(),gap:R(),gradientColorStops:[e],gradientColorStopPositions:[U2,Je],inset:P(),margin:P(),opacity:Me(),padding:R(),saturate:Me(),scale:Me(),sepia:be(),skew:Me(),space:R(),translate:R()},classGroups:{aspect:[{aspect:["auto","square","video",re]}],container:["container"],columns:[{columns:[Ze]}],"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:[...ue(),re]}],overflow:[{overflow:X()}],"overflow-x":[{"overflow-x":X()}],"overflow-y":[{"overflow-y":X()}],overscroll:[{overscroll:W()}],"overscroll-x":[{"overscroll-x":W()}],"overscroll-y":[{"overscroll-y":W()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Et,re]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",re]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",Et,re]}],"grid-cols":[{"grid-cols":[Nt]}],"col-start-end":[{col:["auto",{span:["full",Et,re]},re]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[Nt]}],"row-start-end":[{row:["auto",{span:[Et,re]},re]}],"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",re]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",re]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"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:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",re,t]}],"min-w":[{"min-w":[re,t,"min","max","fit"]}],"max-w":[{"max-w":[re,t,"none","full","min","max","fit","prose",{screen:[Ze]},Ze]}],h:[{h:[re,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[re,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ze,Je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zn]}],"font-family":[{font:[Nt]}],"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",re]}],"line-clamp":[{"line-clamp":["none",mt,zn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Re,re]}],"list-image":[{"list-image":["none",re]}],"list-style-type":[{list:["none","disc","decimal",re]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Re,Je]}],"underline-offset":[{"underline-offset":["auto",Re,re]}],"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:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",re]}],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",re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ue(),Z2]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",J2]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ek]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...ee(),"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":[w]}],"divide-style":[{divide:ee()}],"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:["",...ee()]}],"outline-offset":[{"outline-offset":[Re,re]}],"outline-w":[{outline:[Re,Je]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[Re,Je]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ze,tk]}],"shadow-color":[{shadow:[Nt]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ze,re]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[F]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[F]}],"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",re]}],duration:[{duration:Me()}],ease:[{ease:["linear","in","out","in-out",re]}],delay:[{delay:Me()}],animate:[{animate:["none","spin","ping","pulse","bounce",re]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[Et,re]}],"translate-x":[{"translate-x":[H]}],"translate-y":[{"translate-y":[H]}],"skew-x":[{"skew-x":[G]}],"skew-y":[{"skew-y":[G]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",re]}],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",re]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",re]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Re,Je,zn]}],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"]}}},ik=F2(sk);function _e(...e){return ik(Os(e))}const Fs=C.createContext(null);function ak(){const e=C.useContext(Fs);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const en=8;function lk({children:e}){const[t,n]=C.useState({open:!1,x:0,y:0,items:[]}),[o,r]=C.useState(null),s=C.useRef(null),i=C.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=C.useCallback((c,u,f)=>{r(null),n({open:!0,x:c,y:u,items:f})},[]),l=C.useMemo(()=>({open:a,close:i}),[a,i]);return C.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+c.width>window.innerWidth-en&&(u=Math.max(en,t.x-c.width)),f+c.height>window.innerHeight-en&&(f=Math.max(en,t.y-c.height)),r({left:u,top:f})},[t]),C.useEffect(()=>{if(!t.open)return;const c=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},f=()=>i(),h=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",h),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",h)}},[t.open,i]),d.jsxs(Fs.Provider,{value:l,children:[e,t.open&&d.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:c=>c.preventDefault(),children:t.items.map((c,u)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:_e("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",c.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",c.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),c.onSelect()},children:[d.jsxs("span",{className:"flex items-center gap-2",children:[f?d.jsx(f,{className:"size-4"}):null,d.jsx("span",{children:c.label})]}),c.shortcut?d.jsx("span",{className:"text-xs text-muted-foreground",children:c.shortcut}):null]},`${c.label}-${u}`)})})]})}const lr=e=>{let t;const n=new Set,o=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},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},ck=(e=>e?lr(e):lr),dk=e=>e;function uk(e,t=dk){const n=C.useSyncExternalStore(e.subscribe,C.useCallback(()=>t(e.getState()),[e,t]),C.useCallback(()=>t(e.getInitialState()),[e,t]));return C.useDebugValue(n),n}const cr=e=>{const t=ck(e),n=o=>uk(t,o);return Object.assign(n,t),n},$n=(e=>e?cr(e):cr),dr={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":"选中整个电气节点","props.annText":"文字","props.annRect":"矩形","props.annLine":"线条","props.annTable":"表格","props.annNotFound":"标注 {id} 不存在","props.annLabel":"标签","props.annLabelPlaceholder":"如:1#配电柜","props.annStroke":"线型","props.annStrokeSolid":"实线","props.annStrokeDashed":"虚线","props.annFill":"填充","props.annFillNone":"无","props.annFillTint":"浅色","props.annArrow":"箭头","props.annArrowNone":"无","props.annArrowEnd":"单向","props.annArrowBoth":"双向","props.annFontSize":"字号","props.annRows":"行数","props.annCols":"列数","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":"点击画布放置一段文字注释;双击文字可重新编辑","tool.rect":"矩形","tool.rectHint":"拖动绘制矩形 / 分组框(默认虚线);按住 Shift 画正方形","tool.line":"线条","tool.lineHint":"拖动绘制标注线;按住 Shift 按 45° 约束;箭头在属性面板设置","tool.table":"表格","tool.tableHint":"拖动扫出行列(实时显示 列×行),或单击放置默认表格;双击单元格填写","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.rect":"拖动绘制矩形;Shift 正方形;释放后可拉伸并在属性面板加标签","mode.line":"拖动绘制线条;Shift 按 45° 约束;释放后可在属性面板加箭头","mode.table":"拖动扫出表格行列,或单击放置 3×3 表格;双击单元格填写内容","mode.annTextSel":"单击文字即可编辑 · 拖动移动 · Del 删除","mode.annTableSel":"单击单元格填写内容 · 拖动移动 · Del 删除","mode.annShapeSel":"拖动移动 · 拖动手柄缩放 · 右侧面板改样式 · Del 删除","mode.annEditing":"输入内容 · Enter 确认 · Esc 取消 · 或用 ✓ / ✕ 按钮","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.ariaEdit":"编辑操作","ctx.done":"完成","ctx.cancel":"取消","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","props.annText":"Text","props.annRect":"Rectangle","props.annLine":"Line","props.annTable":"Table","props.annNotFound":"Annotation {id} not found","props.annLabel":"Label","props.annLabelPlaceholder":"e.g. Panel #1","props.annStroke":"Stroke","props.annStrokeSolid":"Solid","props.annStrokeDashed":"Dashed","props.annFill":"Fill","props.annFillNone":"None","props.annFillTint":"Tint","props.annArrow":"Arrows","props.annArrowNone":"None","props.annArrowEnd":"End","props.annArrowBoth":"Both","props.annFontSize":"Font size","props.annRows":"Rows","props.annCols":"Columns","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","tool.rect":"Rectangle","tool.rectHint":"Drag to draw a rectangle / group frame (dashed by default); Shift for a square","tool.line":"Line","tool.lineHint":"Drag to draw an annotation line; Shift snaps to 45°; arrows live in the panel","tool.table":"Table","tool.tableHint":"Drag to sweep out cols × rows (live count), or click for a default table; double-click cells to type","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.rect":"Drag to draw a rectangle · Shift for square · resize and label it after release","mode.line":"Drag to draw a line · Shift snaps to 45° · add arrows in the panel after release","mode.table":"Drag to sweep out the grid, or click for a 3×3 table · double-click cells to type","mode.annTextSel":"Click the text to edit · drag to move · Del to remove","mode.annTableSel":"Click a cell to fill it in · drag to move · Del to remove","mode.annShapeSel":"Drag to move · drag handles to resize · restyle in the panel · Del to remove","mode.annEditing":"Type · Enter to confirm · Esc to cancel · or the ✓ / ✕ buttons","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.ariaEdit":"Editing actions","ctx.done":"Done","ctx.cancel":"Cancel","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"}},Hs="ole-locale";function fk(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Hs);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 ur(e){try{window.localStorage.setItem(Hs,e)}catch{}}const Yt=$n((e,t)=>({locale:fk(),setLocale:n=>{ur(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";ur(n),e({locale:n})}}));function Ws(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function qs(e,t){return dr[e][t]??dr.zh[t]??t}function ve(e,t){return Ws(qs(Yt.getState().locale,e),t)}function le(){const e=Yt(t=>t.locale);return(t,n)=>Ws(qs(e,t),n)}function Xs(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 ro=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return ro(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return ro(o)(n)}}}},hk=(e,t)=>(n,o,r)=>{let s={storage:Xs(()=>window.localStorage),partialize:x=>x,version:0,merge:(x,w)=>({...w,...x}),...t},i=!1,a=0;const l=new Set,c=new Set;let u=s.storage;if(!u)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...x)},o,r);const f=()=>{const x=s.partialize({...o()});return u.setItem(s.name,{state:x,version:s.version})},h=r.setState;r.setState=(x,w)=>(h(x,w),f());const g=e((...x)=>(n(...x),f()),o,r);r.getInitialState=()=>g;let m;const p=()=>{var x,w;if(!u)return;const v=++a;i=!1,l.forEach(I=>{var F;return I((F=o())!=null?F:g)});const M=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(x=o())!=null?x:g))||void 0;return ro(u.getItem.bind(u))(s.name).then(I=>{if(I)if(typeof I.version=="number"&&I.version!==s.version){if(s.migrate){const F=s.migrate(I.state,I.version);return F instanceof Promise?F.then(G=>[!0,G]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,I.state];return[!1,void 0]}).then(I=>{var F;if(v!==a)return;const[G,$]=I;if(m=s.merge($,(F=o())!=null?F:g),n(m,!0),G)return f()}).then(()=>{v===a&&(M==null||M(o(),void 0),m=o(),i=!0,c.forEach(I=>I(m)))}).catch(I=>{v===a&&(M==null||M(void 0,I))})};return r.persist={setOptions:x=>{s={...s,...x},x.storage&&(u=x.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>p(),hasHydrated:()=>i,onHydrate:x=>(l.add(x),()=>{l.delete(x)}),onFinishHydration:x=>(c.add(x),()=>{c.delete(x)})},s.skipHydration||p(),m||g},mk=hk,Fe=.5;function Ys(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])<Fe&&Math.abs(s[1]-e[r][1])<Fe||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>Fe&&l>Fe){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Fe?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<Fe&&Math.abs(i[0]-a[0])<Fe,c=Math.abs(s[1]-i[1])<Fe&&Math.abs(i[1]-a[1])<Fe;l||c||o.push(i)}return o.push(n[n.length-1]),o}function Gs(){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 Ks(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 so(e){return e===90||e===270?"y":"x"}function Ie(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 pk={n:"e",e:"s",s:"w",w:"n"},gk={n:"n",s:"s",e:"w",w:"e"};function Ot(e,t){let n=t.mirror?gk[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=pk[n];return n}function io(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(){jt(this,"parent",new Map);jt(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 fr=["n","e","s","w"],hr={n:"s",s:"n",e:"w",w:"e"};function tn(e,t){const n=fr.indexOf(e),r=((fr.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const Rn=320,nn=220,At=260,Fn=720,Tt=30,mr=30,Qe=80,pr=10,yk=60,xk=520,bk=80,wk=80,gr=8,yr=new Set(["source","renewable"]);function vk(e){var Jo,Zo,Qo,er,tr,nr;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),u=new Map,f=new Set(i.keys()),h=new Set(a.keys()),g=new Map;for(const b of t)g.set(b.id,b);const m=new Map;for(const b of n)m.set(b.id,b);const p=b=>{const k=g.get(b);if(k)return s.get(k.kind)},x=new Set(n.map(b=>b.id)),w=b=>x.has(b),v=new Set(o.map(b=>b.id)),M=new Set(o.filter(b=>{var k;return(k=b.layout)==null?void 0:k.at}).map(b=>b.id)),I=new Us;for(const b of r)I.add(b.ends[0]),I.add(b.ends[1]),I.union(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(k)for(const S of k.terminals)I.add(`${b.id}.${S.id}`)}for(const b of n)I.add(b.id);const F=[];for(const[,b]of I.groups())b.length>=2&&F.push(b);const G=new Map;for(const b of F)for(const k of b)G.set(k,[b]);const $=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of k){const E=b.filter(_=>_!==S),j=$.get(S)??[];j.push(...E),$.set(S,j)}}{const S=T=>g.has(T)&&!!p(T),E=T=>{if(w(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,A=(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 F){const N=[];let L=!1;for(const Y of T){if(w(Y)){L=!0;continue}const te=E(Y);te&&N.push(te)}const D=[...new Set(N)];for(const Y of D)j.has(Y)||j.set(Y,new Set),L&&_.add(Y);const q=D.filter(Y=>v.has(Y)),K=D.filter(Y=>!v.has(Y));if(q.length>0){for(const Y of q)for(const te of K)A(Y,te);for(let Y=0;Y<q.length;Y++)for(let te=Y+1;te<q.length;te++)A(q[Y],q[te])}else for(let Y=0;Y<K.length;Y++)for(let te=Y+1;te<K.length;te++)A(K[Y],K[te])}const z=(T,N)=>{const L=p(T);if(!L)return null;for(const D of L.terminals){const q=`${T}.${D.id}`;for(const K of G.get(q)??[])for(const Y of K)if(E(Y)===N)return D}return null},O=T=>{const N=J=>{var oe;return((oe=j.get(J))==null?void 0:oe.size)??0},L=J=>{var oe;return((oe=p(J))==null?void 0:oe.category)??""},D=J=>{const oe=L(J);return oe==="source"?0:oe==="renewable"?1:2+Math.min(N(J),9)/10},q=T.filter(S).sort((J,oe)=>D(J)-D(oe)||J.localeCompare(oe))[0];if(!q)return;const K=new Map([[q,null]]),Y=new Map([[q,0]]),te=new Map,ne=[],U=[q],V=new Set([q]);for(;U.length;){const J=U.shift();ne.push(J);for(const oe of[...j.get(J)??[]].sort((je,Ee)=>je.localeCompare(Ee)))V.has(oe)||(V.add(oe),K.set(oe,J),Y.set(oe,(Y.get(J)??0)+1),te.has(J)||te.set(J,[]),te.get(J).push(oe),U.push(oe))}let Q=0;const fe=new Map,we=J=>{const oe=te.get(J)??[];if(oe.length===0){fe.set(J,Q++);return}for(const Ee of oe)we(Ee);const je=oe.map(Ee=>fe.get(Ee));fe.set(J,je.reduce((Ee,Qt)=>Ee+Qt,0)/je.length)};we(q);for(const J of ne){const oe=xe(Rn+(fe.get(J)??0)*160),je=xe(nn+(Y.get(J)??0)*140);if(v.has(J)){u.set(J,[oe,je]);continue}let Ee=0;const Qt=K.get(J)??null;if(Qt){const $t=z(J,Qt);$t&&(Ee=tn($t.orientation,"n"))}else{const $t=(te.get(J)??[])[0],or=$t?z(J,$t):null;or&&(Ee=tn(or.orientation,"s"))}l.set(J,{at:[oe,je],rot:Ee,mirror:!1}),f.add(J)}},B=new Set;for(const T of j.keys()){if(B.has(T))continue;const N=[],L=[T];for(B.add(T);L.length;){const D=L.pop();N.push(D);for(const q of j.get(D)??[])B.has(q)||(B.add(q),L.push(q))}N.length<2||N.some(D=>_.has(D))||N.some(D=>l.has(D)||M.has(D))||N.some(S)&&O(N)}}const H=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of b){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=S.slice(E+1),A=H.get(j)??[];for(const z of k)A.some(O=>O.busId===z&&O.pin===_)||A.push({busId:z,pin:_});H.set(j,A)}}const W=[],X=new Set;for(const[b,k]of H)if(new Set(k.map(E=>E.busId)).size>=2){const E=((Zo=s.get(((Jo=g.get(b))==null?void 0:Jo.kind)??""))==null?void 0:Zo.category)==="transformer"?"vertical":"horizontal";W.push({elementId:b,attachments:k,orientation:E}),E==="vertical"&&X.add(b)}const P=new Map,R=(b,k)=>{b!==k&&(P.has(b)||P.set(b,new Set),P.has(k)||P.set(k,new Set),P.get(b).add(k),P.get(k).add(b))};for(const b of r)R(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(!k||k.terminals.length<2)continue;const S=k.terminals.map(E=>`${b.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)R(S[E],S[j])}for(const b of t){if(X.has(b.id))continue;const k=s.get(b.kind);if(!k||k.category!=="transformer"||k.terminals.length<2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1);E.set(A,new Set);const z=new Set(S.filter(T=>T!==_)),O=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.get(A).add(T);continue}const N=P.get(T);if(N)for(const L of N)O.has(L)||z.has(L)||(O.add(L),B.push(L))}}const j=new Set;for(const _ of E.values())for(const A of _)j.add(A);if(j.size>=2){const _=[];for(const[A,z]of E)for(const O of z)_.push({busId:O,pin:A});W.push({elementId:b.id,attachments:_,orientation:"vertical"}),X.add(b.id)}}const Z=(b,k)=>{var z;const S=p(k),E=S?S.terminals.map(O=>`${k}.${O.id}`):[],j=b,_=new Set([j,...E]),A=[j];for(;A.length>0;){const O=A.shift(),B=O.indexOf(".");if(B>0){const N=O.slice(0,B),L=g.get(N);if(L){const D=(z=s.get(L.kind))==null?void 0:z.category;if(D&&yr.has(D))return!0}}const T=P.get(O);if(T)for(const N of T)_.has(N)||(_.add(N),A.push(N))}return!1};for(const b of W){if(b.orientation!=="horizontal")continue;const k=new Set(b.attachments.map(E=>E.busId));let S=0;for(const E of k)Z(E,b.elementId)&&S++;S===1&&(b.orientation="vertical",X.add(b.elementId))}for(const b of t){if(X.has(b.id)||b.kind!=="breaker")continue;const k=s.get(b.kind);if(!k||k.terminals.length!==2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1),z=new Set(S.filter(T=>T!==_)),O=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.set(A,T);break}const N=P.get(T);if(N)for(const L of N){if(O.has(L)||z.has(L))continue;const D=L.indexOf(".");if(D>0){const q=L.slice(0,D);if(q!==b.id){const K=g.get(q),Y=K?s.get(K.kind):void 0;if((Y==null?void 0:Y.category)==="transformer")continue}}O.add(L),B.push(L)}}}if(new Set(E.values()).size>=2){const _=[];for(const[A,z]of E)_.push({busId:z,pin:A});W.push({elementId:b.id,attachments:_,orientation:"horizontal"})}}const ie=new Map;for(const b of n)ie.set(b.id,new Map);for(const b of W){const k=Array.from(new Set(b.attachments.map(S=>S.busId)));for(const S of k)for(const E of k)S!==E&&((Qo=ie.get(S))==null||Qo.set(E,b))}const ue=b=>{var S;const k=(S=s.get(b))==null?void 0:S.category;return k?yr.has(k):!1},ee=[];for(const b of n){const k=$.get(b.id);if(k)for(const S of k){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=g.get(j);if(_&&ue(_.kind)){ee.push(b.id);break}}}ee.length===0&&n.length>0&&ee.push(n[0].id);const ae=new Map;for(const b of ee)ae.set(b,0);{const b=[...ee];for(;b.length>0;){const k=b.shift(),S=ae.get(k),E=ie.get(k);if(E)for(const[j,_]of E){if(ae.has(j))continue;const A=_.orientation==="horizontal"?S:S+1;ae.set(j,A),b.push(j)}}}for(const b of n){if(ae.has(b.id))continue;const k=ae.size===0?-1:Math.max(...Array.from(ae.values()));ae.set(b.id,k+1)}const me=new Map;for(const b of n){const k=ae.get(b.id),S=me.get(k)??[];S.push(b.id),me.set(k,S)}const be=[...me.keys()].sort((b,k)=>b-k),$e=(b,k,S)=>{const E=`${b.elementId}.${S}`,j=k,_=p(b.elementId),A=new Set;if(_)for(const N of _.terminals)N.id!==S&&A.add(`${b.elementId}.${N.id}`);const z=new Set([E]),O=[{ref:E,dist:0}],B=new Map,T=(N,L,D,q)=>{z.add(N),B.set(N,L),O.push({ref:N,dist:q+D})};for(;O.length>0;){const{ref:N,dist:L}=O.shift();if(N===j){const Y=B.get(j);let te;if(Y){const ne=Y.indexOf(".");if(ne>0){const U=Y.slice(0,ne);U!==b.elementId&&(te=U)}}return{extent:L,head:te}}const D=N.indexOf(".");if(D<0)continue;const q=N.slice(0,D),K=N.slice(D+1);if(!w(q)&&!X.has(q)){const Y=p(q),te=Y==null?void 0:Y.terminals.find(ne=>ne.id===K);if(Y&&te)for(const ne of Y.terminals){if(ne.id===K)continue;const U=`${q}.${ne.id}`;z.has(U)||A.has(U)||T(U,N,Math.abs(te.y-ne.y),L)}}for(const Y of G.get(N)??[])for(const te of Y){if(te===N||z.has(te)||A.has(te))continue;const ne=w(N)||w(te);T(te,N,ne?mr:Tt,L)}}return{extent:0}},Me=(b,k)=>{var N,L,D;const S=(N=ie.get(b))==null?void 0:N.get(k);if(!S||S.orientation==="horizontal")return At;const E=p(S.elementId);if(!E)return At;const j=(L=S.attachments.find(q=>q.busId===b))==null?void 0:L.pin,_=(D=S.attachments.find(q=>q.busId===k))==null?void 0:D.pin;if(!j||!_)return At;const A=E.terminals.find(q=>q.id===j),z=E.terminals.find(q=>q.id===_);if(!A||!z)return At;const O=Math.abs(z.y-A.y),B=$e(S,b,j).extent,T=$e(S,k,_).extent;return B+O+T},Pn=new Map;for(const b of W){if(b.orientation!=="vertical")continue;const k=b.attachments.slice().sort((z,O)=>(ae.get(z.busId)??0)-(ae.get(O.busId)??0));if(k.length<2)continue;const S=k[0].busId,E=k[1].busId,j=k[0].pin,A=$e(b,S,j).head??b.elementId;Pn.set(A,{lowerBusId:E})}const Do=30,zo=b=>{const k=p(b);return Math.max((k==null?void 0:k.width)??Qe,Qe)},Gv=2,Ro=(b,k,S,E=0)=>{const j=p(k);let _=zo(k);if(j&&!S.has(k)&&E<Gv){S.add(k);let A=0;for(const z of j.terminals){const O=`${k}.${z.id}`;if(O!==b)for(const B of G.get(O)??[]){const T=new Set;let N=!1;for(const D of B){if(D===O)continue;if(w(D)){N=!0;continue}const q=D.indexOf(".");if(q<0)continue;const K=D.slice(0,q);K===k||S.has(K)||X.has(K)||T.add(K)}if(N||T.size===0)continue;let L=0;for(const D of T){const q=[...B].find(K=>K.indexOf(".")>0&&K.slice(0,K.indexOf("."))===D);L+=(q?Ro(q,D,S,E+1):zo(D))+Do}A=Math.max(A,L-Do)}}S.delete(k),_=Math.max(_,A)}return _},kt=320,dt=new Map,Fo=(b,k)=>{if(!X.has(b))return!1;const S=W.find(A=>A.elementId===b),E=S==null?void 0:S.attachments.find(A=>A.busId!==k);if(!E)return!1;const j=ae.get(k)??0;return(ae.get(E.busId)??0)<j},_t=(b,k,S)=>{const E=Pn.get(b);if(E){const _=dt.get(E.lowerBusId);if(_!==void 0)return Math.max(k,_+Qe)}let j=0;return S&&(j=Ro(S,b,new Set)),Math.max(k,Qe,j)},Ho=(b,k)=>{if(dt.has(b))return dt.get(b);if(k.has(b))return kt;k.add(b);const S=$.get(b)??[];let E=0,j=0;for(const A of S){if(w(A))continue;const z=A.indexOf(".");if(z<0)continue;const O=A.slice(0,z),B=A.slice(z+1);if(Fo(O,b))continue;const T=p(O);if(!T)continue;const N=T.terminals.find(q=>q.id===B);if(!N)continue;const L=Pn.get(O);L&&Ho(L.lowerBusId,k);const D=_t(O,T.width,`${O}.${B}`);N.y>0?E+=D:j+=D}const _=Math.max(kt,Math.max(E,j)+Qe);return dt.set(b,_),k.delete(b),_};for(const b of n)Ho(b.id,new Set);const Ve=new Map,Kv=(b,k,S)=>{const E=p(k);if(!E)return;const j=`${k}.${S}`,_=E.terminals.filter(O=>O.id!==S).map(O=>`${k}.${O.id}`);if(_.length===0)return;const A=new Set([j,..._]),z=_.slice();for(;z.length>0;){const O=z.shift();if(w(O)&&O!==b){const T=c.get(O);return T?T.at[0]:void 0}for(const T of G.get(O)??[])for(const N of T)N===O||A.has(N)||(A.add(N),z.push(N));const B=O.indexOf(".");if(B>0){const T=O.slice(0,B);if(!w(T)){const N=p(T);if(N)for(const L of N.terminals){const D=`${T}.${L.id}`;A.has(D)||(A.add(D),z.push(D))}}}}},Uv=b=>{const k=$.get(b);if(!k||k.length===0)return;const S=c.get(b);if(!S)return;const E=k.flatMap(N=>{if(w(N))return[];const L=N.indexOf(".");if(L<0)return[];const D=N.slice(0,L),q=N.slice(L+1);if(l.has(D))return[];if(Fo(D,b))return[];const K=p(D);if(!K)return[];const Y=K.terminals.find(te=>te.id===q);return Y?[{elId:D,lib:K,localTerm:Y,isLinker:X.has(D),busFacingRef:`${D}.${q}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const A=N=>N.reduce((L,D)=>L+_t(D.elId,D.lib.width,D.busFacingRef),0),z=Math.max(A(j),A(_))+Qe,O=Math.max(S.span,z);O!==S.span&&!h.has(b)&&c.set(b,{...S,span:O});const B=c.get(b),T=(N,L)=>{if(N.length===0)return;const D=new Map;for(const V of N){const Q=Kv(b,V.elId,V.localTerm.id);Q!==void 0&&D.set(V.elId,Q)}N.sort((V,Q)=>{const fe=D.get(V.elId)??B.at[0],we=D.get(Q.elId)??B.at[0];if(fe!==we)return fe-we;const J=_t(V.elId,V.lib.width,V.busFacingRef);return _t(Q.elId,Q.lib.width,Q.busFacingRef)-J});const q=N.map(V=>_t(V.elId,V.lib.width,V.busFacingRef)),K=q.reduce((V,Q)=>V+Q,0),Y=Math.max(O,K),te=(Y-K)/(N.length+1);let ne=B.at[0]-Y/2+te;const U=B.at[1]+L*mr;for(let V=0;V<N.length;V++){const Q=N[V],fe=q[V],we=ne+fe/2;Q.isLinker?Ve.has(Q.elId)||Ve.set(Q.elId,we):l.set(Q.elId,{at:[xe(we-Q.localTerm.x),xe(U-Q.localTerm.y)],rot:0,mirror:!1}),ne+=fe+te}};T(j,-1),T(_,1)},Vv=b=>{if(l.has(b.elementId)||b.orientation==="horizontal")return;const k=p(b.elementId);if(!k)return;const S=b.attachments.filter(ne=>c.has(ne.busId));if(S.length<2)return;const E=S.slice().sort((ne,U)=>(ae.get(ne.busId)??0)-(ae.get(U.busId)??0)),j=E[0].busId,_=c.get(j),A=E[0].pin,z=E[E.length-1].pin,O=k.terminals.find(ne=>ne.id===A),B=k.terminals.find(ne=>ne.id===z);if(!O||!B)return;const T=O.y<=B.y?0:180,N=ae.get(j)??0,L=S.filter(ne=>(ae.get(ne.busId)??0)===N),D=[];let q=0;for(const ne of L){const U=$e(b,ne.busId,ne.pin);q=Math.max(q,U.extent);const V=U.head?l.get(U.head):void 0;V?D.push(V.at[0]):Ve.has(b.elementId)?D.push(Ve.get(b.elementId)):D.push(c.get(ne.busId).at[0])}let K;D.length>0?K=D.reduce((ne,U)=>ne+U,0)/D.length:Ve.has(b.elementId)?K=Ve.get(b.elementId):K=_.at[0];const Y=_.at[1]+q,te=T===0?[xe(K-O.x),xe(Y-O.y)]:[xe(K+O.x),xe(Y+O.y)];if(l.set(b.elementId,{at:te,rot:T,mirror:!1}),L.length>1){const ne=l.get(b.elementId),U=Ie([O.x,O.y],ne),V=Ot(O.orientation,ne);Jv(`${b.elementId}.${A}`,U,V,K)}},Jv=(b,k,S,E)=>{const j=new Set([b]);let _=b,A=k,z=S;for(;;){const O=G.get(_)??[];let B,T=!1;for(const oe of O){if(oe.length>=3){T=!0;break}const je=oe.find(Ee=>Ee!==_);if(!(!je||j.has(je))){if(w(je)){T=!0;break}B=je;break}}if(T||!B)break;const N=B.indexOf(".");if(N<0)break;const L=B.slice(0,N),D=B.slice(N+1);if(w(L)||X.has(L)||l.has(L))break;const q=p(L);if(!q)break;const K=q.terminals.find(oe=>oe.id===D);if(!K)break;const Y=io(z),te=[A[0]+Y[0]*Tt,A[1]+Y[1]*Tt],ne=hr[z],U=tn(K.orientation,ne),V=Ie([K.x,K.y],{at:[0,0],rot:U,mirror:!1}),Q=[xe(E-V[0]),xe(te[1]-V[1])];l.set(L,{at:Q,rot:U,mirror:!1}),j.add(B);const fe=q.terminals.find(oe=>oe.id!==D);if(!fe)break;const we=`${L}.${fe.id}`;j.add(we);const J={at:Q,rot:U,mirror:!1};A=Ie([fe.x,fe.y],J),z=Ot(fe.orientation,J),_=we}},Zv=b=>{if(l.has(b.elementId)||b.orientation!=="horizontal")return;const k=p(b.elementId);if(!k)return;const S=b.attachments.filter(L=>c.has(L.busId));if(S.length<2)return;const E=S.map(L=>{const D=$e(b,L.busId,L.pin),q=D.head?l.get(D.head):void 0,K=q?q.at[0]:c.get(L.busId).at[0];return{att:L,x:K,extent:D.extent}});E.sort((L,D)=>L.x-D.x);const j=E[0],_=E[E.length-1],A=k.terminals.find(L=>L.id===j.att.pin),z=k.terminals.find(L=>L.id===_.att.pin);if(!A||!z)return;const O=A.y<=z.y?270:90,B=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(b.elementId,{at:[xe(B),xe(N)],rot:O,mirror:!1})},Wo=100;let Zt=nn;for(let b=0;b<be.length;b++){const k=be[b],S=me.get(k);let E;if(b===0)E=nn;else{const _=me.get(be[b-1]);let A=0;for(const z of _)for(const O of S)(er=ie.get(z))!=null&&er.get(O)&&(A=Math.max(A,Me(z,O)));A===0&&(A=At),E=Zt+A}Zt=E;let j=Rn;for(const _ of S){if(c.has(_)){Zt=Math.max(Zt,c.get(_).at[1]);continue}let A;if(b>0){const O=me.get(be[b-1]),B=[];for(const T of O){const N=(tr=ie.get(T))==null?void 0:tr.get(_);if(!N||N.orientation!=="vertical")continue;const L=(nr=N.attachments.find(q=>q.busId===T))==null?void 0:nr.pin;if(!L)continue;const D=$e(N,T,L);D.head&&l.has(D.head)?B.push(l.get(D.head).at[0]):Ve.has(N.elementId)?B.push(Ve.get(N.elementId)):B.push(c.get(T).at[0])}B.length>0&&(A=B.reduce((T,N)=>T+N,0)/B.length)}if(A===void 0){const O=dt.get(_)??Fn;A=j+O/2,j+=O+Wo}const z=dt.get(_)??Fn;c.set(_,{at:[xe(A),xe(E)],rot:0,span:z,axis:so(0)})}for(const _ of S)Uv(_);if(b>0)for(const _ of W)l.has(_.elementId)||!_.attachments.some(z=>S.includes(z.busId))||Vv(_);for(const _ of W)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>S.includes(z.busId))||Zv(_)}if(n.length===0&&l.size<t.length){const b=j=>{const _=new Set,A=p(j);if(!A)return _;for(const z of A.terminals){const O=`${j}.${z.id}`;for(const B of G.get(O)??[])for(const T of B){if(T===O||w(T))continue;const N=T.indexOf(".");if(N<0)continue;const L=T.slice(0,N);L!==j&&_.add(L)}}return _},k=new Set,S=[];for(const j of t){if(k.has(j.id)||!p(j.id))continue;const _=[],A=[j.id];for(k.add(j.id);A.length>0;){const z=A.pop();_.push(z);for(const O of b(z))k.has(O)||(k.add(O),A.push(O))}_.length>=2&&S.push(_)}let E=Rn;for(const j of S){if(j.some(B=>l.has(B)))continue;j.sort((B,T)=>{var K,Y;const N=ue(((K=g.get(B))==null?void 0:K.kind)??"")?0:1,L=ue(((Y=g.get(T))==null?void 0:Y.kind)??"")?0:1;if(N!==L)return N-L;const D=b(B).size,q=b(T).size;return D!==q?D-q:B.localeCompare(T)});const _=j[0],A=p(_);if(!A)continue;const z=A.terminals.slice().sort((B,T)=>T.y-B.y)[0],O=z?Ie([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[xe(E-O[0]),xe(nn-O[1])],rot:0,mirror:!1}),E+=Math.max(Fn,j.length*Qe)+Wo}}const Qv=b=>{if(w(b))return c.has(b);const k=b.indexOf(".");return k<0?!1:l.has(b.slice(0,k))};let In=!0,e2=t.length+4;for(;In&&e2-- >0;){In=!1;for(const b of F){if(b.length<2)continue;const k=[],S=new Map;for(const U of b){if(w(U))continue;const V=U.indexOf(".");if(V<0)continue;const Q=U.slice(0,V),fe=U.slice(V+1);if(l.has(Q)){k.push(U);continue}if(X.has(Q)||S.has(Q))continue;const we=p(Q);if(!we)continue;const J=we.terminals.find(oe=>oe.id===fe);J&&S.set(Q,{ref:U,elId:Q,lib:we,localTerm:J})}if(S.size===0||k.length===0)continue;const E=[...S.values()],j=new Map;for(const U of E)for(const V of G.get(U.ref)??[])for(const Q of V){if(Q===U.ref||w(Q)||!Qv(Q))continue;const fe=Q;j.set(fe,(j.get(fe)??0)+1)}let _;if(j.size>0){let U=-1;for(const[V,Q]of j)(Q>U||Q===U&&(_===void 0||V<_))&&(U=Q,_=V)}if(_||(_=[...k].sort()[0]),!_)continue;const A=_.indexOf("."),z=_.slice(0,A),O=_.slice(A+1),B=p(z),T=l.get(z);if(!B||!T)continue;const N=B.terminals.find(U=>U.id===O);if(!N)continue;const L=Ie([N.x,N.y],T),D=Ot(N.orientation,T),q=io(D),K=[-q[1],q[0]];E.sort((U,V)=>U.elId.localeCompare(V.elId));const Y=E.map(U=>Math.max(U.lib.width,Qe));let ne=-Y.reduce((U,V)=>U+V,0)/2;for(let U=0;U<E.length;U++){const V=E[U],Q=Y[U],fe=ne+Q/2;ne+=Q;const we=hr[D],J=tn(V.localTerm.orientation,we),oe=Ie([V.localTerm.x,V.localTerm.y],{at:[0,0],rot:J,mirror:!1}),je=[L[0]+q[0]*Tt+K[0]*fe,L[1]+q[1]*Tt+K[1]*fe],Ee=[xe(je[0]-oe[0]),xe(je[1]-oe[1])];l.set(V.elId,{at:Ee,rot:J,mirror:!1}),In=!0}}}const St=b=>{const k=l.get(b),S=p(b);if(!k||!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:k.at[0]-N,max:k.at[0]+N}}const[j,_,A,z]=E,O=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of O){const L=Ie(N,k);B=Math.min(B,L[0]),T=Math.max(T,L[0])}return{min:B,max:T}},On=b=>{const k=new Set,S=p(b);if(!S)return k;for(const E of S.terminals){const j=`${b}.${E.id}`;for(const _ of G.get(j)??[])for(const A of _){if(A===j||w(A))continue;const z=A.indexOf(".");if(z<0)continue;const O=A.slice(0,z);O!==b&&k.add(O)}}return k},qo=40,Bn=b=>{const k=l.get(b),S=p(b);if(!k||!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:k.at[1]-N,max:k.at[1]+N}}const[j,_,A,z]=E,O=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of O){const L=Ie(N,k);B=Math.min(B,L[1]),T=Math.max(T,L[1])}return{min:B,max:T}},t2=(b,k)=>{const S=new Set,E=[];for(const j of $.get(b)??[]){if(w(j))continue;const _=j.indexOf(".");if(_<0)continue;const A=j.slice(0,_),z=l.get(A);!z||z.at[1]>=k-1||S.has(A)||(S.add(A),E.push(A))}for(;E.length>0;){const j=E.pop();for(const _ of On(j)){if(S.has(_))continue;const A=l.get(_);!A||A.at[1]>=k-1||(S.add(_),E.push(_))}}return S},Xo=(b,k,S)=>{const E=new Set([b]),j=[b];for(;j.length>0;){const _=j.pop();for(const A of On(_))A===k||E.has(A)||!S.has(A)||(E.add(A),j.push(A))}return E},Yo=(b,k)=>{let S=b.length*b.length+8,E=!1,j=!0;for(;j&&S-- >0;){j=!1;for(let _=0;_<b.length&&!j;_++)for(let A=_+1;A<b.length;A++){const z=b[_],O=b[A],B=St(z),T=St(O),N=Bn(z),L=Bn(O);if(!B||!T||!N||!L)continue;const D=Math.min(B.max,T.max)-Math.max(B.min,T.min),q=Math.min(N.max,L.max)-Math.max(N.min,L.min);if(D<=0||q<=0)continue;const K=Xo(z,O,k),Y=Xo(O,z,k);if(K.has(O)||Y.has(z))continue;const te=![...K].some(J=>f.has(J)),ne=![...Y].some(J=>f.has(J));if(!te&&!ne)continue;const U=(B.min+B.max)/2,V=(T.min+T.max)/2;let Q,fe;te&&(!ne||K.size<=Y.size)?(Q=K,fe=U<=V?-1:1):(Q=Y,fe=V<=U?-1:1);const we=xe(fe*(D+qo));if(we!==0){for(const J of Q){const oe=l.get(J);oe&&l.set(J,{...oe,at:[oe.at[0]+we,oe.at[1]]})}E=!0,j=!0;break}}}return E};for(const b of n){const k=c.get(b.id);if(!k)continue;const S=t2(b.id,k.at[1]);if(S.size<2)continue;const E=[...S];if(Yo(E,S)){let _=1/0,A=-1/0;for(const z of E){const O=St(z);O&&(_=Math.min(_,O.min),A=Math.max(A,O.max))}if(Number.isFinite(_)){const O=E.some(T=>f.has(T))?0:xe(k.at[0]-(_+A)/2);if(O!==0)for(const T of E){const N=l.get(T);N&&l.set(T,{...N,at:[N.at[0]+O,N.at[1]]})}const B=A-_+qo;if(B>k.span&&!h.has(b.id)){const T=c.get(b.id);c.set(b.id,{...T,span:B})}}}}const Go=()=>{const k=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:St(E),y:Bn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<k.length;E++)for(let j=E+1;j<k.length;j++){const _=Math.min(k[E].x.max,k[j].x.max)-Math.max(k[E].x.min,k[j].x.min),A=Math.min(k[E].y.max,k[j].y.max)-Math.max(k[E].y.min,k[j].y.min);_>1&&A>1&&S++}return S},n2=Go(),Ko=new Map;for(const[b,k]of l)Ko.set(b,{...k,at:[...k.at]});const Uo=new Map;for(const[b,k]of c)Uo.set(b,{...k,at:[...k.at]});const Ln=120,Vo=new Map;{const b=new Map,k=new Map,S=[];for(const j of n)for(const _ of $.get(j.id)??[]){if(w(_))continue;const A=_.indexOf(".");if(A<0)continue;const z=_.slice(0,A);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:A}=S[E++],z=b.get(j);if(z===void 0)b.set(j,A),k.set(j,_);else if(A===z&&k.get(j)!==_){k.set(j,null);continue}else continue;for(const O of On(j))l.has(O)&&(b.has(O)||S.push({el:O,bus:_,d:A+1}))}for(const[j,_]of k)_&&Vo.set(j,_)}for(const b of be){const k=(me.get(b)??[]).filter(B=>c.has(B));if(k.length<2||k.some(B=>h.has(B)))continue;const S=[];let E=0;for(const B of k){const T=c.get(B),N=[];let L=1/0,D=-1/0;for(const[q,K]of Vo){if(K!==B)continue;const Y=St(q);Y&&(N.push(q),L=Math.min(L,Y.min),D=Math.max(D,Y.max))}Number.isFinite(L)||(L=T.at[0]-kt/2,D=T.at[0]+kt/2),S.push({busId:B,min:L,max:D,members:N}),E+=D-L}if(S.some(B=>B.members.some(T=>f.has(T))))continue;let j=1/0,_=-1/0;for(const B of S)j=Math.min(j,B.min),_=Math.max(_,B.max);const A=_-j,z=E+Ln*(S.length-1);if(!(A>z+Ln))continue;S.sort((B,T)=>(B.min+B.max)/2-(T.min+T.max)/2);let O=j;for(const B of S){const T=xe(O-B.min);if(T!==0){const N=c.get(B.busId);c.set(B.busId,{...N,at:[N.at[0]+T,N.at[1]]});for(const L of B.members){const D=l.get(L);D&&l.set(L,{...D,at:[D.at[0]+T,D.at[1]]})}B.min+=T,B.max+=T}O=B.max+Ln}for(const B of S){const T=c.get(B.busId),N=Math.max(kt,B.max-B.min);N<T.span&&c.set(B.busId,{...T,span:N})}}{const b=t.map(S=>S.id).filter(S=>l.has(S)),k=new Set(b);Yo(b,k)}if(Go()>n2){l.clear();for(const[b,k]of Ko)l.set(b,k);c.clear();for(const[b,k]of Uo)c.set(b,k)}let Dn=0;for(const b of t){if(l.has(b.id))continue;const k=Dn%gr,S=Math.floor(Dn/gr);l.set(b.id,{at:[xe(yk+k*bk),xe(xk+S*wk)],rot:0,mirror:!1}),Dn++}return{devices:l,buses:c,junctions:u}}function xe(e){return Math.round(e/pr)*pr}function kk(e,t){const n=e.ends[0],o=e.ends[1],r=xr(n,t),s=xr(o,t);if(r||s){const l=r?n:o,u=Hn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:h,at:g,span:m}=f.geometry,p=m/2;let x;if(h==="x")x=[gn(u[0],g[0]-p,g[0]+p),g[1]];else{const w=gn(u[1],g[1]-p,g[1]+p);x=[g[0],w]}return{wireId:e.id,path:wr(u,x)}}const i=Hn(n,t),a=Hn(o,t);return!i||!a?null:{wireId:e.id,path:wr(i,a)}}function xr(e,t){return!e.includes(".")&&t.buses.has(e)}function Hn(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 br(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const u=n.junctions.get(e);return u?[u.world[0],u.world[1]]:null}const{axis:s,at:i,span:a}=r.geometry;if(!t)return[i[0],i[1]];const l=a/2;if(s==="x")return[gn(t[0],i[0]-l,i[0]+l),i[1]];const c=gn(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 wr(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function gn(e,t,n){return e<t?t:e>n?n:e}const Vs="ammeter",Js="电流表 (A)",Zs="measurement",Qs="-22 -42 44 44",ei=44,ti=44,ni='<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>',oi=[{id:"t_top",x:0,y:-40,orientation:"n"}],ri={kind:"inline"},_k={id:Vs,name:Js,category:Zs,viewBox:Qs,width:ei,height:ti,svg:ni,terminals:oi,source:ri},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:Zs,default:_k,height:ti,id:Vs,name:Js,source:ri,svg:ni,terminals:oi,viewBox:Qs,width:ei},Symbol.toStringTag,{value:"Module"})),si="arc-suppression-coil",ii="消弧线圈",ai="grounding",li="中性点谐振接地:电感线圈连接到地",ci="-12 -32 24 67",di=24,ui=67,fi='<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"/>',hi=[{id:"t_top",x:0,y:-30,orientation:"n"}],mi={kind:"inline"},$k={id:si,name:ii,category:ai,description:li,viewBox:ci,width:di,height:ui,svg:fi,terminals:hi,source:mi},jk=Object.freeze(Object.defineProperty({__proto__:null,category:ai,default:$k,description:li,height:ui,id:si,name:ii,source:mi,svg:fi,terminals:hi,viewBox:ci,width:di},Symbol.toStringTag,{value:"Module"})),pi="arrester",gi="避雷器 (FBL)",yi="protection",xi="-7 -22 14 44",bi=14,wi=44,vi='<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"/>',ki=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_i={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},Ek={id:pi,name:gi,category:yi,viewBox:xi,width:bi,height:wi,svg:vi,terminals:ki,source:_i},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:yi,default:Ek,height:wi,id:pi,name:gi,source:_i,svg:vi,terminals:ki,viewBox:xi,width:bi},Symbol.toStringTag,{value:"Module"})),Si="async-motor",$i="异步电动机",ji="load",Ei="-62 -82 64 84",Ni=64,Ai=84,Ti='<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"/>',Mi=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Ci={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"},Ak={id:Si,name:$i,category:ji,viewBox:Ei,width:Ni,height:Ai,svg:Ti,terminals:Mi,source:Ci},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:ji,default:Ak,height:Ai,id:Si,name:$i,source:Ci,svg:Ti,terminals:Mi,viewBox:Ei,width:Ni},Symbol.toStringTag,{value:"Module"})),Pi="autotransformer",Ii="自耦变压器",Oi="transformer",Bi="-62 -112 64 144",Li=64,Di=144,zi='<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"}],Fi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},Mk={id:Pi,name:Ii,category:Oi,viewBox:Bi,width:Li,height:Di,svg:zi,terminals:Ri,source:Fi},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:Oi,default:Mk,height:Di,id:Pi,name:Ii,source:Fi,svg:zi,terminals:Ri,viewBox:Bi,width:Li},Symbol.toStringTag,{value:"Module"})),Hi="battery",Wi="电池储能",qi="storage",Xi="-12 -12 29 24",Yi=29,Gi=24,Ki='<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"}],Vi=[{name:"E",label:"容量",type:"number",unit:"kWh"}],Ji={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},Pk={id:Hi,name:Wi,category:qi,viewBox:Xi,width:Yi,height:Gi,svg:Ki,terminals:Ui,params:Vi,source:Ji},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:qi,default:Pk,height:Gi,id:Hi,name:Wi,params:Vi,source:Ji,svg:Ki,terminals:Ui,viewBox:Xi,width:Yi},Symbol.toStringTag,{value:"Module"})),Zi="bell",Qi="电铃 (HA)",ea="control",ta="信号电铃 / 警铃。",na="-32 -32 44 44",oa=44,ra=44,sa='<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"/>',ia=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],aa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},Ok={id:Zi,name:Qi,category:ea,description:ta,viewBox:na,width:oa,height:ra,svg:sa,terminals:ia,source:aa},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:ea,default:Ok,description:ta,height:ra,id:Zi,name:Qi,source:aa,svg:sa,terminals:ia,viewBox:na,width:oa},Symbol.toStringTag,{value:"Module"})),la="break-contact",ca="常闭触点 (NC)",da="control",ua="常闭辅助触点 (break contact)。",fa="-2 -42 14 64",ha=14,ma=64,pa='<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"/>',ga=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ya=[{name:"open",type:"boolean",default:!1,label:"断开"}],xa={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},Lk={id:la,name:ca,category:da,description:ua,viewBox:fa,width:ha,height:ma,svg:pa,terminals:ga,state:ya,source:xa},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:da,default:Lk,description:ua,height:ma,id:la,name:ca,source:xa,state:ya,svg:pa,terminals:ga,viewBox:fa,width:ha},Symbol.toStringTag,{value:"Module"})),ba="breaker",wa="断路器 (QF)",va="switching",ka="-7 -22 15 46",_a=15,Sa=46,$a='<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"/>',ja='<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>',Ea=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Na=[{name:"open",type:"boolean",default:!1,label:"断开"}],Aa={x:6,y:-2,anchor:"start"},Ta={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},zk={id:ba,name:wa,category:va,viewBox:ka,width:_a,height:Sa,svg:$a,terminalLabelsSvg:ja,terminals:Ea,state:Na,label:Aa,source:Ta},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:va,default:zk,height:Sa,id:ba,label:Aa,name:wa,source:Ta,state:Na,svg:$a,terminalLabelsSvg:ja,terminals:Ea,viewBox:ka,width:_a},Symbol.toStringTag,{value:"Module"})),Ma="buchholz-relay",Ca="瓦斯继电器 (63)",Pa="protection",Ia="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Oa="-22 -62 44 64",Ba=44,La=64,Da='<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"/>',za=[{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"},Fk={id:Ma,name:Ca,category:Pa,description:Ia,viewBox:Oa,width:Ba,height:La,svg:Da,terminals:za,source:Ra},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:Fk,description:Ia,height:La,id:Ma,name:Ca,source:Ra,svg:Da,terminals:za,viewBox:Oa,width:Ba},Symbol.toStringTag,{value:"Module"})),Fa="busbar",Ha="母线段",Wa="busbar",qa="可拉伸单母线段,多设备挂接",Xa="-42 -4 84 8",Ya=84,Ga=8,Ka='<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"}],Va={axis:"x",minLength:20,naturalSpan:80},Ja=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],Za={x:0,y:-6,anchor:"middle"},Qa={kind:"inline"},Wk={id:Fa,name:Ha,category:Wa,description:qa,viewBox:Xa,width:Ya,height:Ga,svg:Ka,terminals:Ua,stretchable:Va,params:Ja,label:Za,source:Qa},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Wa,default:Wk,description:qa,height:Ga,id:Fa,label:Za,name:Ha,params:Ja,source:Qa,stretchable:Va,svg:Ka,terminals:Ua,viewBox:Xa,width:Ya},Symbol.toStringTag,{value:"Module"})),el="buzzer",tl="蜂鸣器 (HA)",nl="control",ol="信号蜂鸣器。",rl="-32 -52 44 64",sl=44,il=64,al='<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"/>',ll=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],cl={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},Xk={id:el,name:tl,category:nl,description:ol,viewBox:rl,width:sl,height:il,svg:al,terminals:ll,source:cl},Yk=Object.freeze(Object.defineProperty({__proto__:null,category:nl,default:Xk,description:ol,height:il,id:el,name:tl,source:cl,svg:al,terminals:ll,viewBox:rl,width:sl},Symbol.toStringTag,{value:"Module"})),dl="capacitor",ul="电容 (C)",fl="passive",hl="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",ml="-7 -23 14 27",pl=14,gl=27,yl='<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"/>',xl=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],bl=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],wl={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},Gk={id:dl,name:ul,category:fl,description:hl,viewBox:ml,width:pl,height:gl,svg:yl,terminals:xl,params:bl,source:wl},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:fl,default:Gk,description:hl,height:gl,id:dl,name:ul,params:bl,source:wl,svg:yl,terminals:xl,viewBox:ml,width:pl},Symbol.toStringTag,{value:"Module"})),vl="contactor",kl="接触器 (KM)",_l="motor-control",Sl="主回路接触器, 通常配热继电器和电机使用。",$l="-10 -42 15 64",jl=15,El=64,Nl='<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"/>',Al=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Tl=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ml={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"},Uk={id:vl,name:kl,category:_l,description:Sl,viewBox:$l,width:jl,height:El,svg:Nl,terminals:Al,state:Tl,source:Ml},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:_l,default:Uk,description:Sl,height:El,id:vl,name:kl,source:Ml,state:Tl,svg:Nl,terminals:Al,viewBox:$l,width:jl},Symbol.toStringTag,{value:"Module"})),Cl="converter-bidir",Pl="双向变流器 (PCS)",Il="renewable",Ol="储能变流器:双向 AC ↔ DC",Bl="-42 -42 44 48",Ll=44,Dl=48,zl='<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"}],Fl=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Hl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},Jk={id:Cl,name:Pl,category:Il,description:Ol,viewBox:Bl,width:Ll,height:Dl,svg:zl,terminals:Rl,params:Fl,source:Hl},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:Il,default:Jk,description:Ol,height:Dl,id:Cl,name:Pl,params:Fl,source:Hl,svg:zl,terminals:Rl,viewBox:Bl,width:Ll},Symbol.toStringTag,{value:"Module"})),Wl="ct",ql="电流互感器 (CT)",Xl="instrument-transformer",Yl="-42 -62 54 64",Gl=54,Kl=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"/>',Vl=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Jl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},Qk={id:Wl,name:ql,category:Xl,viewBox:Yl,width:Gl,height:Kl,svg:Ul,terminals:Vl,source:Jl},e_=Object.freeze(Object.defineProperty({__proto__:null,category:Xl,default:Qk,height:Kl,id:Wl,name:ql,source:Jl,svg:Ul,terminals:Vl,viewBox:Yl,width:Gl},Symbol.toStringTag,{value:"Module"})),Zl="dc-combiner",Ql="直流汇流箱",ec="renewable",tc="光伏组串汇流箱 (4 路输入示例)。",nc="-27 -32 54 64",oc=54,rc=64,sc='<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>',ic=[{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"}],ac={kind:"inline"},t_={id:Zl,name:Ql,category:ec,description:tc,viewBox:nc,width:oc,height:rc,svg:sc,terminals:ic,source:ac},n_=Object.freeze(Object.defineProperty({__proto__:null,category:ec,default:t_,description:tc,height:rc,id:Zl,name:Ql,source:ac,svg:sc,terminals:ic,viewBox:nc,width:oc},Symbol.toStringTag,{value:"Module"})),lc="dc-disconnector",cc="直流隔离开关",dc="switching",uc="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",fc="-12 -32 30 64",hc=30,mc=64,pc='<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"/>',gc=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],yc=[{name:"open",type:"boolean",default:!1,label:"断开"}],xc={kind:"inline"},o_={id:lc,name:cc,category:dc,description:uc,viewBox:fc,width:hc,height:mc,svg:pc,terminals:gc,state:yc,source:xc},r_=Object.freeze(Object.defineProperty({__proto__:null,category:dc,default:o_,description:uc,height:mc,id:lc,name:cc,source:xc,state:yc,svg:pc,terminals:gc,viewBox:fc,width:hc},Symbol.toStringTag,{value:"Module"})),bc="dc-motor",wc="直流电机 (M)",vc="load",kc="直流电动机 (串励通用符号)。",_c="-72 -82 89 84",Sc=89,$c=84,jc='<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"/>',Ec=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Nc={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},s_={id:bc,name:wc,category:vc,description:kc,viewBox:_c,width:Sc,height:$c,svg:jc,terminals:Ec,source:Nc},i_=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:s_,description:kc,height:$c,id:bc,name:wc,source:Nc,svg:jc,terminals:Ec,viewBox:_c,width:Sc},Symbol.toStringTag,{value:"Module"})),Ac="diode",Tc="二极管 (D)",Mc="passive",Cc="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Pc="-12 -42 24 44",Ic=24,Oc=44,Bc='<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"/>',Lc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Dc={x:6,y:-20,anchor:"start"},zc={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},a_={id:Ac,name:Tc,category:Mc,description:Cc,viewBox:Pc,width:Ic,height:Oc,svg:Bc,terminals:Lc,label:Dc,source:zc},l_=Object.freeze(Object.defineProperty({__proto__:null,category:Mc,default:a_,description:Cc,height:Oc,id:Ac,label:Dc,name:Tc,source:zc,svg:Bc,terminals:Lc,viewBox:Pc,width:Ic},Symbol.toStringTag,{value:"Module"})),Rc="disconnector",Fc="隔离开关 (QS)",Hc="switching",Wc="-10 -42 15 64",qc=15,Xc=64,Yc='<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"/>',Gc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Kc=[{name:"open",type:"boolean",default:!1,label:"断开"}],Uc={x:6,y:-10,anchor:"start"},Vc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},c_={id:Rc,name:Fc,category:Hc,viewBox:Wc,width:qc,height:Xc,svg:Yc,terminals:Gc,state:Kc,label:Uc,source:Vc},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Hc,default:c_,height:Xc,id:Rc,label:Uc,name:Fc,source:Vc,state:Kc,svg:Yc,terminals:Gc,viewBox:Wc,width:qc},Symbol.toStringTag,{value:"Module"})),Jc="distance-relay",Zc="距离继电器 (21)",Qc="protection",ed="距离 / 低阻抗保护继电器 (ANSI 21)。",td="-62 -42 64 44",nd=64,od=44,rd='<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>',sd=[{id:"t_top",x:-30,y:-40,orientation:"n"}],id={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},u_={id:Jc,name:Zc,category:Qc,description:ed,viewBox:td,width:nd,height:od,svg:rd,terminals:sd,source:id},f_=Object.freeze(Object.defineProperty({__proto__:null,category:Qc,default:u_,description:ed,height:od,id:Jc,name:Zc,source:id,svg:rd,terminals:sd,viewBox:td,width:nd},Symbol.toStringTag,{value:"Module"})),ad="earth",ld="接地",cd="busbar",dd="-12 -17 24 34",ud=24,fd=34,hd='<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"/>',md=[{id:"t1",x:0,y:-15,orientation:"n"}],pd={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"},h_={id:ad,name:ld,category:cd,viewBox:dd,width:ud,height:fd,svg:hd,terminals:md,source:pd},m_=Object.freeze(Object.defineProperty({__proto__:null,category:cd,default:h_,height:fd,id:ad,name:ld,source:pd,svg:hd,terminals:md,viewBox:dd,width:ud},Symbol.toStringTag,{value:"Module"})),gd="earthing-switch",yd="接地刀闸 (QE)",xd="switching",bd="隔离开关 + 接地连接,单端口",wd="-12 -32 24 64",vd=24,kd=64,_d='<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"/>',Sd=[{id:"t_top",x:0,y:-30,orientation:"n"}],$d=[{name:"open",type:"boolean",default:!0,label:"断开"}],jd={x:12,y:-8,anchor:"start"},Ed={kind:"inline"},p_={id:gd,name:yd,category:xd,description:bd,viewBox:wd,width:vd,height:kd,svg:_d,terminals:Sd,state:$d,label:jd,source:Ed},g_=Object.freeze(Object.defineProperty({__proto__:null,category:xd,default:p_,description:bd,height:kd,id:gd,label:jd,name:yd,source:Ed,state:$d,svg:_d,terminals:Sd,viewBox:wd,width:vd},Symbol.toStringTag,{value:"Module"})),Nd="energy-meter",Ad="电能表 (Wh)",Td="measurement",Md="有功电能表 (kWh) — 服务入口 / 子表。",Cd="-22 -36 44 72",Pd=44,Id=72,Od='<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"/>',Bd=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Ld={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},y_={id:Nd,name:Ad,category:Td,description:Md,viewBox:Cd,width:Pd,height:Id,svg:Od,terminals:Bd,source:Ld},x_=Object.freeze(Object.defineProperty({__proto__:null,category:Td,default:y_,description:Md,height:Id,id:Nd,name:Ad,source:Ld,svg:Od,terminals:Bd,viewBox:Cd,width:Pd},Symbol.toStringTag,{value:"Module"})),Dd="ev-charger",zd="EV 充电桩",Rd="load",Fd="电动汽车充电站 / 充电桩。",Hd="-17 -27 34 49",Wd=34,qd=49,Xd='<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>',Yd=[{id:"t_top",x:0,y:-25,orientation:"n"}],Gd={kind:"inline"},b_={id:Dd,name:zd,category:Rd,description:Fd,viewBox:Hd,width:Wd,height:qd,svg:Xd,terminals:Yd,source:Gd},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Rd,default:b_,description:Fd,height:qd,id:Dd,name:zd,source:Gd,svg:Xd,terminals:Yd,viewBox:Hd,width:Wd},Symbol.toStringTag,{value:"Module"})),Kd="frequency-meter",Ud="频率表 (Hz)",Vd="measurement",Jd="-22 -42 44 44",Zd=44,Qd=44,eu='<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>',tu=[{id:"t_top",x:0,y:-40,orientation:"n"}],nu={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},v_={id:Kd,name:Ud,category:Vd,viewBox:Jd,width:Zd,height:Qd,svg:eu,terminals:tu,source:nu},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Vd,default:v_,height:Qd,id:Kd,name:Ud,source:nu,svg:eu,terminals:tu,viewBox:Jd,width:Zd},Symbol.toStringTag,{value:"Module"})),ou="fuse-switch-disconnector",ru="熔断器式隔离开关",su="switching",iu="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",au="-8 -32 12 64",lu=12,cu=64,du='<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"/>',uu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],fu=[{name:"open",type:"boolean",default:!1,label:"断开"}],hu={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"},__={id:ou,name:ru,category:su,description:iu,viewBox:au,width:lu,height:cu,svg:du,terminals:uu,state:fu,source:hu},S_=Object.freeze(Object.defineProperty({__proto__:null,category:su,default:__,description:iu,height:cu,id:ou,name:ru,source:hu,state:fu,svg:du,terminals:uu,viewBox:au,width:lu},Symbol.toStringTag,{value:"Module"})),mu="fuse",pu="熔断器 (FU)",gu="switching",yu="-7 -32 14 64",xu=14,bu=64,wu='<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"/>',vu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ku=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],_u={x:7,y:-2,anchor:"start"},Su={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},$_={id:mu,name:pu,category:gu,viewBox:yu,width:xu,height:bu,svg:wu,terminals:vu,state:ku,label:_u,source:Su},j_=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:$_,height:bu,id:mu,label:_u,name:pu,source:Su,state:ku,svg:wu,terminals:vu,viewBox:yu,width:xu},Symbol.toStringTag,{value:"Module"})),$u="generator",ju="发电机 (G)",Eu="source",Nu="-42 -42 44 44",Au=44,Tu=44,Mu='<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>',Cu=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Pu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},E_={id:$u,name:ju,category:Eu,viewBox:Nu,width:Au,height:Tu,svg:Mu,terminals:Cu,source:Pu},N_=Object.freeze(Object.defineProperty({__proto__:null,category:Eu,default:E_,height:Tu,id:$u,name:ju,source:Pu,svg:Mu,terminals:Cu,viewBox:Nu,width:Au},Symbol.toStringTag,{value:"Module"})),Iu="genset",Ou="发电机组 (G)",Bu="source",Lu="柴油 / 燃气发电机组。",Du="-28 -22 56 64",zu=56,Ru=64,Fu='<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"/>',Hu=[{id:"t_out",x:0,y:40,orientation:"s"}],Wu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],qu={kind:"inline"},A_={id:Iu,name:Ou,category:Bu,description:Lu,viewBox:Du,width:zu,height:Ru,svg:Fu,terminals:Hu,params:Wu,source:qu},T_=Object.freeze(Object.defineProperty({__proto__:null,category:Bu,default:A_,description:Lu,height:Ru,id:Iu,name:Ou,params:Wu,source:qu,svg:Fu,terminals:Hu,viewBox:Du,width:zu},Symbol.toStringTag,{value:"Module"})),Xu="gfci-breaker",Yu="GFCI 断路器 (RCBO)",Gu="protection",Ku="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",Uu="-18 -22 22 44",Vu=22,Ju=44,Zu='<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"/>',Qu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ef=[{name:"open",type:"boolean",default:!1,label:"断开"}],tf=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],nf={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},M_={id:Xu,name:Yu,category:Gu,description:Ku,viewBox:Uu,width:Vu,height:Ju,svg:Zu,terminals:Qu,state:ef,params:tf,source:nf},C_=Object.freeze(Object.defineProperty({__proto__:null,category:Gu,default:M_,description:Ku,height:Ju,id:Xu,name:Yu,params:tf,source:nf,state:ef,svg:Zu,terminals:Qu,viewBox:Uu,width:Vu},Symbol.toStringTag,{value:"Module"})),of="grid-source",rf="系统电源",sf="source",af="无穷大母线 / 外部电网",lf="-16 -31 32 53",cf=32,df=53,uf='<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"/>',ff=[{id:"t_bottom",x:0,y:20,orientation:"s"}],hf={kind:"inline"},P_={id:of,name:rf,category:sf,description:af,viewBox:lf,width:cf,height:df,svg:uf,terminals:ff,source:hf},I_=Object.freeze(Object.defineProperty({__proto__:null,category:sf,default:P_,description:af,height:df,id:of,name:rf,source:hf,svg:uf,terminals:ff,viewBox:lf,width:cf},Symbol.toStringTag,{value:"Module"})),mf="grounding-transformer",pf="接地变 (Z形)",gf="grounding",yf="星-曲折接线变压器,中性点接地用",xf="-62 -152 64 164",bf=64,wf=164,vf='<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"/>',kf=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],_f={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"},O_={id:mf,name:pf,category:gf,description:yf,viewBox:xf,width:bf,height:wf,svg:vf,terminals:kf,source:_f},B_=Object.freeze(Object.defineProperty({__proto__:null,category:gf,default:O_,description:yf,height:wf,id:mf,name:pf,source:_f,svg:vf,terminals:kf,viewBox:xf,width:bf},Symbol.toStringTag,{value:"Module"})),Sf="heater",$f="电加热器 (EH)",jf="load",Ef="电阻加热元件 / 电热负荷。",Nf="-22 -7 54 14",Af=54,Tf=14,Mf='<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"/>',Cf=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Pf=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],If={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},L_={id:Sf,name:$f,category:jf,description:Ef,viewBox:Nf,width:Af,height:Tf,svg:Mf,terminals:Cf,params:Pf,source:If},D_=Object.freeze(Object.defineProperty({__proto__:null,category:jf,default:L_,description:Ef,height:Tf,id:Sf,name:$f,params:Pf,source:If,svg:Mf,terminals:Cf,viewBox:Nf,width:Af},Symbol.toStringTag,{value:"Module"})),Of="igbt",Bf="绝缘栅双极晶体管 (IGBT)",Lf="passive",Df="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",zf="-32 -32 54 74",Rf=54,Ff=74,Hf='<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"/>',Wf=[{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"}],qf={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"},z_={id:Of,name:Bf,category:Lf,description:Df,viewBox:zf,width:Rf,height:Ff,svg:Hf,terminals:Wf,source:qf},R_=Object.freeze(Object.defineProperty({__proto__:null,category:Lf,default:z_,description:Df,height:Ff,id:Of,name:Bf,source:qf,svg:Hf,terminals:Wf,viewBox:zf,width:Rf},Symbol.toStringTag,{value:"Module"})),Xf="indicator-light",Yf="指示灯 (HL)",Gf="control",Kf="信号 / 状态指示灯。",Uf="-12 -22 24 24",Vf=24,Jf=24,Zf='<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"/>',Qf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],eh=[{name:"color",label:"颜色",type:"string"}],th={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},F_={id:Xf,name:Yf,category:Gf,description:Kf,viewBox:Uf,width:Vf,height:Jf,svg:Zf,terminals:Qf,params:eh,source:th},H_=Object.freeze(Object.defineProperty({__proto__:null,category:Gf,default:F_,description:Kf,height:Jf,id:Xf,name:Yf,params:eh,source:th,svg:Zf,terminals:Qf,viewBox:Uf,width:Vf},Symbol.toStringTag,{value:"Module"})),nh="inductor",oh="电感 (L)",rh="passive",sh="通用电感 / 线圈 / 扼流圈。",ih="-17 -32 34 64",ah=34,lh=64,ch='<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"/>',dh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],uh=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],fh={x:6,y:0,anchor:"start"},hh={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},W_={id:nh,name:oh,category:rh,description:sh,viewBox:ih,width:ah,height:lh,svg:ch,terminals:dh,params:uh,label:fh,source:hh},q_=Object.freeze(Object.defineProperty({__proto__:null,category:rh,default:W_,description:sh,height:lh,id:nh,label:fh,name:oh,params:uh,source:hh,svg:ch,terminals:dh,viewBox:ih,width:ah},Symbol.toStringTag,{value:"Module"})),mh="inverter",ph="逆变器 (DC→AC)",gh="renewable",yh="-42 -42 44 44",xh=44,bh=44,wh='<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>',vh=[{id:"t_dc",x:-20,y:0,orientation:"s"},{id:"t_ac",x:-20,y:-40,orientation:"n"}],kh={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},X_={id:mh,name:ph,category:gh,viewBox:yh,width:xh,height:bh,svg:wh,terminals:vh,source:kh},Y_=Object.freeze(Object.defineProperty({__proto__:null,category:gh,default:X_,height:bh,id:mh,name:ph,source:kh,svg:wh,terminals:vh,viewBox:yh,width:xh},Symbol.toStringTag,{value:"Module"})),_h="limit-switch",Sh="限位开关 (SQ)",$h="control",jh="行程 / 位置开关 (常开, 机械操作)。",Eh="-10 -42 12 64",Nh=12,Ah=64,Th='<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"/>',Mh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ch=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Ph={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},G_={id:_h,name:Sh,category:$h,description:jh,viewBox:Eh,width:Nh,height:Ah,svg:Th,terminals:Mh,state:Ch,source:Ph},K_=Object.freeze(Object.defineProperty({__proto__:null,category:$h,default:G_,description:jh,height:Ah,id:_h,name:Sh,source:Ph,state:Ch,svg:Th,terminals:Mh,viewBox:Eh,width:Nh},Symbol.toStringTag,{value:"Module"})),Ih="load-switch",Oh="负荷开关",Bh="switching",Lh="-10 -42 14 64",Dh=14,zh=64,Rh='<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"/>',Fh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Hh=[{name:"open",type:"boolean",default:!1,label:"断开"}],Wh={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"},U_={id:Ih,name:Oh,category:Bh,viewBox:Lh,width:Dh,height:zh,svg:Rh,terminals:Fh,state:Hh,source:Wh},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Bh,default:U_,height:zh,id:Ih,name:Oh,source:Wh,state:Hh,svg:Rh,terminals:Fh,viewBox:Lh,width:Dh},Symbol.toStringTag,{value:"Module"})),qh="load",Xh="负荷",Yh="load",Gh="抽象负荷(电流流出箭头)",Kh="-8 -22 16 46",Uh=16,Vh=46,Jh='<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"/>',Zh=[{id:"t_top",x:0,y:-20,orientation:"n"}],Qh=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],em={x:6,y:0,anchor:"start"},tm={kind:"inline"},J_={id:qh,name:Xh,category:Yh,description:Gh,viewBox:Kh,width:Uh,height:Vh,svg:Jh,terminals:Zh,params:Qh,label:em,source:tm},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:Yh,default:J_,description:Gh,height:Vh,id:qh,label:em,name:Xh,params:Qh,source:tm,svg:Jh,terminals:Zh,viewBox:Kh,width:Uh},Symbol.toStringTag,{value:"Module"})),nm="make-contact",om="常开触点 (NO)",rm="control",sm="常开辅助触点 (make contact)。",im="-10 -42 12 64",am=12,lm=64,cm='<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"/>',dm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],um=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],fm={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"},Q_={id:nm,name:om,category:rm,description:sm,viewBox:im,width:am,height:lm,svg:cm,terminals:dm,state:um,source:fm},eS=Object.freeze(Object.defineProperty({__proto__:null,category:rm,default:Q_,description:sm,height:lm,id:nm,name:om,source:fm,state:um,svg:cm,terminals:dm,viewBox:im,width:am},Symbol.toStringTag,{value:"Module"})),hm="motor-starter",mm="电机启动器",pm="motor-control",gm="电机启动器 (IEC 60617 通用符号)。",ym="-22 -27 44 54",xm=44,bm=54,wm='<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"/>',vm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],km={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},tS={id:hm,name:mm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,source:km},nS=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:tS,description:gm,height:bm,id:hm,name:mm,source:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),_m="ngr",Sm="中性点电阻 (NGR)",$m="grounding",jm="小电阻接地:连接变压器中性点到地",Em="-12 -32 24 62",Nm=24,Am=62,Tm='<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"/>',Mm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Cm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Pm={kind:"inline"},oS={id:_m,name:Sm,category:$m,description:jm,viewBox:Em,width:Nm,height:Am,svg:Tm,terminals:Mm,params:Cm,source:Pm},rS=Object.freeze(Object.defineProperty({__proto__:null,category:$m,default:oS,description:jm,height:Am,id:_m,name:Sm,params:Cm,source:Pm,svg:Tm,terminals:Mm,viewBox:Em,width:Nm},Symbol.toStringTag,{value:"Module"})),Im="overcurrent-relay",Om="过流继电器 (50/51)",Bm="protection",Lm="过电流保护继电器 (ANSI 50/51)。",Dm="-62 -62 64 64",zm=64,Rm=64,Fm='<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>',Hm=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Wm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},sS={id:Im,name:Om,category:Bm,description:Lm,viewBox:Dm,width:zm,height:Rm,svg:Fm,terminals:Hm,source:Wm},iS=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:sS,description:Lm,height:Rm,id:Im,name:Om,source:Wm,svg:Fm,terminals:Hm,viewBox:Dm,width:zm},Symbol.toStringTag,{value:"Module"})),qm="panelboard",Xm="配电箱",Ym="load",Gm="配电箱 / 负荷中心(IEC 60617 分配中心符号):顶部进线,底部分路示意",Km="-52 -62 54 64",Um=54,Vm=64,Jm='<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>',Zm=[{id:"t_in",x:-25,y:-60,orientation:"n"}],Qm={kind:"elmt",path:"91_en_60617/en_60617_11/en_60617_11_12/en_60617_11_12_07.elmt",qetEnglishName:"Distribution centre"},aS={id:qm,name:Xm,category:Ym,description:Gm,viewBox:Km,width:Um,height:Vm,svg:Jm,terminals:Zm,source:Qm},lS=Object.freeze(Object.defineProperty({__proto__:null,category:Ym,default:aS,description:Gm,height:Vm,id:qm,name:Xm,source:Qm,svg:Jm,terminals:Zm,viewBox:Km,width:Um},Symbol.toStringTag,{value:"Module"})),ep="phase-failure-relay",tp="断相继电器",np="protection",op="断相 / 缺相保护继电器。",rp="-62 -42 64 44",sp=64,ip=44,ap='<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>',lp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],cp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},cS={id:ep,name:tp,category:np,description:op,viewBox:rp,width:sp,height:ip,svg:ap,terminals:lp,source:cp},dS=Object.freeze(Object.defineProperty({__proto__:null,category:np,default:cS,description:op,height:ip,id:ep,name:tp,source:cp,svg:ap,terminals:lp,viewBox:rp,width:sp},Symbol.toStringTag,{value:"Module"})),dp="plc",up="PLC / 控制器",fp="control",hp="可编程逻辑控制器 (PLC)。",mp="-24 -42 48 84",pp=48,gp=84,yp='<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"/>',xp=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],bp={kind:"inline"},uS={id:dp,name:up,category:fp,description:hp,viewBox:mp,width:pp,height:gp,svg:yp,terminals:xp,source:bp},fS=Object.freeze(Object.defineProperty({__proto__:null,category:fp,default:uS,description:hp,height:gp,id:dp,name:up,source:bp,svg:yp,terminals:xp,viewBox:mp,width:pp},Symbol.toStringTag,{value:"Module"})),wp="power-factor-meter",vp="功率因数表 (cosφ)",kp="measurement",_p="功率因数表 (cosφ)。",Sp="-22 -42 44 44",$p=44,jp=44,Ep='<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>',Np=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ap={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},hS={id:wp,name:vp,category:kp,description:_p,viewBox:Sp,width:$p,height:jp,svg:Ep,terminals:Np,source:Ap},mS=Object.freeze(Object.defineProperty({__proto__:null,category:kp,default:hS,description:_p,height:jp,id:wp,name:vp,source:Ap,svg:Ep,terminals:Np,viewBox:Sp,width:$p},Symbol.toStringTag,{value:"Module"})),Tp="power-supply",Mp="开关电源 (PS)",Cp="source",Pp="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Ip="-24 -42 48 84",Op=48,Bp=84,Lp='<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"/>',Dp=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],zp=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Rp={kind:"inline"},pS={id:Tp,name:Mp,category:Cp,description:Pp,viewBox:Ip,width:Op,height:Bp,svg:Lp,terminals:Dp,params:zp,source:Rp},gS=Object.freeze(Object.defineProperty({__proto__:null,category:Cp,default:pS,description:Pp,height:Bp,id:Tp,name:Mp,params:zp,source:Rp,svg:Lp,terminals:Dp,viewBox:Ip,width:Op},Symbol.toStringTag,{value:"Module"})),Fp="protective-relay",Hp="保护继电器",Wp="protection",qp="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Xp="-32 -42 64 44",Yp=64,Gp=44,Kp='<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"/>',Up=[{id:"t_top",x:0,y:-40,orientation:"n"}],Vp={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"},yS={id:Fp,name:Hp,category:Wp,description:qp,viewBox:Xp,width:Yp,height:Gp,svg:Kp,terminals:Up,source:Vp},xS=Object.freeze(Object.defineProperty({__proto__:null,category:Wp,default:yS,description:qp,height:Gp,id:Fp,name:Hp,source:Vp,svg:Kp,terminals:Up,viewBox:Xp,width:Yp},Symbol.toStringTag,{value:"Module"})),Jp="proximity-switch",Zp="接近开关 (SQ)",Qp="control",e0="接近传感器 / 无触点接近开关。",t0="-12 -32 24 64",n0=24,o0=64,r0='<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"/>',s0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],i0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},bS={id:Jp,name:Zp,category:Qp,description:e0,viewBox:t0,width:n0,height:o0,svg:r0,terminals:s0,source:i0},wS=Object.freeze(Object.defineProperty({__proto__:null,category:Qp,default:bS,description:e0,height:o0,id:Jp,name:Zp,source:i0,svg:r0,terminals:s0,viewBox:t0,width:n0},Symbol.toStringTag,{value:"Module"})),a0="pt",l0="电压互感器 (PT)",c0="instrument-transformer",d0="-22 -42 44 115",u0=44,f0=115,h0='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',m0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],p0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},vS={id:a0,name:l0,category:c0,viewBox:d0,width:u0,height:f0,svg:h0,terminals:m0,source:p0},kS=Object.freeze(Object.defineProperty({__proto__:null,category:c0,default:vS,height:f0,id:a0,name:l0,source:p0,svg:h0,terminals:m0,viewBox:d0,width:u0},Symbol.toStringTag,{value:"Module"})),g0="push-button",y0="按钮 (SB)",x0="control",b0="手动按钮, 自动复位 (常开 make)。",w0="-37 -42 39 64",v0=39,k0=64,_0='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',S0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],$0={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"},_S={id:g0,name:y0,category:x0,description:b0,viewBox:w0,width:v0,height:k0,svg:_0,terminals:S0,source:$0},SS=Object.freeze(Object.defineProperty({__proto__:null,category:x0,default:_S,description:b0,height:k0,id:g0,name:y0,source:$0,svg:_0,terminals:S0,viewBox:w0,width:v0},Symbol.toStringTag,{value:"Module"})),j0="pv",E0="光伏组件",N0="renewable",A0="-33 -22 85 64",T0=85,M0=64,C0='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',P0=[{id:"t_dc",x:0,y:40,orientation:"s"}],I0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},$S={id:j0,name:E0,category:N0,viewBox:A0,width:T0,height:M0,svg:C0,terminals:P0,source:I0},jS=Object.freeze(Object.defineProperty({__proto__:null,category:N0,default:$S,height:M0,id:j0,name:E0,source:I0,svg:C0,terminals:P0,viewBox:A0,width:T0},Symbol.toStringTag,{value:"Module"})),O0="rcd",B0="剩余电流装置 (RCD)",L0="protection",D0="不带过流保护的剩余电流断路器 (IEC 61008)。",z0="-12 -22 19 44",R0=19,F0=44,H0='<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"/>',W0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],q0=[{name:"open",type:"boolean",default:!1,label:"断开"}],X0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Y0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},ES={id:O0,name:B0,category:L0,description:D0,viewBox:z0,width:R0,height:F0,svg:H0,terminals:W0,state:q0,params:X0,source:Y0},NS=Object.freeze(Object.defineProperty({__proto__:null,category:L0,default:ES,description:D0,height:F0,id:O0,name:B0,params:X0,source:Y0,state:q0,svg:H0,terminals:W0,viewBox:z0,width:R0},Symbol.toStringTag,{value:"Module"})),G0="recloser",K0="重合闸 (Recloser)",U0="protection",V0="中压自动重合闸开关。",J0="-12 -32 36 64",Z0=36,Q0=64,eg='<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>',tg=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ng=[{name:"open",type:"boolean",default:!1,label:"断开"}],og={kind:"inline"},AS={id:G0,name:K0,category:U0,description:V0,viewBox:J0,width:Z0,height:Q0,svg:eg,terminals:tg,state:ng,source:og},TS=Object.freeze(Object.defineProperty({__proto__:null,category:U0,default:AS,description:V0,height:Q0,id:G0,name:K0,source:og,state:ng,svg:eg,terminals:tg,viewBox:J0,width:Z0},Symbol.toStringTag,{value:"Module"})),rg="rectifier",sg="整流器 (AC→DC)",ig="renewable",ag="-42 -42 44 44",lg=44,cg=44,dg='<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"/>',ug=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],fg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},MS={id:rg,name:sg,category:ig,viewBox:ag,width:lg,height:cg,svg:dg,terminals:ug,source:fg},CS=Object.freeze(Object.defineProperty({__proto__:null,category:ig,default:MS,height:cg,id:rg,name:sg,source:fg,svg:dg,terminals:ug,viewBox:ag,width:lg},Symbol.toStringTag,{value:"Module"})),hg="relay-coil",mg="继电器线圈 (KA)",pg="control",gg="继电器 / 接触器操作线圈 (方框)。",yg="-22 -22 44 44",xg=44,bg=44,wg='<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"/>',vg=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],kg={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"},PS={id:hg,name:mg,category:pg,description:gg,viewBox:yg,width:xg,height:bg,svg:wg,terminals:vg,source:kg},IS=Object.freeze(Object.defineProperty({__proto__:null,category:pg,default:PS,description:gg,height:bg,id:hg,name:mg,source:kg,svg:wg,terminals:vg,viewBox:yg,width:xg},Symbol.toStringTag,{value:"Module"})),_g="resistor",Sg="电阻 (R)",$g="passive",jg="通用电阻 / 限流 / 制动电阻。",Eg="-6 -23 12 35",Ng=12,Ag=35,Tg='<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"/>',Mg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Cg=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Pg={x:6,y:0,anchor:"start"},Ig={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},OS={id:_g,name:Sg,category:$g,description:jg,viewBox:Eg,width:Ng,height:Ag,svg:Tg,terminals:Mg,params:Cg,label:Pg,source:Ig},BS=Object.freeze(Object.defineProperty({__proto__:null,category:$g,default:OS,description:jg,height:Ag,id:_g,label:Pg,name:Sg,params:Cg,source:Ig,svg:Tg,terminals:Mg,viewBox:Eg,width:Ng},Symbol.toStringTag,{value:"Module"})),Og="reverse-power-relay",Bg="逆功率继电器 (32)",Lg="protection",Dg="逆功率 / 逆流保护继电器 (ANSI 32)。",zg="-62 -42 64 44",Rg=64,Fg=44,Hg='<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"/>',Wg=[{id:"t_top",x:-30,y:-40,orientation:"n"}],qg={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},LS={id:Og,name:Bg,category:Lg,description:Dg,viewBox:zg,width:Rg,height:Fg,svg:Hg,terminals:Wg,source:qg},DS=Object.freeze(Object.defineProperty({__proto__:null,category:Lg,default:LS,description:Dg,height:Fg,id:Og,name:Bg,source:qg,svg:Hg,terminals:Wg,viewBox:zg,width:Rg},Symbol.toStringTag,{value:"Module"})),Xg="selector-switch",Yg="选择开关 (SA)",Gg="switching",Kg="转换 / 选择开关 (旋转操作, 保位)。",Ug="-34 -42 36 64",Vg=36,Jg=64,Zg='<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"/>',Qg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],e1=[{name:"open",type:"boolean",default:!1,label:"断开"}],t1={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"},zS={id:Xg,name:Yg,category:Gg,description:Kg,viewBox:Ug,width:Vg,height:Jg,svg:Zg,terminals:Qg,state:e1,source:t1},RS=Object.freeze(Object.defineProperty({__proto__:null,category:Gg,default:zS,description:Kg,height:Jg,id:Xg,name:Yg,source:t1,state:e1,svg:Zg,terminals:Qg,viewBox:Ug,width:Vg},Symbol.toStringTag,{value:"Module"})),n1="series-reactor",o1="串联电抗器",r1="compensation",s1="与并联电抗器同符号;通过用法区分。",i1="-62 -82 64 104",a1=64,l1=104,c1='<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"/>',d1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],u1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},FS={id:n1,name:o1,category:r1,description:s1,viewBox:i1,width:a1,height:l1,svg:c1,terminals:d1,source:u1},HS=Object.freeze(Object.defineProperty({__proto__:null,category:r1,default:FS,description:s1,height:l1,id:n1,name:o1,source:u1,svg:c1,terminals:d1,viewBox:i1,width:a1},Symbol.toStringTag,{value:"Module"})),f1="shunt-capacitor",h1="并联电容器",m1="compensation",p1="-7 -23 14 27",g1=14,y1=27,x1='<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"/>',b1=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],w1=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],v1={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},WS={id:f1,name:h1,category:m1,viewBox:p1,width:g1,height:y1,svg:x1,terminals:b1,params:w1,source:v1},qS=Object.freeze(Object.defineProperty({__proto__:null,category:m1,default:WS,height:y1,id:f1,name:h1,params:w1,source:v1,svg:x1,terminals:b1,viewBox:p1,width:g1},Symbol.toStringTag,{value:"Module"})),k1="shunt-reactor",_1="并联电抗器",S1="compensation",$1="-62 -82 64 104",j1=64,E1=104,N1='<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"/>',A1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],T1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},XS={id:k1,name:_1,category:S1,viewBox:$1,width:j1,height:E1,svg:N1,terminals:A1,source:T1},YS=Object.freeze(Object.defineProperty({__proto__:null,category:S1,default:XS,height:E1,id:k1,name:_1,source:T1,svg:N1,terminals:A1,viewBox:$1,width:j1},Symbol.toStringTag,{value:"Module"})),M1="siren",C1="警笛 (HA)",P1="control",I1="声响警笛 / 报警器。",O1="-32 -42 44 54",B1=44,L1=54,D1='<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"/>',z1=[{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"},GS={id:M1,name:C1,category:P1,description:I1,viewBox:O1,width:B1,height:L1,svg:D1,terminals:z1,source:R1},KS=Object.freeze(Object.defineProperty({__proto__:null,category:P1,default:GS,description:I1,height:L1,id:M1,name:C1,source:R1,svg:D1,terminals:z1,viewBox:O1,width:B1},Symbol.toStringTag,{value:"Module"})),F1="socket-outlet",H1="插座 / 连接器",W1="load",q1="电源插座 / 多极连接器。",X1="-7 -2 13 34",Y1=13,G1=34,K1='<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"}],V1={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
217
|
+
unifilar`},US={id:F1,name:H1,category:W1,description:q1,viewBox:X1,width:Y1,height:G1,svg:K1,terminals:U1,source:V1},VS=Object.freeze(Object.defineProperty({__proto__:null,category:W1,default:US,description:q1,height:G1,id:F1,name:H1,source:V1,svg:K1,terminals:U1,viewBox:X1,width:Y1},Symbol.toStringTag,{value:"Module"})),J1="soft-starter",Z1="软启动器",Q1="motor-control",ey="电机软启动器 (晶闸管降压启动)。",ty="-22 -42 44 84",ny=44,oy=84,ry='<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"/>',sy=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],iy={kind:"inline"},JS={id:J1,name:Z1,category:Q1,description:ey,viewBox:ty,width:ny,height:oy,svg:ry,terminals:sy,source:iy},ZS=Object.freeze(Object.defineProperty({__proto__:null,category:Q1,default:JS,description:ey,height:oy,id:J1,name:Z1,source:iy,svg:ry,terminals:sy,viewBox:ty,width:ny},Symbol.toStringTag,{value:"Module"})),ay="sync-motor",ly="同步电动机",cy="load",dy="-62 -82 64 114",uy=64,fy=114,hy='<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"/>',my=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],py={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},QS={id:ay,name:ly,category:cy,viewBox:dy,width:uy,height:fy,svg:hy,terminals:my,source:py},e$=Object.freeze(Object.defineProperty({__proto__:null,category:cy,default:QS,height:fy,id:ay,name:ly,source:py,svg:hy,terminals:my,viewBox:dy,width:uy},Symbol.toStringTag,{value:"Module"})),gy="synchronoscope",yy="同步表",xy="measurement",by="同步指示器 / 同步表。",wy="-22 -42 44 44",vy=44,ky=44,_y='<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"/>',Sy=[{id:"t_top",x:0,y:-40,orientation:"n"}],$y={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},t$={id:gy,name:yy,category:xy,description:by,viewBox:wy,width:vy,height:ky,svg:_y,terminals:Sy,source:$y},n$=Object.freeze(Object.defineProperty({__proto__:null,category:xy,default:t$,description:by,height:ky,id:gy,name:yy,source:$y,svg:_y,terminals:Sy,viewBox:wy,width:vy},Symbol.toStringTag,{value:"Module"})),jy="terminal",Ey="接线端子 / 节点 (X)",Ny="busbar",Ay="接线端子 / 接线盒 / 汇接节点。",Ty="-5 -5 10 10",My=10,Cy=10,Py='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',Iy=[{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"}],Oy={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},o$={id:jy,name:Ey,category:Ny,description:Ay,viewBox:Ty,width:My,height:Cy,svg:Py,terminals:Iy,source:Oy},r$=Object.freeze(Object.defineProperty({__proto__:null,category:Ny,default:o$,description:Ay,height:Cy,id:jy,name:Ey,source:Oy,svg:Py,terminals:Iy,viewBox:Ty,width:My},Symbol.toStringTag,{value:"Module"})),By="thermal-overload",Ly="热过载继电器",Dy="motor-control",zy="电机热过载保护继电器, 通常串接在接触器和电机之间。",Ry="-9 -32 19 64",Fy=19,Hy=64,Wy='<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"/>',qy=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Xy=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],Yy={kind:"inline"},s$={id:By,name:Ly,category:Dy,description:zy,viewBox:Ry,width:Fy,height:Hy,svg:Wy,terminals:qy,state:Xy,source:Yy},i$=Object.freeze(Object.defineProperty({__proto__:null,category:Dy,default:s$,description:zy,height:Hy,id:By,name:Ly,source:Yy,state:Xy,svg:Wy,terminals:qy,viewBox:Ry,width:Fy},Symbol.toStringTag,{value:"Module"})),Gy="thermocouple",Ky="热电偶 (BT)",Uy="measurement",Vy="热电偶温度传感器。",Jy="-26 -42 52 46",Zy=52,Qy=46,ex='<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"/>',tx=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],nx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},a$={id:Gy,name:Ky,category:Uy,description:Vy,viewBox:Jy,width:Zy,height:Qy,svg:ex,terminals:tx,source:nx},l$=Object.freeze(Object.defineProperty({__proto__:null,category:Uy,default:a$,description:Vy,height:Qy,id:Gy,name:Ky,source:nx,svg:ex,terminals:tx,viewBox:Jy,width:Zy},Symbol.toStringTag,{value:"Module"})),ox="thyristor",rx="晶闸管 (V)",sx="passive",ix="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ax="-22 -42 34 44",lx=34,cx=44,dx='<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"/>',ux=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fx={x:6,y:-20,anchor:"start"},hx={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)"},c$={id:ox,name:rx,category:sx,description:ix,viewBox:ax,width:lx,height:cx,svg:dx,terminals:ux,label:fx,source:hx},d$=Object.freeze(Object.defineProperty({__proto__:null,category:sx,default:c$,description:ix,height:cx,id:ox,label:fx,name:rx,source:hx,svg:dx,terminals:ux,viewBox:ax,width:lx},Symbol.toStringTag,{value:"Module"})),mx="time-relay",px="时间继电器 (KT)",gx="control",yx="延时 (缓动) 继电器线圈。",xx="-32 -22 54 44",bx=54,wx=44,vx='<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"/>',kx=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_x={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"},u$={id:mx,name:px,category:gx,description:yx,viewBox:xx,width:bx,height:wx,svg:vx,terminals:kx,source:_x},f$=Object.freeze(Object.defineProperty({__proto__:null,category:gx,default:u$,description:yx,height:wx,id:mx,name:px,source:_x,svg:vx,terminals:kx,viewBox:xx,width:bx},Symbol.toStringTag,{value:"Module"})),Sx="transfer-switch",$x="切换开关 (ATS)",jx="switching",Ex="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Nx="-27 -32 51 64",Ax=51,Tx=64,Mx='<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"/>',Cx=[{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"}],Px=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Ix={kind:"inline"},h$={id:Sx,name:$x,category:jx,description:Ex,viewBox:Nx,width:Ax,height:Tx,svg:Mx,terminals:Cx,state:Px,source:Ix},m$=Object.freeze(Object.defineProperty({__proto__:null,category:jx,default:h$,description:Ex,height:Tx,id:Sx,name:$x,source:Ix,state:Px,svg:Mx,terminals:Cx,viewBox:Nx,width:Ax},Symbol.toStringTag,{value:"Module"})),Ox="transformer-2w",Bx="双绕组变压器",Lx="transformer",Dx="-62 -142 64 144",zx=64,Rx=144,Fx='<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"/>',Hx=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Wx=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],qx={x:4,y:-68,anchor:"start"},Xx={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"},p$={id:Ox,name:Bx,category:Lx,viewBox:Dx,width:zx,height:Rx,svg:Fx,terminals:Hx,params:Wx,label:qx,source:Xx},g$=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:p$,height:Rx,id:Ox,label:qx,name:Bx,params:Wx,source:Xx,svg:Fx,terminals:Hx,viewBox:Dx,width:zx},Symbol.toStringTag,{value:"Module"})),Yx="transformer-3w",Gx="三绕组变压器",Kx="transformer",Ux="-82 -131 114 133",Vx=114,Jx=133,Zx='<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"/>',Qx=[{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"}],eb={x:4,y:-64,anchor:"start"},tb={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"},y$={id:Yx,name:Gx,category:Kx,viewBox:Ux,width:Vx,height:Jx,svg:Zx,terminals:Qx,label:eb,source:tb},x$=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:y$,height:Jx,id:Yx,label:eb,name:Gx,source:tb,svg:Zx,terminals:Qx,viewBox:Ux,width:Vx},Symbol.toStringTag,{value:"Module"})),nb="triac",ob="双向晶闸管 (V)",rb="passive",sb="双向三极晶闸管 (TRIAC)。",ib="-22 -42 44 44",ab=44,lb=44,cb='<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"/>',db=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],ub={x:6,y:-20,anchor:"start"},fb={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},b$={id:nb,name:ob,category:rb,description:sb,viewBox:ib,width:ab,height:lb,svg:cb,terminals:db,label:ub,source:fb},w$=Object.freeze(Object.defineProperty({__proto__:null,category:rb,default:b$,description:sb,height:lb,id:nb,label:ub,name:ob,source:fb,svg:cb,terminals:db,viewBox:ib,width:ab},Symbol.toStringTag,{value:"Module"})),hb="undervoltage-relay",mb="欠压继电器 (27)",pb="protection",gb="欠电压保护继电器 (ANSI 27)。",yb="-62 -82 64 84",xb=64,bb=84,wb='<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>',vb=[{id:"t_top",x:-30,y:-80,orientation:"n"}],kb={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},v$={id:hb,name:mb,category:pb,description:gb,viewBox:yb,width:xb,height:bb,svg:wb,terminals:vb,source:kb},k$=Object.freeze(Object.defineProperty({__proto__:null,category:pb,default:v$,description:gb,height:bb,id:hb,name:mb,source:kb,svg:wb,terminals:vb,viewBox:yb,width:xb},Symbol.toStringTag,{value:"Module"})),_b="ups",Sb="不间断电源 (UPS)",$b="source",jb="在线 / 后备式不间断电源。",Eb="-26 -42 52 84",Nb=52,Ab=84,Tb='<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"/>',Mb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Cb=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Pb={kind:"inline"},_$={id:_b,name:Sb,category:$b,description:jb,viewBox:Eb,width:Nb,height:Ab,svg:Tb,terminals:Mb,params:Cb,source:Pb},S$=Object.freeze(Object.defineProperty({__proto__:null,category:$b,default:_$,description:jb,height:Ab,id:_b,name:Sb,params:Cb,source:Pb,svg:Tb,terminals:Mb,viewBox:Eb,width:Nb},Symbol.toStringTag,{value:"Module"})),Ib="varmeter",Ob="无功功率表 (var)",Bb="measurement",Lb="无功功率表 (var)。",Db="-22 -42 44 44",zb=44,Rb=44,Fb='<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>',Hb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Wb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},$$={id:Ib,name:Ob,category:Bb,description:Lb,viewBox:Db,width:zb,height:Rb,svg:Fb,terminals:Hb,source:Wb},j$=Object.freeze(Object.defineProperty({__proto__:null,category:Bb,default:$$,description:Lb,height:Rb,id:Ib,name:Ob,source:Wb,svg:Fb,terminals:Hb,viewBox:Db,width:zb},Symbol.toStringTag,{value:"Module"})),qb="vfd",Xb="变频器 (VFD)",Yb="motor-control",Gb="Variable Frequency Drive — 异步电动机调速。",Kb="-24 -42 48 84",Ub=48,Vb=84,Jb='<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"/>',Zb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Qb={kind:"inline"},E$={id:qb,name:Xb,category:Yb,description:Gb,viewBox:Kb,width:Ub,height:Vb,svg:Jb,terminals:Zb,source:Qb},N$=Object.freeze(Object.defineProperty({__proto__:null,category:Yb,default:E$,description:Gb,height:Vb,id:qb,name:Xb,source:Qb,svg:Jb,terminals:Zb,viewBox:Kb,width:Ub},Symbol.toStringTag,{value:"Module"})),ew="voltage-regulator",tw="调压器 (T)",nw="transformer",ow="可调感应调压器 / 自耦调压器。",rw="-17 -32 38 64",sw=38,iw=64,aw='<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"/>',lw=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],cw=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],dw={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},A$={id:ew,name:tw,category:nw,description:ow,viewBox:rw,width:sw,height:iw,svg:aw,terminals:lw,params:cw,source:dw},T$=Object.freeze(Object.defineProperty({__proto__:null,category:nw,default:A$,description:ow,height:iw,id:ew,name:tw,params:cw,source:dw,svg:aw,terminals:lw,viewBox:rw,width:sw},Symbol.toStringTag,{value:"Module"})),uw="voltmeter",fw="电压表 (V)",hw="measurement",mw="-22 -42 44 44",pw=44,gw=44,yw='<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>',xw=[{id:"t_top",x:0,y:-40,orientation:"n"}],bw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},M$={id:uw,name:fw,category:hw,viewBox:mw,width:pw,height:gw,svg:yw,terminals:xw,source:bw},C$=Object.freeze(Object.defineProperty({__proto__:null,category:hw,default:M$,height:gw,id:uw,name:fw,source:bw,svg:yw,terminals:xw,viewBox:mw,width:pw},Symbol.toStringTag,{value:"Module"})),ww="wattmeter",vw="功率表 (W)",kw="measurement",_w="-22 -42 44 44",Sw=44,$w=44,jw='<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>',Ew=[{id:"t_top",x:0,y:-40,orientation:"n"}],Nw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},P$={id:ww,name:vw,category:kw,viewBox:_w,width:Sw,height:$w,svg:jw,terminals:Ew,source:Nw},I$=Object.freeze(Object.defineProperty({__proto__:null,category:kw,default:P$,height:$w,id:ww,name:vw,source:Nw,svg:jw,terminals:Ew,viewBox:_w,width:Sw},Symbol.toStringTag,{value:"Module"})),Aw="wind-turbine",Tw="风力发电机",Mw="renewable",Cw="风机:发电机 + 三叶轮标记",Pw="-22 -46 44 68",Iw=44,Ow=68,Bw='<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"/>',Lw=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Dw={kind:"inline"},O$={id:Aw,name:Tw,category:Mw,description:Cw,viewBox:Pw,width:Iw,height:Ow,svg:Bw,terminals:Lw,source:Dw},B$=Object.freeze(Object.defineProperty({__proto__:null,category:Mw,default:O$,description:Cw,height:Ow,id:Aw,name:Tw,source:Dw,svg:Bw,terminals:Lw,viewBox:Pw,width:Iw},Symbol.toStringTag,{value:"Module"})),zw="zener-diode",Rw="稳压二极管 (D)",Fw="passive",Hw="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",Ww="-12 -42 24 44",qw=24,Xw=44,Yw='<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"/>',Gw=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Kw={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"},L$={id:zw,name:Rw,category:Fw,description:Hw,viewBox:Ww,width:qw,height:Xw,svg:Yw,terminals:Gw,label:Kw,source:Uw},D$=Object.freeze(Object.defineProperty({__proto__:null,category:Fw,default:L$,description:Hw,height:Xw,id:zw,label:Kw,name:Rw,source:Uw,svg:Yw,terminals:Gw,viewBox:Ww,width:qw},Symbol.toStringTag,{value:"Module"})),z$=Object.assign({"./ammeter.json":Sk,"./arc-suppression-coil.json":jk,"./arrester.json":Nk,"./async-motor.json":Tk,"./autotransformer.json":Ck,"./battery.json":Ik,"./bell.json":Bk,"./break-contact.json":Dk,"./breaker.json":Rk,"./buchholz-relay.json":Hk,"./busbar.json":qk,"./buzzer.json":Yk,"./capacitor.json":Kk,"./contactor.json":Vk,"./converter-bidir.json":Zk,"./ct.json":e_,"./dc-combiner.json":n_,"./dc-disconnector.json":r_,"./dc-motor.json":i_,"./diode.json":l_,"./disconnector.json":d_,"./distance-relay.json":f_,"./earth.json":m_,"./earthing-switch.json":g_,"./energy-meter.json":x_,"./ev-charger.json":w_,"./frequency-meter.json":k_,"./fuse-switch-disconnector.json":S_,"./fuse.json":j_,"./generator.json":N_,"./genset.json":T_,"./gfci-breaker.json":C_,"./grid-source.json":I_,"./grounding-transformer.json":B_,"./heater.json":D_,"./igbt.json":R_,"./indicator-light.json":H_,"./inductor.json":q_,"./inverter.json":Y_,"./limit-switch.json":K_,"./load-switch.json":V_,"./load.json":Z_,"./make-contact.json":eS,"./motor-starter.json":nS,"./ngr.json":rS,"./overcurrent-relay.json":iS,"./panelboard.json":lS,"./phase-failure-relay.json":dS,"./plc.json":fS,"./power-factor-meter.json":mS,"./power-supply.json":gS,"./protective-relay.json":xS,"./proximity-switch.json":wS,"./pt.json":kS,"./push-button.json":SS,"./pv.json":jS,"./rcd.json":NS,"./recloser.json":TS,"./rectifier.json":CS,"./relay-coil.json":IS,"./resistor.json":BS,"./reverse-power-relay.json":DS,"./selector-switch.json":RS,"./series-reactor.json":HS,"./shunt-capacitor.json":qS,"./shunt-reactor.json":YS,"./siren.json":KS,"./socket-outlet.json":VS,"./soft-starter.json":ZS,"./sync-motor.json":e$,"./synchronoscope.json":n$,"./terminal.json":r$,"./thermal-overload.json":i$,"./thermocouple.json":l$,"./thyristor.json":d$,"./time-relay.json":f$,"./transfer-switch.json":m$,"./transformer-2w.json":g$,"./transformer-3w.json":x$,"./triac.json":w$,"./undervoltage-relay.json":k$,"./ups.json":S$,"./varmeter.json":j$,"./vfd.json":N$,"./voltage-regulator.json":T$,"./voltmeter.json":C$,"./wattmeter.json":I$,"./wind-turbine.json":B$,"./zener-diode.json":D$}),Vw=Object.values(z$).map(e=>e.default),ot=Object.fromEntries(Vw.map(e=>[e.id,e])),vr=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],R$=(()=>{var t;const e={};for(const n of Vw)(e[t=n.category]??(e[t]=[])).push(n);return e})(),ao=new Map(Object.entries(ot));function Jw(e){return ot[e]}function F$(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 H$=320;function et(e){var v,M,I,F,G;const t=Gs(),n=new Map;e.elements.forEach(($,H)=>{if(n.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/elements/${H}`});return}n.set($.id,$);const W=ao.get($.kind);W||t.diagnostics.push({code:"E003",severity:"error",message:`${ve("compile.unknownKind",{kind:$.kind})} (id=${$.id})`,pointer:`/elements/${H}`}),t.elements.set($.id,{element:$,libraryDef:W})});const o=new Map,r=new Map;(e.buses??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/buses/${H}`});return}if(o.set($.id,$),$.layout){const W=$.layout.rot??0;r.set($.id,{at:$.layout.at,span:$.layout.span,rot:W,axis:so(W)})}});const s=new Map;(e.junctions??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)||s.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/junctions/${H}`});return}s.set($.id,$)});const i=$=>!$.includes(".")&&o.has($),a=$=>!$.includes(".")&&s.has($),l=($,H)=>{if(i($)||a($))return!0;const W=$.indexOf(".");if(W<=0)return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.invalidTermRef",{ref:$}),pointer:H}),!1;const X=$.slice(0,W),P=$.slice(W+1),R=t.elements.get(X);if(!R)return t.diagnostics.push({code:"E002",severity:"error",message:ve("compile.elementMissing",{id:X}),pointer:H}),!1;if(!R.libraryDef)return!1;if(!R.libraryDef.terminals.find(Z=>Z.id===P)){const Z=R.libraryDef.terminals.map(ie=>ie.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.missingPin",{id:X,kind:R.element.kind,pin:P,available:Z}),pointer:H}),!1}return!0},c=[];(e.wires??[]).forEach(($,H)=>{const W=`/wires/${H}`,X=l($.ends[0],W),P=l($.ends[1],W);X&&P&&c.push($)});const u=new Map;if(e.layout)for(const[$,H]of Object.entries(e.layout))t.elements.has($)?u.set($,Ks(H)):t.diagnostics.push({code:"E004",severity:"error",message:ve("compile.layoutMissingElement",{id:$}),pointer:`/layout/${$}`});const f=vk({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:ao,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[$,H]of f.buses){const W=o.get($);W&&t.buses.set($,{bus:W,geometry:H})}for(const[$,H]of o)t.buses.has($)||t.buses.set($,{bus:H,geometry:{at:((v=H.layout)==null?void 0:v.at)??[0,0],span:((M=H.layout)==null?void 0:M.span)??H$,rot:((I=H.layout)==null?void 0:I.rot)??0,axis:so(((F=H.layout)==null?void 0:F.rot)??0)}});for(const $ of t.elements.values()){if(!$.libraryDef)continue;const H=t.layout.get($.element.id);if(!H)continue;const W=[];for(const X of $.libraryDef.terminals){const P=`${$.element.id}.${X.id}`,R=Ie([X.x,X.y],H),Z=Ot(X.orientation,H);t.terminals.set(P,{ref:P,elementId:$.element.id,pin:X.id,world:R,orientation:Z}),W.push(P)}t.elementToTerminals.set($.element.id,W)}const h=new Map,g=new Set;for(const[$,H]of s)(G=H.layout)!=null&&G.at?(h.set($,[H.layout.at[0],H.layout.at[1]]),g.add($)):f.junctions.has($)&&(h.set($,f.junctions.get($)),g.add($));const m=$=>{if(!$.includes(".")){const W=t.buses.get($);return W?W.geometry.at:h.get($)??null}const H=t.terminals.get($);return H?H.world:null},p=new Map;for(const[$]of s)g.has($)||p.set($,[]);for(const $ of c){const[H,W]=$.ends;p.has(H)&&p.get(H).push(W),p.has(W)&&p.get(W).push(H)}for(let $=0;$<12;$++){let H=!1;for(const[W,X]of p){let P=0,R=0,Z=0;for(const ae of X){const me=m(ae);me&&(P+=me[0],R+=me[1],Z++)}if(!Z)continue;const ie=P/Z,ue=R/Z,ee=h.get(W);(!ee||Math.abs(ee[0]-ie)>.01||Math.abs(ee[1]-ue)>.01)&&(h.set(W,[ie,ue]),H=!0)}if(!H)break}const x=new Map;for(const[$]of s)x.set($,0);for(const $ of c)for(const H of $.ends){const W=x.get(H);W!==void 0&&x.set(H,W+1)}for(const[$,H]of s)t.junctions.set($,{junction:H,world:h.get($)??[0,0],degree:x.get($)??0});const w=new Us;for(const $ of c)w.add($.ends[0]),w.add($.ends[1]),w.union($.ends[0],$.ends[1]);for(const[,$]of w.groups()){const H=F$($);t.nodes.set(H,{id:H,terminals:$});for(const W of $)t.terminalToNode.set(W,H)}for(const $ of t.elements.values()){const H=t.elementToTerminals.get($.element.id)??[];if(H.length===0)continue;H.some(X=>t.terminalToNode.has(X))||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$.element.id})})}for(const $ of t.buses.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of t.junctions.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of c){if($.path&&$.path.length>=2){const W=$.path,X=W.length>=2?W[1]:null,P=W.length>=2?W[W.length-2]:null,R=br($.ends[0],X,t),Z=br($.ends[1],P,t);if(R&&Z){const ie=[[R[0],R[1]],...W.slice(1,-1).map(ee=>[ee[0],ee[1]]),[Z[0],Z[1]]],ue=Ys(ie);if(ue.length>=2){t.wireRenders.set($.id,{wireId:$.id,path:ue,userEdited:!0,...$.label?{label:$.label}:{}});continue}}}const H=kk($,t);H&&t.wireRenders.set($.id,$.label?{...H,label:$.label}:H)}return t}const W$={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"},kr="B",_r="J";function Ao(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Rt(e,t){const n=W$[t]??t,o=Ao(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function lo(e){const t=Ao(e);let n=1;for(;t.has(`${kr}${n}`);)n++;return`${kr}${n}`}function co(e){const t=Ao(e);let n=1;for(;t.has(`${_r}${n}`);)n++;return`${_r}${n}`}function hn(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function at(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 Sr={version:"1",elements:[]},q$=100,qn=20;function X$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const y=$n()(mk((e,t)=>({diagram:Sr,internal:et(Sr),fileSession:null,activeTool:X$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,readOnly:!1,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:et(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview: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:et(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview: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>=q$?r.slice(1):r;e({diagram:s,internal:et(s),past:[...i,o],future:[],annotationPreview:null})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:et(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview: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:et(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview: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,annotationDraft: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:Y$(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,editingCell: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,editingCell:n?t().editingCell:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement,editingCell:null}),setEditingCell:n=>e({editingCell:n}),setAnnotationDraft:n=>e({annotationDraft:n}),setAnnotationPreview:n=>e({annotationPreview:n}),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 g;const{selection:n,selectedAnnotation:o,diagram:r,internal:s}=t();if(n.length===0){if(!o)return;const m=(r.annotations??[]).find(p=>p.id===o);if(!m)return;e({clipboard:{elements:[],buses:[],junctions:[],placements:{},busLayouts:{},wires:[],annotations:[structuredClone(m)]},clipboardPasteIndex:0});return}const i=new Set(n),a=r.elements.filter(m=>i.has(m.id)).map(m=>structuredClone(m)),l=(r.buses??[]).filter(m=>i.has(m.id)).map(m=>structuredClone(m)),c=(r.junctions??[]).filter(m=>i.has(m.id)).map(m=>{var x;const p=structuredClone(m);if(!p.layout){const w=(x=s.junctions.get(m.id))==null?void 0:x.world;w&&(p.layout={at:[w[0],w[1]]})}return p}),u={};for(const m of n)if(i.has(m)&&!s.buses.has(m)){const p=(g=r.layout)==null?void 0:g[m];if(p){u[m]=structuredClone(p);continue}const x=s.layout.get(m);x&&(u[m]=on(x))}const f={};for(const m of n){const p=s.buses.get(m);p&&(f[m]=ut(p.geometry))}const h=(r.wires??[]).filter(m=>m.ends.every(p=>i.has(Xn(p)))).map(m=>structuredClone(m));e({clipboard:{elements:a,buses:l,junctions:c,placements:u,busLayouts:f,wires:h,annotations:[]},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n,selectedAnnotation:o}=t();n.length===0&&!o||(t().copySelection(),n.length===0&&o?t().deleteAnnotation(o):t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n)return;if(n.elements.length===0&&n.buses.length===0&&n.junctions.length===0){const f=n.annotations??[];if(f.length===0)return;const h=o+1,g=qn*h;let m=null;t().dispatch(p=>{let x=p;for(const w of f){const v=hn(x);m=v;const M={...structuredClone(w),id:v,at:[w.at[0]+g,w.at[1]+g]};x={...x,annotations:[...x.annotations??[],M]}}return x}),m&&e({selectedAnnotation:m,selection:[],selectedWire:null,selectedNode:null,clipboardPasteIndex:h});return}const s=o+1,i=qn*s,a=qn*s,l=new Map;let c=r;for(const f of n.elements){const h=Rt(c,f.kind);l.set(f.id,h),c={...c,elements:[...c.elements,{id:h,kind:f.kind}]}}for(const f of n.buses){const h=lo(c);l.set(f.id,h),c={...c,buses:[...c.buses??[],{id:h}]}}for(const f of n.junctions){const h=co(c);l.set(f.id,h),c={...c,junctions:[...c.junctions??[],{id:h}]}}const u=f=>{const h=f.indexOf("."),g=h<0?f:f.slice(0,h),m=l.get(g);return m?h<0?m:`${m}${f.slice(h)}`:f};t().dispatch(f=>{const h=n.elements.map(v=>{const M=structuredClone(v);return M.id=l.get(v.id),M}),g=n.buses.map(v=>{const M=structuredClone(v);M.id=l.get(v.id);const I=n.busLayouts[v.id];return I&&(M.layout={...I,at:[I.at[0]+i,I.at[1]+a]}),M}),m=n.junctions.map(v=>{const M=structuredClone(v);return M.id=l.get(v.id),M.layout&&(M.layout={at:[M.layout.at[0]+i,M.layout.at[1]+a]}),M}),p={...f.layout??{}};for(const[v,M]of l){const I=n.placements[v];I&&(p[M]={...I,at:[I.at[0]+i,I.at[1]+a]})}const x=n.wires.map(v=>{const M=[u(v.ends[0]),u(v.ends[1])];return{id:at(M[0],M[1]),ends:M,...v.label?{label:v.label}:{}}}),w=$r(f.wires??[],x);return{...f,elements:[...f.elements,...h],buses:g.length?[...f.buses??[],...g]:f.buses,junctions:m.length?[...f.junctions??[],...m]:f.junctions,wires:w.length?w:void 0,layout:Object.keys(p).length?p:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:u,...f}=c;return f});return{...i,buses:a}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const l={};for(const[c,u]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:u,...f}=c;return f}return c});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const c=n.layout.get(l.id);c&&(s[l.id]=on(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:ut(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(c=r.buses)!=null&&c.find(h=>h.id===u&&h.layout)||a.set(u,ut(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=on(f))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const h=o.layout.get(u),g=s[u]??(h?on(h):{at:[0,0]});s[u]={...g,at:[g.at[0]+f[0],g.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const h=u.layout??ut(o.buses.get(u.id).geometry);return{...u,layout:{...h,at:[h.at[0]+f[0],h.at[1]+f[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(u=>{var g,m;const f=a.get(u.id);if(!f)return u;const h=((g=u.layout)==null?void 0:g.at)??((m=o.junctions.get(u.id))==null?void 0:m.world)??[0,0];return{...u,layout:{at:[h[0]+f[0],h[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(f=>!o.has(f.id)),i=(r.buses??[]).filter(f=>!o.has(f.id)),a=(r.junctions??[]).filter(f=>!o.has(f.id)),l=(r.wires??[]).filter(f=>!o.has(Xn(f.ends[0]))&&!o.has(Xn(f.ends[1]))),c=Wn(r.wires??[],l,a),u=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([f])=>!o.has(f))):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:u&&Object.keys(u).length?u: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(f=>f.id!==n);if(l.length===a.length)return i;const c={...i.layout??{}};for(const f of s){if(c[f])continue;const h=o.layout.get(f);if(!h)continue;const g={at:h.at};h.rot&&(g.rot=h.rot),h.mirror&&(g.mirror=h.mirror),c[f]=g}const u=Wn(a,l,i.junctions??[]);return{...i,wires:l.length?l:void 0,junctions:u.length?u: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 h of i){if(l[h])continue;const g=o.layout.get(h);if(!g)continue;const m={at:g.at};g.rot&&(m.rot=g.rot),g.mirror&&(m.mirror=g.mirror),l[h]=m}const c=a.wires??[],u=c.filter(h=>!s.has(h.ends[0])&&!s.has(h.ends[1])),f=Wn(c,u,a.junctions??[]);return{...a,wires:u.length?u:void 0,junctions:f.length?f:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var c,u,f,h;const i={...s.layout??{}},a=new Map;for(const g of o){if(r.junctions.has(g))continue;if(r.buses.has(g)){const x=r.buses.get(g),v=(((((f=(u=(c=s.buses)==null?void 0:c.find(M=>M.id===g))==null?void 0:u.layout)==null?void 0:f.rot)??x.geometry.rot??0)+n)%360+360)%360;a.set(g,v);continue}const m=i[g]??{at:((h=r.layout.get(g))==null?void 0:h.at)??[0,0]},p=(((m.rot??0)+n)%360+360)%360;i[g]={...m,rot:p}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(g=>{if(!a.has(g.id))return g;const m=g.layout??ut(r.buses.get(g.id).geometry);return{...g,layout:{...m,rot:a.get(g.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a)||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=Rt(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=lo(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=co(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=at(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(m=>m.id),...(s.buses??[]).map(m=>m.id),...(s.junctions??[]).map(m=>m.id)]),a=()=>{let m=1;for(;i.has(`J${m}`);)m++;const p=`J${m}`;return i.add(p),p},l=m=>{const p=a();return s={...s,junctions:[...s.junctions??[],{id:p,layout:{at:m}}]},p},c=m=>{if("end"in m)return m.end;if("junctionAt"in m)return l(m.junctionAt);const p=(s.wires??[]).find(M=>M.id===m.onWire),x=l(m.at);if(!p)return x;const w=(s.wires??[]).filter(M=>M.id!==m.onWire),v=(M,I)=>({id:at(M,I),ends:[M,I],...p.label?{label:p.label}:{}});return s={...s,wires:$r(w,[v(p.ends[0],x),v(x,p.ends[1])])},x},u=c(n),f=c(o);if(u===null||f===null||u===f)return s;const h=at(u,f),g=s.wires??[];return g.some(m=>m.id===h)?s:{...s,wires:[...g,{id:h,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?Ys(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:u,...f}=c;return f});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateWire:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];return s.some(i=>i.id===n)?{...r,wires:s.map(i=>i.id===n?{...i,...o}:i)}:r})},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)?ut(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=hn(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},insertAnnotation:n=>{const o=hn(t().diagram);return t().dispatch(r=>({...r,annotations:[...r.annotations??[],{...n,id:o}]})),o},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=>{var o;t().dispatch(r=>{const s=r.annotations??[],i=s.filter(a=>a.id!==n);return i.length===s.length?r:{...r,annotations:i.length?i:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null,editingCell:null}),((o=t().annotationPreview)==null?void 0:o.id)===n&&e({annotationPreview:null})}}),{name:"ole-editor",version:2,storage:Xs(()=>({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>{y.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=et(e.diagram))}}));function Y$(e){return Array.from(new Set(e))}function Xn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function $r(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 on(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function ut(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Zw=null;function jr(e){Zw=e}function Xe(){return Zw}const yn=10;function Qw(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function de(e){return Qw()?Math.round(e/yn)*yn:e}function We(e){return[de(e[0]),de(e[1])]}const G$=30,K$=144;function ev(e,t){const n=ot[e],o=y.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=U$(r,t);if(!s){const p=tv(n),x=p?[de(t[0])-p.x,de(t[1])-p.y]:[de(t[0]),de(t[1])];return{newElementId:o.addElement(e,x),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=V$(n,l),u=Rt(r,e),f=n.terminals.find(p=>p.id===c),h=l==="x"?t[0]:a[0],g=l==="y"?t[1]:a[1],m=f?[de(h)-f.x,de(g)-f.y]:[de(t[0]),de(t[1])];return o.dispatch(p=>{const x={id:u,kind:e},w={at:m},v=`${u}.${c}`,M={id:at(i,v),ends:[i,v]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],M],layout:{...p.layout??{},[u]:w}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function U$(e,t){const n=y.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let c;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,h=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,g=Math.abs(t[1]-a[1]);c=Math.sqrt(h*h+g*g)}else{const u=a[1]-l/2,f=a[1]+l/2,h=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,g=Math.abs(t[0]-a[0]);c=Math.sqrt(g*g+h*h)}c<=G$&&(!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 V$(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 tv(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function nv(e,t){const n=y.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const g=i[0]-a/2,m=i[0]+a/2,p=Math.max(g,Math.min(m,t[0])),x=i[1],w=t[1]>=x?"s":"n";return{ref:e,world:[p,x],orientation:w,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,u=Math.max(l,Math.min(c,t[1])),f=i[0],h=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:h,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 J$={n:"s",s:"n",e:"w",w:"e"};function ov(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=J$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Er(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],u=Er(c,n,t.world);u<a&&(a=u,i=c)}return i}function Er(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function Z$(e,t,n){const o=ot[e],r=y.getState(),s=r.diagram;if(!o)return null;const i=nv(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=K$,u=[de(n[0]),de(n[1])],f=ov(o,i,u),h=c?i.world:u,g=[de(h[0]-f.x),de(h[1]-f.y)],m=Rt(s,e);return r.dispatch(p=>{const x={id:m,kind:e},w={at:g},v=`${m}.${f.id}`,M=i.isBus&&i.busId?i.busId:t,I={id:at(M,v),ends:[M,v]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],I],layout:{...p.layout??{},[m]:w}}}),r.setSelection([m]),{newElementId:m,attachedToBus:i.isBus}}const Gt=9,ze=7;function jn(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 En(e){const t=rv(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+t.h/2+ze/3,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Q$(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 Nn(e,t,n,o){const r=Q$(e,n),s=e.anchor??"start",i=rv(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:ze}:{world:r,textAnchor:"middle",dy:-(o-1)*Gt}}function rv(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 Nr=8;function An(e){if(e.length<2)return null;let t=-1,n=0;for(let c=0;c<e.length-1;c++){const u=Math.hypot(e[c+1][0]-e[c][0],e[c+1][1]-e[c][1]);u>n&&(n=u,t=c)}if(t<0||n<=0)return null;const[o,r]=e[t],[s,i]=e[t+1],a=(o+s)/2,l=(r+i)/2;return Math.abs(s-o)>=Math.abs(i-r)?{world:[a,l-Nr],textAnchor:"middle"}:{world:[a+Nr,l+ze/3],textAnchor:"start"}}function ej(){const e=y(s=>s.internal.elements),t=y(s=>s.internal.layout),n=y(s=>s.internal.wireRenders),o=y(s=>{var i;return((i=s.diagram.meta)==null?void 0:i.labelMode)??"all"}),r=y(s=>s.editingElement);return d.jsxs("g",{className:"ole-annotation-layer",pointerEvents:"none",children:[Array.from(e.values()).map(s=>{var h;const i=t.get(s.element.id);if(!i||!s.libraryDef)return null;const a=s.libraryDef.label??En(s.libraryDef),l=jn(s,o),{world:c,textAnchor:u,dy:f}=Nn(a,s.libraryDef,i,Math.max(1,l.length));return r===s.element.id?d.jsx(tj,{elementId:s.element.id,currentName:((h=s.element.name)==null?void 0:h.trim())||s.element.id,world:c,anchor:u},s.element.id):o==="off"||l.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${c[0]} ${c[1]})`,children:l.map((g,m)=>d.jsx("text",{x:0,y:f+m*Gt,textAnchor:u,className:"ole-annotation-text",children:g},m))},s.element.id)}),o!=="off"&&Array.from(n.values()).map(s=>{var l;const i=(l=s.label)==null?void 0:l.trim();if(!i)return null;const a=An(s.path);return a?d.jsx("text",{x:a.world[0],y:a.world[1],textAnchor:a.textAnchor,className:"ole-annotation-text",children:i},`wire-${s.wireId}`):null})]})}const Yn=200,Gn=9;function tj({elementId:e,currentName:t,world:n,anchor:o}){const r=C.useRef(null);C.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(c)},[e]);function s(){var h;const l=y.getState(),c=l.diagram.elements.find(g=>g.id===e);if(!c){l.setEditingElement(null);return}const u=(((h=r.current)==null?void 0:h.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==c.name&&l.updateElement(e,{name:f}),l.setEditingElement(null)}function i(l){if(l.key==="Escape"||l.key==="Enter"&&!l.shiftKey){l.preventDefault(),s();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=Yn/2:o==="end"&&(a-=Yn),d.jsx("foreignObject",{x:a,y:n[1]-Gn,width:Yn,height:Gn*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:`${Gn}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})})}function Le(e){return e.type??"text"}function nj(e){return e.type===void 0||e.type==="text"}const qe=8,oj=1.25,Kt="6 4",rj=.05,Ar=8,rn=3,gt=4,Ft=3,Ht=60,Wt=20,uo=16,fo=12,xn=10,sj=10;function ij(e,t){const n=e===""?[""]:e.split(`
|
|
218
|
+
`);return[Math.max(20,...n.map(r=>r.length*t*.55)),n.length*t*oj]}function Ut(e){return e.points.map(([t,n])=>[e.at[0]+t,e.at[1]+n])}function To(e,t){if(!t||t==="none"||e.length<2)return[];const n=[];return(t==="end"||t==="both")&&n.push(Tr(e[e.length-2],e[e.length-1])),t==="both"&&n.push(Tr(e[1],e[0])),n}function Tr(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o)||1,s=n/r,i=o/r,a=t[0]-s*Ar,l=t[1]-i*Ar,c=-i,u=s;return[t,[a+c*rn,l+u*rn],[a-c*rn,l-u*rn]]}function Ge(e){return[Cr(e.colWidths),Cr(e.rowHeights)]}function wt(e){return sv(e.colWidths)}function vt(e){return sv(e.rowHeights)}function aj(e,t){const n=t[0]-e.at[0],o=t[1]-e.at[1],[r,s]=Ge(e);if(n<0||o<0||n>r||o>s)return null;const i=Mr(wt(e),n),a=Mr(vt(e),o);return i===null||a===null?null:[a,i]}function Mr(e,t){for(let n=0;n<e.length-1;n++)if(t>=e[n]&&t<=e[n+1])return n;return null}function sv(e){const t=[0];let n=0;for(const o of e)n+=o,t.push(n);return t}function Cr(e){return e.reduce((t,n)=>t+n,0)}function iv(e){let t=e.current[0]-e.start[0],n=e.current[1]-e.start[1];if(e.constrain){const r=Math.max(Math.abs(t),Math.abs(n));t=Math.sign(t||1)*r,n=Math.sign(n||1)*r}return{at:[Math.min(e.start[0],e.start[0]+t),Math.min(e.start[1],e.start[1]+n)],size:[Math.abs(t),Math.abs(n)]}}function av(e){return e.constrain?lv(e.start,e.current):e.current}function lv(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o);if(r===0)return t;const s=Math.PI/4,i=Math.round(Math.atan2(o,n)/s)*s;return[e[0]+Math.cos(i)*r,e[1]+Math.sin(i)*r]}function cv(e){const t=Math.abs(e.current[0]-e.start[0]),n=Math.abs(e.current[1]-e.start[1]),o=Math.min(30,Math.max(1,Math.round(t/Ht))),r=Math.min(60,Math.max(1,Math.round(n/Wt)));return{at:[Math.min(e.start[0],e.current[0]),Math.min(e.start[1],e.current[1])],cols:o,rows:r}}function dv(e,t){return{colWidths:Array.from({length:e},()=>Ht),rowHeights:Array.from({length:t},()=>Wt),cells:Array.from({length:t},()=>Array.from({length:e},()=>""))}}function lj(e){switch(e.type){case"rect":{const t=e;return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+t.size[0],maxY:t.at[1]+t.size[1]}}case"line":{const t=Ut(e),n=t.map(r=>r[0]),o=t.map(r=>r[1]);return{minX:Math.min(...n),minY:Math.min(...o),maxX:Math.max(...n),maxY:Math.max(...o)}}case"table":{const t=e,[n,o]=Ge(t);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+n,maxY:t.at[1]+o}}default:{const t=e,n=t.fontSize??qe,[o,r]=ij(t.text,n);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+o,maxY:t.at[1]+r}}}}const yt=qe,bn=1.25;function cj(){const e=y(s=>s.diagram.annotations),t=y(s=>s.selectedAnnotation),n=y(s=>s.editingAnnotation),o=y(s=>s.editingCell),r=y(s=>s.annotationPreview);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(s=>{const i=(r==null?void 0:r.id)===s.id?r:s,a=t===s.id;switch(Le(i)){case"rect":return d.jsx(dj,{ann:i,isSelected:a},s.id);case"line":return d.jsx(uj,{ann:i,isSelected:a},s.id);case"table":return d.jsx(fj,{ann:i,isSelected:a,editingCell:n===s.id?o:null},s.id);default:return n===s.id?d.jsx(pj,{ann:i},s.id):d.jsx(mj,{ann:i,isSelected:a},s.id)}})})}function dj({ann:e,isSelected:t}){const[n,o]=e.at,[r,s]=e.size,i=(e.stroke??"dashed")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-rect","data-selected":t?"true":void 0,children:[e.fill==="tint"&&d.jsx("rect",{className:"ole-ann-fill",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-shape-hit",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-rect-border",x:n,y:o,width:r,height:s,strokeDasharray:i}),e.label&&d.jsx("text",{className:"ole-ann-label",x:n+gt,y:o+gt+yt*.85,fontSize:yt,children:e.label})]})}function uj({ann:e,isSelected:t}){const n=Ut(e),o=n.map(s=>`${s[0]},${s[1]}`).join(" "),r=(e.stroke??"solid")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-line-group","data-selected":t?"true":void 0,children:[d.jsx("polyline",{className:"ole-ann-shape-hit",points:o}),d.jsx("polyline",{className:"ole-ann-line",points:o,strokeDasharray:r}),To(n,e.arrow).map((s,i)=>d.jsx("polygon",{className:"ole-ann-arrow",points:s.map(a=>`${a[0]},${a[1]}`).join(" ")},i))]})}function fj({ann:e,isSelected:t,editingCell:n}){var g;const[o,r]=e.at,[s,i]=Ge(e),a=wt(e),l=vt(e),c=e.fontSize??yt;let u="";for(let m=1;m<e.colWidths.length;m++)u+=`M${o+a[m]} ${r}V${r+i}`;for(let m=1;m<e.rowHeights.length;m++)u+=`M${o} ${r+l[m]}H${o+s}`;const f=[],h=[];for(let m=0;m<e.rowHeights.length;m++)for(let p=0;p<e.colWidths.length;p++){const x=((g=e.cells[m])==null?void 0:g[p])??"";if(x==="")continue;const w=e.colWidths[p],v=o+a[p]+Ft,M=r+l[m]+e.rowHeights[m]/2+c*.35,I=x.length*c*.55>w-2*Ft,F=`ole-ann-clip-${e.id}-${m}-${p}`;I&&h.push(d.jsx("clipPath",{id:F,children:d.jsx("rect",{x:o+a[p],y:r+l[m],width:w,height:e.rowHeights[m]})},F)),f.push(d.jsx("text",{className:"ole-ann-table-text",x:v,y:M,fontSize:c,clipPath:I?`url(#${F})`:void 0,children:x},`${m}-${p}`))}return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-table","data-selected":t?"true":void 0,children:[h.length>0&&d.jsx("defs",{children:h}),d.jsx("rect",{className:"ole-ann-table-bg",x:o,y:r,width:s,height:i}),u&&d.jsx("path",{className:"ole-ann-table-grid",d:u}),d.jsx("rect",{className:"ole-ann-table-border",x:o,y:r,width:s,height:i}),f,n&&d.jsx(hj,{ann:e,cell:n})]})}function hj({ann:e,cell:t}){var g;const[n,o]=t,r=C.useRef(null),s=wt(e),i=vt(e),a=e.fontSize??yt,l=((g=e.cells[n])==null?void 0:g[o])??"";C.useEffect(()=>{const m=r.current;m&&(m.focus(),m.select())},[n,o]);function c(){var x;const m=y.getState(),p=((x=r.current)==null?void 0:x.value)??"";if(p!==l){const w=e.cells.map(v=>[...v]);for(;w.length<=n;)w.push([]);w[n][o]=p,m.updateAnnotation(e.id,{cells:w})}}function u(){y.getState().setEditingAnnotation(null)}function f(m,p){const x=e.rowHeights.length,w=e.colWidths.length;if(p>=w?(p=0,m+=1):p<0&&(p=w-1,m-=1),m<0||m>=x){u();return}y.getState().setEditingCell([m,p])}function h(m){if(m.key==="Enter"){m.preventDefault(),c(),f(n+1,o);return}if(m.key==="Tab"){m.preventDefault(),c(),f(n,m.shiftKey?o-1:o+1);return}if(m.key==="Escape"){m.preventDefault(),r.current&&(r.current.value=l),c(),u();return}m.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0]+s[o],y:e.at[1]+i[n],width:e.colWidths[o],height:e.rowHeights[n],className:"ole-ann-cell-edit-fo",children:d.jsx("input",{ref:r,defaultValue:l,onBlur:()=>{c(),u()},onKeyDown:h,onPointerDown:m=>m.stopPropagation(),onMouseDown:m=>m.stopPropagation(),style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1px solid var(--selection)",outline:"none",background:"var(--canvas-bg)",color:"var(--foreground)",font:`${a}px ui-sans-serif, system-ui, sans-serif`,padding:`0 ${Ft}px`}},`${n}-${o}`)})}function mj({ann:e,isSelected:t}){const n=e.fontSize??yt,o=e.text===""?[""]:e.text.split(`
|
|
219
|
+
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*bn;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*bn,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function pj({ann:e}){const t=C.useRef(null),n=e.fontSize??yt;C.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=y.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(),t.current&&(t.current.innerText=e.text),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:bn,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*bn}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}function gj(){const e=y(a=>a.annotationDraft);if(!e)return null;if(e.kind==="rect"){const{at:a,size:l}=iv(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("rect",{x:a[0],y:a[1],width:l[0],height:l[1],strokeDasharray:Kt})})}if(e.kind==="line"){const a=av(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("line",{x1:e.start[0],y1:e.start[1],x2:a[0],y2:a[1]})})}const{at:t,cols:n,rows:o}=cv(e),r=n*Ht,s=o*Wt,i=[];for(let a=1;a<n;a++){const l=t[0]+a*Ht;i.push(d.jsx("line",{x1:l,y1:t[1],x2:l,y2:t[1]+s},`c${a}`))}for(let a=1;a<o;a++){const l=t[1]+a*Wt;i.push(d.jsx("line",{x1:t[0],y1:l,x2:t[0]+r,y2:l},`r${a}`))}return d.jsxs("g",{className:"ole-ann-draft",pointerEvents:"none",children:[d.jsx("rect",{x:t[0],y:t[1],width:r,height:s}),i,d.jsxs("text",{className:"ole-ann-draft-badge",x:e.current[0]+12,y:e.current[1]-8,children:[n," × ",o]})]})}const sn=7,wn=3;function yj(){const e=y(i=>i.selectedAnnotation),t=y(i=>i.diagram.annotations),n=y(i=>i.annotationPreview);if(y(i=>i.readOnly)||!e)return null;const r=(t??[]).find(i=>i.id===e);if(!r)return null;const s=(n==null?void 0:n.id)===e?n:r;switch(Le(s)){case"rect":return d.jsx(xj,{ann:s,model:r});case"table":return d.jsx(wj,{ann:s,model:r});case"line":return d.jsx(Sj,{ann:s,model:r});default:return null}}function Vt(e,t,n){const o=C.useRef(null);return{onPointerDown:l=>{if(l.button!==0)return;l.stopPropagation(),l.preventDefault();const c=Xe();c&&(o.current={pointerId:l.pointerId,startSvg:c.screenToSvg(l.clientX,l.clientY),orig:structuredClone(e)},l.target.setPointerCapture(l.pointerId))},onPointerMove:l=>{const c=o.current,u=Xe();if(!c||l.pointerId!==c.pointerId||!u)return;const f=u.screenToSvg(l.clientX,l.clientY),h=de(f[0]-c.startSvg[0]),g=de(f[1]-c.startSvg[1]);y.getState().setAnnotationPreview(t(c.orig,h,g,l.nativeEvent))},onPointerUp:l=>{const c=o.current;if(!c||l.pointerId!==c.pointerId)return;o.current=null;const u=l.target;u.hasPointerCapture(l.pointerId)&&u.releasePointerCapture(l.pointerId);const f=y.getState(),h=f.annotationPreview;f.setAnnotationPreview(null),h&&h.id===e.id&&f.updateAnnotation(e.id,n(h))},onPointerCancel:l=>{const c=o.current;!c||l.pointerId!==c.pointerId||(o.current=null,y.getState().setAnnotationPreview(null))}}}function uv(e,t,n,o,r,s,i,a){let[l,c]=e,[u,f]=t;return n===1&&(u=Math.max(i,t[0]+r)),n===-1&&(u=Math.max(i,t[0]-r),l=e[0]+t[0]-u),o===1&&(f=Math.max(a,t[1]+s)),o===-1&&(f=Math.max(a,t[1]-s),c=e[1]+t[1]-f),{at:[l,c],size:[u,f]}}const fv=[{dirX:-1,dirY:-1,cursor:"nwse-resize"},{dirX:0,dirY:-1,cursor:"ns-resize"},{dirX:1,dirY:-1,cursor:"nesw-resize"},{dirX:1,dirY:0,cursor:"ew-resize"},{dirX:1,dirY:1,cursor:"nwse-resize"},{dirX:0,dirY:1,cursor:"ns-resize"},{dirX:-1,dirY:1,cursor:"nesw-resize"},{dirX:-1,dirY:0,cursor:"ew-resize"}];function hv(e,t,n,o){const r=n===-1?e[0]:n===1?e[0]+t[0]:e[0]+t[0]/2,s=o===-1?e[1]:o===1?e[1]+t[1]:e[1]+t[1]/2;return[r,s]}function mv({pos:e,cursor:t,handlers:n}){return d.jsx("rect",{className:"ole-annotation-handle",x:e[0]-sn/2,y:e[1]-sn/2,width:sn,height:sn,style:{cursor:t},onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onPointerCancel:n.onPointerCancel})}function xj({ann:e,model:t}){return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:fv.map((n,o)=>d.jsx(bj,{grip:n,ann:e,model:t},o))})}function bj({grip:e,ann:t,model:n}){const o=Vt(n,(r,s,i)=>{const a=uv(r.at,r.size,e.dirX,e.dirY,s,i,xn,xn);return{...r,at:a.at,size:a.size}},r=>({at:r.at,size:r.size}));return d.jsx(mv,{pos:hv(t.at,t.size,e.dirX,e.dirY),cursor:e.cursor,handlers:o})}function wj({ann:e,model:t}){const n=Ge(e),o=wt(e),r=vt(e);return d.jsxs("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:[o.slice(1,-1).map((s,i)=>d.jsx(kj,{index:i,x:e.at[0]+s,ann:e,model:t},`c${i}`)),r.slice(1,-1).map((s,i)=>d.jsx(_j,{index:i,y:e.at[1]+s,ann:e,model:t},`r${i}`)),fv.map((s,i)=>d.jsx(vj,{grip:s,ann:e,model:t,size:n},i))]})}function vj({grip:e,ann:t,model:n,size:o}){const r=Vt(n,(s,i,a)=>{const l=Ge(s),c=uv(s.at,l,e.dirX,e.dirY,i,a,uo*s.colWidths.length,fo*s.rowHeights.length),u=Pr(s.colWidths,c.size[0]/l[0],uo),f=Pr(s.rowHeights,c.size[1]/l[1],fo),h=u.reduce((p,x)=>p+x,0),g=f.reduce((p,x)=>p+x,0),m=[e.dirX===-1?s.at[0]+l[0]-h:s.at[0],e.dirY===-1?s.at[1]+l[1]-g:s.at[1]];return{...s,at:m,colWidths:u,rowHeights:f}},s=>({at:s.at,colWidths:s.colWidths,rowHeights:s.rowHeights}));return d.jsx(mv,{pos:hv(t.at,o,e.dirX,e.dirY),cursor:e.cursor,handlers:r})}function Pr(e,t,n){return e.map(o=>Math.max(n,Math.round(o*t)))}function kj({index:e,x:t,ann:n,model:o}){const[,r]=Ge(n),s=Vt(o,(i,a)=>{const l=[...i.colWidths];return l[e]=Math.max(uo,i.colWidths[e]+a),{...i,colWidths:l}},i=>({colWidths:i.colWidths}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:t-wn,y:n.at[1],width:wn*2,height:r,style:{cursor:"col-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function _j({index:e,y:t,ann:n,model:o}){const[r]=Ge(n),s=Vt(o,(i,a,l)=>{const c=[...i.rowHeights];return c[e]=Math.max(fo,i.rowHeights[e]+l),{...i,rowHeights:c}},i=>({rowHeights:i.rowHeights}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:n.at[0],y:t-wn,width:r,height:wn*2,style:{cursor:"row-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function Sj({ann:e,model:t}){const n=Ut(e);return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:n.map((o,r)=>d.jsx($j,{index:r,pos:o,model:t},r))})}function $j({index:e,pos:t,model:n}){const o=Vt(n,(r,s,i,a)=>{const l=r.points.map(u=>[...u]);let c=[r.points[e][0]+s,r.points[e][1]+i];if(a.shiftKey){const u=r.points[e-1]??r.points[e+1]??[0,0];c=lv(u,c)}return l[e]=c,{...r,points:l}},r=>({points:r.points}));return d.jsx("circle",{className:"ole-annotation-handle",cx:t[0],cy:t[1],r:4.5,style:{cursor:"move"},onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel})}const jj=20;function Ej(){const e=y(u=>u.selection),t=y(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,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(Ir,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(Ir,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function Ir({x:e,y:t,busId:n,side:o,axis:r}){const s=Xe(),i=C.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=y.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const h=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?h[0]-f.startSvg[0]:h[1]-f.startSvg[1],m=Qw()?Math.round(g/yn)*yn:g,p=f.startSpan+(o==="end"?m:-m);if(p<jj)return;const x=r==="x"?[f.startAt[0]+m/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+m/2];y.getState().updateBus(n,{span:p,at:x})},c=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const ho=.5;function Bt(e,t){return Math.abs(e[1]-t[1])<ho?"h":"v"}function Nj(){const e=y(a=>a.selectedWire),t=y(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=Bt(o[a-1],o[a]),c=Bt(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,h=u&&l==="v"||f&&c==="v",g=u&&l==="h"||f&&c==="h";h&&g||s.push(d.jsx(Aj,{wireId:e,index:a,xLocked:h,yLocked:g},`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])<ho&&Math.abs(l[1]-c[1])<ho||i.push(d.jsx(Tj,{wireId:e,segIndex:a,axis:Bt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function Aj({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Xe(),s=C.useRef(null),i=y(m=>{var p;return(p=m.internal.wireRenders.get(e))==null?void 0:p.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=m=>{if(m.button!==0||(m.stopPropagation(),m.preventDefault(),!r))return;const p=y.getState().internal.wireRenders.get(e);p&&(s.current={pointerId:m.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:r.screenToSvg(m.clientX,m.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,m.target.setPointerCapture(m.pointerId))},f=m=>{const p=s.current;if(!p||m.pointerId!==p.pointerId||!r)return;const x=r.screenToSvg(m.clientX,m.clientY),w=p.startPath,v=p.index;if(v<=0||v>=w.length-1)return;const M=w[v],I=[p.xLocked?M[0]:de(M[0]+(x[0]-p.startSvg[0])),p.yLocked?M[1]:de(M[1]+(x[1]-p.startSvg[1]))];if(I[0]===M[0]&&I[1]===M[1])return;const F=w.map(H=>[H[0],H[1]]);F[v]=I;const G=Bt(w[v-1],w[v]);v-1>0&&(G==="h"?F[v-1]=[w[v-1][0],I[1]]:F[v-1]=[I[0],w[v-1][1]]);const $=Bt(w[v],w[v+1]);v+1<w.length-1&&($==="h"?F[v+1]=[w[v+1][0],I[1]]:F[v+1]=[I[0],w[v+1][1]]),y.getState().updateWirePath(e,F)},h=m=>{const p=s.current;!p||m.pointerId!==p.pointerId||(m.target.hasPointerCapture(m.pointerId)&&m.target.releasePointerCapture(m.pointerId),s.current=null,document.body.style.cursor="")},g=m=>{m.stopPropagation(),m.preventDefault();const p=y.getState().internal.wireRenders.get(e);if(!p||p.path.length<=2||t<=0||t>=p.path.length-1)return;const x=p.path.filter((w,v)=>v!==t);y.getState().updateWirePath(e,x)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:u,onPointerMove:f,onPointerUp:h,onPointerCancel:h,onDoubleClick:g})}function Tj({wireId:e,segIndex:t,axis:n}){const o=Xe(),r=C.useRef(null),s=y(m=>{var p;return(p=m.internal.wireRenders.get(e))==null?void 0:p.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,c=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=m=>{if(m.button!==0||(m.stopPropagation(),m.preventDefault(),!o))return;const p=y.getState().internal.wireRenders.get(e);p&&(r.current={pointerId:m.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:o.screenToSvg(m.clientX,m.clientY),axis:n,segIndex:t},document.body.style.cursor=u,m.currentTarget.setPointerCapture(m.pointerId))},h=m=>{const p=r.current;if(!p||m.pointerId!==p.pointerId||!o)return;const x=o.screenToSvg(m.clientX,m.clientY),w=p.startPath,v=p.segIndex;if(v>=w.length-1)return;const M=w[v],I=w[v+1],F=[];for(let G=0;G<=v;G++)F.push(w[G]);if(p.axis==="h"){const G=de(M[1]+(x[1]-p.startSvg[1]));F.push([M[0],G]),F.push([I[0],G])}else{const G=de(M[0]+(x[0]-p.startSvg[0]));F.push([G,M[1]]),F.push([G,I[1]])}for(let G=v+1;G<w.length;G++)F.push(w[G]);y.getState().updateWirePath(e,F)},g=m=>{const p=r.current;if(!p||m.pointerId!==p.pointerId)return;const x=m.currentTarget;x.hasPointerCapture(m.pointerId)&&x.releasePointerCapture(m.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:h,onPointerUp:g,onPointerCancel:g,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 Mj=3,Kn=12;function Cj(){const e=y(a=>a.internal.buses),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)!l.includes(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:u,span:f}=l,h=f/2,g=c==="x"?u[0]-h:u[0],m=c==="x"?u[1]:u[1]-h,p=c==="x"?u[0]+h:u[0],x=c==="x"?u[1]:u[1]+h,w=s.has(a.id),v=i.has(a.id),M=r.get(a.id)??void 0,I=Kn/2,F=c==="x"?u[0]-h:u[0]-I,G=c==="x"?u[1]-I:u[1]-h,$=c==="x"?f:Kn,H=c==="x"?Kn:f;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":M,"data-selected":w?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:F,y:G,width:$,height:H,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:g,y1:m,x2:p,y2:x,stroke:"currentColor",strokeWidth:Mj,strokeLinecap:"round",fill:"none"})]},a.id)})})}function Pj(){const e=y(a=>a.busbarDrawStart),t=y(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 Ij=2.5,Oj=9,Bj=13,Lj=-13,Dj=4.5,zj=8;function Rj(){const e=y(a=>a.internal.junctions),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(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,degree:c})=>{const u=r.get(a.id)??void 0,f=t.length===1&&t[0]===a.id,h=l[0]+Bj,g=l[1]+Lj;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":u,"data-solder":c>=3?"true":void 0,"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:Oj,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:Ij,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:h,y2:g,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:h,cy:g,r:zj,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:h,cy:g,r:Dj,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function nt(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 Fj(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 Hj({lib:e}){const t=Fj(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 Wj(){const e=y(a=>a.internal.elements),t=y(a=>a.internal.layout),n=y(a=>a.selection),o=y(a=>a.selectedNode),r=y(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const c=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:nt(l),className:"ole-element",children:[d.jsx(Hj,{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":u?"true":void 0,transform:nt(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 pv=null;const mo=new Set;function an(e){pv=e;for(const t of mo)t(e)}function qj(){return pv}function Xj(e){return mo.add(e),()=>{mo.delete(e)}}function Yj(){const[e,t]=C.useState(qj());return C.useEffect(()=>Xj(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 Gj(){const e=y(c=>c.activeTool),t=y(c=>c.placeKind),n=y(c=>c.cursorSvg),o=y(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Jw(t);if(!r)return null;let s=null,i=null;if(o){const c=nv(o,n);c&&(s=ov(r,c,n),i={source:c.world,pin:n})}else s=tv(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 Kj(){const e=y(r=>r.selection),t=y(r=>r.internal.elements),n=y(r=>r.internal.layout),o=y(r=>r.internal.buses);return e.length===0?null:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:u,span:f}=s.geometry,h=f/2,g=c==="x"?u[0]-h:u[0]-4,m=c==="x"?u[1]-4:u[1]-h,p=c==="x"?f:8,x=c==="x"?8:f;return d.jsx("rect",{x:g,y:m,width:p,height:x,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=Uj(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:nt(a)},r):null})})}function Uj(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 Vj(){const e=y(s=>s.internal.terminals),t=y(s=>s.internal.terminalToNode),n=y(s=>s.wireFromTerminal),o=y(s=>s.selection),r=new Set(o);return 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 Or=4;function Jj(e,t,n,o){const r=t[0]-e[0],s=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=r*a-s*i;if(Math.abs(l)<1e-9)return null;const c=((n[0]-e[0])*a-(n[1]-e[1])*i)/l,u=((n[0]-e[0])*s-(n[1]-e[1])*r)/l,f=1e-6;return c<=f||c>=1-f||u<=f||u>=1-f?null:[e[0]+c*r,e[1]+c*s]}function Zj(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],u=Math.hypot(l,c)||1,f=l/u,h=c/u,g=p=>(p[0]-s[0])*f+(p[1]-s[1])*h,m=a.slice().sort((p,x)=>g(p)-g(x));for(const p of m){const x=g(p),w=Math.max(0,x-Or),v=Math.min(u,x+Or);o.push([s[0]+f*w,s[1]+h*w]),n.push(o),o=[[s[0]+f*v,s[1]+h*v]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function Qj(){const e=y(c=>c.internal.wireRenders),t=y(c=>c.internal.terminalToNode),n=y(c=>c.diagram.wires),o=y(c=>c.selectedWire),r=y(c=>c.selectedNode),s=new Map;for(const c of n??[]){const u=t.get(c.ends[0]);u&&s.set(c.id,u)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const u=s.get(c.wireId);for(let f=0;f<c.path.length-1;f++)a.push({wireId:c.wireId,node:u,i:f,a:c.path[f],b:c.path[f+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const f=a[c],h=a[u];if(f.wireId===h.wireId||!(f.node&&h.node&&f.node!==h.node))continue;const g=Jj(f.a,f.b,h.a,h.b);if(!g)continue;const m=f.wireId<h.wireId?f:h;let p=l.get(m.wireId);p||(p=new Map,l.set(m.wireId,p));const x=p.get(m.i)??[];x.push(g),p.set(m.i,x)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const u=c.path,f=u.map(v=>`${v[0]},${v[1]}`).join(" "),h=s.get(c.wireId),g=o===c.wireId,m=r!=null&&r===h,p=g||m?"true":void 0,x=l.get(c.wireId),w=x?Zj(u,x):[u];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":h,className:"ole-wire-hit",points:f},`hit-${c.wireId}`),...w.map((v,M)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":h,"data-manual":c.userEdited?"true":void 0,"data-selected":p,className:"ole-wire",points:v.map(I=>`${I[0]},${I[1]}`).join(" ")},`${c.wireId}-${M}`))]})})}let it=null;const po=new Set;function tt(e){if(!(e===null&&it===null||e&&it&&e.ref===it.ref&&e.world[0]===it.world[0]&&e.world[1]===it.world[1])){it=e;for(const t of po)t(e)}}function e4(){return it}function t4(e){return po.add(e),()=>{po.delete(e)}}function n4(){const e=y(l=>l.wireDragFrom),t=y(l=>l.cursorSvg),[n,o]=C.useState(e4());if(C.useEffect(()=>t4(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 lt(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function xt(e){var t;return((t=lt(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function o4(e){var t;return((t=lt(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function r4(e){var t;return((t=lt(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function Tn(e){var r;const t=(r=lt(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=r4(e);if(n)return n;const o=o4(e);return o||null}function Mn(e){var t;return((t=lt(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function go(e){var t;return((t=lt(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function qt(e){var t;return((t=lt(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function gv(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function s4(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function yv(){const e=y.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable], .ole-ann-cell-edit-fo input");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"||t==="rect"||t==="line"||t==="table"){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 i4(){C.useEffect(()=>{const e=t=>{if(s4(t.target)||y.getState().readOnly)return;const n=t.metaKey||t.ctrlKey,o=y.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=y.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase(),s=o.selection.length>0||o.selectedAnnotation!=null;if(r==="c"){if(!s)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(!s)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"f":case"F":o.setActiveTool("rect");return;case"l":case"L":o.setActiveTool("line");return;case"d":case"D":o.setActiveTool("table");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":yv();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let yo=null;const xo=new Set;function a4(e){if(e!==yo){yo=e;for(const t of xo)t(e)}}function l4(){return yo}function c4(e){return xo.add(e),()=>{xo.delete(e)}}const Br="ole-hover-element-host",d4="ole-hover-terminal-on",u4="ole-hover-node-on";function f4(e){C.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,h,g)=>{for(const m of f)m.classList.remove(g);f.clear();for(const m of h)m.classList.add(g),f.add(m)},a=f=>{var g,m;if(f===n)return;n&&((g=t.querySelector(`[data-element-id="${ln(n)}"]`))==null||g.classList.remove(Br)),f&&((m=t.querySelector(`[data-element-id="${ln(f)}"]`))==null||m.classList.add(Br));const h=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${ln(f)}"]`)):[];i(r,h,d4),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),a4(f)},l=f=>{if(f===o)return;const h=f?Array.from(t.querySelectorAll(`[data-node-id="${ln(f)}"]`)):[];i(s,h,u4),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=f=>{a(xt(f.target));const h=Tn(f.target);let g=null;h?g=y.getState().internal.terminalToNode.get(h)??null:g=Mn(f.target),l(g)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function ln(e){return e.replace(/(["\\])/g,"\\$1")}function h4(e,t){const n=y.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 h=a[0]-l/2,g=a[0]+l/2,m=Math.max(h,Math.min(g,t[0]));return{ref:e,world:[m,a[1]],isBus:!0}}const c=a[1]-l/2,u=a[1]+l/2,f=Math.max(c,Math.min(u,t[1]));return{ref:e,world:[a[0],f],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const Lr=10,cn=e=>Math.round(e/Lr)*Lr,m4=16;function xv(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,u=l-i,f=c*c+u*u,h=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*u)/f)),g=s+h*c,m=i+h*u,p=(g-t[0])**2+(m-t[1])**2;p<o&&(o=p,n=[g,m])}return n}function vn(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function p4(e,t){const n=y.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=xv(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 Lt(e,t,n){const o=e?Tn(e):null;if(o){const a=h4(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?go(e):null,s=null;if(r){const a=y.getState().internal.wireRenders.get(r);s=a?xv(a.path,t):t}else{const a=p4(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[cn(s[0]),cn(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[cn(t[0]),cn(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Dt(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+m4,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function bv(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function kn(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 Dr=3;let he=null,Ce=null,Ne=null,pe=null;const g4={id:"select",cursor:"default",onPointerDown(e,t){var m,p,x,w,v,M,I,F,G,$,H,W;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle, .ole-annotation-handle"))return;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const X=(m=n.diagram.annotations)==null?void 0:m.find(R=>R.id===o);if(!X)return;const P=n.selectedAnnotation===o;n.setSelectedAnnotation(o),pe={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[X.at[0],X.at[1]],moved:!1,wasSelected:P};return}const r=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(r){const X=(p=r.closest("[data-junction-id]"))==null?void 0:p.getAttribute("data-junction-id");if(X){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((w=(x=e.target).hasPointerCapture)!=null&&w.call(x,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(X);const P=(v=n.internal.junctions.get(X))==null?void 0:v.world;P&&n.setWireDragFrom({spec:{end:X},world:P,ref:X}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:X};return}}const i=(e.target instanceof Element?(M=e.target.closest("[data-terminal-id]"))==null?void 0:M.getAttribute("data-terminal-id"):null)?Tn(e.target):null;if(i){const X=i.indexOf("."),P=X>0?i.slice(0,X):"";if(P&&n.selection.includes(P)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((F=(I=e.target).hasPointerCapture)!=null&&F.call(I,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const R=(G=n.internal.terminals.get(i))==null?void 0:G.world;R&&n.setWireDragFrom({spec:{end:i},world:R,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:i};return}}let a=xt(e.target);if(!a){const X=go(e.target);if(X&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const R of P){const Z=(H=($=R.closest)==null?void 0:$.call(R,"[data-bus-id]"))==null?void 0:H.getAttribute("data-bus-id");if(!Z)continue;const ie=(W=n.diagram.wires)==null?void 0:W.find(ue=>ue.id===X);ie&&(ie.ends[0]===Z||ie.ends[1]===Z)&&(a=Z);break}}}if(!a){const X=go(e.target);if(X){if(e.preventDefault(),e.altKey){const P=Mn(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(X);return}e.shiftKey||n.clearSelection(),Ce={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?y.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const u=y.getState().internal,f=new Map,h=new Map,g=new Map;for(const X of c){const P=u.buses.get(X);if(P){h.set(X,[P.geometry.at[0],P.geometry.at[1]]);continue}const R=u.junctions.get(X);if(R){g.set(X,[R.world[0],R.world[1]]);continue}const Z=u.layout.get(X);Z&&f.set(X,{...Z})}f.size===0&&h.size===0&&g.size===0||(he={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:f,busOriginals:h,junctionOriginals:g,moved:!1},e.preventDefault())},onPointerMove(e,t){if(pe&&e.pointerId===pe.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-pe.startSvg[0]),r=de(n[1]-pe.startSvg[1]);!pe.moved&&(o!==0||r!==0)&&(pe.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Ne&&e.pointerId===Ne.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg(n);const o=vn(e.clientX,e.clientY),r=Lt(o,n,Dt(t,e.clientX,e.clientY)),s={spec:{end:Ne.fromRef},world:[0,0],ref:Ne.fromRef};tt(kn(s,r)?null:bv(r));return}if(he&&e.pointerId===he.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-he.startSvg[0]),r=de(n[1]-he.startSvg[1]);!he.moved&&(o!==0||r!==0)&&(he.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of he.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",nt(l))}for(const s of he.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of he.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Ce&&e.pointerId===Ce.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);an(Rr(Ce.startSvg,n));return}},onPointerUp(e,t){var n;if(pe&&e.pointerId===pe.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-pe.startSvg[0]),s=de(o[1]-pe.startSvg[1]),i=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(i&&i.removeAttribute("transform"),pe.moved&&(r!==0||s!==0))y.getState().updateAnnotation(pe.id,{at:[pe.origin[0]+r,pe.origin[1]+s]});else if(!pe.moved&&pe.wasSelected){const a=y.getState(),l=(n=a.diagram.annotations)==null?void 0:n.find(c=>c.id===pe.id);l&&zr(a,l,o)}pe=null;return}if(Ne&&e.pointerId===Ne.pointerId){const o=y.getState(),r=Ne.fromRef;Ne=null,t.hostEl.classList.remove("tool-wire"),o.setWireFromTerminal(null),o.setWireDragFrom(null),o.setCursorSvg(null),tt(null);const s=t.viewport.screenToSvg(e.clientX,e.clientY),i=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),a=Lt(i,s,Dt(t,e.clientX,e.clientY));if(kn({world:[0,0],ref:r},a))return;o.connectWire({end:r},a.spec);return}if(he&&e.pointerId===he.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),he.moved){const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-he.startSvg[0]),s=de(o[1]-he.startSvg[1]);if(r!==0||s!==0){const i=new Map;for(const a of he.originals.keys())i.set(a,[r,s]);for(const a of he.busOriginals.keys())i.set(a,[r,s]);for(const a of he.junctionOriginals.keys())i.set(a,[r,s]);y.getState().moveElements(i)}for(const i of he.busOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}for(const i of he.junctionOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}}he=null;return}if(Ce&&e.pointerId===Ce.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=Rr(Ce.startSvg,o);if(r.w>=Dr||r.h>=Dr){const s=y4(r);if(Ce.shiftKey){const i=new Set(Ce.baseSelection);for(const a of s)i.has(a)?i.delete(a):i.add(a);y.getState().setSelection([...i])}else y.getState().setSelection(s)}an(null),Ce=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(pe&&e.pointerId===pe.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}pe=null}if(he&&e.pointerId===he.pointerId){for(const[l,c]of he.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",nt(c))}for(const l of he.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of he.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{}he=null}if(Ne&&e.pointerId===Ne.pointerId){t.hostEl.classList.remove("tool-wire");const l=y.getState();l.setWireFromTerminal(null),l.setWireDragFrom(null),l.setCursorSvg(null),tt(null),Ne=null}if(Ce&&e.pointerId===Ce.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}an(null),Ce=null}},onDoubleClick(e,t){var s;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const i=(s=n.diagram.annotations)==null?void 0:s.find(a=>a.id===o);if(!i)return;n.setSelectedAnnotation(o),zr(n,i,t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=xt(e.target);r&&(e.preventDefault(),e.stopPropagation(),n.setEditingElement(r))},onDeactivate(e){if(he=null,Ce=null,pe=null,Ne){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(null),Ne=null}an(null)}};function zr(e,t,n){const o=Le(t);if(o==="table"){const r=aj(t,n);r&&(e.setEditingAnnotation(t.id),e.setEditingCell(r))}else o==="text"&&e.setEditingAnnotation(t.id)}function Rr(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),r=Math.abs(t[0]-e[0]),s=Math.abs(t[1]-e[1]);return{x:n,y:o,w:r,h:s}}function y4(e){const{internal:t}=y.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=b4(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([f,h])=>x4([f,h],r));let a=1/0,l=-1/0,c=1/0,u=-1/0;for(const[f,h]of i)f<a&&(a=f),f>l&&(l=f),h<c&&(c=h),h>u&&(u=h);l>=e.x&&a<=e.x+e.w&&u>=e.y&&c<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,h=s==="x"?i[1]:i[1]+l;u>=e.x&&c<=e.x+e.w&&h>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function x4(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 b4(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 w4=4;let ce=null;const v4={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=y.getState().readOnly?null:xt(e.target);let r=null;if(o){const s=y.getState();s.selection.includes(o)||s.setSelection([o]);const i=y.getState().selection,a=y.getState().internal,l=new Map,c=new Map;for(const u of i){const f=a.buses.get(u);if(f){c.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const h=a.layout.get(u);h&&l.set(u,{...h})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}ce={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(!ce||e.pointerId!==ce.pointerId)return;const n=e.clientX-ce.startX,o=e.clientY-ce.startY;if(!ce.moved&&Math.hypot(n,o)>w4){ce.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(ce.moved){if(ce.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=de(r[0]-ce.elementDrag.startSvg[0]),i=de(r[1]-ce.elementDrag.startSvg[1]);for(const[a,l]of ce.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);if(!c)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",nt(u))}for(const a of ce.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:ce.startTx+n,ty:ce.startTy+o})}},onPointerUp(e,t){if(!(!ce||e.pointerId!==ce.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",ce.elementDrag&&ce.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.elementDrag.startSvg[0]),r=de(n[1]-ce.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ce.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of ce.elementDrag.busOriginals.keys())s.set(i,[o,r]);y.getState().moveElements(s)}for(const s of ce.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Mt(s)}"]`);i&&i.removeAttribute("transform")}}else!ce.moved&&!y.getState().readOnly&&k4(ce.startTarget);ce=null}},onPointerCancel(e,t){if(ce!=null&&ce.elementDrag){for(const[n,o]of ce.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);r&&r.setAttribute("transform",nt(o))}for(const n of ce.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);o&&o.removeAttribute("transform")}}ce=null},onDeactivate(){ce=null}};function k4(e){if(!e)return;const t=y.getState(),n=qt(e);if(n){t.setSelectedAnnotation(n);return}const o=xt(e);if(o){t.setSelection([o]);return}const r=Mn(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function Mt(e){return e.replace(/(["\\])/g,"\\$1")}const Pt={tight:1024,compact:720,dense:520,mini:380},Fr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return Fr[e]>=Fr[t]}function _4(e){return e>=Pt.tight?"full":e>=Pt.compact?"tight":e>=Pt.dense?"compact":e>=Pt.mini?"dense":"mini"}const wv=C.createContext("full");function rt(){return C.useContext(wv)}function S4(e){const[t,n]=C.useState(null);return C.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 vv(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<Pt.dense}function ct(){vv()&&y.getState().setActiveTool("pan")}function $4(){vv()&&y.getState().setPlaceKind(null)}const j4={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(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=Dt(t,e.clientX,e.clientY),r=Lt(e.target instanceof Element?e.target:null,n,o),s=y.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=y.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=vn(e.clientX,e.clientY),i=Lt(s,r,Dt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};tt(kn(a,i)?null:bv(i))},onPointerUp(e,t){const n=y.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),tt(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Lt(s,r,Dt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};kn(a,i)||(n.connectWire(o.spec,i.spec),ct())},onPointerLeave(){const e=y.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),tt(null)}},Hr=10;let Ct=!1;function Wr(){setTimeout(()=>$4(),0)}const E4={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=y.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),Ct=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=y.getState();if(!n)return;e.preventDefault();const o=Tn(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=y.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);ev(n,r),Ct=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([qr(n[0]),qr(n[1])])},onPointerUp(e,t){const n=y.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);Z$(r,o,s),Wr();return}Ct&&(Ct=!1,Wr())},onPointerLeave(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),Ct=!1}};function qr(e){return Math.round(e/Hr)*Hr}const Xr=10,Yr=20;function ft(e){return Math.round(e/Xr)*Xr}const N4={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[ft(n[0]),ft(n[1])];y.getState().setBusbarDrawStart(o),y.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([ft(n[0]),ft(n[1])])},onPointerUp(e,t){const n=y.getState().busbarDrawStart;if(y.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=ft(o[0]),s=ft(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,u,f;if(l){if(u=Math.abs(i),u<Yr)return;c=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<Yr)return;c=90,f=[n[0],(n[1]+s)/2]}y.getState().addBus(f,u,c),ct()},onPointerLeave(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},Gr=10,Kr=e=>Math.round(e/Gr)*Gr,A4={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);y.getState().addJunction([Kr(n[0]),Kr(n[1])]),ct()}},T4={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=y.getState(),o=qt(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),ct()}},M4={id:"rect",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"rect",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),{at:s,size:i}=iv({...o,current:r,constrain:e.shiftKey});if(i[0]<xn||i[1]<xn)return;const a=n.insertAnnotation({type:"rect",at:s,size:i,stroke:"dashed"});n.setSelectedAnnotation(a),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},C4={id:"line",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"line",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=av({...o,current:r,constrain:e.shiftKey}),i=s[0]-o.start[0],a=s[1]-o.start[1];if(Math.hypot(i,a)<sj)return;const l=n.insertAnnotation({type:"line",at:o.start,points:[[0,0],[i,a]]});n.setSelectedAnnotation(l),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Ur=15,P4=3,I4=3,O4={id:"table",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"table",start:n,current:n,constrain:!1})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY))})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=Math.abs(r[0]-o.start[0]),i=Math.abs(r[1]-o.start[1]),a=s<Ur&&i<Ur,{at:l,cols:c,rows:u}=a?{at:o.start,cols:P4,rows:I4}:cv({...o,current:r}),f=n.insertAnnotation({type:"table",at:l,...dv(c,u)});n.setSelectedAnnotation(f),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Vr={select:g4,pan:v4,wire:j4,place:E4,busbar:N4,junction:A4,text:T4,rect:M4,line:C4,table:O4};function B4(e,t){const n=y(r=>r.activeTool),o=y(r=>r.readOnly);C.useEffect(()=>{var m;const r=e.current;if(!r)return;const s=o?"pan":n,i=o?Vr.pan:Vr[n],a={viewport:t,hostEl:r};r.dataset.tool=s,(m=i.onActivate)==null||m.call(i,a),i.cursor&&(r.style.cursor=i.cursor);const l=p=>{var x;return(x=i.onPointerDown)==null?void 0:x.call(i,p,a)},c=p=>{var x;return(x=i.onPointerMove)==null?void 0:x.call(i,p,a)},u=p=>{var x;return(x=i.onPointerUp)==null?void 0:x.call(i,p,a)},f=p=>{var x;return i.onPointerCancel?i.onPointerCancel(p,a):(x=i.onPointerUp)==null?void 0:x.call(i,p,a)},h=p=>{var x;return(x=i.onPointerLeave)==null?void 0:x.call(i,p,a)},g=p=>{var x;return(x=i.onDoubleClick)==null?void 0:x.call(i,p,a)};return r.addEventListener("pointerdown",l),r.addEventListener("pointermove",c),r.addEventListener("pointerup",u),r.addEventListener("pointercancel",f),r.addEventListener("pointerleave",h),r.addEventListener("dblclick",g),()=>{var p;r.removeEventListener("pointerdown",l),r.removeEventListener("pointermove",c),r.removeEventListener("pointerup",u),r.removeEventListener("pointercancel",f),r.removeEventListener("pointerleave",h),r.removeEventListener("dblclick",g),(p=i.onDeactivate)==null||p.call(i,a),r.style.cursor="",delete r.dataset.tool}},[n,o,e,t])}let bo=1;const wo=new Set;function L4(e){if(e!==bo){bo=e;for(const t of wo)t(e)}}function D4(){return bo}function z4(e){return wo.add(e),()=>{wo.delete(e)}}const Un=.1,Vn=8,R4=1.0015,F4=1.02;function H4(e,t,n={tx:0,ty:0,scale:1}){const o=C.useRef({...n}),r=C.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)),L4(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return C.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,u=0,f=0,h=0,g=!1;const m=new Map;let p=null,x=!1;const w=()=>{if(m.size<2){p=null;return}const P=[...m.values()],R=P[1].x-P[0].x,Z=P[1].y-P[0].y,ie=Math.hypot(R,Z)||1,ue=i.getBoundingClientRect();p={startDist:ie,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(P[0].x+P[1].x)/2-ue.left,startMidY:(P[0].y+P[1].y)/2-ue.top}},v=P=>{if(P.pointerType==="touch"){if(m.set(P.pointerId,{x:P.clientX,y:P.clientY}),m.size>=2&&!x){x=!0;for(const R of m.keys())R!==P.pointerId&&gv(i,R);w()}if(x){P.stopPropagation(),P.preventDefault();try{i.setPointerCapture(P.pointerId)}catch{}}}},M=P=>{if(P.pointerType!=="touch"||!m.has(P.pointerId)||(m.set(P.pointerId,{x:P.clientX,y:P.clientY}),!x||!p))return;P.stopPropagation();const R=[...m.values()];if(R.length<2)return;const Z=R[1].x-R[0].x,ie=R[1].y-R[0].y,ue=Math.hypot(Z,ie)||1,ee=i.getBoundingClientRect(),ae=(R[0].x+R[1].x)/2-ee.left,me=(R[0].y+R[1].y)/2-ee.top,be=ue/p.startDist,$e=Jn(p.startScale*be,Un,Vn),Me=$e/p.startScale;o.current.tx=p.startMidX-(p.startMidX-p.startTx)*Me+(ae-p.startMidX),o.current.ty=p.startMidY-(p.startMidY-p.startTy)*Me+(me-p.startMidY),o.current.scale=$e,s()},I=P=>{var R;if(P.pointerType==="touch"&&m.has(P.pointerId)&&(m.delete(P.pointerId),x)){if(P.stopPropagation(),(R=i.hasPointerCapture)!=null&&R.call(i,P.pointerId))try{i.releasePointerCapture(P.pointerId)}catch{}m.size>=2?w():p=null,m.size===0&&(x=!1)}},F=P=>{P.preventDefault();const R=i.getBoundingClientRect(),Z=P.clientX-R.left,ie=P.clientY-R.top,ue=P.ctrlKey||P.metaKey;if(P.deltaX===0||ue){const me=Math.pow(ue?F4:R4,-P.deltaY),be=Jn(o.current.scale*me,Un,Vn),$e=be/o.current.scale;o.current.tx=Z-(Z-o.current.tx)*$e,o.current.ty=ie-(ie-o.current.ty)*$e,o.current.scale=be}else o.current.tx-=P.deltaX,o.current.ty-=P.deltaY;s()},G=P=>{const R=P.button===1,Z=g&&P.button===0;!R&&!Z||(P.preventDefault(),a=!0,l=P.pointerId,c=P.clientX,u=P.clientY,f=o.current.tx,h=o.current.ty,i.setPointerCapture(P.pointerId),i.style.cursor="grabbing")},$=P=>{!a||P.pointerId!==l||(o.current.tx=f+(P.clientX-c),o.current.ty=h+(P.clientY-u),s())},H=P=>{a&&P.pointerId===l&&(a=!1,i.releasePointerCapture(P.pointerId),i.style.cursor=g?"grab":"")},W=P=>{if(P.code==="Space"&&!g){const R=P.target;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable))return;g=!0,i.style.cursor="grab",P.preventDefault()}},X=P=>{P.code==="Space"&&(g=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",F,{passive:!1}),i.addEventListener("pointerdown",G),i.addEventListener("pointermove",$),i.addEventListener("pointerup",H),i.addEventListener("pointercancel",H),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",M,{capture:!0}),i.addEventListener("pointerup",I,{capture:!0}),i.addEventListener("pointercancel",I,{capture:!0}),window.addEventListener("keydown",W),window.addEventListener("keyup",X),s(),()=>{i.removeEventListener("wheel",F),i.removeEventListener("pointerdown",G),i.removeEventListener("pointermove",$),i.removeEventListener("pointerup",H),i.removeEventListener("pointercancel",H),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",M,{capture:!0}),i.removeEventListener("pointerup",I,{capture:!0}),i.removeEventListener("pointercancel",I,{capture:!0}),window.removeEventListener("keydown",W),window.removeEventListener("keyup",X)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const c=l.getBoundingClientRect(),u=(i-c.left-o.current.tx)/o.current.scale,f=(a-c.top-o.current.ty)/o.current.scale;return[u,f]},getViewport(){return{...o.current}},setViewport(i){i.tx!==void 0&&(o.current.tx=i.tx),i.ty!==void 0&&(o.current.ty=i.ty),i.scale!==void 0&&(o.current.scale=Jn(i.scale,Un,Vn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function Jn(e,t,n){return e<t?t:e>n?n:e}const kv=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ht=kv?"⌘":"Ctrl+",W4=kv?"⇧":"Shift+",Zn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],q4=18;function X4(e){for(const t of Zn)if(t*e>=q4)return t;return Zn[Zn.length-1]}function Y4(){const e=le(),t=C.useRef(null),n=C.useRef(null),o=C.useRef(null),r=H4(t,n);B4(t,r),f4(t),C.useEffect(()=>(jr(r),()=>jr(null)),[r]),C.useEffect(()=>{const u=f=>{const h=o.current;if(!h)return;const m=X4(f.scale)*f.scale;h.setAttribute("width",String(m)),h.setAttribute("height",String(m)),h.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=ak(),i=C.useCallback((u,f,h)=>{const g=y.getState();if(g.readOnly)return;const m=g.activeTool;if(m==="wire"||m==="busbar"||m==="junction"||m==="place"){yv();return}const p=qt(h),x=p?null:xt(h);if(p)g.selectedAnnotation!==p&&g.setSelectedAnnotation(p);else if(x)g.selection.includes(x)||g.setSelection([x]);else{const W=Mn(h);W&&g.selectedNode!==W&&g.setSelectedNode(W)}const w=y.getState(),v=w.selection.length>0,M=w.selectedAnnotation!=null,I=v||M,F=w.selectedNode!=null,G=!!w.clipboard,$=w.diagram.elements.length>0,H=[{label:e("menu.undo"),shortcut:`${ht}Z`,icon:Eo,onSelect:()=>y.getState().undo(),disabled:w.past.length===0},{label:e("menu.redo"),shortcut:`${ht}${W4}Z`,icon:jo,onSelect:()=>y.getState().redo(),disabled:w.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ht}X`,icon:Ts,onSelect:()=>y.getState().cutSelection(),disabled:!I},{label:e("menu.copy"),shortcut:`${ht}C`,icon:js,onSelect:()=>y.getState().copySelection(),disabled:!I},{label:e("menu.paste"),shortcut:`${ht}V`,icon:$s,onSelect:()=>y.getState().pasteClipboard(),disabled:!G},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:As,onSelect:()=>y.getState().rotateSelection(90),disabled:!v},{label:e("menu.mirror"),shortcut:"M",icon:Es,onSelect:()=>y.getState().mirrorSelection(),disabled:!v},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ht}A`,icon:j2,onSelect:()=>{const W=y.getState();W.setSelection(W.diagram.elements.map(X=>X.id))},disabled:!$},{type:"separator"},{label:e(F&&!I?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Cs,destructive:!0,onSelect:()=>{const W=y.getState();F&&!I?W.deleteSelectedNode():M&&W.selectedAnnotation?W.deleteAnnotation(W.selectedAnnotation):W.deleteSelection()},disabled:!I&&!F}];s.open(u,f,H)},[s,e]);C.useEffect(()=>{const u=t.current;if(!u)return;const f=700,h=4;let g,m=null;const p=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,m=null},x=M=>{M.pointerType==="touch"&&(p(),m={pointerId:M.pointerId,x:M.clientX,y:M.clientY,target:M.target},g=window.setTimeout(()=>{const I=m;m=null,g=void 0,I&&(gv(u,I.pointerId),i(I.x,I.y,I.target))},f))},w=M=>{if(!m||M.pointerId!==m.pointerId)return;const I=M.clientX-m.x,F=M.clientY-m.y;Math.hypot(I,F)>h&&p()},v=M=>{!m||M.pointerId!==m.pointerId||p()};return u.addEventListener("pointerdown",x),u.addEventListener("pointermove",w),u.addEventListener("pointerup",v),u.addEventListener("pointercancel",v),()=>{p(),u.removeEventListener("pointerdown",x),u.removeEventListener("pointermove",w),u.removeEventListener("pointerup",v),u.removeEventListener("pointercancel",v)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{if(y.getState().readOnly)return;const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const h=r.screenToSvg(u.clientX,u.clientY);ev(f,h)},c=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(Cj,{}),d.jsx(Qj,{}),d.jsx(Rj,{}),d.jsx(Wj,{}),d.jsx(ej,{}),d.jsx(cj,{}),d.jsx(Kj,{}),d.jsx(Ej,{}),d.jsx(Nj,{}),d.jsx(yj,{}),d.jsx(Vj,{}),d.jsx(n4,{}),d.jsx(Pj,{}),d.jsx(gj,{}),d.jsx(Gj,{}),d.jsx(Yj,{})]})]})})}const Jr=60,G4=.1,K4=8,U4=8;function V4(e,t,n){return e<t?t:e>n?n:e}function J4(){return document.querySelector(".ole-canvas-root")}function Mo(){const e=Xe(),t=J4();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 w of o){const v=w.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),[u,f]=e.screenToSvg(i,a),h=Math.max(u-l,1),g=Math.max(f-c,1),m=V4(Math.min((n.width-Jr*2)/h,(n.height-Jr*2)/g),G4,K4),p=(l+u)/2,x=(c+f)/2;return e.setViewport({tx:n.width/2-m*p,ty:n.height/2-m*x,scale:m}),!0}function Co(){let e=U4;const t=()=>{Mo()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const Zr=10,Z4=100;function Q4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function Qr(){const[e,t]=C.useState(l4()),[n,o]=C.useState(!1),[r,s]=C.useState(null),i=C.useRef(null),a=C.useRef(void 0),[l]=C.useState(Q4);C.useEffect(()=>c4(m=>t(m)),[]),C.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),Z4),()=>window.clearTimeout(a.current)},[e]);const c=y(m=>e?m.diagram.elements.find(p=>p.id===e)??null:null);if(C.useLayoutEffect(()=>{if(!n||!e)return;let m=0,p=-1,x=-1;const w=()=>{const v=document.querySelector(`[data-element-id="${e6(e)}"]`),M=i.current;if(v&&M){const I=v.getBoundingClientRect();let F=I.bottom+Zr;F+M.offsetHeight>window.innerHeight-4&&(F=I.top-M.offsetHeight-Zr);let G=I.left+I.width/2-M.offsetWidth/2;G=Math.max(4,Math.min(G,window.innerWidth-M.offsetWidth-4)),(F!==p||G!==x)&&(s({top:F,left:G}),p=F,x=G)}m=requestAnimationFrame(w)};return m=requestAnimationFrame(w),()=>cancelAnimationFrame(m)},[n,e]),l||!n||!e||!c)return null;const u=ot[c.kind],f=c.name??c.id,h=(u==null?void 0:u.name)??c.kind,g=c.name&&c.name!==c.id;return typeof document>"u"?null:ks.createPortal(d.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[d.jsx("span",{className:"font-medium text-foreground",children:f}),g&&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:h})]}),document.body)}function e6(e){return e.replace(/(["\\])/g,"\\$1")}function t6({width:e,children:t}){const n=e==null?"full":_4(e);return d.jsx(wv.Provider,{value:n,children:t})}function es(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function n6(...e){return t=>{let n=!1;const o=e.map(r=>{const s=es(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():es(e[r],null)}}}}var o6=Symbol.for("react.lazy"),_n=Se[" use ".trim().toString()];function r6(e){return typeof e=="object"&&e!==null&&"then"in e}function _v(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===o6&&"_payload"in e&&r6(e._payload)}function s6(e){const t=a6(e),n=Se.forwardRef((o,r)=>{let{children:s,...i}=o;_v(s)&&typeof _n=="function"&&(s=_n(s._payload));const a=Se.Children.toArray(s),l=a.find(c6);if(l){const c=l.props.children,u=a.map(f=>f===l?Se.Children.count(c)>1?Se.Children.only(null):Se.isValidElement(c)?c.props.children:null:f);return d.jsx(t,{...i,ref:r,children:Se.isValidElement(c)?Se.cloneElement(c,void 0,u):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var i6=s6("Slot");function a6(e){const t=Se.forwardRef((n,o)=>{let{children:r,...s}=n;if(_v(r)&&typeof _n=="function"&&(r=_n(r._payload)),Se.isValidElement(r)){const i=u6(r),a=d6(s,r.props);return r.type!==Se.Fragment&&(a.ref=o?n6(o,i):i),Se.cloneElement(r,a)}return Se.Children.count(r)>1?Se.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var l6=Symbol("radix.slottable");function c6(e){return Se.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===l6}function d6(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 u6(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 ts=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ns=Os,f6=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return ns(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const u=n==null?void 0:n[c],f=s==null?void 0:s[c];if(u===null)return null;const h=ts(u)||ts(f);return r[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:h,...g}=u;return Object.entries(g).every(m=>{let[p,x]=m;return Array.isArray(x)?x.includes({...s,...a}[p]):{...s,...a}[p]===x})?[...c,f,h]:c},[]);return ns(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},h6=f6("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=Se.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?i6:"button";return d.jsx(i,{className:_e(h6({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const m6=350;function Te({content:e,children:t,disabled:n,delayMs:o=m6}){const r=C.useRef(null),s=C.useRef(null),[i,a]=C.useState(!1),[l,c]=C.useState(null),u=C.useId(),f=C.useRef(void 0),h=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},g=()=>{window.clearTimeout(f.current),a(!1)};C.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const w=r.current.getBoundingClientRect(),v=s.current.getBoundingClientRect(),M=8;let I="top",F=w.top-v.height-M;F<4&&(I="bottom",F=w.bottom+M);let G=w.left+w.width/2-v.width/2;G=Math.max(4,Math.min(G,window.innerWidth-v.width-4)),c({top:F,left:G,side:I})},[i,e]),C.useEffect(()=>()=>window.clearTimeout(f.current),[]),C.useEffect(()=>{if(!i)return;const w=M=>{M.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",w),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",w),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const m=t,p=m.props,x=C.cloneElement(m,{ref:w=>{r.current=w;const v=m.ref;typeof v=="function"?v(w):v&&typeof v=="object"&&(v.current=w)},onPointerEnter:w=>{var v;(v=p.onPointerEnter)==null||v.call(p,w),h()},onPointerLeave:w=>{var v;(v=p.onPointerLeave)==null||v.call(p,w),g()},onFocus:w=>{var v;(v=p.onFocus)==null||v.call(p,w),h()},onBlur:w=>{var v;(v=p.onBlur)==null||v.call(p,w),g()},"aria-describedby":i?u:p["aria-describedby"]});return d.jsxs(d.Fragment,{children:[x,i&&typeof document<"u"&&ks.createPortal(d.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const os=12,p6=56;function g6(){var w;const e=le(),t=y(v=>v.selection),n=y(v=>v.selectedNode),o=y(v=>v.selectedWire),r=y(v=>v.activeTool),s=y(v=>v.rotateSelection),i=y(v=>v.mirrorSelection),a=y(v=>v.deleteSelection),l=y(v=>v.deleteSelectedNode),c=y(v=>v.deleteSelectedWire),u=y(v=>v.resetWirePath),f=y(v=>v.internal.wireRenders),h=o!=null&&((w=f.get(o))==null?void 0:w.userEdited)===!0,g=C.useRef(null);C.useEffect(()=>{const v=g.current;if(!v)return;const M=t.length>0,I=!M&&o!=null,F=!M&&!I&&n!=null;if(!((M||I||F)&&(r==="select"||r==="pan"))){v.style.display="none";return}v.style.display="flex";let $=0,H="";const W=()=>{let X=1/0,P=-1/0,R=1/0,Z=-1/0,ie=!1;const ue=ee=>{ee.width===0&&ee.height===0||(ee.left<X&&(X=ee.left),ee.right>P&&(P=ee.right),ee.top<R&&(R=ee.top),ee.bottom>Z&&(Z=ee.bottom),ie=!0)};if(M)for(const ee of t){const ae=document.querySelector(`[data-element-id="${CSS.escape(ee)}"]`);ae&&ue(ae.getBoundingClientRect())}else if(I&&o){const ee=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ee&&ue(ee.getBoundingClientRect())}else if(F&&n){const ee=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const ae of ee)ue(ae.getBoundingClientRect())}if(ie){const ee=(X+P)/2;let ae=R-os,me="-100%";ae<p6&&(ae=Z+os,me="0%");const be=`translate3d(${ee}px, ${ae}px, 0) translate(-50%, ${me})`;be!==H&&(v.style.transform=be,H=be)}$=requestAnimationFrame(W)};return $=requestAnimationFrame(W),()=>cancelAnimationFrame($)},[t,n,o,r]);const m=t.length===0&&o!=null,p=t.length===0&&!m&&n!=null,x=p||m;return d.jsxs("div",{ref:g,role:"toolbar","aria-label":e(m?"ctx.ariaWire":p?"ctx.ariaNode":"ctx.ariaElement"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-30 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[m&&h&&o&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{children:d.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx($2,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!x&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{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(As,{})})}),d.jsx(Te,{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(Es,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Te,{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(m?"ctx.deleteHintWire":p?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>m?c():p?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(Cs,{})})})]})}const rs=8,y6=56,vo=".ole-ann-cell-edit-fo",ko=".ole-free-annotation-edit-fo";function ss(){return document.querySelector(`${vo} input`)??document.querySelector(`${ko} [contenteditable]`)}function x6(){const e=le(),t=y(i=>i.editingAnnotation),n=y(i=>i.editingCell),o=C.useRef(null);C.useEffect(()=>{const i=o.current;if(!i)return;if(!t){i.style.display="none";return}i.style.display="flex";let a=0,l="";const c=()=>{const u=ss()??document.querySelector(vo)??document.querySelector(ko)??document.querySelector(`[data-annotation-id="${CSS.escape(t)}"]`);if(u){const f=u.getBoundingClientRect();let h=f.top-rs,g="-100%";h<y6&&(h=f.bottom+rs,g="0%");const m=`translate3d(${f.left}px, ${h}px, 0) translate(0, ${g})`;m!==l&&(i.style.transform=m,l=m)}a=requestAnimationFrame(c)};return a=requestAnimationFrame(c),()=>cancelAnimationFrame(a)},[t,n]);const r=()=>{var i;(i=ss())==null||i.blur()},s=()=>{var c,u;const i=y.getState(),a=i.editingAnnotation,l=(c=i.diagram.annotations)==null?void 0:c.find(f=>f.id===a);if(!l){i.setEditingAnnotation(null);return}if(Le(l)==="table"&&i.editingCell){const f=document.querySelector(`${vo} input`),[h,g]=i.editingCell;if(f){f.value=((u=l.cells[h])==null?void 0:u[g])??"",f.blur();return}}else{const f=document.querySelector(`${ko} [contenteditable]`);if(f){f.innerText=l.text??"",f.blur();return}}i.setEditingAnnotation(null)};return d.jsxs("div",{ref:o,role:"toolbar","aria-label":e("ctx.ariaEdit"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-40 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.done")," · Enter"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-emerald-600 hover:text-emerald-600 dark:text-emerald-400 dark:hover:text-emerald-400",onMouseDown:i=>i.preventDefault(),onClick:r,"aria-label":e("ctx.done"),children:d.jsx(c2,{})})}),d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.cancel")," · Esc"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onMouseDown:i=>i.preventDefault(),onClick:s,"aria-label":e("ctx.cancel"),children:d.jsx(Sn,{})})})]})}function Po({open:e,onOpenChange:t,trigger:n,children:o}){const r=C.useRef(null);return C.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 Sv="ole-panel-open";function b6(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Sv);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 is(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Sv,JSON.stringify(t))}catch{}}const Xt=$n((e,t)=>({...b6(),setOutlineOpen:n=>{e({outlineOpen:n}),is(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),is(t())}})),mn=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],$v=.1,jv=8,Ev="ole-grid";function w6(){try{const e=window.localStorage.getItem(Ev);return e==null?!0:e==="1"}catch{return!0}}function v6(e){try{window.localStorage.setItem(Ev,e?"1":"0")}catch{}}function k6(e,t,n){return e<t?t:e>n?n:e}function Nv(){return document.querySelector(".ole-canvas-root")}function Io(e){const t=Xe(),n=Nv();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=k6(e,$v,jv),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function _6(){const e=Xe();if(!e)return;const t=e.getViewport().scale,n=mn.find(o=>o>t+1e-6)??jv;Io(n)}function S6(){const e=Xe();if(!e)return;const t=e.getViewport().scale;let n=$v;for(let o=mn.length-1;o>=0;o--)if(mn[o]<t-1e-6){n=mn[o];break}Io(n)}const $6={off:"id",id:"all",all:"off"};function j6(){var o;const e=y.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=$6[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Av(){const[e,t]=C.useState(()=>w6());return C.useEffect(()=>{const n=Nv();n==null||n.classList.toggle("hide-grid",!e),v6(e)},[e]),C.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 Tv(){const e=le();return d.jsx(Te,{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:S6,"aria-label":e("view.zoomOut"),children:d.jsx($o,{})})})}function Mv(){const e=le();return d.jsx(Te,{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:_6,"aria-label":e("view.zoomIn"),children:d.jsx(k2,{})})})}function Cv(){const e=le(),[t,n]=C.useState(D4);return C.useEffect(()=>z4(n),[]),d.jsx(Te,{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:()=>Io(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 Pv(){const e=le();return d.jsx(Te,{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:Mo,"aria-label":e("view.fit"),children:d.jsx(b2,{})})})}function Iv({grid:e,setGrid:t}){const n=le();return d.jsx(Te,{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:_e(!e&&"text-muted-foreground/60"),children:d.jsx(y2,{})})})}function Ov(){const e=le(),t=y(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Te,{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:j6,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:_e(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Ps,{})})})}function E6({stacked:e}={}){const t=le(),[n,o]=C.useState(!1),[r,s]=Av(),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(Te,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:_e("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[d.jsx(no,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Te,{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(no,{})})});return d.jsx(Po,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(Cv,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Tv,{}),d.jsx(Mv,{})]}),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(Pv,{}),d.jsx(Iv,{grid:r,setGrid:s}),d.jsx(Ov,{})]})]})})}function as(){const e=rt();return!y(n=>n.readOnly)&&Oe(e,"dense")?null:d.jsx(N6,{tier:e})}function N6({tier:e}){const t=Oe(e,"tight"),n=y(s=>s.readOnly),[o,r]=Av();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(Tv,{}),!t&&d.jsx(Cv,{}),d.jsx(Mv,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(Pv,{}),d.jsx(Iv,{grid:o,setGrid:r}),!n&&d.jsx(Ov,{})]})})}const ls=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:w2,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:x2,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:$o,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:u2,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Ms,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Ss,switchTo:"wire",groupBreakAfter:!0},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Ps,switchTo:"text",iconOnly:!0},{id:"rect",labelKey:"tool.rect",hotkey:"F",descriptionKey:"tool.rectHint",icon:E2,switchTo:"rect",iconOnly:!0},{id:"line",labelKey:"tool.line",hotkey:"L",descriptionKey:"tool.lineHint",icon:S2,switchTo:"line",iconOnly:!0},{id:"table",labelKey:"tool.table",hotkey:"D",descriptionKey:"tool.tableHint",icon:N2,switchTo:"table",iconOnly:!0}];function A6(){const e=le(),t=y(h=>h.activeTool),n=y(h=>h.placeKind),o=y(h=>h.placeFromTerminal),r=y(h=>h.wireDragFrom),s=y(h=>h.busbarDrawStart),i=y(h=>h.selection.length>0||h.selectedNode!=null),a=y(h=>h.editingAnnotation),l=y(h=>{var p;const g=h.selectedAnnotation;if(!g)return null;const m=(p=h.diagram.annotations)==null?void 0:p.find(x=>x.id===g);return m?Le(m):null});if(a)return d.jsx("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:e("mode.annEditing")})});let c=null,u=!1;switch(t){case"select":if(l){c=e(l==="table"?"mode.annTableSel":l==="text"?"mode.annTextSel":"mode.annShapeSel"),u=!0;break}c=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(u=!0);break;case"pan":c=e("mode.pan");break;case"wire":c=e(r?"mode.wireDragging":"mode.wireInit"),u=!0;break;case"busbar":c=e(s?"mode.busDragging":"mode.busInit"),u=!0;break;case"junction":c=e("mode.junction"),u=!0;break;case"place":n?o?c=e("mode.placeFromTerm"):c=e("mode.placeNormal"):c=e("mode.placeNoKind"),u=!0;break;case"text":c=e("mode.text"),u=!0;break;case"rect":c=e("mode.rect"),u=!0;break;case"line":c=e("mode.line"),u=!0;break;case"table":c=e("mode.table"),u=!0;break}if(!c)return null;const f=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:c}),u&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",f]})]})}function T6(){const e=le(),t=y(w=>w.activeTool),n=y(w=>w.placeKind),o=y(w=>w.setActiveTool),r=y(w=>w.past.length),s=y(w=>w.future.length),i=y(w=>w.undo),a=y(w=>w.redo),l=rt(),c=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),h=new Set(["select","text","rect","line","table"]),g=f?ls.filter(w=>!h.has(w.id)):ls,m=w=>t===w.switchTo,[p,x]=C.useState(!1);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:[u&&d.jsx("div",{className:_e("transition-opacity duration-150",p&&"pointer-events-none opacity-0"),children:d.jsx(A6,{})}),d.jsxs("div",{onPointerEnter:()=>x(!0),onPointerLeave:()=>x(!1),className:_e("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",f?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[f&&d.jsx(M6,{stacked:!0}),g.map(w=>{const v=w.icon,M=m(w),I=w.id==="place"&&M&&n==null?e("tool.placeNoKindTooltip"):e(w.descriptionKey);return d.jsxs(C.Fragment,{children:[d.jsx(pt,{icon:v,label:e(w.labelKey),hotkey:w.hotkey,active:M,iconOnly:!f&&(w.iconOnly||c),stacked:f,description:I,onClick:()=>{o(w.switchTo,{placeKind:w.presetPlaceKind!==void 0?w.presetPlaceKind:void 0})}}),w.groupBreakAfter&&!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},w.id)}),!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?d.jsx(P6,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(pt,{icon:Eo,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(pt,{icon:jo,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(C6,{iconOnly:c})]}),f&&d.jsx(E6,{stacked:!0})]})]})}function M6({stacked:e}){const t=le(),n=Xt(r=>r.outlineOpen),o=Xt(r=>r.toggleOutline);return d.jsx(pt,{icon:Ns,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function pt({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(Te,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:_e("rounded-md font-medium transition-colors",i?"flex h-12 w-12 flex-col items-center justify-center gap-0.5 text-[10px] leading-tight":"flex h-9 items-center gap-1.5 text-xs",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[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:_e("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function Bv(){const e=y(r=>r.diagram.elements),t=y(r=>r.diagram.layout),n=y(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function C6({iconOnly:e}){const t=le(),[n,o]=C.useState(!1),r=Bv(),s=i=>()=>{o(!1),i()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:It,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function P6({stacked:e}){const t=le(),[n,o]=C.useState(!1),r=y(h=>h.past.length),s=y(h=>h.future.length),i=y(h=>h.undo),a=y(h=>h.redo),l=y(h=>h.selection.length>0),c=y(h=>h.clipboard!=null),u=Bv(),f=h=>()=>{o(!1),h()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:no,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(h=>!h)}),children:[d.jsx(Pe,{onClick:f(i),icon:d.jsx(Eo,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Pe,{onClick:f(a),icon:d.jsx(jo,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().cutSelection()),icon:d.jsx(Ts,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Pe,{onClick:f(()=>y.getState().copySelection()),icon:d.jsx(js,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Pe,{onClick:f(()=>y.getState().pasteClipboard()),icon:d.jsx($s,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Pe({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:_e("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,d.jsx("span",{className:"flex-1",children:e})]})}function I6(){const e=Xt(r=>r.outlineOpen),t=Xt(r=>r.setOutlineOpen),n=rt();return Oe(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(cs,{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(cs,{onClose:()=>t(!1)}):d.jsx(O6,{onClick:()=>t(!0)})})}function O6({onClick:e}){const t=le(),n=rt(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:_e("ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",o?"w-12 justify-center":"gap-2 px-3"),children:[d.jsx(Ns,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function cs({onClose:e,sheet:t}){const n=le(),o=y(c=>c.diagram.elements),r=y(c=>c.activeTool==="place"),s=rt(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:_e("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:l},children:[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(L6,{children:o.length}),d.jsx(v2,{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(B6,{element:c},c.id))})})]})}function B6({element:e}){const t=ot[e.kind],n=y(l=>l.selection.includes(e.id)),o=y(l=>l.setSelection),r=y(l=>l.toggleInSelection),s=rt(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function L6({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 D6={"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":"剩余动作电流"},z6={"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"},ds={zh:D6,en:z6};function R6(e,t){return ds[e][t]??ds.zh[t]}function Jt(){const e=Yt(t=>t.locale);return(t,n)=>R6(e,t)??n??t}const Lv="ole-palette-collapsed",F6=new Set(["busbar"]),zt=(()=>{const e={};for(const[t,n]of Object.entries(R$)){const o=n.filter(r=>!F6.has(r.id));o.length&&(e[t]=o)}return e})(),H6=(()=>{const e=new Set(vr),t=Object.keys(zt).filter(n=>!e.has(n));return[...vr.filter(n=>{var o;return(o=zt[n])==null?void 0:o.length}),...t]})();function W6(){try{const e=window.localStorage.getItem(Lv);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 q6(e){try{window.localStorage.setItem(Lv,JSON.stringify([...e]))}catch{}}function X6(){const e=le(),t=y(f=>f.activeTool==="place"),n=y(f=>f.placeKind),o=y(f=>f.setActiveTool),r=Xt(f=>f.outlineOpen),s=rt(),i=Oe(s,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px) + 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:u,role:"dialog","aria-label":e("library.title"),children:d.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:d.jsx(Sn,{className:"size-3.5"})})]}),d.jsx(Y6,{sheet:i})]})})}function Y6({sheet:e}){const t=le(),n=Jt(),[o,r]=C.useState(""),[s,i]=C.useState(()=>W6()),a=C.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return zt;const h={};for(const[g,m]of Object.entries(zt)){const p=m.filter(x=>{const w=n(`${x.id}.name`,x.name).toLowerCase(),v=n(`${x.id}.desc`,x.description??"").toLowerCase();return w.includes(f)||x.id.toLowerCase().includes(f)||v.includes(f)});p.length&&(h[g]=p)}return h},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=C.useCallback((f,h)=>{i(g=>{const m=new Set(g);return h?m.delete(f):m.add(f),q6(m),m})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(G6,{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")}):H6.map(f=>{var x;const h=a[f];if(!(h!=null&&h.length))return null;const g=((x=zt[f])==null?void 0:x.length)??h.length,m=t(`cat.${f}`),p=l||!s.has(f);return d.jsxs("details",{open:p,className:"group mb-2 last:mb-0",onToggle:w=>{l||u(f,w.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(d2,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:m}),d.jsx(U6,{children:l&&h.length!==g?`${h.length}/${g}`:g})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:h.map(w=>d.jsx(K6,{entry:w,sheet:e},w.id))})]},f)})})]})}function G6({value:e,onChange:t}){const n=le();return d.jsxs("div",{className:"relative",children:[d.jsx(_2,{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(Sn,{className:"size-3"})})]})}function K6({entry:e,sheet:t}){const n=le(),o=Jt(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=y(f=>f.setActiveTool),a=y(f=>f.activeTool==="place"&&f.placeKind===e.id),l=y(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),c=C.useRef(null);C.useEffect(()=>{var f;l&&((f=c.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const h=document.createElement("div");h.className="ole-glass",h.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),h.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(h),f.dataTransfer.setDragImage(h,32,32),setTimeout(()=>h.remove(),0)};return d.jsxs("li",{ref:c,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function U6({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 _o="ole-onboarding-dismissed";function V6(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(_o)==="1"}catch{return!1}}function us(e){try{e?window.localStorage.setItem(_o,"1"):window.localStorage.removeItem(_o)}catch{}}const fs=$n(e=>({dismissed:V6(),dismiss:()=>{us(!0),e({dismissed:!0})},reset:()=>{us(!1),e({dismissed:!1})}}));function J6(){const e=le(),t=fs(o=>o.dismissed),n=fs(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(Sn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Qn,{n:1,icon:d.jsx(Ms,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Qn,{n:2,icon:d.jsx(Ss,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Qn,{n:3,icon:d.jsx($o,{}),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 Qn({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 Z6(){const e=le(),t=y(g=>g.selection),n=y(g=>g.diagram.elements),o=y(g=>g.diagram.buses),r=y(g=>g.diagram.junctions),s=y(g=>g.selectedNode),i=y(g=>g.selectedWire),a=y(g=>g.selectedAnnotation);if(i)return d.jsx(dE,{wireId:i});if(s)return d.jsx(fE,{nodeId:s});if(a)return d.jsx(rE,{annId:a});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 l=t[0],c=(o??[]).find(g=>g.id===l);if(c)return d.jsx(nE,{bus:c});const u=(r??[]).find(g=>g.id===l);if(u)return d.jsx(uE,{junction:u});const f=n.find(g=>g.id===l);if(!f)return null;const h=ot[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(Ke,{label:e("props.name"),value:f.name??"",placeholder:f.id,onCommit:g=>y.getState().updateElement(l,{name:g.trim()===""?void 0:g.trim()})}),d.jsx(Oo,{label:e("props.note"),value:f.note??"",onCommit:g=>y.getState().updateElement(l,{note:g.trim()===""?void 0:g.trim()})},l),(h==null?void 0:h.state)&&h.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:h.state.map(g=>d.jsx(mE,{id:l,element:f,field:g},g.name))}),d.jsx(Q6,{id:l,element:f,schema:(h==null?void 0:h.params)??[]})]})}function Q6({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(eE,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(tE,{id:e,element:t,fieldKey:s,value:i},s))]})}function eE({id:e,element:t,field:n}){var l;const o=le(),r=Jt(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const u={...t.params??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:i,children:d.jsx(Bo,{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(Ke,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function tE({id:e,element:t,fieldKey:n,value:o}){const r=le(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,y.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?d.jsx(st,{label:n,children:d.jsx(Bo,{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(Ke,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function nE({bus:e}){const t=le(),n=e.id,o=r=>{const s=r.trim();So(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(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:r=>So(n,{note:r.trim()===""?void 0:r.trim()})},n),d.jsx(oE,{bus:e})]})}function oE({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,So(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 So(e,t){y.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function rE({annId:e}){const t=le(),n=y(r=>(r.diagram.annotations??[]).find(s=>s.id===e));if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.annNotFound",{id:e})});const o=r=>y.getState().updateAnnotation(e,r);switch(Le(n)){case"rect":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(Ke,{label:t("props.annLabel"),value:r.label??"",placeholder:t("props.annLabelPlaceholder"),onCommit:s=>o({label:s.trim()===""?void 0:s.trim()})}),d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"dashed",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annFill"),value:r.fill??"none",options:[{value:"none",label:t("props.annFillNone")},{value:"tint",label:t("props.annFillTint")}],onChange:s=>o({fill:s==="none"?void 0:s})})]})}case"line":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"solid",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annArrow"),value:r.arrow??"none",options:[{value:"none",label:t("props.annArrowNone")},{value:"end",label:t("props.annArrowEnd")},{value:"both",label:t("props.annArrowBoth")}],onChange:s=>o({arrow:s==="none"?void 0:s})})]})}case"table":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(hs,{label:t("props.annRows"),value:r.rowHeights.length,min:1,onChange:s=>o(sE(r,s))}),d.jsx(hs,{label:t("props.annCols"),value:r.colWidths.length,min:1,onChange:s=>o(iE(r,s))}),d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})]})}default:{const r=n;return d.jsx("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})})}}}function sE(e,t){const n=e.colWidths.length,o=e.rowHeights[e.rowHeights.length-1]??Wt,r=e.rowHeights.slice(0,t);for(;r.length<t;)r.push(o);const s=e.cells.slice(0,t).map(i=>[...i]);for(;s.length<t;)s.push(dv(n,1).cells[0]);return{rowHeights:r,cells:s}}function iE(e,t){const n=e.colWidths[e.colWidths.length-1]??Ht,o=e.colWidths.slice(0,t);for(;o.length<t;)o.push(n);const r=e.cells.map(s=>{const i=s.slice(0,t);for(;i.length<t;)i.push("");return i});return{colWidths:o,cells:r}}function dn({label:e,value:t,options:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsx("div",{className:"flex overflow-hidden rounded-md border border-border/60",children:n.map(r=>d.jsx("button",{type:"button","aria-pressed":t===r.value,onClick:()=>o(r.value),className:_e("h-7 flex-1 truncate px-1.5 text-[11px] transition-colors",t===r.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:r.label},r.value))})})}function hs({label:e,value:t,min:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button","aria-label":`${e} −`,disabled:t<=n,onClick:()=>o(t-1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40",children:"−"}),d.jsx("span",{className:"w-8 text-center font-mono text-[11px] tabular-nums",children:t}),d.jsx("button",{type:"button","aria-label":`${e} +`,onClick:()=>o(t+1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent",children:"+"})]})})}const aE=5,lE=32,cE=8;function ms({label:e,value:t,onCommit:n}){return d.jsx(Ke,{label:e,value:t!=null?String(t):"",placeholder:String(cE),unit:"px",onCommit:o=>{const r=o.trim();if(r===""){n(void 0);return}const s=Number(r);Number.isFinite(s)&&n(Math.min(lE,Math.max(aE,Math.round(s))))}})}function dE({wireId:e}){const t=le(),n=y(x=>x.diagram.wires),o=y(x=>x.diagram.elements),r=y(x=>x.diagram.buses),s=y(x=>x.diagram.junctions),i=y(x=>x.internal.terminalToNode),a=y(x=>x.setSelectedNode),l=(n??[]).find(x=>x.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),u=new Map(o.map(x=>[x.id,x])),f=new Map((r??[]).map(x=>[x.id,x])),h=new Map((s??[]).map(x=>[x.id,x])),g=x=>{if(!x.includes(".")){const F=f.get(x);if(F)return{id:x,label:F.name??x};const G=h.get(x);return{id:x,label:(G==null?void 0:G.name)??x}}const w=x.indexOf("."),v=x.slice(0,w),M=x.slice(w+1),I=u.get(v);return{id:v,label:(I==null?void 0:I.name)??v,pin:M}},m=g(l.ends[0]),p=g(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(Ke,{label:t("props.label"),value:l.label??"",placeholder:t("props.labelPlaceholder"),onCommit:x=>y.getState().updateWire(e,{label:x.trim()===""?void 0:x.trim()})}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[m,p].map((x,w)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>y.getState().setSelection([x.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:x.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:x.label}),x.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:x.pin})]},w))}),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 uE({junction:e}){var r;const t=le(),n=y(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(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>y.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:s=>y.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 fE({nodeId:e}){const t=le(),n=y(a=>a.internal.nodes.get(e)),o=y(a=>a.diagram.elements),r=y(a=>a.setSelection);if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const c=a.slice(0,l),u=a.slice(l+1),f=s.get(c)??[];f.push(u),s.set(c,f)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function st({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 Ke({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=C.useState(t),a=C.useRef(null);return C.useEffect(()=>i(t),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:_e("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&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 hE=350;function Oo({label:e,value:t,onCommit:n}){const[o,r]=C.useState(t),s=C.useRef(!1),i=C.useRef(null),a=C.useRef({local:o,value:t,onCommit:n});a.current={local:o,value:t,onCommit:n};const l=C.useRef(null);C.useEffect(()=>{s.current||(r(t),l.current=null)},[t]);const c=()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null);const f=a.current;f.local===f.value||f.local===l.current||(l.current=f.local,f.onCommit(f.local))},u=C.useRef(c);return u.current=c,C.useEffect(()=>()=>u.current(),[]),d.jsx(st,{label:e,children:d.jsx("textarea",{rows:2,value:o,onFocus:()=>{s.current=!0},onChange:f=>{r(f.target.value),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,u.current()},hE)},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]=C.useState(String(t)),a=C.useRef(null);return C.useEffect(()=>i(String(t)),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:_e("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 font-mono text-[11px] tabular-nums focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&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 Bo({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:_e("flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",e?"border-[var(--selection)] bg-[var(--selection)]/15 text-foreground":"border-border/60 text-muted-foreground hover:bg-accent"),"aria-pressed":e,children:n})}function mE({id:e,element:t,field:n}){var l;const o=le(),s=Jt()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const u={...t.state??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:s,children:d.jsx(Bo,{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(Ke,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function pE(){const e=le(),t=Jt(),n=y(g=>g.selection),o=y(g=>g.selectedNode),r=y(g=>g.selectedWire),s=y(g=>g.selectedAnnotation),i=y(g=>g.diagram.annotations),a=y(g=>g.diagram.elements),l=y(g=>g.diagram.buses),c=rt(),u=Oe(c,"dense");if(n.length===0&&!o&&!r&&!s)return null;let f=e("props.title"),h=null;if(r)f=e("props.wire");else if(o)f=e("props.node");else if(s){const g=(i??[]).find(p=>p.id===s),m=g?Le(g):"text";f=e(m==="rect"?"props.annRect":m==="line"?"props.annLine":m==="table"?"props.annTable":"props.annText")}else if(n.length===1){const g=n[0],m=(l??[]).find(p=>p.id===g);if(m)f=m.name??e("props.bus");else{const p=a.find(x=>x.id===g);if(p){const x=ot[p.kind];f=x?t(`${x.id}.name`,x.name):p.kind}}}else h=n.length;return d.jsxs("aside",{className:_e("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",u?"w-48":"w-56"),style:{top:`calc(${u?"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% - ${u?"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:f}),h!=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:h})})]}),d.jsx(Z6,{})]})}function gE(){C.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 yE(){gE();const e=y(o=>o.readOnly),t=C.useRef(null),n=S4(t);return d.jsx(lk,{children:d.jsx("div",{ref:t,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(t6,{width:n,children:[d.jsx(Y4,{}),e?d.jsxs(d.Fragment,{children:[d.jsx(as,{}),d.jsx(Qr,{})]}):d.jsxs(d.Fragment,{children:[d.jsx(I6,{}),d.jsx(pE,{}),d.jsx(T6,{}),d.jsx(as,{}),d.jsx(g6,{}),d.jsx(x6,{}),d.jsx(X6,{}),d.jsx(J6,{}),d.jsx(Qr,{})]})]})})})}const xE="ole-theme";function bE(){try{const e=window.localStorage.getItem(xE);return e==="light"||e==="dark"?e:null}catch{return null}}function wE(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function vE(){return typeof window>"u"?"light":bE()??(wE()?"dark":"light")}function Dv(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function kE({className:e,diagram:t,readOnly:n,locale:o,theme:r}){return C.useEffect(()=>{y.getState().setReadOnly(!!n)},[n]),C.useEffect(()=>{if(!t)return;if(n){y.getState().setDiagram(t),y.getState().setActiveTool("pan");return}y.getState().diagram.elements.length===0&&y.getState().setDiagram(t)},[t,n]),C.useEffect(()=>{o&&Yt.getState().setLocale(o)},[o]),C.useEffect(()=>{r&&Dv(r)},[r]),C.useEffect(()=>{Co()},[]),i4(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(yE,{})})}const zv={"application/json":[".json"]},Rv=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Fv=e=>e instanceof DOMException&&e.name==="AbortError";function ps(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(ve("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(ve("io.notObject"));const n=t;if(n.version!=="1")throw new Error(ve("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(ve("io.elementsMissing"));return n}function _E(e){return JSON.stringify(e,null,2)+`
|
|
220
|
+
`}async function SE(){if(Rv()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:ve("topbar.file.fileDescription"),accept:zv}]})}catch(n){if(Fv(n))return null;throw n}const t=await e.getFile();return{diagram:ps(await t.text()),session:{handle:e,name:t.name}}}return new Promise((e,t)=>{const n=document.createElement("input");n.type="file",n.accept=".json,application/json",n.addEventListener("change",async()=>{var r;const o=(r=n.files)==null?void 0:r[0];if(!o)return e(null);try{e({diagram:ps(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function gs(e,t,n={}){const o=_E(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Rv()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:ve("topbar.file.fileDescription"),accept:zv}]})}catch(l){if(Fv(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const r=URL.createObjectURL(new Blob([o],{type:"application/json"})),s=document.createElement("a");return s.href=r,s.download=(t==null?void 0:t.name)??"diagram.json",s.click(),URL.revokeObjectURL(r),t??{name:"diagram.json"}}function $E(){const e=le(),t=y(f=>f.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=jE(),[a,l]=C.useState(!1),c=C.useRef(null);C.useEffect(()=>{const f=h=>{if(!(h.metaKey||h.ctrlKey))return;const g=h.key.toLowerCase();g==="o"?(h.preventDefault(),r()):g==="s"&&(h.preventDefault(),h.shiftKey?i():s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,s,i]),C.useEffect(()=>{if(!a)return;const f=g=>{c.current&&!c.current.contains(g.target)&&l(!1)},h=g=>{g.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",h)}},[a]);const u=f=>()=>{l(!1),f()};return d.jsxs("div",{ref:c,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(f=>!f),children:[d.jsx(rr,{}),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(un,{onClick:u(o),icon:d.jsx(p2,{}),children:e("topbar.file.new")}),d.jsx(un,{onClick:u(r),icon:d.jsx(rr,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(un,{onClick:u(s),icon:d.jsx(sr,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(un,{onClick:u(i),icon:d.jsx(sr,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function un({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 jE(){const e=le(),t=y(l=>l.loadDiagramFromFile),n=y(l=>l.setFileSession),o=y(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=y.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await SE();l&&(t(l.diagram,l.session),Co())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const eo="WIRES",Ue="ELEMENTS",to="LABELS",De="ANNOTATIONS",ys=32,xs=64,EE=8,NE=1.25,AE=6;function Hv(e,t={}){var r,s;const n=new HE(t.precision??6);n.header(t.title),n.tables([{name:eo,color:7},{name:Ue,color:7},{name:to,color:8},{name:De,color:3}]),n.beginEntities();for(const i of e.wireRenders.values())i.path.length<2||n.lwpolyline(eo,i.path.map(ye),!1);for(const{geometry:i}of e.buses.values()){const{axis:a,at:l,span:c}=i,u=c/2,f=a==="x"?[l[0]-u,l[1]]:[l[0],l[1]-u],h=a==="x"?[l[0]+u,l[1]]:[l[0],l[1]+u];n.lwpolyline(eo,[f,h].map(ye),!1)}for(const i of e.elements.values()){const a=e.layout.get(i.element.id),l=i.libraryDef;!a||!l||TE(n,l.svg,a)}const o=t.labelMode??"all";if(o!=="off"){for(const i of e.elements.values()){const a=e.layout.get(i.element.id);if(!a||!i.libraryDef)continue;const l=jn(i,o);if(l.length===0)continue;const c=i.libraryDef.label??En(i.libraryDef),{world:[u,f],textAnchor:h,dy:g}=Nn(c,i.libraryDef,a,l.length);for(let m=0;m<l.length;m++){const[p,x]=ye([u,f+g+m*Gt]);n.text(to,[p,x],l[m],ze,0,!1,h)}}for(const i of e.wireRenders.values()){const a=(r=i.label)==null?void 0:r.trim();if(!a)continue;const l=An(i.path);if(!l)continue;const c=ye(l.world);n.text(to,c,a,ze,0,!1,l.textAnchor)}}for(const i of t.annotations??[])switch(Le(i)){case"rect":{const a=i,[l,c]=a.at,[u,f]=a.size;if(n.lwpolyline(De,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0),a.label){const h=ye([l+gt,c+gt+qe]);n.text(De,h,a.label,qe,0,!1)}break}case"line":{const a=i,l=Ut(a);if(l.length<2)break;n.lwpolyline(De,l.map(ye),!1);for(const c of To(l,a.arrow))n.lwpolyline(De,c.map(ye),!0);break}case"table":{const a=i,[l,c]=a.at,[u,f]=Ge(a),h=wt(a),g=vt(a),m=a.fontSize??qe;n.lwpolyline(De,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0);for(let p=1;p<a.colWidths.length;p++)n.line(De,ye([l+h[p],c]),ye([l+h[p],c+f]));for(let p=1;p<a.rowHeights.length;p++)n.line(De,ye([l,c+g[p]]),ye([l+u,c+g[p]]));for(let p=0;p<a.rowHeights.length;p++)for(let x=0;x<a.colWidths.length;x++){const w=((s=a.cells[p])==null?void 0:s[x])??"";if(w==="")continue;const v=ye([l+h[x]+Ft,c+g[p]+a.rowHeights[p]/2+m*.35]);n.text(De,v,w,m,0,!1)}break}default:{const a=i;if(!a.text)break;const l=a.fontSize??EE,c=a.text.split(`
|
|
221
|
+
`);for(let u=0;u<c.length;u++){const[f,h]=ye([a.at[0],a.at[1]+(u+1)*l*NE]);n.text(De,[f,h],c[u],l,0,!1)}break}}return n.endEntities(),n.toString()}async function Wv(e,t="diagram.dxf",n){const o=Hv(e,n),r=URL.createObjectURL(new Blob([o],{type:"application/dxf;charset=utf-8"})),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}function TE(e,t,n){const o=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,s=new DOMParser().parseFromString(o,"image/svg+xml").documentElement;if(!(!s||s.querySelector("parsererror")))for(const i of Array.from(s.children))switch(i.tagName.toLowerCase()){case"line":ME(e,i,n);break;case"polyline":bs(e,i,n,!1);break;case"polygon":bs(e,i,n,!0);break;case"rect":CE(e,i,n);break;case"circle":PE(e,i,n);break;case"ellipse":IE(e,i,n);break;case"path":DE(e,i,n);break;case"text":LE(e,i,n);break}}function ME(e,t,n){const o=ke(t,"x1"),r=ke(t,"y1"),s=ke(t,"x2"),i=ke(t,"y2"),a=ye(Ye([o,r],n)),l=ye(Ye([s,i],n));e.line(Ue,a,l)}function bs(e,t,n,o){const r=FE(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>ye(Ye(i,n)));e.lwpolyline(Ue,s,o)}function CE(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=ke(t,"width"),i=ke(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(c=>ye(Ye(c,n)));e.lwpolyline(Ue,l,!0)}function PE(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"r"),i=ye(Ye([o,r],n));e.circle(Ue,i,s)}function IE(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"rx"),i=ke(t,"ry");if(Math.abs(s-i)<1e-6){OE(e,o,r,s,n);return}BE(e,o,r,s,i,n)}function OE(e,t,n,o,r){const s=ye(Ye([t,n],r));e.circle(Ue,s,o)}function BE(e,t,n,o,r,s){const i=[];for(let a=0;a<xs;a++){const l=a/xs*Math.PI*2;i.push(ye(Ye([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Ue,i,!0)}function LE(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||AE,i=(t.textContent??"").trim();if(!i)return;const a=ye(Ye([o,r],n));e.text(Ue,a,i,s,n.rot,n.mirror)}function DE(e,t,n){const o=t.getAttribute("d")??"",r=zE(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Ue,i.map(l=>ye(Ye(l,n))),!1),i=[]};for(const l of r)if(l.cmd==="M")a(),s=[l.args[0],l.args[1]],i.push(s);else if(l.cmd==="A"&&s){const[c,u,,f,h,g,m]=l.args,p=RE(s,[g,m],c,u,f!==0,h!==0);if(p)for(let x=1;x<=ys;x++){const w=p.theta1+p.delta*x/ys;i.push([p.cx+c*Math.cos(w),p.cy+u*Math.sin(w)])}else i.push([g,m]);s=[g,m]}a()}function zE(e){const t=[],n=/([MmAa])([^MmAa]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1].toUpperCase(),s=o[2].trim().split(/[\s,]+/).filter(i=>i.length>0).map(Number);t.push({cmd:r,args:s})}return t}function RE(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,c]=t;if(i===l&&a===c)return null;const u=(i-l)/2,f=(a-c)/2;let h=Math.abs(n),g=Math.abs(o);const m=h*h,p=g*g,x=u*u/m+f*f/p;if(x>1){const R=Math.sqrt(x);h*=R,g*=R}const w=r===s?-1:1,v=h*h*g*g-h*h*f*f-g*g*u*u,M=h*h*f*f+g*g*u*u,I=w*Math.sqrt(Math.max(0,v/M)),F=I*(h*f)/g,G=I*-(g*u)/h,$=F+(i+l)/2,H=G+(a+c)/2,W=(R,Z,ie,ue)=>{const ee=R*ie+Z*ue,ae=Math.hypot(R,Z)*Math.hypot(ie,ue);let me=Math.acos(Math.max(-1,Math.min(1,ee/ae)));return R*ue-Z*ie<0&&(me=-me),me},X=W(1,0,(u-F)/h,(f-G)/g);let P=W((u-F)/h,(f-G)/g,(-u-F)/h,(-f-G)/g);return!s&&P>0?P-=2*Math.PI:s&&P<0&&(P+=2*Math.PI),{cx:$,cy:H,theta1:X,delta:P}}function Ye(e,t){return Ie(e,t)}function ye(e){return[e[0],-e[1]]}function ke(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function FE(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 HE{constructor(t){jt(this,"out",[]);jt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
|
|
201
222
|
${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
|
-
`)
|
|
204
|
-
`)}function
|
|
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}=b.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=b;exports.useLocale=It;exports.wireIdFromEnds=Qe;
|
|
223
|
+
`)}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,ws(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i,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,r),this.g(1,ws(o)),s!==0&&this.g(50,s),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 ws(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const WE="http://www.w3.org/2000/svg",fn=24,qE=1.25;function Lo(e,t={}){var f;const n=UE(e,t),o=Math.floor(n.minX-fn),r=Math.floor(n.minY-fn),s=Math.ceil(n.maxX+fn)-o,i=Math.ceil(n.maxY+fn)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${WE}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${He(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const h of e.wireRenders.values()){if(h.path.length<2)continue;const g=h.path.map(([m,p])=>`${m},${p}`).join(" ");l.push(` <polyline points="${g}"/>`)}l.push(" </g>");for(const{bus:h,geometry:g}of e.buses.values()){const{axis:m,at:p,span:x}=g,w=x/2,v=m==="x"?p[0]-w:p[0],M=m==="x"?p[1]:p[1]-w,I=m==="x"?p[0]+w:p[0],F=m==="x"?p[1]:p[1]+w;l.push(` <line id="${He(h.id)}" x1="${v}" y1="${M}" x2="${I}" y2="${F}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:h,world:g,degree:m}of e.junctions.values())m<3||l.push(` <circle id="${He(h.id)}" cx="${g[0]}" cy="${g[1]}" r="3.5" fill="black"/>`);for(const h of e.elements.values()){if(!h.libraryDef)continue;const g=e.layout.get(h.element.id);g&&(l.push(` <g id="${He(h.element.id)}" transform="${nt(g)}">`),l.push(` ${h.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const h=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${ze}" paint-order="stroke" stroke="${h}" stroke-width="2" stroke-linejoin="round">`);for(const g of e.elements.values()){const m=e.layout.get(g.element.id);if(!m||!g.libraryDef)continue;const p=jn(g,c);if(p.length===0)continue;const x=g.libraryDef.label??En(g.libraryDef),{world:[w,v],textAnchor:M,dy:I}=Nn(x,g.libraryDef,m,p.length);for(let F=0;F<p.length;F++)l.push(` <text x="${w}" y="${v+I+F*Gt}" text-anchor="${M}">${He(p[F])}</text>`)}for(const g of e.wireRenders.values()){const m=(f=g.label)==null?void 0:f.trim();if(!m)continue;const p=An(g.path);p&&l.push(` <text x="${p.world[0]}" y="${p.world[1]}" text-anchor="${p.textAnchor}">${He(m)}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){const h=a==="transparent"?"#FFFFFF":a,g=a==="transparent"?"none":a,m=`font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${h}" stroke-width="2" stroke-linejoin="round"`;for(const p of u)switch(Le(p)){case"rect":YE(l,p,m);break;case"line":GE(l,p);break;case"table":KE(l,p,g);break;default:XE(l,p,m);break}}return l.push("</svg>"),l.join(`
|
|
224
|
+
`)}function XE(e,t,n){if(!t.text)return;const o=t.fontSize??qe,r=t.text.split(`
|
|
225
|
+
`);e.push(` <g fill="black" ${n}>`);for(let s=0;s<r.length;s++){const i=t.at[1]+o*.85+s*o*qE;e.push(` <text x="${t.at[0]}" y="${i}" font-size="${o}">${He(r[s])}</text>`)}e.push(" </g>")}function YE(e,t,n){const[o,r]=t.at,[s,i]=t.size,a=(t.stroke??"dashed")==="dashed"?` stroke-dasharray="${Kt}"`:"";t.fill==="tint"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="black" fill-opacity="${rj}"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"${a}/>`),t.label&&(e.push(` <g fill="black" ${n}>`),e.push(` <text x="${o+gt}" y="${r+gt+qe*.85}" font-size="${qe}">${He(t.label)}</text>`),e.push(" </g>"))}function GE(e,t){const n=Ut(t);if(n.length<2)return;const o=(t.stroke??"solid")==="dashed"?` stroke-dasharray="${Kt}"`:"",r=n.map(([s,i])=>`${s},${i}`).join(" ");e.push(` <polyline points="${r}" fill="none" stroke="black" stroke-width="1"${o}/>`);for(const s of To(n,t.arrow))e.push(` <polygon points="${s.map(([i,a])=>`${i},${a}`).join(" ")}" fill="black"/>`)}function KE(e,t,n){var h;const[o,r]=t.at,[s,i]=Ge(t),a=wt(t),l=vt(t),c=t.fontSize??qe;n!=="none"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${n}"/>`);let u="";for(let g=1;g<t.colWidths.length;g++)u+=`M${o+a[g]} ${r}V${r+i}`;for(let g=1;g<t.rowHeights.length;g++)u+=`M${o} ${r+l[g]}H${o+s}`;u&&e.push(` <path d="${u}" fill="none" stroke="black" stroke-width="0.5"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"/>`);const f=[];for(let g=0;g<t.rowHeights.length;g++)for(let m=0;m<t.colWidths.length;m++){const p=((h=t.cells[g])==null?void 0:h[m])??"";if(p==="")continue;const x=o+a[m]+Ft,w=r+l[g]+t.rowHeights[g]/2+c*.35;f.push(` <text x="${x}" y="${w}" font-size="${c}">${He(p)}</text>`)}f.length>0&&(e.push(' <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif">'),e.push(...f),e.push(" </g>"))}function UE(e,t){var l;let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(c,u)=>{c<n&&(n=c),c>r&&(r=c),u<o&&(o=u),u>s&&(s=u)};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 u=e.layout.get(c.element.id),f=c.libraryDef;if(!u||!f)continue;const h=VE(f.viewBox);if(!h){i(u.at[0],u.at[1]);continue}const g=[[h.x,h.y],[h.x+h.w,h.y],[h.x,h.y+h.h],[h.x+h.w,h.y+h.h]];for(const m of g){const[p,x]=Ie(m,u);i(p,x)}}for(const{geometry:c}of e.buses.values()){const{axis:u,at:f,span:h}=c,g=h/2;u==="x"?(i(f[0]-g,f[1]),i(f[0]+g,f[1])):(i(f[0],f[1]-g),i(f[0],f[1]+g))}for(const c of e.wireRenders.values())for(const[u,f]of c.path)i(u,f);const a=t.labelMode??"all";if(a!=="off"){for(const c of e.elements.values()){const u=e.layout.get(c.element.id);if(!u||!c.libraryDef)continue;const f=jn(c,a);if(f.length===0)continue;const h=c.libraryDef.label??En(c.libraryDef),{world:[g,m],textAnchor:p,dy:x}=Nn(h,c.libraryDef,u,f.length),w=vs(f,ze),v=f.length*Gt,M=p==="middle"?g-w/2:p==="end"?g-w:g;i(M,m+x-ze),i(M+w,m+x+v)}for(const c of e.wireRenders.values()){const u=(l=c.label)==null?void 0:l.trim();if(!u)continue;const f=An(c.path);if(!f)continue;const[h,g]=f.world,m=vs([u],ze),p=f.textAnchor==="middle"?h-m/2:h;i(p,g-ze),i(p+m,g)}}for(const c of t.annotations??[]){if(Le(c)==="text"&&!c.text)continue;const u=lj(c);i(u.minX,u.minY),i(u.maxX,u.maxY)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function vs(e,t){let n=0;for(const o of e){const r=o.length*t*.55;r>n&&(n=r)}return Math.max(20,n)}function VE(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function He(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function qv(e,t="diagram.svg",n){const o=Lo(e,n);Yv(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function Xv(e,t="diagram.png",n){const o=Lo(e,n),r=(n==null?void 0:n.scale)??2,s=URL.createObjectURL(new Blob([o],{type:"image/svg+xml;charset=utf-8"}));try{const i=await JE(s),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*r),a.height=Math.round(i.naturalHeight*r);const l=a.getContext("2d");if(!l)throw new Error("canvas 2d context unavailable");n!=null&&n.background&&n.background!=="transparent"&&(l.fillStyle=n.background,l.fillRect(0,0,a.width,a.height)),l.drawImage(i,0,0,a.width,a.height);const c=await new Promise((u,f)=>{a.toBlob(h=>h?u(h):f(new Error("toBlob failed")),"image/png")});Yv(c,t)}finally{URL.revokeObjectURL(s)}}function JE(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 Yv(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function ZE(){const e=le(),[t,n]=C.useState(!1),o=C.useRef(null);C.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var f,h,g,m;n(!1);const{internal:i,diagram:a,fileSession:l}=y.getState(),c=((f=l==null?void 0:l.name)==null?void 0:f.replace(/\.json$/i,""))??((h=a.meta)==null?void 0:h.title)??"diagram",u={title:(g=a.meta)==null?void 0:g.title,labelMode:(m=a.meta)==null?void 0:m.labelMode,annotations:a.annotations};s==="svg"?qv(i,`${c}.svg`,u):s==="png"?Xv(i,`${c}.png`,{...u,scale:2}).catch(p=>{console.error(p),alert(e("topbar.export.pngFailed",{err:p.message}))}):Wv(i,`${c}.dxf`,u).catch(p=>{console.error(p),alert(e("topbar.export.dxfFailed",{err:p.message}))})};return d.jsxs("div",{ref:o,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[d.jsx(f2,{}),e("topbar.export.label")]}),t&&d.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[d.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[d.jsx(g2,{}),d.jsx("span",{className:"flex-1",children:"SVG"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[d.jsx(m2,{}),d.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[d.jsx(h2,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=ZE;exports.FileMenu=$E;exports.LIBRARY=ao;exports.OneLineEditor=kE;exports.annotationKind=Le;exports.applyTheme=Dv;exports.buildExportDxf=Hv;exports.buildExportSvg=Lo;exports.compile=et;exports.downloadDxf=Wv;exports.downloadPng=Xv;exports.downloadSvg=qv;exports.emptyInternalModel=Gs;exports.fitToContent=Mo;exports.fitToContentSoon=Co;exports.getInitialTheme=vE;exports.getLibraryEntry=Jw;exports.isTextAnnotation=nj;exports.newAnnotationId=hn;exports.newBusId=lo;exports.newElementId=Rt;exports.newJunctionId=co;exports.orientationVec=io;exports.resolvePlacement=Ks;exports.transformOrientation=Ot;exports.transformPoint=Ie;exports.useEditorStore=y;exports.useLocale=Yt;exports.wireIdFromEnds=at;
|
|
206
226
|
//# sourceMappingURL=sldeditor.cjs.map
|