sldeditor 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,54 +1,54 @@
1
- "use strict";var Vw=Object.defineProperty;var Uw=(e,t,n)=>t in e?Vw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var gt=(e,t,n)=>Uw(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),O=require("react"),Ir=require("react-dom");function Jw(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ke=Jw(O);/**
1
+ "use strict";var Uw=Object.defineProperty;var Jw=(e,t,n)=>t in e?Uw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var gt=(e,t,n)=>Jw(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),O=require("react"),Pr=require("react-dom");function Zw(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ke=Zw(O);/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Zw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pr=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
6
+ */const Qw=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Or=(...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 Qw={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"};/**
11
+ */var ev={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 ev=O.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>O.createElement("svg",{ref:l,...Qw,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Pr("lucide",r),...a},[...i.map(([d,u])=>O.createElement(d,u)),...Array.isArray(s)?s:[s]]));/**
16
+ */const tv=O.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>O.createElement("svg",{ref:l,...ev,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Or("lucide",r),...a},[...i.map(([c,u])=>O.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 oe=(e,t)=>{const n=O.forwardRef(({className:o,...r},s)=>O.createElement(ev,{ref:s,iconNode:t,className:Pr(`lucide-${Zw(e)}`,o),...r}));return n.displayName=`${e}`,n};/**
21
+ */const oe=(e,t)=>{const n=O.forwardRef(({className:o,...r},s)=>O.createElement(tv,{ref:s,iconNode:t,className:Or(`lucide-${Qw(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 Or=oe("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"}]]);/**
26
+ */const Br=oe("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 tv=oe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
31
+ */const nv=oe("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
32
32
  * @license lucide-react v0.469.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const nv=oe("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
36
+ */const ov=oe("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
37
37
  * @license lucide-react v0.469.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const Br=oe("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"}]]);/**
41
+ */const Lr=oe("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
42
42
  * @license lucide-react v0.469.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const Lr=oe("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"}]]);/**
46
+ */const zr=oe("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
47
47
  * @license lucide-react v0.469.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const ov=oe("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"}]]);/**
51
+ */const rv=oe("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
52
52
  * @license lucide-react v0.469.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
@@ -58,27 +58,27 @@
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 rv=oe("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"}]]);/**
61
+ */const sv=oe("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/**
62
62
  * @license lucide-react v0.469.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const sv=oe("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"}]]);/**
66
+ */const iv=oe("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
67
67
  * @license lucide-react v0.469.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const iv=oe("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"}]]);/**
71
+ */const av=oe("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
72
72
  * @license lucide-react v0.469.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const av=oe("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"}]]);/**
76
+ */const lv=oe("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
77
77
  * @license lucide-react v0.469.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const zr=oe("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"}]]);/**
81
+ */const Rr=oe("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/**
82
82
  * @license lucide-react v0.469.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
@@ -88,12 +88,12 @@
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 lv=oe("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"}]]);/**
91
+ */const cv=oe("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
92
92
  * @license lucide-react v0.469.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const cv=oe("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"}]]);/**
96
+ */const dv=oe("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
97
97
  * @license lucide-react v0.469.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
@@ -103,12 +103,12 @@
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 Rr=oe("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"}]]);/**
106
+ */const Dr=oe("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
107
107
  * @license lucide-react v0.469.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const dv=oe("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"}]]);/**
111
+ */const uv=oe("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
112
112
  * @license lucide-react v0.469.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
@@ -118,17 +118,17 @@
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 uv=oe("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"}]]);/**
121
+ */const fv=oe("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
122
122
  * @license lucide-react v0.469.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const fv=oe("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"}]]);/**
126
+ */const mv=oe("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/**
127
127
  * @license lucide-react v0.469.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const mv=oe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
131
+ */const hv=oe("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
132
132
  * @license lucide-react v0.469.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
@@ -138,7 +138,7 @@
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 Dr=oe("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"}]]);/**
141
+ */const Fr=oe("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
142
142
  * @license lucide-react v0.469.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
@@ -148,37 +148,37 @@
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 Fr=oe("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"}]]);/**
151
+ */const Hr=oe("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
152
152
  * @license lucide-react v0.469.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const hv=oe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
156
+ */const pv=oe("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
157
157
  * @license lucide-react v0.469.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Hr=oe("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"}]]);/**
161
+ */const Wr=oe("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
162
162
  * @license lucide-react v0.469.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const pv=oe("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"}]]);/**
166
+ */const gv=oe("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
167
167
  * @license lucide-react v0.469.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const gv=oe("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"}]]);/**
171
+ */const yv=oe("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/**
172
172
  * @license lucide-react v0.469.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const Wr=oe("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"}]]);/**
176
+ */const qr=oe("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
177
177
  * @license lucide-react v0.469.0 - ISC
178
178
  *
179
179
  * This source code is licensed under the ISC license.
180
180
  * See the LICENSE file in the root directory of this source tree.
181
- */const qr=oe("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"}]]);/**
181
+ */const Gr=oe("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
182
182
  * @license lucide-react v0.469.0 - ISC
183
183
  *
184
184
  * This source code is licensed under the ISC license.
@@ -193,14 +193,14 @@
193
193
  *
194
194
  * This source code is licensed under the ISC license.
195
195
  * See the LICENSE file in the root directory of this source tree.
196
- */const Vn=oe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Gr(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=Gr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Xr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Gr(e))&&(o&&(o+=" "),o+=t);return o}const Un="-",yv=e=>{const t=bv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Un);return a[0]===""&&a.length!==1&&a.shift(),Yr(a,t)||xv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Yr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Yr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(Un);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},No=/^\[(.+)\]$/,xv=e=>{if(No.test(e)){const t=No.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},bv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return vv(Object.entries(e.classGroups),n).forEach(([s,i])=>{Mn(i,o,s,t)}),o},Mn=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:Mo(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(wv(r)){Mn(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{Mn(i,Mo(t,s),n,o)})})},Mo=(e,t)=>{let n=e;return t.split(Un).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},wv=e=>e.isThemeGetter,vv=(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,kv=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)}}},Kr="!",_v=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let d=0,u=0,f;for(let w=0;w<a.length;w++){let $=a[w];if(d===0){if($===r&&(o||a.slice(w,w+s)===t)){l.push(a.slice(u,w)),u=w+s;continue}if($==="/"){f=w;continue}}$==="["?d++:$==="]"&&d--}const m=l.length===0?a:a.substring(u),p=m.startsWith(Kr),h=p?m.substring(1):m,y=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:y}};return n?a=>n({className:a,parseClassName:i}):i},$v=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},Sv=e=>({cache:kv(e.cacheSize),parseClassName:_v(e),...yv(e)}),jv=/\s+/,Ev=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(jv);let a="";for(let l=i.length-1;l>=0;l-=1){const d=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:p}=n(d);let h=!!p,y=o(h?m.substring(0,p):m);if(!y){if(!h){a=d+(a.length>0?" "+a:a);continue}if(y=o(m),!y){a=d+(a.length>0?" "+a:a);continue}h=!1}const w=$v(u).join(":"),$=f?w+Kr:w,k=$+y;if(s.includes(k))continue;s.push(k);const b=r(y,h);for(let S=0;S<b.length;++S){const C=b[S];s.push($+C)}a=d+(a.length>0?" "+a:a)}return a};function Nv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Vr(t))&&(o&&(o+=" "),o+=n);return o}const Vr=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Vr(e[o]))&&(n&&(n+=" "),n+=t);return n};function Mv(e,...t){let n,o,r,s=i;function i(l){const d=t.reduce((u,f)=>f(u),e());return n=Sv(d),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const d=o(l);if(d)return d;const u=Ev(l,n);return r(l,u),u}return function(){return s(Nv.apply(null,arguments))}}const fe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Ur=/^\[(?:([a-z-]+):)?(.+)\]$/i,Tv=/^\d+\/\d+$/,Av=new Set(["px","full","screen"]),Cv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Iv=/\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$/,Pv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ov=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Bv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=e=>st(e)||Av.has(e)||Tv.test(e),We=e=>ct(e,"length",qv),st=e=>!!e&&!Number.isNaN(Number(e)),fn=e=>ct(e,"number",st),yt=e=>!!e&&Number.isInteger(Number(e)),Lv=e=>e.endsWith("%")&&st(e.slice(0,-1)),ee=e=>Ur.test(e),qe=e=>Cv.test(e),zv=new Set(["length","size","percentage"]),Rv=e=>ct(e,zv,Jr),Dv=e=>ct(e,"position",Jr),Fv=new Set(["image","url"]),Hv=e=>ct(e,Fv,Xv),Wv=e=>ct(e,"",Gv),xt=()=>!0,ct=(e,t,n)=>{const o=Ur.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},qv=e=>Iv.test(e)&&!Pv.test(e),Jr=()=>!1,Gv=e=>Ov.test(e),Xv=e=>Bv.test(e),Yv=()=>{const e=fe("colors"),t=fe("spacing"),n=fe("blur"),o=fe("brightness"),r=fe("borderColor"),s=fe("borderRadius"),i=fe("borderSpacing"),a=fe("borderWidth"),l=fe("contrast"),d=fe("grayscale"),u=fe("hueRotate"),f=fe("invert"),m=fe("gap"),p=fe("gradientColorStops"),h=fe("gradientColorStopPositions"),y=fe("inset"),w=fe("margin"),$=fe("opacity"),k=fe("padding"),b=fe("saturate"),S=fe("scale"),C=fe("sepia"),R=fe("skew"),X=fe("space"),V=fe("translate"),te=()=>["auto","contain","none"],ae=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",ee,t],W=()=>[ee,t],ye=()=>["",Le,We],ue=()=>["auto",st,ee],pe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ge=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",ee],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ee=()=>[st,ee];return{cacheSize:500,separator:":",theme:{colors:[xt],spacing:[Le,We],blur:["none","",qe,ee],brightness:Ee(),borderColor:[e],borderRadius:["none","","full",qe,ee],borderSpacing:W(),borderWidth:ye(),contrast:Ee(),grayscale:xe(),hueRotate:Ee(),invert:xe(),gap:W(),gradientColorStops:[e],gradientColorStopPositions:[Lv,We],inset:D(),margin:D(),opacity:Ee(),padding:W(),saturate:Ee(),scale:Ee(),sepia:xe(),skew:Ee(),space:W(),translate:W()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],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:[...pe(),ee]}],overflow:[{overflow:ae()}],"overflow-x":[{"overflow-x":ae()}],"overflow-y":[{"overflow-y":ae()}],overscroll:[{overscroll:te()}],"overscroll-x":[{"overscroll-x":te()}],"overscroll-y":[{"overscroll-y":te()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",yt,ee]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",yt,ee]}],"grid-cols":[{"grid-cols":[xt]}],"col-start-end":[{col:["auto",{span:["full",yt,ee]},ee]}],"col-start":[{"col-start":ue()}],"col-end":[{"col-end":ue()}],"grid-rows":[{"grid-rows":[xt]}],"row-start-end":[{row:["auto",{span:[yt,ee]},ee]}],"row-start":[{"row-start":ue()}],"row-end":[{"row-end":ue()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...ge()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ge(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ge(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[k]}],px:[{px:[k]}],py:[{py:[k]}],ps:[{ps:[k]}],pe:[{pe:[k]}],pt:[{pt:[k]}],pr:[{pr:[k]}],pb:[{pb:[k]}],pl:[{pl:[k]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[X]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[X]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,t]}],"min-w":[{"min-w":[ee,t,"min","max","fit"]}],"max-w":[{"max-w":[ee,t,"none","full","min","max","fit","prose",{screen:[qe]},qe]}],h:[{h:[ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qe,We]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",fn]}],"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",ee]}],"line-clamp":[{"line-clamp":["none",st,fn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Le,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[$]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[$]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Le,We]}],"underline-offset":[{"underline-offset":["auto",Le,ee]}],"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:W()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ee]}],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",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[$]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...pe(),Dv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Rv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Hv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[$]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[$]}],"divide-style":[{divide:ne()}],"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:["",...ne()]}],"outline-offset":[{"outline-offset":[Le,ee]}],"outline-w":[{outline:[Le,We]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[$]}],"ring-offset-w":[{"ring-offset":[Le,We]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",qe,Wv]}],"shadow-color":[{shadow:[xt]}],opacity:[{opacity:[$]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",qe,ee]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[b]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[$]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"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",ee]}],duration:[{duration:Ee()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:Ee()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[yt,ee]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],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",ee]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":W()}],"scroll-mx":[{"scroll-mx":W()}],"scroll-my":[{"scroll-my":W()}],"scroll-ms":[{"scroll-ms":W()}],"scroll-me":[{"scroll-me":W()}],"scroll-mt":[{"scroll-mt":W()}],"scroll-mr":[{"scroll-mr":W()}],"scroll-mb":[{"scroll-mb":W()}],"scroll-ml":[{"scroll-ml":W()}],"scroll-p":[{"scroll-p":W()}],"scroll-px":[{"scroll-px":W()}],"scroll-py":[{"scroll-py":W()}],"scroll-ps":[{"scroll-ps":W()}],"scroll-pe":[{"scroll-pe":W()}],"scroll-pt":[{"scroll-pt":W()}],"scroll-pr":[{"scroll-pr":W()}],"scroll-pb":[{"scroll-pb":W()}],"scroll-pl":[{"scroll-pl":W()}],"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",ee]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Le,We,fn]}],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"]}}},Kv=Mv(Yv);function je(...e){return Kv(Xr(e))}const Zr=O.createContext(null);function Vv(){const e=O.useContext(Zr);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Pt=8;function Uv({children:e}){const[t,n]=O.useState({open:!1,x:0,y:0,items:[]}),[o,r]=O.useState(null),s=O.useRef(null),i=O.useCallback(()=>{n(d=>d.open?{...d,open:!1}:d)},[]),a=O.useCallback((d,u,f)=>{r(null),n({open:!0,x:d,y:u,items:f})},[]),l=O.useMemo(()=>({open:a,close:i}),[a,i]);return O.useLayoutEffect(()=>{if(!t.open||!s.current)return;const d=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+d.width>window.innerWidth-Pt&&(u=Math.max(Pt,t.x-d.width)),f+d.height>window.innerHeight-Pt&&(f=Math.max(Pt,t.y-d.height)),r({left:u,top:f})},[t]),O.useEffect(()=>{if(!t.open)return;const d=p=>{s.current&&!s.current.contains(p.target)&&i()},u=p=>{p.key==="Escape"&&(p.preventDefault(),i())},f=()=>i(),m=()=>i();return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",m),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",m)}},[t.open,i]),c.jsxs(Zr.Provider,{value:l,children:[e,t.open&&c.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:d=>d.preventDefault(),children:t.items.map((d,u)=>{if(d.type==="separator")return c.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=d.icon;return c.jsxs("button",{type:"button",role:"menuitem",disabled:d.disabled,className:je("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",d.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",d.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),d.onSelect()},children:[c.jsxs("span",{className:"flex items-center gap-2",children:[f?c.jsx(f,{className:"size-4"}):null,c.jsx("span",{children:d.label})]}),d.shortcut?c.jsx("span",{className:"text-xs text-muted-foreground",children:d.shortcut}):null]},`${d.label}-${u}`)})})]})}const To=e=>{let t;const n=new Set,o=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const m=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,m))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(o,r,a);return a},Jv=(e=>e?To(e):To),Zv=e=>e;function Qv(e,t=Zv){const n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),O.useCallback(()=>t(e.getInitialState()),[e,t]));return O.useDebugValue(n),n}const Ao=e=>{const t=Jv(e),n=o=>Qv(t,o);return Object.assign(n,t),n},Jt=(e=>e?Ao(e):Ao),Co={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.junction":"接线柱","props.junctionPos":"位置","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从端子/母线/接线柱拖出;拖到空白处会自动新建接线柱,拖到已有连线上可打接点","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"画母线","onboard.step1.body":"选择 母线 工具(B),在画布上按下拖动","onboard.step2.title":"从母线拖出元件","onboard.step2.body":"切到 元件(P)选一种,按住母线拖到目标位置 — 自动连接","onboard.step3.title":"继续串接","onboard.step3.body":"从任意端子拖出,落到目标即与该端子相连","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.junction":"Junction","props.junctionPos":"Position","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.junction":"Click the canvas to drop a junction","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Draw a busbar","onboard.step1.body":"Pick the busbar tool (B), then press and drag on the canvas","onboard.step2.title":"Drag elements from the bus","onboard.step2.body":"Switch to Place (P), pick a kind, then drag from the bus — it auto-connects","onboard.step3.title":"Chain the next one","onboard.step3.body":"Drag from any terminal — the new element drops pre-connected","onboard.dismiss":"Got it"}},Qr="ole-locale";function e2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Qr);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 Io(e){try{window.localStorage.setItem(Qr,e)}catch{}}const Tt=Jt((e,t)=>({locale:e2(),setLocale:n=>{Io(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Io(n),e({locale:n})}}));function es(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function ts(e,t){return Co[e][t]??Co.zh[t]??t}function we(e,t){return es(ts(Tt.getState().locale,e),t)}function ie(){const e=Tt(t=>t.locale);return(t,n)=>es(ts(e,t),n)}function ns(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 Tn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Tn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Tn(o)(n)}}}},t2=(e,t)=>(n,o,r)=>{let s={storage:ns(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,$)=>({...$,...w}),...t},i=!1,a=0;const l=new Set,d=new Set;let u=s.storage;if(!u)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...w)},o,r);const f=()=>{const w=s.partialize({...o()});return u.setItem(s.name,{state:w,version:s.version})},m=r.setState;r.setState=(w,$)=>(m(w,$),f());const p=e((...w)=>(n(...w),f()),o,r);r.getInitialState=()=>p;let h;const y=()=>{var w,$;if(!u)return;const k=++a;i=!1,l.forEach(S=>{var C;return S((C=o())!=null?C:p)});const b=(($=s.onRehydrateStorage)==null?void 0:$.call(s,(w=o())!=null?w:p))||void 0;return Tn(u.getItem.bind(u))(s.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==s.version){if(s.migrate){const C=s.migrate(S.state,S.version);return C instanceof Promise?C.then(R=>[!0,R]):[!0,C]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var C;if(k!==a)return;const[R,X]=S;if(h=s.merge(X,(C=o())!=null?C:p),n(h,!0),R)return f()}).then(()=>{k===a&&(b==null||b(o(),void 0),h=o(),i=!0,d.forEach(S=>S(h)))}).catch(S=>{k===a&&(b==null||b(void 0,S))})};return r.persist={setOptions:w=>{s={...s,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>y(),hasHydrated:()=>i,onHydrate:w=>(l.add(w),()=>{l.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},s.skipHydration||y(),h||p},n2=t2,ze=.5;function os(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<ze&&Math.abs(s[1]-e[r][1])<ze||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],a=Math.abs(s[0]-i[0]),l=Math.abs(s[1]-i[1]);if(a>ze&&l>ze){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<ze?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<ze&&Math.abs(i[0]-a[0])<ze,d=Math.abs(s[1]-i[1])<ze&&Math.abs(i[1]-a[1])<ze;l||d||o.push(i)}return o.push(n[n.length-1]),o}function rs(){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 ss(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 An(e){return e===90||e===270?"y":"x"}function Pe(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const o2={n:"e",e:"s",s:"w",w:"n"},r2={n:"n",s:"s",e:"w",w:"e"};function St(e,t){let n=t.mirror?r2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=o2[n];return n}function Cn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class is{constructor(){gt(this,"parent",new Map);gt(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const Po=["n","e","s","w"],Oo={n:"s",s:"n",e:"w",w:"e"};function Ot(e,t){const n=Po.indexOf(e),r=((Po.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const mn=320,Bt=220,bt=260,hn=720,wt=30,Bo=30,Ge=80,Lo=10,s2=60,i2=520,a2=80,l2=80,zo=8,Ro=new Set(["source","renewable"]);function c2(e){var bo,wo,vo,ko,_o,$o;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),d=new Map(a),u=new Map,f=new Set(i.keys()),m=new Set(a.keys()),p=new Map;for(const g of t)p.set(g.id,g);const h=new Map;for(const g of n)h.set(g.id,g);const y=g=>{const v=p.get(g);if(v)return s.get(v.kind)},w=new Set(n.map(g=>g.id)),$=g=>w.has(g),k=new Set(o.map(g=>g.id)),b=new Set(o.filter(g=>{var v;return(v=g.layout)==null?void 0:v.at}).map(g=>g.id)),S=new is;for(const g of r)S.add(g.ends[0]),S.add(g.ends[1]),S.union(g.ends[0],g.ends[1]);for(const g of t){const v=s.get(g.kind);if(v)for(const j of v.terminals)S.add(`${g.id}.${j.id}`)}for(const g of n)S.add(g.id);const C=[];for(const[,g]of S.groups())g.length>=2&&C.push(g);const R=new Map;for(const g of C)for(const v of g)R.set(v,[g]);const X=new Map;for(const g of C){const v=g.filter($);if(v.length!==0)for(const j of v){const N=g.filter(_=>_!==j),E=X.get(j)??[];E.push(...N),X.set(j,E)}}{const j=A=>p.has(A)&&!!y(A),N=A=>{if($(A))return null;if(k.has(A))return A;const M=A.indexOf(".");return M>0?A.slice(0,M):null},E=new Map,_=new Set,T=(A,M)=>{E.has(A)||E.set(A,new Set),E.has(M)||E.set(M,new Set),A!==M&&(E.get(A).add(M),E.get(M).add(A))};for(const A of C){const M=[];let B=!1;for(const H of A){if($(H)){B=!0;continue}const J=N(H);J&&M.push(J)}const L=[...new Set(M)];for(const H of L)E.has(H)||E.set(H,new Set),B&&_.add(H);const F=L.filter(H=>k.has(H)),q=L.filter(H=>!k.has(H));if(F.length>0){for(const H of F)for(const J of q)T(H,J);for(let H=0;H<F.length;H++)for(let J=H+1;J<F.length;J++)T(F[H],F[J])}else for(let H=0;H<q.length;H++)for(let J=H+1;J<q.length;J++)T(q[H],q[J])}const z=(A,M)=>{const B=y(A);if(!B)return null;for(const L of B.terminals){const F=`${A}.${L.id}`;for(const q of R.get(F)??[])for(const H of q)if(N(H)===M)return L}return null},I=A=>{const M=K=>{var Q;return((Q=E.get(K))==null?void 0:Q.size)??0},B=K=>{var Q;return((Q=y(K))==null?void 0:Q.category)??""},L=K=>{const Q=B(K);return Q==="source"?0:Q==="renewable"?1:2+Math.min(M(K),9)/10},F=A.filter(j).sort((K,Q)=>L(K)-L(Q)||K.localeCompare(Q))[0];if(!F)return;const q=new Map([[F,null]]),H=new Map([[F,0]]),J=new Map,Z=[],G=[F],Y=new Set([F]);for(;G.length;){const K=G.shift();Z.push(K);for(const Q of[...E.get(K)??[]].sort(($e,Se)=>$e.localeCompare(Se)))Y.has(Q)||(Y.add(Q),q.set(Q,K),H.set(Q,(H.get(K)??0)+1),J.has(K)||J.set(K,[]),J.get(K).push(Q),G.push(Q))}let U=0;const le=new Map,be=K=>{const Q=J.get(K)??[];if(Q.length===0){le.set(K,U++);return}for(const Se of Q)be(Se);const $e=Q.map(Se=>le.get(Se));le.set(K,$e.reduce((Se,It)=>Se+It,0)/$e.length)};be(F);for(const K of Z){const Q=me(mn+(le.get(K)??0)*160),$e=me(Bt+(H.get(K)??0)*140);if(k.has(K)){u.set(K,[Q,$e]);continue}let Se=0;const It=q.get(K)??null;if(It){const pt=z(K,It);pt&&(Se=Ot(pt.orientation,"n"))}else{const pt=(J.get(K)??[])[0],So=pt?z(K,pt):null;So&&(Se=Ot(So.orientation,"s"))}l.set(K,{at:[Q,$e],rot:Se,mirror:!1}),f.add(K)}},P=new Set;for(const A of E.keys()){if(P.has(A))continue;const M=[],B=[A];for(P.add(A);B.length;){const L=B.pop();M.push(L);for(const F of E.get(L)??[])P.has(F)||(P.add(F),B.push(F))}M.length<2||M.some(L=>_.has(L))||M.some(L=>l.has(L)||b.has(L))||M.some(j)&&I(M)}}const V=new Map;for(const g of C){const v=g.filter($);if(v.length!==0)for(const j of g){if($(j))continue;const N=j.indexOf(".");if(N<0)continue;const E=j.slice(0,N),_=j.slice(N+1),T=V.get(E)??[];for(const z of v)T.some(I=>I.busId===z&&I.pin===_)||T.push({busId:z,pin:_});V.set(E,T)}}const te=[],ae=new Set;for(const[g,v]of V)if(new Set(v.map(N=>N.busId)).size>=2){const N=((wo=s.get(((bo=p.get(g))==null?void 0:bo.kind)??""))==null?void 0:wo.category)==="transformer"?"vertical":"horizontal";te.push({elementId:g,attachments:v,orientation:N}),N==="vertical"&&ae.add(g)}const D=new Map,W=(g,v)=>{g!==v&&(D.has(g)||D.set(g,new Set),D.has(v)||D.set(v,new Set),D.get(g).add(v),D.get(v).add(g))};for(const g of r)W(g.ends[0],g.ends[1]);for(const g of t){const v=s.get(g.kind);if(!v||v.terminals.length<2)continue;const j=v.terminals.map(N=>`${g.id}.${N.id}`);for(let N=0;N<j.length;N++)for(let E=N+1;E<j.length;E++)W(j[N],j[E])}for(const g of t){if(ae.has(g.id))continue;const v=s.get(g.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const j=v.terminals.map(_=>`${g.id}.${_.id}`),N=new Map;for(const _ of j){const T=_.slice(g.id.length+1);N.set(T,new Set);const z=new Set(j.filter(A=>A!==_)),I=new Set([_]),P=[_];for(;P.length>0;){const A=P.shift();if($(A)){N.get(T).add(A);continue}const M=D.get(A);if(M)for(const B of M)I.has(B)||z.has(B)||(I.add(B),P.push(B))}}const E=new Set;for(const _ of N.values())for(const T of _)E.add(T);if(E.size>=2){const _=[];for(const[T,z]of N)for(const I of z)_.push({busId:I,pin:T});te.push({elementId:g.id,attachments:_,orientation:"vertical"}),ae.add(g.id)}}const ye=(g,v)=>{var z;const j=y(v),N=j?j.terminals.map(I=>`${v}.${I.id}`):[],E=g,_=new Set([E,...N]),T=[E];for(;T.length>0;){const I=T.shift(),P=I.indexOf(".");if(P>0){const M=I.slice(0,P),B=p.get(M);if(B){const L=(z=s.get(B.kind))==null?void 0:z.category;if(L&&Ro.has(L))return!0}}const A=D.get(I);if(A)for(const M of A)_.has(M)||(_.add(M),T.push(M))}return!1};for(const g of te){if(g.orientation!=="horizontal")continue;const v=new Set(g.attachments.map(N=>N.busId));let j=0;for(const N of v)ye(N,g.elementId)&&j++;j===1&&(g.orientation="vertical",ae.add(g.elementId))}for(const g of t){if(ae.has(g.id)||g.kind!=="breaker")continue;const v=s.get(g.kind);if(!v||v.terminals.length!==2)continue;const j=v.terminals.map(_=>`${g.id}.${_.id}`),N=new Map;for(const _ of j){const T=_.slice(g.id.length+1),z=new Set(j.filter(A=>A!==_)),I=new Set([_]),P=[_];for(;P.length>0;){const A=P.shift();if($(A)){N.set(T,A);break}const M=D.get(A);if(M)for(const B of M){if(I.has(B)||z.has(B))continue;const L=B.indexOf(".");if(L>0){const F=B.slice(0,L);if(F!==g.id){const q=p.get(F),H=q?s.get(q.kind):void 0;if((H==null?void 0:H.category)==="transformer")continue}}I.add(B),P.push(B)}}}if(new Set(N.values()).size>=2){const _=[];for(const[T,z]of N)_.push({busId:z,pin:T});te.push({elementId:g.id,attachments:_,orientation:"horizontal"})}}const ue=new Map;for(const g of n)ue.set(g.id,new Map);for(const g of te){const v=Array.from(new Set(g.attachments.map(j=>j.busId)));for(const j of v)for(const N of v)j!==N&&((vo=ue.get(j))==null||vo.set(N,g))}const pe=g=>{var j;const v=(j=s.get(g))==null?void 0:j.category;return v?Ro.has(v):!1},ne=[];for(const g of n){const v=X.get(g.id);if(v)for(const j of v){if($(j))continue;const N=j.indexOf(".");if(N<0)continue;const E=j.slice(0,N),_=p.get(E);if(_&&pe(_.kind)){ne.push(g.id);break}}}ne.length===0&&n.length>0&&ne.push(n[0].id);const re=new Map;for(const g of ne)re.set(g,0);{const g=[...ne];for(;g.length>0;){const v=g.shift(),j=re.get(v),N=ue.get(v);if(N)for(const[E,_]of N){if(re.has(E))continue;const T=_.orientation==="horizontal"?j:j+1;re.set(E,T),g.push(E)}}}for(const g of n){if(re.has(g.id))continue;const v=re.size===0?-1:Math.max(...Array.from(re.values()));re.set(g.id,v+1)}const ge=new Map;for(const g of n){const v=re.get(g.id),j=ge.get(v)??[];j.push(g.id),ge.set(v,j)}const xe=[...ge.keys()].sort((g,v)=>g-v),_e=(g,v,j)=>{const N=`${g.elementId}.${j}`,E=v,_=y(g.elementId),T=new Set;if(_)for(const M of _.terminals)M.id!==j&&T.add(`${g.elementId}.${M.id}`);const z=new Set([N]),I=[{ref:N,dist:0}],P=new Map,A=(M,B,L,F)=>{z.add(M),P.set(M,B),I.push({ref:M,dist:F+L})};for(;I.length>0;){const{ref:M,dist:B}=I.shift();if(M===E){const H=P.get(E);let J;if(H){const Z=H.indexOf(".");if(Z>0){const G=H.slice(0,Z);G!==g.elementId&&(J=G)}}return{extent:B,head:J}}const L=M.indexOf(".");if(L<0)continue;const F=M.slice(0,L),q=M.slice(L+1);if(!$(F)&&!ae.has(F)){const H=y(F),J=H==null?void 0:H.terminals.find(Z=>Z.id===q);if(H&&J)for(const Z of H.terminals){if(Z.id===q)continue;const G=`${F}.${Z.id}`;z.has(G)||T.has(G)||A(G,M,Math.abs(J.y-Z.y),B)}}for(const H of R.get(M)??[])for(const J of H){if(J===M||z.has(J)||T.has(J))continue;const Z=$(M)||$(J);A(J,M,Z?Bo:wt,B)}}return{extent:0}},Ee=(g,v)=>{var M,B,L;const j=(M=ue.get(g))==null?void 0:M.get(v);if(!j||j.orientation==="horizontal")return bt;const N=y(j.elementId);if(!N)return bt;const E=(B=j.attachments.find(F=>F.busId===g))==null?void 0:B.pin,_=(L=j.attachments.find(F=>F.busId===v))==null?void 0:L.pin;if(!E||!_)return bt;const T=N.terminals.find(F=>F.id===E),z=N.terminals.find(F=>F.id===_);if(!T||!z)return bt;const I=Math.abs(z.y-T.y),P=_e(j,g,E).extent,A=_e(j,v,_).extent;return P+I+A},sn=new Map;for(const g of te){if(g.orientation!=="vertical")continue;const v=g.attachments.slice().sort((z,I)=>(re.get(z.busId)??0)-(re.get(I.busId)??0));if(v.length<2)continue;const j=v[0].busId,N=v[1].busId,E=v[0].pin,T=_e(g,j,E).head??g.elementId;sn.set(T,{lowerBusId:N})}const so=30,io=g=>{const v=y(g);return Math.max((v==null?void 0:v.width)??Ge,Ge)},Rw=2,ao=(g,v,j,N=0)=>{const E=y(v);let _=io(v);if(E&&!j.has(v)&&N<Rw){j.add(v);let T=0;for(const z of E.terminals){const I=`${v}.${z.id}`;if(I!==g)for(const P of R.get(I)??[]){const A=new Set;let M=!1;for(const L of P){if(L===I)continue;if($(L)){M=!0;continue}const F=L.indexOf(".");if(F<0)continue;const q=L.slice(0,F);q===v||j.has(q)||ae.has(q)||A.add(q)}if(M||A.size===0)continue;let B=0;for(const L of A){const F=[...P].find(q=>q.indexOf(".")>0&&q.slice(0,q.indexOf("."))===L);B+=(F?ao(F,L,j,N+1):io(L))+so}T=Math.max(T,B-so)}}j.delete(v),_=Math.max(_,T)}return _},ft=320,et=new Map,lo=(g,v)=>{if(!ae.has(g))return!1;const j=te.find(T=>T.elementId===g),N=j==null?void 0:j.attachments.find(T=>T.busId!==v);if(!N)return!1;const E=re.get(v)??0;return(re.get(N.busId)??0)<E},mt=(g,v,j)=>{const N=sn.get(g);if(N){const _=et.get(N.lowerBusId);if(_!==void 0)return Math.max(v,_+Ge)}let E=0;return j&&(E=ao(j,g,new Set)),Math.max(v,Ge,E)},co=(g,v)=>{if(et.has(g))return et.get(g);if(v.has(g))return ft;v.add(g);const j=X.get(g)??[];let N=0,E=0;for(const T of j){if($(T))continue;const z=T.indexOf(".");if(z<0)continue;const I=T.slice(0,z),P=T.slice(z+1);if(lo(I,g))continue;const A=y(I);if(!A)continue;const M=A.terminals.find(F=>F.id===P);if(!M)continue;const B=sn.get(I);B&&co(B.lowerBusId,v);const L=mt(I,A.width,`${I}.${P}`);M.y>0?N+=L:E+=L}const _=Math.max(ft,Math.max(N,E)+Ge);return et.set(g,_),v.delete(g),_};for(const g of n)co(g.id,new Set);const He=new Map,Dw=(g,v,j)=>{const N=y(v);if(!N)return;const E=`${v}.${j}`,_=N.terminals.filter(I=>I.id!==j).map(I=>`${v}.${I.id}`);if(_.length===0)return;const T=new Set([E,..._]),z=_.slice();for(;z.length>0;){const I=z.shift();if($(I)&&I!==g){const A=d.get(I);return A?A.at[0]:void 0}for(const A of R.get(I)??[])for(const M of A)M===I||T.has(M)||(T.add(M),z.push(M));const P=I.indexOf(".");if(P>0){const A=I.slice(0,P);if(!$(A)){const M=y(A);if(M)for(const B of M.terminals){const L=`${A}.${B.id}`;T.has(L)||(T.add(L),z.push(L))}}}}},Fw=g=>{const v=X.get(g);if(!v||v.length===0)return;const j=d.get(g);if(!j)return;const N=v.flatMap(M=>{if($(M))return[];const B=M.indexOf(".");if(B<0)return[];const L=M.slice(0,B),F=M.slice(B+1);if(l.has(L))return[];if(lo(L,g))return[];const q=y(L);if(!q)return[];const H=q.terminals.find(J=>J.id===F);return H?[{elId:L,lib:q,localTerm:H,isLinker:ae.has(L),busFacingRef:`${L}.${F}`}]:[]});if(N.length===0)return;const E=[],_=[];for(const M of N)M.localTerm.y>0?E.push(M):_.push(M);const T=M=>M.reduce((B,L)=>B+mt(L.elId,L.lib.width,L.busFacingRef),0),z=Math.max(T(E),T(_))+Ge,I=Math.max(j.span,z);I!==j.span&&!m.has(g)&&d.set(g,{...j,span:I});const P=d.get(g),A=(M,B)=>{if(M.length===0)return;const L=new Map;for(const Y of M){const U=Dw(g,Y.elId,Y.localTerm.id);U!==void 0&&L.set(Y.elId,U)}M.sort((Y,U)=>{const le=L.get(Y.elId)??P.at[0],be=L.get(U.elId)??P.at[0];if(le!==be)return le-be;const K=mt(Y.elId,Y.lib.width,Y.busFacingRef);return mt(U.elId,U.lib.width,U.busFacingRef)-K});const F=M.map(Y=>mt(Y.elId,Y.lib.width,Y.busFacingRef)),q=F.reduce((Y,U)=>Y+U,0),H=Math.max(I,q),J=(H-q)/(M.length+1);let Z=P.at[0]-H/2+J;const G=P.at[1]+B*Bo;for(let Y=0;Y<M.length;Y++){const U=M[Y],le=F[Y],be=Z+le/2;U.isLinker?He.has(U.elId)||He.set(U.elId,be):l.set(U.elId,{at:[me(be-U.localTerm.x),me(G-U.localTerm.y)],rot:0,mirror:!1}),Z+=le+J}};A(E,-1),A(_,1)},Hw=g=>{if(l.has(g.elementId)||g.orientation==="horizontal")return;const v=y(g.elementId);if(!v)return;const j=g.attachments.filter(Z=>d.has(Z.busId));if(j.length<2)return;const N=j.slice().sort((Z,G)=>(re.get(Z.busId)??0)-(re.get(G.busId)??0)),E=N[0].busId,_=d.get(E),T=N[0].pin,z=N[N.length-1].pin,I=v.terminals.find(Z=>Z.id===T),P=v.terminals.find(Z=>Z.id===z);if(!I||!P)return;const A=I.y<=P.y?0:180,M=re.get(E)??0,B=j.filter(Z=>(re.get(Z.busId)??0)===M),L=[];let F=0;for(const Z of B){const G=_e(g,Z.busId,Z.pin);F=Math.max(F,G.extent);const Y=G.head?l.get(G.head):void 0;Y?L.push(Y.at[0]):He.has(g.elementId)?L.push(He.get(g.elementId)):L.push(d.get(Z.busId).at[0])}let q;L.length>0?q=L.reduce((Z,G)=>Z+G,0)/L.length:He.has(g.elementId)?q=He.get(g.elementId):q=_.at[0];const H=_.at[1]+F,J=A===0?[me(q-I.x),me(H-I.y)]:[me(q+I.x),me(H+I.y)];if(l.set(g.elementId,{at:J,rot:A,mirror:!1}),B.length>1){const Z=l.get(g.elementId),G=Pe([I.x,I.y],Z),Y=St(I.orientation,Z);Ww(`${g.elementId}.${T}`,G,Y,q)}},Ww=(g,v,j,N)=>{const E=new Set([g]);let _=g,T=v,z=j;for(;;){const I=R.get(_)??[];let P,A=!1;for(const Q of I){if(Q.length>=3){A=!0;break}const $e=Q.find(Se=>Se!==_);if(!(!$e||E.has($e))){if($($e)){A=!0;break}P=$e;break}}if(A||!P)break;const M=P.indexOf(".");if(M<0)break;const B=P.slice(0,M),L=P.slice(M+1);if($(B)||ae.has(B)||l.has(B))break;const F=y(B);if(!F)break;const q=F.terminals.find(Q=>Q.id===L);if(!q)break;const H=Cn(z),J=[T[0]+H[0]*wt,T[1]+H[1]*wt],Z=Oo[z],G=Ot(q.orientation,Z),Y=Pe([q.x,q.y],{at:[0,0],rot:G,mirror:!1}),U=[me(N-Y[0]),me(J[1]-Y[1])];l.set(B,{at:U,rot:G,mirror:!1}),E.add(P);const le=F.terminals.find(Q=>Q.id!==L);if(!le)break;const be=`${B}.${le.id}`;E.add(be);const K={at:U,rot:G,mirror:!1};T=Pe([le.x,le.y],K),z=St(le.orientation,K),_=be}},qw=g=>{if(l.has(g.elementId)||g.orientation!=="horizontal")return;const v=y(g.elementId);if(!v)return;const j=g.attachments.filter(B=>d.has(B.busId));if(j.length<2)return;const N=j.map(B=>{const L=_e(g,B.busId,B.pin),F=L.head?l.get(L.head):void 0,q=F?F.at[0]:d.get(B.busId).at[0];return{att:B,x:q,extent:L.extent}});N.sort((B,L)=>B.x-L.x);const E=N[0],_=N[N.length-1],T=v.terminals.find(B=>B.id===E.att.pin),z=v.terminals.find(B=>B.id===_.att.pin);if(!T||!z)return;const I=T.y<=z.y?270:90,P=(E.x+_.x)/2,M=d.get(E.att.busId).at[1]+Math.max(E.extent,_.extent);l.set(g.elementId,{at:[me(P),me(M)],rot:I,mirror:!1})},uo=100;let Ct=Bt;for(let g=0;g<xe.length;g++){const v=xe[g],j=ge.get(v);let N;if(g===0)N=Bt;else{const _=ge.get(xe[g-1]);let T=0;for(const z of _)for(const I of j)(ko=ue.get(z))!=null&&ko.get(I)&&(T=Math.max(T,Ee(z,I)));T===0&&(T=bt),N=Ct+T}Ct=N;let E=mn;for(const _ of j){if(d.has(_)){Ct=Math.max(Ct,d.get(_).at[1]);continue}let T;if(g>0){const I=ge.get(xe[g-1]),P=[];for(const A of I){const M=(_o=ue.get(A))==null?void 0:_o.get(_);if(!M||M.orientation!=="vertical")continue;const B=($o=M.attachments.find(F=>F.busId===A))==null?void 0:$o.pin;if(!B)continue;const L=_e(M,A,B);L.head&&l.has(L.head)?P.push(l.get(L.head).at[0]):He.has(M.elementId)?P.push(He.get(M.elementId)):P.push(d.get(A).at[0])}P.length>0&&(T=P.reduce((A,M)=>A+M,0)/P.length)}if(T===void 0){const I=et.get(_)??hn;T=E+I/2,E+=I+uo}const z=et.get(_)??hn;d.set(_,{at:[me(T),me(N)],rot:0,span:z,axis:An(0)})}for(const _ of j)Fw(_);if(g>0)for(const _ of te)l.has(_.elementId)||!_.attachments.some(z=>j.includes(z.busId))||Hw(_);for(const _ of te)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>j.includes(z.busId))||qw(_)}if(n.length===0&&l.size<t.length){const g=E=>{const _=new Set,T=y(E);if(!T)return _;for(const z of T.terminals){const I=`${E}.${z.id}`;for(const P of R.get(I)??[])for(const A of P){if(A===I||$(A))continue;const M=A.indexOf(".");if(M<0)continue;const B=A.slice(0,M);B!==E&&_.add(B)}}return _},v=new Set,j=[];for(const E of t){if(v.has(E.id)||!y(E.id))continue;const _=[],T=[E.id];for(v.add(E.id);T.length>0;){const z=T.pop();_.push(z);for(const I of g(z))v.has(I)||(v.add(I),T.push(I))}_.length>=2&&j.push(_)}let N=mn;for(const E of j){if(E.some(P=>l.has(P)))continue;E.sort((P,A)=>{var q,H;const M=pe(((q=p.get(P))==null?void 0:q.kind)??"")?0:1,B=pe(((H=p.get(A))==null?void 0:H.kind)??"")?0:1;if(M!==B)return M-B;const L=g(P).size,F=g(A).size;return L!==F?L-F:P.localeCompare(A)});const _=E[0],T=y(_);if(!T)continue;const z=T.terminals.slice().sort((P,A)=>A.y-P.y)[0],I=z?Pe([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[me(N-I[0]),me(Bt-I[1])],rot:0,mirror:!1}),N+=Math.max(hn,E.length*Ge)+uo}}const Gw=g=>{if($(g))return d.has(g);const v=g.indexOf(".");return v<0?!1:l.has(g.slice(0,v))};let an=!0,Xw=t.length+4;for(;an&&Xw-- >0;){an=!1;for(const g of C){if(g.length<2)continue;const v=[],j=new Map;for(const G of g){if($(G))continue;const Y=G.indexOf(".");if(Y<0)continue;const U=G.slice(0,Y),le=G.slice(Y+1);if(l.has(U)){v.push(G);continue}if(ae.has(U)||j.has(U))continue;const be=y(U);if(!be)continue;const K=be.terminals.find(Q=>Q.id===le);K&&j.set(U,{ref:G,elId:U,lib:be,localTerm:K})}if(j.size===0||v.length===0)continue;const N=[...j.values()],E=new Map;for(const G of N)for(const Y of R.get(G.ref)??[])for(const U of Y){if(U===G.ref||$(U)||!Gw(U))continue;const le=U;E.set(le,(E.get(le)??0)+1)}let _;if(E.size>0){let G=-1;for(const[Y,U]of E)(U>G||U===G&&(_===void 0||Y<_))&&(G=U,_=Y)}if(_||(_=[...v].sort()[0]),!_)continue;const T=_.indexOf("."),z=_.slice(0,T),I=_.slice(T+1),P=y(z),A=l.get(z);if(!P||!A)continue;const M=P.terminals.find(G=>G.id===I);if(!M)continue;const B=Pe([M.x,M.y],A),L=St(M.orientation,A),F=Cn(L),q=[-F[1],F[0]];N.sort((G,Y)=>G.elId.localeCompare(Y.elId));const H=N.map(G=>Math.max(G.lib.width,Ge));let Z=-H.reduce((G,Y)=>G+Y,0)/2;for(let G=0;G<N.length;G++){const Y=N[G],U=H[G],le=Z+U/2;Z+=U;const be=Oo[L],K=Ot(Y.localTerm.orientation,be),Q=Pe([Y.localTerm.x,Y.localTerm.y],{at:[0,0],rot:K,mirror:!1}),$e=[B[0]+F[0]*wt+q[0]*le,B[1]+F[1]*wt+q[1]*le],Se=[me($e[0]-Q[0]),me($e[1]-Q[1])];l.set(Y.elId,{at:Se,rot:K,mirror:!1}),an=!0}}}const ht=g=>{const v=l.get(g),j=y(g);if(!v||!j)return null;const N=j.viewBox.split(/\s+/).map(Number);if(N.length<4||N.some(M=>Number.isNaN(M))){const M=j.width/2;return{min:v.at[0]-M,max:v.at[0]+M}}const[E,_,T,z]=N,I=[[E,_],[E+T,_],[E,_+z],[E+T,_+z]];let P=1/0,A=-1/0;for(const M of I){const B=Pe(M,v);P=Math.min(P,B[0]),A=Math.max(A,B[0])}return{min:P,max:A}},ln=g=>{const v=new Set,j=y(g);if(!j)return v;for(const N of j.terminals){const E=`${g}.${N.id}`;for(const _ of R.get(E)??[])for(const T of _){if(T===E||$(T))continue;const z=T.indexOf(".");if(z<0)continue;const I=T.slice(0,z);I!==g&&v.add(I)}}return v},fo=40,cn=g=>{const v=l.get(g),j=y(g);if(!v||!j)return null;const N=j.viewBox.split(/\s+/).map(Number);if(N.length<4||N.some(M=>Number.isNaN(M))){const M=j.height/2;return{min:v.at[1]-M,max:v.at[1]+M}}const[E,_,T,z]=N,I=[[E,_],[E+T,_],[E,_+z],[E+T,_+z]];let P=1/0,A=-1/0;for(const M of I){const B=Pe(M,v);P=Math.min(P,B[1]),A=Math.max(A,B[1])}return{min:P,max:A}},Yw=(g,v)=>{const j=new Set,N=[];for(const E of X.get(g)??[]){if($(E))continue;const _=E.indexOf(".");if(_<0)continue;const T=E.slice(0,_),z=l.get(T);!z||z.at[1]>=v-1||j.has(T)||(j.add(T),N.push(T))}for(;N.length>0;){const E=N.pop();for(const _ of ln(E)){if(j.has(_))continue;const T=l.get(_);!T||T.at[1]>=v-1||(j.add(_),N.push(_))}}return j},mo=(g,v,j)=>{const N=new Set([g]),E=[g];for(;E.length>0;){const _=E.pop();for(const T of ln(_))T===v||N.has(T)||!j.has(T)||(N.add(T),E.push(T))}return N},ho=(g,v)=>{let j=g.length*g.length+8,N=!1,E=!0;for(;E&&j-- >0;){E=!1;for(let _=0;_<g.length&&!E;_++)for(let T=_+1;T<g.length;T++){const z=g[_],I=g[T],P=ht(z),A=ht(I),M=cn(z),B=cn(I);if(!P||!A||!M||!B)continue;const L=Math.min(P.max,A.max)-Math.max(P.min,A.min),F=Math.min(M.max,B.max)-Math.max(M.min,B.min);if(L<=0||F<=0)continue;const q=mo(z,I,v),H=mo(I,z,v);if(q.has(I)||H.has(z))continue;const J=![...q].some(K=>f.has(K)),Z=![...H].some(K=>f.has(K));if(!J&&!Z)continue;const G=(P.min+P.max)/2,Y=(A.min+A.max)/2;let U,le;J&&(!Z||q.size<=H.size)?(U=q,le=G<=Y?-1:1):(U=H,le=Y<=G?-1:1);const be=me(le*(L+fo));if(be!==0){for(const K of U){const Q=l.get(K);Q&&l.set(K,{...Q,at:[Q.at[0]+be,Q.at[1]]})}N=!0,E=!0;break}}}return N};for(const g of n){const v=d.get(g.id);if(!v)continue;const j=Yw(g.id,v.at[1]);if(j.size<2)continue;const N=[...j];if(ho(N,j)){let _=1/0,T=-1/0;for(const z of N){const I=ht(z);I&&(_=Math.min(_,I.min),T=Math.max(T,I.max))}if(Number.isFinite(_)){const I=N.some(A=>f.has(A))?0:me(v.at[0]-(_+T)/2);if(I!==0)for(const A of N){const M=l.get(A);M&&l.set(A,{...M,at:[M.at[0]+I,M.at[1]]})}const P=T-_+fo;if(P>v.span&&!m.has(g.id)){const A=d.get(g.id);d.set(g.id,{...A,span:P})}}}}const po=()=>{const v=t.map(N=>N.id).filter(N=>l.has(N)).map(N=>({x:ht(N),y:cn(N)})).filter(N=>N.x&&N.y);let j=0;for(let N=0;N<v.length;N++)for(let E=N+1;E<v.length;E++){const _=Math.min(v[N].x.max,v[E].x.max)-Math.max(v[N].x.min,v[E].x.min),T=Math.min(v[N].y.max,v[E].y.max)-Math.max(v[N].y.min,v[E].y.min);_>1&&T>1&&j++}return j},Kw=po(),go=new Map;for(const[g,v]of l)go.set(g,{...v,at:[...v.at]});const yo=new Map;for(const[g,v]of d)yo.set(g,{...v,at:[...v.at]});const dn=120,xo=new Map;{const g=new Map,v=new Map,j=[];for(const E of n)for(const _ of X.get(E.id)??[]){if($(_))continue;const T=_.indexOf(".");if(T<0)continue;const z=_.slice(0,T);l.has(z)&&j.push({el:z,bus:E.id,d:1})}j.sort((E,_)=>E.d-_.d);let N=0;for(;N<j.length;){const{el:E,bus:_,d:T}=j[N++],z=g.get(E);if(z===void 0)g.set(E,T),v.set(E,_);else if(T===z&&v.get(E)!==_){v.set(E,null);continue}else continue;for(const I of ln(E))l.has(I)&&(g.has(I)||j.push({el:I,bus:_,d:T+1}))}for(const[E,_]of v)_&&xo.set(E,_)}for(const g of xe){const v=(ge.get(g)??[]).filter(P=>d.has(P));if(v.length<2||v.some(P=>m.has(P)))continue;const j=[];let N=0;for(const P of v){const A=d.get(P),M=[];let B=1/0,L=-1/0;for(const[F,q]of xo){if(q!==P)continue;const H=ht(F);H&&(M.push(F),B=Math.min(B,H.min),L=Math.max(L,H.max))}Number.isFinite(B)||(B=A.at[0]-ft/2,L=A.at[0]+ft/2),j.push({busId:P,min:B,max:L,members:M}),N+=L-B}if(j.some(P=>P.members.some(A=>f.has(A))))continue;let E=1/0,_=-1/0;for(const P of j)E=Math.min(E,P.min),_=Math.max(_,P.max);const T=_-E,z=N+dn*(j.length-1);if(!(T>z+dn))continue;j.sort((P,A)=>(P.min+P.max)/2-(A.min+A.max)/2);let I=E;for(const P of j){const A=me(I-P.min);if(A!==0){const M=d.get(P.busId);d.set(P.busId,{...M,at:[M.at[0]+A,M.at[1]]});for(const B of P.members){const L=l.get(B);L&&l.set(B,{...L,at:[L.at[0]+A,L.at[1]]})}P.min+=A,P.max+=A}I=P.max+dn}for(const P of j){const A=d.get(P.busId),M=Math.max(ft,P.max-P.min);M<A.span&&d.set(P.busId,{...A,span:M})}}{const g=t.map(j=>j.id).filter(j=>l.has(j)),v=new Set(g);ho(g,v)}if(po()>Kw){l.clear();for(const[g,v]of go)l.set(g,v);d.clear();for(const[g,v]of yo)d.set(g,v)}let un=0;for(const g of t){if(l.has(g.id))continue;const v=un%zo,j=Math.floor(un/zo);l.set(g.id,{at:[me(s2+v*a2),me(i2+j*l2)],rot:0,mirror:!1}),un++}return{devices:l,buses:d,junctions:u}}function me(e){return Math.round(e/Lo)*Lo}function d2(e,t){const n=e.ends[0],o=e.ends[1],r=Do(n,t),s=Do(o,t);if(r||s){const l=r?n:o,u=pn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:m,at:p,span:h}=f.geometry,y=h/2;let w;if(m==="x")w=[Gt(u[0],p[0]-y,p[0]+y),p[1]];else{const $=Gt(u[1],p[1]-y,p[1]+y);w=[p[0],$]}return{wireId:e.id,path:Ho(u,w)}}const i=pn(n,t),a=pn(o,t);return!i||!a?null:{wireId:e.id,path:Ho(i,a)}}function Do(e,t){return!e.includes(".")&&t.buses.has(e)}function pn(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 Fo(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[Gt(t[0],i[0]-l,i[0]+l),i[1]];const d=Gt(t[1],i[1]-l,i[1]+l);return[i[0],d]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function Ho(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Gt(e,t,n){return e<t?t:e>n?n:e}const as="ammeter",ls="电流表 (A)",cs="measurement",ds="-22 -42 44 44",us=44,fs=44,ms='<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>',hs=[{id:"t_top",x:0,y:-40,orientation:"n"}],ps={kind:"inline"},u2={id:as,name:ls,category:cs,viewBox:ds,width:us,height:fs,svg:ms,terminals:hs,source:ps},f2=Object.freeze(Object.defineProperty({__proto__:null,category:cs,default:u2,height:fs,id:as,name:ls,source:ps,svg:ms,terminals:hs,viewBox:ds,width:us},Symbol.toStringTag,{value:"Module"})),gs="arc-suppression-coil",ys="消弧线圈",xs="grounding",bs="中性点谐振接地:电感线圈连接到地",ws="-12 -32 24 67",vs=24,ks=67,_s='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',$s=[{id:"t_top",x:0,y:-30,orientation:"n"}],Ss={kind:"inline"},m2={id:gs,name:ys,category:xs,description:bs,viewBox:ws,width:vs,height:ks,svg:_s,terminals:$s,source:Ss},h2=Object.freeze(Object.defineProperty({__proto__:null,category:xs,default:m2,description:bs,height:ks,id:gs,name:ys,source:Ss,svg:_s,terminals:$s,viewBox:ws,width:vs},Symbol.toStringTag,{value:"Module"})),js="arrester",Es="避雷器 (FBL)",Ns="protection",Ms="-7 -22 14 44",Ts=14,As=44,Cs='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Is=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ps={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:js,name:Es,category:Ns,viewBox:Ms,width:Ts,height:As,svg:Cs,terminals:Is,source:Ps},g2=Object.freeze(Object.defineProperty({__proto__:null,category:Ns,default:p2,height:As,id:js,name:Es,source:Ps,svg:Cs,terminals:Is,viewBox:Ms,width:Ts},Symbol.toStringTag,{value:"Module"})),Os="async-motor",Bs="异步电动机",Ls="load",zs="-62 -82 64 84",Rs=64,Ds=84,Fs='<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"/>',Hs=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Ws={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"},y2={id:Os,name:Bs,category:Ls,viewBox:zs,width:Rs,height:Ds,svg:Fs,terminals:Hs,source:Ws},x2=Object.freeze(Object.defineProperty({__proto__:null,category:Ls,default:y2,height:Ds,id:Os,name:Bs,source:Ws,svg:Fs,terminals:Hs,viewBox:zs,width:Rs},Symbol.toStringTag,{value:"Module"})),qs="autotransformer",Gs="自耦变压器",Xs="transformer",Ys="-62 -112 64 144",Ks=64,Vs=144,Us='<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"/>',Js=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Zs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},b2={id:qs,name:Gs,category:Xs,viewBox:Ys,width:Ks,height:Vs,svg:Us,terminals:Js,source:Zs},w2=Object.freeze(Object.defineProperty({__proto__:null,category:Xs,default:b2,height:Vs,id:qs,name:Gs,source:Zs,svg:Us,terminals:Js,viewBox:Ys,width:Ks},Symbol.toStringTag,{value:"Module"})),Qs="battery",ei="电池储能",ti="storage",ni="-12 -12 29 24",oi=29,ri=24,si='<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"/>',ii=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],ai=[{name:"E",label:"容量",type:"number",unit:"kWh"}],li={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},v2={id:Qs,name:ei,category:ti,viewBox:ni,width:oi,height:ri,svg:si,terminals:ii,params:ai,source:li},k2=Object.freeze(Object.defineProperty({__proto__:null,category:ti,default:v2,height:ri,id:Qs,name:ei,params:ai,source:li,svg:si,terminals:ii,viewBox:ni,width:oi},Symbol.toStringTag,{value:"Module"})),ci="bell",di="电铃 (HA)",ui="control",fi="信号电铃 / 警铃。",mi="-32 -32 44 44",hi=44,pi=44,gi='<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"/>',yi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],xi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},_2={id:ci,name:di,category:ui,description:fi,viewBox:mi,width:hi,height:pi,svg:gi,terminals:yi,source:xi},$2=Object.freeze(Object.defineProperty({__proto__:null,category:ui,default:_2,description:fi,height:pi,id:ci,name:di,source:xi,svg:gi,terminals:yi,viewBox:mi,width:hi},Symbol.toStringTag,{value:"Module"})),bi="break-contact",wi="常闭触点 (NC)",vi="control",ki="常闭辅助触点 (break contact)。",_i="-2 -42 14 64",$i=14,Si=64,ji='<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"/>',Ei=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ni=[{name:"open",type:"boolean",default:!1,label:"断开"}],Mi={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},S2={id:bi,name:wi,category:vi,description:ki,viewBox:_i,width:$i,height:Si,svg:ji,terminals:Ei,state:Ni,source:Mi},j2=Object.freeze(Object.defineProperty({__proto__:null,category:vi,default:S2,description:ki,height:Si,id:bi,name:wi,source:Mi,state:Ni,svg:ji,terminals:Ei,viewBox:_i,width:$i},Symbol.toStringTag,{value:"Module"})),Ti="breaker",Ai="断路器 (QF)",Ci="switching",Ii="-7 -22 15 46",Pi=15,Oi=46,Bi='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',Li=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],zi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ri={x:6,y:-2,anchor:"start"},Di={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},E2={id:Ti,name:Ai,category:Ci,viewBox:Ii,width:Pi,height:Oi,svg:Bi,terminals:Li,state:zi,label:Ri,source:Di},N2=Object.freeze(Object.defineProperty({__proto__:null,category:Ci,default:E2,height:Oi,id:Ti,label:Ri,name:Ai,source:Di,state:zi,svg:Bi,terminals:Li,viewBox:Ii,width:Pi},Symbol.toStringTag,{value:"Module"})),Fi="buchholz-relay",Hi="瓦斯继电器 (63)",Wi="protection",qi="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Gi="-22 -62 44 64",Xi=44,Yi=64,Ki='<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"/>',Vi=[{id:"t_top",x:0,y:-60,orientation:"n"}],Ui={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"},M2={id:Fi,name:Hi,category:Wi,description:qi,viewBox:Gi,width:Xi,height:Yi,svg:Ki,terminals:Vi,source:Ui},T2=Object.freeze(Object.defineProperty({__proto__:null,category:Wi,default:M2,description:qi,height:Yi,id:Fi,name:Hi,source:Ui,svg:Ki,terminals:Vi,viewBox:Gi,width:Xi},Symbol.toStringTag,{value:"Module"})),Ji="busbar",Zi="母线段",Qi="busbar",ea="可拉伸单母线段,多设备挂接",ta="-42 -4 84 8",na=84,oa=8,ra='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',sa=[{id:"tap",x:0,y:0,orientation:"n"}],ia={axis:"x",minLength:20,naturalSpan:80},aa=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],la={x:0,y:-6,anchor:"middle"},ca={kind:"inline"},A2={id:Ji,name:Zi,category:Qi,description:ea,viewBox:ta,width:na,height:oa,svg:ra,terminals:sa,stretchable:ia,params:aa,label:la,source:ca},C2=Object.freeze(Object.defineProperty({__proto__:null,category:Qi,default:A2,description:ea,height:oa,id:Ji,label:la,name:Zi,params:aa,source:ca,stretchable:ia,svg:ra,terminals:sa,viewBox:ta,width:na},Symbol.toStringTag,{value:"Module"})),da="buzzer",ua="蜂鸣器 (HA)",fa="control",ma="信号蜂鸣器。",ha="-32 -52 44 64",pa=44,ga=64,ya='<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"/>',xa=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ba={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},I2={id:da,name:ua,category:fa,description:ma,viewBox:ha,width:pa,height:ga,svg:ya,terminals:xa,source:ba},P2=Object.freeze(Object.defineProperty({__proto__:null,category:fa,default:I2,description:ma,height:ga,id:da,name:ua,source:ba,svg:ya,terminals:xa,viewBox:ha,width:pa},Symbol.toStringTag,{value:"Module"})),wa="capacitor",va="电容 (C)",ka="passive",_a="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",$a="-7 -23 14 27",Sa=14,ja=27,Ea='<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"/>',Na=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Ma=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Ta={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},O2={id:wa,name:va,category:ka,description:_a,viewBox:$a,width:Sa,height:ja,svg:Ea,terminals:Na,params:Ma,source:Ta},B2=Object.freeze(Object.defineProperty({__proto__:null,category:ka,default:O2,description:_a,height:ja,id:wa,name:va,params:Ma,source:Ta,svg:Ea,terminals:Na,viewBox:$a,width:Sa},Symbol.toStringTag,{value:"Module"})),Aa="contactor",Ca="接触器 (KM)",Ia="motor-control",Pa="主回路接触器, 通常配热继电器和电机使用。",Oa="-10 -42 15 64",Ba=15,La=64,za='<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"/>',Ra=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Da=[{name:"open",type:"boolean",default:!0,label:"断开"}],Fa={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"},L2={id:Aa,name:Ca,category:Ia,description:Pa,viewBox:Oa,width:Ba,height:La,svg:za,terminals:Ra,state:Da,source:Fa},z2=Object.freeze(Object.defineProperty({__proto__:null,category:Ia,default:L2,description:Pa,height:La,id:Aa,name:Ca,source:Fa,state:Da,svg:za,terminals:Ra,viewBox:Oa,width:Ba},Symbol.toStringTag,{value:"Module"})),Ha="converter-bidir",Wa="双向变流器 (PCS)",qa="renewable",Ga="储能变流器:双向 AC ↔ DC",Xa="-42 -42 44 48",Ya=44,Ka=48,Va='<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"/>',Ua=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Ja=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Za={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},R2={id:Ha,name:Wa,category:qa,description:Ga,viewBox:Xa,width:Ya,height:Ka,svg:Va,terminals:Ua,params:Ja,source:Za},D2=Object.freeze(Object.defineProperty({__proto__:null,category:qa,default:R2,description:Ga,height:Ka,id:Ha,name:Wa,params:Ja,source:Za,svg:Va,terminals:Ua,viewBox:Xa,width:Ya},Symbol.toStringTag,{value:"Module"})),Qa="ct",el="电流互感器 (CT)",tl="instrument-transformer",nl="-42 -62 54 64",ol=54,rl=64,sl='<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"/>',il=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],al={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},F2={id:Qa,name:el,category:tl,viewBox:nl,width:ol,height:rl,svg:sl,terminals:il,source:al},H2=Object.freeze(Object.defineProperty({__proto__:null,category:tl,default:F2,height:rl,id:Qa,name:el,source:al,svg:sl,terminals:il,viewBox:nl,width:ol},Symbol.toStringTag,{value:"Module"})),ll="dc-combiner",cl="直流汇流箱",dl="renewable",ul="光伏组串汇流箱 (4 路输入示例)。",fl="-27 -32 54 64",ml=54,hl=64,pl='<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>',gl=[{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"}],yl={kind:"inline"},W2={id:ll,name:cl,category:dl,description:ul,viewBox:fl,width:ml,height:hl,svg:pl,terminals:gl,source:yl},q2=Object.freeze(Object.defineProperty({__proto__:null,category:dl,default:W2,description:ul,height:hl,id:ll,name:cl,source:yl,svg:pl,terminals:gl,viewBox:fl,width:ml},Symbol.toStringTag,{value:"Module"})),xl="dc-disconnector",bl="直流隔离开关",wl="switching",vl="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",kl="-12 -32 30 64",_l=30,$l=64,Sl='<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"/>',jl=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],El=[{name:"open",type:"boolean",default:!1,label:"断开"}],Nl={kind:"inline"},G2={id:xl,name:bl,category:wl,description:vl,viewBox:kl,width:_l,height:$l,svg:Sl,terminals:jl,state:El,source:Nl},X2=Object.freeze(Object.defineProperty({__proto__:null,category:wl,default:G2,description:vl,height:$l,id:xl,name:bl,source:Nl,state:El,svg:Sl,terminals:jl,viewBox:kl,width:_l},Symbol.toStringTag,{value:"Module"})),Ml="dc-motor",Tl="直流电机 (M)",Al="load",Cl="直流电动机 (串励通用符号)。",Il="-72 -82 89 84",Pl=89,Ol=84,Bl='<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"/>',Ll=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],zl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},Y2={id:Ml,name:Tl,category:Al,description:Cl,viewBox:Il,width:Pl,height:Ol,svg:Bl,terminals:Ll,source:zl},K2=Object.freeze(Object.defineProperty({__proto__:null,category:Al,default:Y2,description:Cl,height:Ol,id:Ml,name:Tl,source:zl,svg:Bl,terminals:Ll,viewBox:Il,width:Pl},Symbol.toStringTag,{value:"Module"})),Rl="diode",Dl="二极管 (D)",Fl="passive",Hl="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Wl="-12 -42 24 44",ql=24,Gl=44,Xl='<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"/>',Yl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Kl={x:6,y:-20,anchor:"start"},Vl={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},V2={id:Rl,name:Dl,category:Fl,description:Hl,viewBox:Wl,width:ql,height:Gl,svg:Xl,terminals:Yl,label:Kl,source:Vl},U2=Object.freeze(Object.defineProperty({__proto__:null,category:Fl,default:V2,description:Hl,height:Gl,id:Rl,label:Kl,name:Dl,source:Vl,svg:Xl,terminals:Yl,viewBox:Wl,width:ql},Symbol.toStringTag,{value:"Module"})),Ul="disconnector",Jl="隔离开关 (QS)",Zl="switching",Ql="-10 -42 15 64",ec=15,tc=64,nc='<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"/>',oc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],rc=[{name:"open",type:"boolean",default:!1,label:"断开"}],sc={x:6,y:-10,anchor:"start"},ic={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},J2={id:Ul,name:Jl,category:Zl,viewBox:Ql,width:ec,height:tc,svg:nc,terminals:oc,state:rc,label:sc,source:ic},Z2=Object.freeze(Object.defineProperty({__proto__:null,category:Zl,default:J2,height:tc,id:Ul,label:sc,name:Jl,source:ic,state:rc,svg:nc,terminals:oc,viewBox:Ql,width:ec},Symbol.toStringTag,{value:"Module"})),ac="distance-relay",lc="距离继电器 (21)",cc="protection",dc="距离 / 低阻抗保护继电器 (ANSI 21)。",uc="-62 -42 64 44",fc=64,mc=44,hc='<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 &lt;</text>',pc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],gc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},Q2={id:ac,name:lc,category:cc,description:dc,viewBox:uc,width:fc,height:mc,svg:hc,terminals:pc,source:gc},ek=Object.freeze(Object.defineProperty({__proto__:null,category:cc,default:Q2,description:dc,height:mc,id:ac,name:lc,source:gc,svg:hc,terminals:pc,viewBox:uc,width:fc},Symbol.toStringTag,{value:"Module"})),yc="earth",xc="接地",bc="busbar",wc="-12 -17 24 34",vc=24,kc=34,_c='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',$c=[{id:"t1",x:0,y:-15,orientation:"n"}],Sc={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"},tk={id:yc,name:xc,category:bc,viewBox:wc,width:vc,height:kc,svg:_c,terminals:$c,source:Sc},nk=Object.freeze(Object.defineProperty({__proto__:null,category:bc,default:tk,height:kc,id:yc,name:xc,source:Sc,svg:_c,terminals:$c,viewBox:wc,width:vc},Symbol.toStringTag,{value:"Module"})),jc="earthing-switch",Ec="接地刀闸 (QE)",Nc="switching",Mc="隔离开关 + 接地连接,单端口",Tc="-12 -32 24 64",Ac=24,Cc=64,Ic='<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"/>',Pc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Oc=[{name:"open",type:"boolean",default:!0,label:"断开"}],Bc={x:12,y:-8,anchor:"start"},Lc={kind:"inline"},ok={id:jc,name:Ec,category:Nc,description:Mc,viewBox:Tc,width:Ac,height:Cc,svg:Ic,terminals:Pc,state:Oc,label:Bc,source:Lc},rk=Object.freeze(Object.defineProperty({__proto__:null,category:Nc,default:ok,description:Mc,height:Cc,id:jc,label:Bc,name:Ec,source:Lc,state:Oc,svg:Ic,terminals:Pc,viewBox:Tc,width:Ac},Symbol.toStringTag,{value:"Module"})),zc="energy-meter",Rc="电能表 (Wh)",Dc="measurement",Fc="有功电能表 (kWh) — 服务入口 / 子表。",Hc="-22 -36 44 72",Wc=44,qc=72,Gc='<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"/>',Xc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Yc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},sk={id:zc,name:Rc,category:Dc,description:Fc,viewBox:Hc,width:Wc,height:qc,svg:Gc,terminals:Xc,source:Yc},ik=Object.freeze(Object.defineProperty({__proto__:null,category:Dc,default:sk,description:Fc,height:qc,id:zc,name:Rc,source:Yc,svg:Gc,terminals:Xc,viewBox:Hc,width:Wc},Symbol.toStringTag,{value:"Module"})),Kc="ev-charger",Vc="EV 充电桩",Uc="load",Jc="电动汽车充电站 / 充电桩。",Zc="-17 -27 34 49",Qc=34,ed=49,td='<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>',nd=[{id:"t_top",x:0,y:-25,orientation:"n"}],od={kind:"inline"},ak={id:Kc,name:Vc,category:Uc,description:Jc,viewBox:Zc,width:Qc,height:ed,svg:td,terminals:nd,source:od},lk=Object.freeze(Object.defineProperty({__proto__:null,category:Uc,default:ak,description:Jc,height:ed,id:Kc,name:Vc,source:od,svg:td,terminals:nd,viewBox:Zc,width:Qc},Symbol.toStringTag,{value:"Module"})),rd="frequency-meter",sd="频率表 (Hz)",id="measurement",ad="-22 -42 44 44",ld=44,cd=44,dd='<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>',ud=[{id:"t_top",x:0,y:-40,orientation:"n"}],fd={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},ck={id:rd,name:sd,category:id,viewBox:ad,width:ld,height:cd,svg:dd,terminals:ud,source:fd},dk=Object.freeze(Object.defineProperty({__proto__:null,category:id,default:ck,height:cd,id:rd,name:sd,source:fd,svg:dd,terminals:ud,viewBox:ad,width:ld},Symbol.toStringTag,{value:"Module"})),md="fuse-switch-disconnector",hd="熔断器式隔离开关",pd="switching",gd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",yd="-8 -32 12 64",xd=12,bd=64,wd='<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"/>',vd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],kd=[{name:"open",type:"boolean",default:!1,label:"断开"}],_d={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},uk={id:md,name:hd,category:pd,description:gd,viewBox:yd,width:xd,height:bd,svg:wd,terminals:vd,state:kd,source:_d},fk=Object.freeze(Object.defineProperty({__proto__:null,category:pd,default:uk,description:gd,height:bd,id:md,name:hd,source:_d,state:kd,svg:wd,terminals:vd,viewBox:yd,width:xd},Symbol.toStringTag,{value:"Module"})),$d="fuse",Sd="熔断器 (FU)",jd="switching",Ed="-7 -32 14 64",Nd=14,Md=64,Td='<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"/>',Ad=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Cd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Id={x:7,y:-2,anchor:"start"},Pd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},mk={id:$d,name:Sd,category:jd,viewBox:Ed,width:Nd,height:Md,svg:Td,terminals:Ad,state:Cd,label:Id,source:Pd},hk=Object.freeze(Object.defineProperty({__proto__:null,category:jd,default:mk,height:Md,id:$d,label:Id,name:Sd,source:Pd,state:Cd,svg:Td,terminals:Ad,viewBox:Ed,width:Nd},Symbol.toStringTag,{value:"Module"})),Od="generator",Bd="发电机 (G)",Ld="source",zd="-42 -42 44 44",Rd=44,Dd=44,Fd='<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>',Hd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Wd={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:Od,name:Bd,category:Ld,viewBox:zd,width:Rd,height:Dd,svg:Fd,terminals:Hd,source:Wd},gk=Object.freeze(Object.defineProperty({__proto__:null,category:Ld,default:pk,height:Dd,id:Od,name:Bd,source:Wd,svg:Fd,terminals:Hd,viewBox:zd,width:Rd},Symbol.toStringTag,{value:"Module"})),qd="genset",Gd="发电机组 (G)",Xd="source",Yd="柴油 / 燃气发电机组。",Kd="-28 -22 56 64",Vd=56,Ud=64,Jd='<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"/>',Zd=[{id:"t_out",x:0,y:40,orientation:"s"}],Qd=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],eu={kind:"inline"},yk={id:qd,name:Gd,category:Xd,description:Yd,viewBox:Kd,width:Vd,height:Ud,svg:Jd,terminals:Zd,params:Qd,source:eu},xk=Object.freeze(Object.defineProperty({__proto__:null,category:Xd,default:yk,description:Yd,height:Ud,id:qd,name:Gd,params:Qd,source:eu,svg:Jd,terminals:Zd,viewBox:Kd,width:Vd},Symbol.toStringTag,{value:"Module"})),tu="gfci-breaker",nu="GFCI 断路器 (RCBO)",ou="protection",ru="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",su="-18 -22 22 44",iu=22,au=44,lu='<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"/>',cu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],du=[{name:"open",type:"boolean",default:!1,label:"断开"}],uu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],fu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},bk={id:tu,name:nu,category:ou,description:ru,viewBox:su,width:iu,height:au,svg:lu,terminals:cu,state:du,params:uu,source:fu},wk=Object.freeze(Object.defineProperty({__proto__:null,category:ou,default:bk,description:ru,height:au,id:tu,name:nu,params:uu,source:fu,state:du,svg:lu,terminals:cu,viewBox:su,width:iu},Symbol.toStringTag,{value:"Module"})),mu="grid-source",hu="系统电源",pu="source",gu="无穷大母线 / 外部电网",yu="-16 -31 32 53",xu=32,bu=53,wu='<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"/>',vu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],ku={kind:"inline"},vk={id:mu,name:hu,category:pu,description:gu,viewBox:yu,width:xu,height:bu,svg:wu,terminals:vu,source:ku},kk=Object.freeze(Object.defineProperty({__proto__:null,category:pu,default:vk,description:gu,height:bu,id:mu,name:hu,source:ku,svg:wu,terminals:vu,viewBox:yu,width:xu},Symbol.toStringTag,{value:"Module"})),_u="grounding-transformer",$u="接地变 (Z形)",Su="grounding",ju="星-曲折接线变压器,中性点接地用",Eu="-62 -152 64 164",Nu=64,Mu=164,Tu='<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"/>',Au=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Cu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},_k={id:_u,name:$u,category:Su,description:ju,viewBox:Eu,width:Nu,height:Mu,svg:Tu,terminals:Au,source:Cu},$k=Object.freeze(Object.defineProperty({__proto__:null,category:Su,default:_k,description:ju,height:Mu,id:_u,name:$u,source:Cu,svg:Tu,terminals:Au,viewBox:Eu,width:Nu},Symbol.toStringTag,{value:"Module"})),Iu="heater",Pu="电加热器 (EH)",Ou="load",Bu="电阻加热元件 / 电热负荷。",Lu="-22 -7 54 14",zu=54,Ru=14,Du='<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"/>',Fu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Hu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Wu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},Sk={id:Iu,name:Pu,category:Ou,description:Bu,viewBox:Lu,width:zu,height:Ru,svg:Du,terminals:Fu,params:Hu,source:Wu},jk=Object.freeze(Object.defineProperty({__proto__:null,category:Ou,default:Sk,description:Bu,height:Ru,id:Iu,name:Pu,params:Hu,source:Wu,svg:Du,terminals:Fu,viewBox:Lu,width:zu},Symbol.toStringTag,{value:"Module"})),qu="igbt",Gu="绝缘栅双极晶体管 (IGBT)",Xu="passive",Yu="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Ku="-32 -32 54 74",Vu=54,Uu=74,Ju='<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"/>',Zu=[{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"}],Qu={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"},Ek={id:qu,name:Gu,category:Xu,description:Yu,viewBox:Ku,width:Vu,height:Uu,svg:Ju,terminals:Zu,source:Qu},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:Xu,default:Ek,description:Yu,height:Uu,id:qu,name:Gu,source:Qu,svg:Ju,terminals:Zu,viewBox:Ku,width:Vu},Symbol.toStringTag,{value:"Module"})),ef="indicator-light",tf="指示灯 (HL)",nf="control",of="信号 / 状态指示灯。",rf="-12 -22 24 24",sf=24,af=24,lf='<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"/>',cf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],df=[{name:"color",label:"颜色",type:"string"}],uf={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},Mk={id:ef,name:tf,category:nf,description:of,viewBox:rf,width:sf,height:af,svg:lf,terminals:cf,params:df,source:uf},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:nf,default:Mk,description:of,height:af,id:ef,name:tf,params:df,source:uf,svg:lf,terminals:cf,viewBox:rf,width:sf},Symbol.toStringTag,{value:"Module"})),ff="inductor",mf="电感 (L)",hf="passive",pf="通用电感 / 线圈 / 扼流圈。",gf="-17 -32 34 64",yf=34,xf=64,bf='<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"/>',wf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],vf=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],kf={x:6,y:0,anchor:"start"},_f={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Ak={id:ff,name:mf,category:hf,description:pf,viewBox:gf,width:yf,height:xf,svg:bf,terminals:wf,params:vf,label:kf,source:_f},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:hf,default:Ak,description:pf,height:xf,id:ff,label:kf,name:mf,params:vf,source:_f,svg:bf,terminals:wf,viewBox:gf,width:yf},Symbol.toStringTag,{value:"Module"})),$f="inverter",Sf="逆变器 (DC→AC)",jf="renewable",Ef="-42 -42 44 44",Nf=44,Mf=44,Tf='<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"/>',Af=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],Cf={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Ik={id:$f,name:Sf,category:jf,viewBox:Ef,width:Nf,height:Mf,svg:Tf,terminals:Af,source:Cf},Pk=Object.freeze(Object.defineProperty({__proto__:null,category:jf,default:Ik,height:Mf,id:$f,name:Sf,source:Cf,svg:Tf,terminals:Af,viewBox:Ef,width:Nf},Symbol.toStringTag,{value:"Module"})),If="limit-switch",Pf="限位开关 (SQ)",Of="control",Bf="行程 / 位置开关 (常开, 机械操作)。",Lf="-10 -42 12 64",zf=12,Rf=64,Df='<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"/>',Ff=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Hf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Wf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Ok={id:If,name:Pf,category:Of,description:Bf,viewBox:Lf,width:zf,height:Rf,svg:Df,terminals:Ff,state:Hf,source:Wf},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:Of,default:Ok,description:Bf,height:Rf,id:If,name:Pf,source:Wf,state:Hf,svg:Df,terminals:Ff,viewBox:Lf,width:zf},Symbol.toStringTag,{value:"Module"})),qf="load-switch",Gf="负荷开关",Xf="switching",Yf="-10 -42 14 64",Kf=14,Vf=64,Uf='<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"/>',Jf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Zf=[{name:"open",type:"boolean",default:!1,label:"断开"}],Qf={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"},Lk={id:qf,name:Gf,category:Xf,viewBox:Yf,width:Kf,height:Vf,svg:Uf,terminals:Jf,state:Zf,source:Qf},zk=Object.freeze(Object.defineProperty({__proto__:null,category:Xf,default:Lk,height:Vf,id:qf,name:Gf,source:Qf,state:Zf,svg:Uf,terminals:Jf,viewBox:Yf,width:Kf},Symbol.toStringTag,{value:"Module"})),em="load",tm="负荷",nm="load",om="抽象负荷(电流流出箭头)",rm="-8 -22 16 46",sm=16,im=46,am='<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"/>',lm=[{id:"t_top",x:0,y:-20,orientation:"n"}],cm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],dm={x:6,y:0,anchor:"start"},um={kind:"inline"},Rk={id:em,name:tm,category:nm,description:om,viewBox:rm,width:sm,height:im,svg:am,terminals:lm,params:cm,label:dm,source:um},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:nm,default:Rk,description:om,height:im,id:em,label:dm,name:tm,params:cm,source:um,svg:am,terminals:lm,viewBox:rm,width:sm},Symbol.toStringTag,{value:"Module"})),fm="make-contact",mm="常开触点 (NO)",hm="control",pm="常开辅助触点 (make contact)。",gm="-10 -42 12 64",ym=12,xm=64,bm='<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"/>',wm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],vm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],km={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"},Fk={id:fm,name:mm,category:hm,description:pm,viewBox:gm,width:ym,height:xm,svg:bm,terminals:wm,state:vm,source:km},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:hm,default:Fk,description:pm,height:xm,id:fm,name:mm,source:km,state:vm,svg:bm,terminals:wm,viewBox:gm,width:ym},Symbol.toStringTag,{value:"Module"})),_m="motor-starter",$m="电机启动器",Sm="motor-control",jm="电机启动器 (IEC 60617 通用符号)。",Em="-22 -27 44 54",Nm=44,Mm=54,Tm='<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"/>',Am=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Cm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},Wk={id:_m,name:$m,category:Sm,description:jm,viewBox:Em,width:Nm,height:Mm,svg:Tm,terminals:Am,source:Cm},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Sm,default:Wk,description:jm,height:Mm,id:_m,name:$m,source:Cm,svg:Tm,terminals:Am,viewBox:Em,width:Nm},Symbol.toStringTag,{value:"Module"})),Im="ngr",Pm="中性点电阻 (NGR)",Om="grounding",Bm="小电阻接地:连接变压器中性点到地",Lm="-12 -32 24 62",zm=24,Rm=62,Dm='<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"/>',Fm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Hm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Wm={kind:"inline"},Gk={id:Im,name:Pm,category:Om,description:Bm,viewBox:Lm,width:zm,height:Rm,svg:Dm,terminals:Fm,params:Hm,source:Wm},Xk=Object.freeze(Object.defineProperty({__proto__:null,category:Om,default:Gk,description:Bm,height:Rm,id:Im,name:Pm,params:Hm,source:Wm,svg:Dm,terminals:Fm,viewBox:Lm,width:zm},Symbol.toStringTag,{value:"Module"})),qm="overcurrent-relay",Gm="过流继电器 (50/51)",Xm="protection",Ym="过电流保护继电器 (ANSI 50/51)。",Km="-62 -62 64 64",Vm=64,Um=64,Jm='<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>',Zm=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Qm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Yk={id:qm,name:Gm,category:Xm,description:Ym,viewBox:Km,width:Vm,height:Um,svg:Jm,terminals:Zm,source:Qm},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:Xm,default:Yk,description:Ym,height:Um,id:qm,name:Gm,source:Qm,svg:Jm,terminals:Zm,viewBox:Km,width:Vm},Symbol.toStringTag,{value:"Module"})),eh="phase-failure-relay",th="断相继电器",nh="protection",oh="断相 / 缺相保护继电器。",rh="-62 -42 64 44",sh=64,ih=44,ah='<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 &lt; 3</text>',lh=[{id:"t_top",x:-30,y:-40,orientation:"n"}],ch={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Vk={id:eh,name:th,category:nh,description:oh,viewBox:rh,width:sh,height:ih,svg:ah,terminals:lh,source:ch},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:nh,default:Vk,description:oh,height:ih,id:eh,name:th,source:ch,svg:ah,terminals:lh,viewBox:rh,width:sh},Symbol.toStringTag,{value:"Module"})),dh="plc",uh="PLC / 控制器",fh="control",mh="可编程逻辑控制器 (PLC)。",hh="-24 -42 48 84",ph=48,gh=84,yh='<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"/>',xh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],bh={kind:"inline"},Jk={id:dh,name:uh,category:fh,description:mh,viewBox:hh,width:ph,height:gh,svg:yh,terminals:xh,source:bh},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:fh,default:Jk,description:mh,height:gh,id:dh,name:uh,source:bh,svg:yh,terminals:xh,viewBox:hh,width:ph},Symbol.toStringTag,{value:"Module"})),wh="power-factor-meter",vh="功率因数表 (cosφ)",kh="measurement",_h="功率因数表 (cosφ)。",$h="-22 -42 44 44",Sh=44,jh=44,Eh='<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>',Nh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Mh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},Qk={id:wh,name:vh,category:kh,description:_h,viewBox:$h,width:Sh,height:jh,svg:Eh,terminals:Nh,source:Mh},e_=Object.freeze(Object.defineProperty({__proto__:null,category:kh,default:Qk,description:_h,height:jh,id:wh,name:vh,source:Mh,svg:Eh,terminals:Nh,viewBox:$h,width:Sh},Symbol.toStringTag,{value:"Module"})),Th="power-supply",Ah="开关电源 (PS)",Ch="source",Ih="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Ph="-24 -42 48 84",Oh=48,Bh=84,Lh='<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"/>',zh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],Rh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Dh={kind:"inline"},t_={id:Th,name:Ah,category:Ch,description:Ih,viewBox:Ph,width:Oh,height:Bh,svg:Lh,terminals:zh,params:Rh,source:Dh},n_=Object.freeze(Object.defineProperty({__proto__:null,category:Ch,default:t_,description:Ih,height:Bh,id:Th,name:Ah,params:Rh,source:Dh,svg:Lh,terminals:zh,viewBox:Ph,width:Oh},Symbol.toStringTag,{value:"Module"})),Fh="protective-relay",Hh="保护继电器",Wh="protection",qh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Gh="-32 -42 64 44",Xh=64,Yh=44,Kh='<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"/>',Vh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Uh={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"},o_={id:Fh,name:Hh,category:Wh,description:qh,viewBox:Gh,width:Xh,height:Yh,svg:Kh,terminals:Vh,source:Uh},r_=Object.freeze(Object.defineProperty({__proto__:null,category:Wh,default:o_,description:qh,height:Yh,id:Fh,name:Hh,source:Uh,svg:Kh,terminals:Vh,viewBox:Gh,width:Xh},Symbol.toStringTag,{value:"Module"})),Jh="proximity-switch",Zh="接近开关 (SQ)",Qh="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"},s_={id:Jh,name:Zh,category:Qh,description:e0,viewBox:t0,width:n0,height:o0,svg:r0,terminals:s0,source:i0},i_=Object.freeze(Object.defineProperty({__proto__:null,category:Qh,default:s_,description:e0,height:o0,id:Jh,name:Zh,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,m0='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',h0=[{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"},a_={id:a0,name:l0,category:c0,viewBox:d0,width:u0,height:f0,svg:m0,terminals:h0,source:p0},l_=Object.freeze(Object.defineProperty({__proto__:null,category:c0,default:a_,height:f0,id:a0,name:l0,source:p0,svg:m0,terminals:h0,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"/>',$0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],S0={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"},c_={id:g0,name:y0,category:x0,description:b0,viewBox:w0,width:v0,height:k0,svg:_0,terminals:$0,source:S0},d_=Object.freeze(Object.defineProperty({__proto__:null,category:x0,default:c_,description:b0,height:k0,id:g0,name:y0,source:S0,svg:_0,terminals:$0,viewBox:w0,width:v0},Symbol.toStringTag,{value:"Module"})),j0="pv",E0="光伏组件",N0="renewable",M0="-33 -22 85 64",T0=85,A0=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"/>',I0=[{id:"t_dc",x:50,y:10,orientation:"e"}],P0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},u_={id:j0,name:E0,category:N0,viewBox:M0,width:T0,height:A0,svg:C0,terminals:I0,source:P0},f_=Object.freeze(Object.defineProperty({__proto__:null,category:N0,default:u_,height:A0,id:j0,name:E0,source:P0,svg:C0,terminals:I0,viewBox:M0,width:T0},Symbol.toStringTag,{value:"Module"})),O0="rcd",B0="剩余电流装置 (RCD)",L0="protection",z0="不带过流保护的剩余电流断路器 (IEC 61008)。",R0="-12 -22 19 44",D0=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:"断开"}],G0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],X0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},m_={id:O0,name:B0,category:L0,description:z0,viewBox:R0,width:D0,height:F0,svg:H0,terminals:W0,state:q0,params:G0,source:X0},h_=Object.freeze(Object.defineProperty({__proto__:null,category:L0,default:m_,description:z0,height:F0,id:O0,name:B0,params:G0,source:X0,state:q0,svg:H0,terminals:W0,viewBox:R0,width:D0},Symbol.toStringTag,{value:"Module"})),Y0="recloser",K0="重合闸 (Recloser)",V0="protection",U0="中压自动重合闸开关。",J0="-12 -32 36 64",Z0=36,Q0=64,ep='<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>',tp=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],np=[{name:"open",type:"boolean",default:!1,label:"断开"}],op={kind:"inline"},p_={id:Y0,name:K0,category:V0,description:U0,viewBox:J0,width:Z0,height:Q0,svg:ep,terminals:tp,state:np,source:op},g_=Object.freeze(Object.defineProperty({__proto__:null,category:V0,default:p_,description:U0,height:Q0,id:Y0,name:K0,source:op,state:np,svg:ep,terminals:tp,viewBox:J0,width:Z0},Symbol.toStringTag,{value:"Module"})),rp="rectifier",sp="整流器 (AC→DC)",ip="renewable",ap="-42 -42 44 44",lp=44,cp=44,dp='<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"/>',up=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],fp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},y_={id:rp,name:sp,category:ip,viewBox:ap,width:lp,height:cp,svg:dp,terminals:up,source:fp},x_=Object.freeze(Object.defineProperty({__proto__:null,category:ip,default:y_,height:cp,id:rp,name:sp,source:fp,svg:dp,terminals:up,viewBox:ap,width:lp},Symbol.toStringTag,{value:"Module"})),mp="relay-coil",hp="继电器线圈 (KA)",pp="control",gp="继电器 / 接触器操作线圈 (方框)。",yp="-22 -22 44 44",xp=44,bp=44,wp='<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"/>',vp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],kp={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"},b_={id:mp,name:hp,category:pp,description:gp,viewBox:yp,width:xp,height:bp,svg:wp,terminals:vp,source:kp},w_=Object.freeze(Object.defineProperty({__proto__:null,category:pp,default:b_,description:gp,height:bp,id:mp,name:hp,source:kp,svg:wp,terminals:vp,viewBox:yp,width:xp},Symbol.toStringTag,{value:"Module"})),_p="resistor",$p="电阻 (R)",Sp="passive",jp="通用电阻 / 限流 / 制动电阻。",Ep="-6 -23 12 35",Np=12,Mp=35,Tp='<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"/>',Ap=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Cp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Ip={x:6,y:0,anchor:"start"},Pp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},v_={id:_p,name:$p,category:Sp,description:jp,viewBox:Ep,width:Np,height:Mp,svg:Tp,terminals:Ap,params:Cp,label:Ip,source:Pp},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Sp,default:v_,description:jp,height:Mp,id:_p,label:Ip,name:$p,params:Cp,source:Pp,svg:Tp,terminals:Ap,viewBox:Ep,width:Np},Symbol.toStringTag,{value:"Module"})),Op="reverse-power-relay",Bp="逆功率继电器 (32)",Lp="protection",zp="逆功率 / 逆流保护继电器 (ANSI 32)。",Rp="-62 -42 64 44",Dp=64,Fp=44,Hp='<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"/>',Wp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],qp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},__={id:Op,name:Bp,category:Lp,description:zp,viewBox:Rp,width:Dp,height:Fp,svg:Hp,terminals:Wp,source:qp},$_=Object.freeze(Object.defineProperty({__proto__:null,category:Lp,default:__,description:zp,height:Fp,id:Op,name:Bp,source:qp,svg:Hp,terminals:Wp,viewBox:Rp,width:Dp},Symbol.toStringTag,{value:"Module"})),Gp="selector-switch",Xp="选择开关 (SA)",Yp="switching",Kp="转换 / 选择开关 (旋转操作, 保位)。",Vp="-34 -42 36 64",Up=36,Jp=64,Zp='<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"/>',Qp=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],eg=[{name:"open",type:"boolean",default:!1,label:"断开"}],tg={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"},S_={id:Gp,name:Xp,category:Yp,description:Kp,viewBox:Vp,width:Up,height:Jp,svg:Zp,terminals:Qp,state:eg,source:tg},j_=Object.freeze(Object.defineProperty({__proto__:null,category:Yp,default:S_,description:Kp,height:Jp,id:Gp,name:Xp,source:tg,state:eg,svg:Zp,terminals:Qp,viewBox:Vp,width:Up},Symbol.toStringTag,{value:"Module"})),ng="series-reactor",og="串联电抗器",rg="compensation",sg="与并联电抗器同符号;通过用法区分。",ig="-62 -82 64 104",ag=64,lg=104,cg='<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"/>',dg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],ug={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},E_={id:ng,name:og,category:rg,description:sg,viewBox:ig,width:ag,height:lg,svg:cg,terminals:dg,source:ug},N_=Object.freeze(Object.defineProperty({__proto__:null,category:rg,default:E_,description:sg,height:lg,id:ng,name:og,source:ug,svg:cg,terminals:dg,viewBox:ig,width:ag},Symbol.toStringTag,{value:"Module"})),fg="shunt-capacitor",mg="并联电容器",hg="compensation",pg="-7 -23 14 27",gg=14,yg=27,xg='<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"/>',bg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],wg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],vg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},M_={id:fg,name:mg,category:hg,viewBox:pg,width:gg,height:yg,svg:xg,terminals:bg,params:wg,source:vg},T_=Object.freeze(Object.defineProperty({__proto__:null,category:hg,default:M_,height:yg,id:fg,name:mg,params:wg,source:vg,svg:xg,terminals:bg,viewBox:pg,width:gg},Symbol.toStringTag,{value:"Module"})),kg="shunt-reactor",_g="并联电抗器",$g="compensation",Sg="-62 -82 64 104",jg=64,Eg=104,Ng='<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"/>',Mg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Tg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},A_={id:kg,name:_g,category:$g,viewBox:Sg,width:jg,height:Eg,svg:Ng,terminals:Mg,source:Tg},C_=Object.freeze(Object.defineProperty({__proto__:null,category:$g,default:A_,height:Eg,id:kg,name:_g,source:Tg,svg:Ng,terminals:Mg,viewBox:Sg,width:jg},Symbol.toStringTag,{value:"Module"})),Ag="siren",Cg="警笛 (HA)",Ig="control",Pg="声响警笛 / 报警器。",Og="-32 -42 44 54",Bg=44,Lg=54,zg='<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"/>',Rg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Dg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},I_={id:Ag,name:Cg,category:Ig,description:Pg,viewBox:Og,width:Bg,height:Lg,svg:zg,terminals:Rg,source:Dg},P_=Object.freeze(Object.defineProperty({__proto__:null,category:Ig,default:I_,description:Pg,height:Lg,id:Ag,name:Cg,source:Dg,svg:zg,terminals:Rg,viewBox:Og,width:Bg},Symbol.toStringTag,{value:"Module"})),Fg="socket-outlet",Hg="插座 / 连接器",Wg="load",qg="电源插座 / 多极连接器。",Gg="-7 -2 13 34",Xg=13,Yg=34,Kg='<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"/>',Vg=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Ug={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
197
- unifilar`},O_={id:Fg,name:Hg,category:Wg,description:qg,viewBox:Gg,width:Xg,height:Yg,svg:Kg,terminals:Vg,source:Ug},B_=Object.freeze(Object.defineProperty({__proto__:null,category:Wg,default:O_,description:qg,height:Yg,id:Fg,name:Hg,source:Ug,svg:Kg,terminals:Vg,viewBox:Gg,width:Xg},Symbol.toStringTag,{value:"Module"})),Jg="soft-starter",Zg="软启动器",Qg="motor-control",e1="电机软启动器 (晶闸管降压启动)。",t1="-22 -42 44 84",n1=44,o1=84,r1='<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"/>',s1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],i1={kind:"inline"},L_={id:Jg,name:Zg,category:Qg,description:e1,viewBox:t1,width:n1,height:o1,svg:r1,terminals:s1,source:i1},z_=Object.freeze(Object.defineProperty({__proto__:null,category:Qg,default:L_,description:e1,height:o1,id:Jg,name:Zg,source:i1,svg:r1,terminals:s1,viewBox:t1,width:n1},Symbol.toStringTag,{value:"Module"})),a1="sync-motor",l1="同步电动机",c1="load",d1="-62 -82 64 114",u1=64,f1=114,m1='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',h1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],p1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},R_={id:a1,name:l1,category:c1,viewBox:d1,width:u1,height:f1,svg:m1,terminals:h1,source:p1},D_=Object.freeze(Object.defineProperty({__proto__:null,category:c1,default:R_,height:f1,id:a1,name:l1,source:p1,svg:m1,terminals:h1,viewBox:d1,width:u1},Symbol.toStringTag,{value:"Module"})),g1="synchronoscope",y1="同步表",x1="measurement",b1="同步指示器 / 同步表。",w1="-22 -42 44 44",v1=44,k1=44,_1='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',$1=[{id:"t_top",x:0,y:-40,orientation:"n"}],S1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},F_={id:g1,name:y1,category:x1,description:b1,viewBox:w1,width:v1,height:k1,svg:_1,terminals:$1,source:S1},H_=Object.freeze(Object.defineProperty({__proto__:null,category:x1,default:F_,description:b1,height:k1,id:g1,name:y1,source:S1,svg:_1,terminals:$1,viewBox:w1,width:v1},Symbol.toStringTag,{value:"Module"})),j1="terminal",E1="接线端子 / 节点 (X)",N1="busbar",M1="接线端子 / 接线盒 / 汇接节点。",T1="-5 -5 10 10",A1=10,C1=10,I1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',P1=[{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"}],O1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},W_={id:j1,name:E1,category:N1,description:M1,viewBox:T1,width:A1,height:C1,svg:I1,terminals:P1,source:O1},q_=Object.freeze(Object.defineProperty({__proto__:null,category:N1,default:W_,description:M1,height:C1,id:j1,name:E1,source:O1,svg:I1,terminals:P1,viewBox:T1,width:A1},Symbol.toStringTag,{value:"Module"})),B1="thermal-overload",L1="热过载继电器",z1="motor-control",R1="电机热过载保护继电器, 通常串接在接触器和电机之间。",D1="-9 -32 19 64",F1=19,H1=64,W1='<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"/>',q1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],G1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],X1={kind:"inline"},G_={id:B1,name:L1,category:z1,description:R1,viewBox:D1,width:F1,height:H1,svg:W1,terminals:q1,state:G1,source:X1},X_=Object.freeze(Object.defineProperty({__proto__:null,category:z1,default:G_,description:R1,height:H1,id:B1,name:L1,source:X1,state:G1,svg:W1,terminals:q1,viewBox:D1,width:F1},Symbol.toStringTag,{value:"Module"})),Y1="thermocouple",K1="热电偶 (BT)",V1="measurement",U1="热电偶温度传感器。",J1="-26 -42 52 46",Z1=52,Q1=46,ey='<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"/>',ty=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],ny={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},Y_={id:Y1,name:K1,category:V1,description:U1,viewBox:J1,width:Z1,height:Q1,svg:ey,terminals:ty,source:ny},K_=Object.freeze(Object.defineProperty({__proto__:null,category:V1,default:Y_,description:U1,height:Q1,id:Y1,name:K1,source:ny,svg:ey,terminals:ty,viewBox:J1,width:Z1},Symbol.toStringTag,{value:"Module"})),oy="thyristor",ry="晶闸管 (V)",sy="passive",iy="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ay="-22 -42 34 44",ly=34,cy=44,dy='<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"/>',uy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fy={x:6,y:-20,anchor:"start"},my={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},V_={id:oy,name:ry,category:sy,description:iy,viewBox:ay,width:ly,height:cy,svg:dy,terminals:uy,label:fy,source:my},U_=Object.freeze(Object.defineProperty({__proto__:null,category:sy,default:V_,description:iy,height:cy,id:oy,label:fy,name:ry,source:my,svg:dy,terminals:uy,viewBox:ay,width:ly},Symbol.toStringTag,{value:"Module"})),hy="time-relay",py="时间继电器 (KT)",gy="control",yy="延时 (缓动) 继电器线圈。",xy="-32 -22 54 44",by=54,wy=44,vy='<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"/>',ky=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_y={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},J_={id:hy,name:py,category:gy,description:yy,viewBox:xy,width:by,height:wy,svg:vy,terminals:ky,source:_y},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:gy,default:J_,description:yy,height:wy,id:hy,name:py,source:_y,svg:vy,terminals:ky,viewBox:xy,width:by},Symbol.toStringTag,{value:"Module"})),$y="transfer-switch",Sy="切换开关 (ATS)",jy="switching",Ey="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Ny="-27 -32 51 64",My=51,Ty=64,Ay='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',Cy=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],Iy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Py={kind:"inline"},Q_={id:$y,name:Sy,category:jy,description:Ey,viewBox:Ny,width:My,height:Ty,svg:Ay,terminals:Cy,state:Iy,source:Py},e$=Object.freeze(Object.defineProperty({__proto__:null,category:jy,default:Q_,description:Ey,height:Ty,id:$y,name:Sy,source:Py,state:Iy,svg:Ay,terminals:Cy,viewBox:Ny,width:My},Symbol.toStringTag,{value:"Module"})),Oy="transformer-2w",By="双绕组变压器",Ly="transformer",zy="-62 -142 64 144",Ry=64,Dy=144,Fy='<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"/>',Hy=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Wy=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],qy={x:4,y:-68,anchor:"start"},Gy={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"},t$={id:Oy,name:By,category:Ly,viewBox:zy,width:Ry,height:Dy,svg:Fy,terminals:Hy,params:Wy,label:qy,source:Gy},n$=Object.freeze(Object.defineProperty({__proto__:null,category:Ly,default:t$,height:Dy,id:Oy,label:qy,name:By,params:Wy,source:Gy,svg:Fy,terminals:Hy,viewBox:zy,width:Ry},Symbol.toStringTag,{value:"Module"})),Xy="transformer-3w",Yy="三绕组变压器",Ky="transformer",Vy="-82 -131 114 133",Uy=114,Jy=133,Zy='<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"/>',Qy=[{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"}],ex={x:4,y:-64,anchor:"start"},tx={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},o$={id:Xy,name:Yy,category:Ky,viewBox:Vy,width:Uy,height:Jy,svg:Zy,terminals:Qy,label:ex,source:tx},r$=Object.freeze(Object.defineProperty({__proto__:null,category:Ky,default:o$,height:Jy,id:Xy,label:ex,name:Yy,source:tx,svg:Zy,terminals:Qy,viewBox:Vy,width:Uy},Symbol.toStringTag,{value:"Module"})),nx="triac",ox="双向晶闸管 (V)",rx="passive",sx="双向三极晶闸管 (TRIAC)。",ix="-22 -42 44 44",ax=44,lx=44,cx='<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"/>',dx=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],ux={x:6,y:-20,anchor:"start"},fx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},s$={id:nx,name:ox,category:rx,description:sx,viewBox:ix,width:ax,height:lx,svg:cx,terminals:dx,label:ux,source:fx},i$=Object.freeze(Object.defineProperty({__proto__:null,category:rx,default:s$,description:sx,height:lx,id:nx,label:ux,name:ox,source:fx,svg:cx,terminals:dx,viewBox:ix,width:ax},Symbol.toStringTag,{value:"Module"})),mx="undervoltage-relay",hx="欠压继电器 (27)",px="protection",gx="欠电压保护继电器 (ANSI 27)。",yx="-62 -82 64 84",xx=64,bx=84,wx='<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 &lt;</text>',vx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],kx={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},a$={id:mx,name:hx,category:px,description:gx,viewBox:yx,width:xx,height:bx,svg:wx,terminals:vx,source:kx},l$=Object.freeze(Object.defineProperty({__proto__:null,category:px,default:a$,description:gx,height:bx,id:mx,name:hx,source:kx,svg:wx,terminals:vx,viewBox:yx,width:xx},Symbol.toStringTag,{value:"Module"})),_x="ups",$x="不间断电源 (UPS)",Sx="source",jx="在线 / 后备式不间断电源。",Ex="-26 -42 52 84",Nx=52,Mx=84,Tx='<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"/>',Ax=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Cx=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Ix={kind:"inline"},c$={id:_x,name:$x,category:Sx,description:jx,viewBox:Ex,width:Nx,height:Mx,svg:Tx,terminals:Ax,params:Cx,source:Ix},d$=Object.freeze(Object.defineProperty({__proto__:null,category:Sx,default:c$,description:jx,height:Mx,id:_x,name:$x,params:Cx,source:Ix,svg:Tx,terminals:Ax,viewBox:Ex,width:Nx},Symbol.toStringTag,{value:"Module"})),Px="varmeter",Ox="无功功率表 (var)",Bx="measurement",Lx="无功功率表 (var)。",zx="-22 -42 44 44",Rx=44,Dx=44,Fx='<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>',Hx=[{id:"t_top",x:0,y:-40,orientation:"n"}],Wx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},u$={id:Px,name:Ox,category:Bx,description:Lx,viewBox:zx,width:Rx,height:Dx,svg:Fx,terminals:Hx,source:Wx},f$=Object.freeze(Object.defineProperty({__proto__:null,category:Bx,default:u$,description:Lx,height:Dx,id:Px,name:Ox,source:Wx,svg:Fx,terminals:Hx,viewBox:zx,width:Rx},Symbol.toStringTag,{value:"Module"})),qx="vfd",Gx="变频器 (VFD)",Xx="motor-control",Yx="Variable Frequency Drive — 异步电动机调速。",Kx="-24 -42 48 84",Vx=48,Ux=84,Jx='<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"/>',Zx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Qx={kind:"inline"},m$={id:qx,name:Gx,category:Xx,description:Yx,viewBox:Kx,width:Vx,height:Ux,svg:Jx,terminals:Zx,source:Qx},h$=Object.freeze(Object.defineProperty({__proto__:null,category:Xx,default:m$,description:Yx,height:Ux,id:qx,name:Gx,source:Qx,svg:Jx,terminals:Zx,viewBox:Kx,width:Vx},Symbol.toStringTag,{value:"Module"})),eb="voltage-regulator",tb="调压器 (T)",nb="transformer",ob="可调感应调压器 / 自耦调压器。",rb="-17 -32 38 64",sb=38,ib=64,ab='<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"/>',lb=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],cb=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],db={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},p$={id:eb,name:tb,category:nb,description:ob,viewBox:rb,width:sb,height:ib,svg:ab,terminals:lb,params:cb,source:db},g$=Object.freeze(Object.defineProperty({__proto__:null,category:nb,default:p$,description:ob,height:ib,id:eb,name:tb,params:cb,source:db,svg:ab,terminals:lb,viewBox:rb,width:sb},Symbol.toStringTag,{value:"Module"})),ub="voltmeter",fb="电压表 (V)",mb="measurement",hb="-22 -42 44 44",pb=44,gb=44,yb='<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>',xb=[{id:"t_top",x:0,y:-40,orientation:"n"}],bb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},y$={id:ub,name:fb,category:mb,viewBox:hb,width:pb,height:gb,svg:yb,terminals:xb,source:bb},x$=Object.freeze(Object.defineProperty({__proto__:null,category:mb,default:y$,height:gb,id:ub,name:fb,source:bb,svg:yb,terminals:xb,viewBox:hb,width:pb},Symbol.toStringTag,{value:"Module"})),wb="wattmeter",vb="功率表 (W)",kb="measurement",_b="-22 -42 44 44",$b=44,Sb=44,jb='<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>',Eb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Nb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},b$={id:wb,name:vb,category:kb,viewBox:_b,width:$b,height:Sb,svg:jb,terminals:Eb,source:Nb},w$=Object.freeze(Object.defineProperty({__proto__:null,category:kb,default:b$,height:Sb,id:wb,name:vb,source:Nb,svg:jb,terminals:Eb,viewBox:_b,width:$b},Symbol.toStringTag,{value:"Module"})),Mb="wind-turbine",Tb="风力发电机",Ab="renewable",Cb="风机:发电机 + 三叶轮标记",Ib="-22 -46 44 68",Pb=44,Ob=68,Bb='<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"/>',Lb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],zb={kind:"inline"},v$={id:Mb,name:Tb,category:Ab,description:Cb,viewBox:Ib,width:Pb,height:Ob,svg:Bb,terminals:Lb,source:zb},k$=Object.freeze(Object.defineProperty({__proto__:null,category:Ab,default:v$,description:Cb,height:Ob,id:Mb,name:Tb,source:zb,svg:Bb,terminals:Lb,viewBox:Ib,width:Pb},Symbol.toStringTag,{value:"Module"})),Rb="zener-diode",Db="稳压二极管 (D)",Fb="passive",Hb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",Wb="-12 -42 24 44",qb=24,Gb=44,Xb='<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"/>',Yb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Kb={x:6,y:-20,anchor:"start"},Vb={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},_$={id:Rb,name:Db,category:Fb,description:Hb,viewBox:Wb,width:qb,height:Gb,svg:Xb,terminals:Yb,label:Kb,source:Vb},$$=Object.freeze(Object.defineProperty({__proto__:null,category:Fb,default:_$,description:Hb,height:Gb,id:Rb,label:Kb,name:Db,source:Vb,svg:Xb,terminals:Yb,viewBox:Wb,width:qb},Symbol.toStringTag,{value:"Module"})),S$=Object.assign({"./ammeter.json":f2,"./arc-suppression-coil.json":h2,"./arrester.json":g2,"./async-motor.json":x2,"./autotransformer.json":w2,"./battery.json":k2,"./bell.json":$2,"./break-contact.json":j2,"./breaker.json":N2,"./buchholz-relay.json":T2,"./busbar.json":C2,"./buzzer.json":P2,"./capacitor.json":B2,"./contactor.json":z2,"./converter-bidir.json":D2,"./ct.json":H2,"./dc-combiner.json":q2,"./dc-disconnector.json":X2,"./dc-motor.json":K2,"./diode.json":U2,"./disconnector.json":Z2,"./distance-relay.json":ek,"./earth.json":nk,"./earthing-switch.json":rk,"./energy-meter.json":ik,"./ev-charger.json":lk,"./frequency-meter.json":dk,"./fuse-switch-disconnector.json":fk,"./fuse.json":hk,"./generator.json":gk,"./genset.json":xk,"./gfci-breaker.json":wk,"./grid-source.json":kk,"./grounding-transformer.json":$k,"./heater.json":jk,"./igbt.json":Nk,"./indicator-light.json":Tk,"./inductor.json":Ck,"./inverter.json":Pk,"./limit-switch.json":Bk,"./load-switch.json":zk,"./load.json":Dk,"./make-contact.json":Hk,"./motor-starter.json":qk,"./ngr.json":Xk,"./overcurrent-relay.json":Kk,"./phase-failure-relay.json":Uk,"./plc.json":Zk,"./power-factor-meter.json":e_,"./power-supply.json":n_,"./protective-relay.json":r_,"./proximity-switch.json":i_,"./pt.json":l_,"./push-button.json":d_,"./pv.json":f_,"./rcd.json":h_,"./recloser.json":g_,"./rectifier.json":x_,"./relay-coil.json":w_,"./resistor.json":k_,"./reverse-power-relay.json":$_,"./selector-switch.json":j_,"./series-reactor.json":N_,"./shunt-capacitor.json":T_,"./shunt-reactor.json":C_,"./siren.json":P_,"./socket-outlet.json":B_,"./soft-starter.json":z_,"./sync-motor.json":D_,"./synchronoscope.json":H_,"./terminal.json":q_,"./thermal-overload.json":X_,"./thermocouple.json":K_,"./thyristor.json":U_,"./time-relay.json":Z_,"./transfer-switch.json":e$,"./transformer-2w.json":n$,"./transformer-3w.json":r$,"./triac.json":i$,"./undervoltage-relay.json":l$,"./ups.json":d$,"./varmeter.json":f$,"./vfd.json":h$,"./voltage-regulator.json":g$,"./voltmeter.json":x$,"./wattmeter.json":w$,"./wind-turbine.json":k$,"./zener-diode.json":$$}),Ub=Object.values(S$).map(e=>e.default),Ke=Object.fromEntries(Ub.map(e=>[e.id,e])),Wo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],j$=(()=>{var t;const e={};for(const n of Ub)(e[t=n.category]??(e[t]=[])).push(n);return e})(),In=new Map(Object.entries(Ke));function Jb(e){return Ke[e]}function E$(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 N$=320;function Xe(e){var h,y,w,$,k;const t=rs(),n=new Map;e.elements.forEach((b,S)=>{if(n.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/elements/${S}`});return}n.set(b.id,b);const C=In.get(b.kind);C||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:b.kind})} (id=${b.id})`,pointer:`/elements/${S}`}),t.elements.set(b.id,{element:b,libraryDef:C})});const o=new Map,r=new Map;(e.buses??[]).forEach((b,S)=>{if(n.has(b.id)||o.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/buses/${S}`});return}if(o.set(b.id,b),b.layout){const C=b.layout.rot??0;r.set(b.id,{at:b.layout.at,span:b.layout.span,rot:C,axis:An(C)})}});const s=new Map;(e.junctions??[]).forEach((b,S)=>{if(n.has(b.id)||o.has(b.id)||s.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/junctions/${S}`});return}s.set(b.id,b)});const i=b=>!b.includes(".")&&o.has(b),a=b=>!b.includes(".")&&s.has(b),l=(b,S)=>{if(i(b)||a(b))return!0;const C=b.indexOf(".");if(C<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:b}),pointer:S}),!1;const R=b.slice(0,C),X=b.slice(C+1),V=t.elements.get(R);if(!V)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:R}),pointer:S}),!1;if(!V.libraryDef)return!1;if(!V.libraryDef.terminals.find(te=>te.id===X)){const te=V.libraryDef.terminals.map(ae=>ae.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:R,kind:V.element.kind,pin:X,available:te}),pointer:S}),!1}return!0},d=[];(e.wires??[]).forEach((b,S)=>{const C=`/wires/${S}`,R=l(b.ends[0],C),X=l(b.ends[1],C);R&&X&&d.push(b)});const u=new Map;if(e.layout)for(const[b,S]of Object.entries(e.layout))t.elements.has(b)?u.set(b,ss(S)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:b}),pointer:`/layout/${b}`});const f=c2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:d,library:In,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[b,S]of f.buses){const C=o.get(b);C&&t.buses.set(b,{bus:C,geometry:S})}for(const[b,S]of o)t.buses.has(b)||t.buses.set(b,{bus:S,geometry:{at:((h=S.layout)==null?void 0:h.at)??[0,0],span:((y=S.layout)==null?void 0:y.span)??N$,rot:((w=S.layout)==null?void 0:w.rot)??0,axis:An((($=S.layout)==null?void 0:$.rot)??0)}});for(const b of t.elements.values()){if(!b.libraryDef)continue;const S=t.layout.get(b.element.id);if(!S)continue;const C=[];for(const R of b.libraryDef.terminals){const X=`${b.element.id}.${R.id}`,V=Pe([R.x,R.y],S),te=St(R.orientation,S);t.terminals.set(X,{ref:X,elementId:b.element.id,pin:R.id,world:V,orientation:te}),C.push(X)}t.elementToTerminals.set(b.element.id,C)}const m=b=>{if(!b.includes(".")){const C=t.buses.get(b);return C?C.geometry.at:null}const S=t.terminals.get(b);return S?S.world:null};for(const[b,S]of s){let C;if((k=S.layout)!=null&&k.at)C=[S.layout.at[0],S.layout.at[1]];else if(f.junctions.has(b))C=f.junctions.get(b);else{const R=[];for(const X of d){const[V,te]=X.ends,ae=V===b?te:te===b?V:null;if(ae===null)continue;const D=m(ae);D&&R.push(D)}C=R.length?[R.reduce((X,V)=>X+V[0],0)/R.length,R.reduce((X,V)=>X+V[1],0)/R.length]:[0,0]}t.junctions.set(b,{junction:S,world:C})}const p=new is;for(const b of d)p.add(b.ends[0]),p.add(b.ends[1]),p.union(b.ends[0],b.ends[1]);for(const[,b]of p.groups()){const S=E$(b);t.nodes.set(S,{id:S,terminals:b});for(const C of b)t.terminalToNode.set(C,S)}for(const b of t.elements.values()){const S=t.elementToTerminals.get(b.element.id)??[];if(S.length===0)continue;S.some(R=>t.terminalToNode.has(R))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b.element.id})})}for(const b of t.buses.keys())t.terminalToNode.has(b)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b})});for(const b of t.junctions.keys())t.terminalToNode.has(b)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b})});for(const b of d){if(b.path&&b.path.length>=2){const C=b.path,R=C.length>=2?C[1]:null,X=C.length>=2?C[C.length-2]:null,V=Fo(b.ends[0],R,t),te=Fo(b.ends[1],X,t);if(V&&te){const ae=[[V[0],V[1]],...C.slice(1,-1).map(W=>[W[0],W[1]]),[te[0],te[1]]],D=os(ae);if(D.length>=2){t.wireRenders.set(b.id,{wireId:b.id,path:D,userEdited:!0});continue}}}const S=d2(b,t);S&&t.wireRenders.set(b.id,S)}return t}const M$={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"},qo="B",Go="J";function Jn(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Nt(e,t){const n=M$[t]??t,o=Jn(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Pn(e){const t=Jn(e);let n=1;for(;t.has(`${qo}${n}`);)n++;return`${qo}${n}`}function On(e){const t=Jn(e);let n=1;for(;t.has(`${Go}${n}`);)n++;return`${Go}${n}`}function T$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Je(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}const Xo={version:"1",elements:[]},A$=100,Yo=20;function C$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=Jt()(n2((e,t)=>({diagram:Xo,internal:Xe(Xo),fileSession:null,activeTool:C$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal: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}),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:r}=t(),s=n(o);if(s===o)return;const i=r.length>=A$?r.slice(1):r;e({diagram:s,internal:Xe(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:Xe(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:Xe(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:I$(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var m;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>s.has(p.id)).map(p=>{var y;const h=structuredClone(p);if(!h.layout){const w=(y=r.junctions.get(p.id))==null?void 0:y.world;w&&(h.layout={at:[w[0],w[1]]})}return h}),d={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const h=(m=o.layout)==null?void 0:m[p];if(h){d[p]=structuredClone(h);continue}const y=r.layout.get(p);y&&(d[p]=Lt(y))}const u={};for(const p of n){const h=r.buses.get(p);h&&(u[p]=tt(h.geometry))}const f=(o.wires??[]).filter(p=>p.ends.every(h=>s.has(gn(h)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,junctions:l,placements:d,busLayouts:u,wires:f},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0&&n.junctions.length===0)return;const s=o+1,i=Yo*s,a=Yo*s,l=new Map;let d=r;for(const f of n.elements){const m=Nt(d,f.kind);l.set(f.id,m),d={...d,elements:[...d.elements,{id:m,kind:f.kind}]}}for(const f of n.buses){const m=Pn(d);l.set(f.id,m),d={...d,buses:[...d.buses??[],{id:m}]}}for(const f of n.junctions){const m=On(d);l.set(f.id,m),d={...d,junctions:[...d.junctions??[],{id:m}]}}const u=f=>{const m=f.indexOf("."),p=m<0?f:f.slice(0,m),h=l.get(p);return h?m<0?h:`${h}${f.slice(m)}`:f};t().dispatch(f=>{const m=n.elements.map(k=>{const b=structuredClone(k);return b.id=l.get(k.id),b}),p=n.buses.map(k=>{const b=structuredClone(k);b.id=l.get(k.id);const S=n.busLayouts[k.id];return S&&(b.layout={...S,at:[S.at[0]+i,S.at[1]+a]}),b}),h=n.junctions.map(k=>{const b=structuredClone(k);return b.id=l.get(k.id),b.layout&&(b.layout={at:[b.layout.at[0]+i,b.layout.at[1]+a]}),b}),y={...f.layout??{}};for(const[k,b]of l){const S=n.placements[k];S&&(y[b]={...S,at:[S.at[0]+i,S.at[1]+a]})}const w=n.wires.map(k=>{const b=[u(k.ends[0]),u(k.ends[1])];return{id:Je(b[0],b[1]),ends:b}}),$=Ko(f.wires??[],w);return{...f,elements:[...f.elements,...m],buses:p.length?[...f.buses??[],...p]:f.buses,junctions:h.length?[...f.junctions??[],...h]:f.junctions,wires:$.length?$:void 0,layout:Object.keys(y).length?y:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(d=>d.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(d=>{const{layout:u,...f}=d;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[d,u]of Object.entries(i)){if(o.has(d)){s=!0;continue}l[d]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(d=>{if(o.has(d.id)&&d.layout){s=!0;const{layout:u,...f}=d;return f}return d});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const d=n.layout.get(l.id);d&&(s[l.id]=Lt(d))}const i=[];if((o.buses??[]).forEach((l,d)=>{l.layout||n.buses.has(l.id)&&i.push({idx:d,bus:l})}),Object.keys(s).length===0&&i.length===0)return o;let a=o.buses;return i.length>0&&a&&(a=a.map(l=>{const d=n.buses.get(l.id);return!l.layout&&d?{...l,layout:tt(d.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var d;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(d=r.buses)!=null&&d.find(m=>m.id===u&&m.layout)||a.set(u,tt(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=Lt(f))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const m=o.layout.get(u),p=s[u]??(m?Lt(m):{at:[0,0]});s[u]={...p,at:[p.at[0]+f[0],p.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const m=u.layout??tt(o.buses.get(u.id).geometry);return{...u,layout:{...m,at:[m.at[0]+f[0],m.at[1]+f[1]]}}}));let d=r.junctions;return a.size>0&&(d=(r.junctions??[]).map(u=>{var p,h;const f=a.get(u.id);if(!f)return u;const m=((p=u.layout)==null?void 0:p.at)??((h=o.junctions.get(u.id))==null?void 0:h.world)??[0,0];return{...u,layout:{at:[m[0]+f[0],m[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:d}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(u=>!o.has(u.id)),i=(r.buses??[]).filter(u=>!o.has(u.id)),a=(r.junctions??[]).filter(u=>!o.has(u.id)),l=(r.wires??[]).filter(u=>!o.has(gn(u.ends[0]))&&!o.has(gn(u.ends[1]))),d=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([u])=>!o.has(u))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:a.length?a:void 0,wires:l.length?l:void 0,layout:d&&Object.keys(d).length?d:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const a=i.indexOf(".");a>0&&s.add(i.slice(0,a))}t().dispatch(i=>{const a=(i.wires??[]).filter(d=>d.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const d of s){if(l[d])continue;const u=o.layout.get(d);if(!u)continue;const f={at:u.at};u.rot&&(f.rot=u.rot),u.mirror&&(f.mirror=u.mirror),l[d]=f}return{...i,wires:a.length?a:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const a of r.terminals){const l=a.indexOf(".");l>0&&i.add(a.slice(0,l))}t().dispatch(a=>{const l={...a.layout??{}};for(const u of i){if(l[u])continue;const f=o.layout.get(u);if(!f)continue;const m={at:f.at};f.rot&&(m.rot=f.rot),f.mirror&&(m.mirror=f.mirror),l[u]=m}const d=(a.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...a,wires:d.length?d:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var d,u,f,m;const i={...s.layout??{}},a=new Map;for(const p of o){if(r.junctions.has(p))continue;if(r.buses.has(p)){const w=r.buses.get(p),k=(((((f=(u=(d=s.buses)==null?void 0:d.find(b=>b.id===p))==null?void 0:u.layout)==null?void 0:f.rot)??w.geometry.rot??0)+n)%360+360)%360;a.set(p,k);continue}const h=i[p]??{at:((m=r.layout.get(p))==null?void 0:m.at)??[0,0]},y=(((h.rot??0)+n)%360+360)%360;i[p]={...h,rot:y}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??tt(r.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a)||o.junctions.has(a))continue;const l=s[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};s[a]={...l,mirror:!(l.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=Nt(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=Pn(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=On(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=Je(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(a=>a.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(h=>h.id),...(s.buses??[]).map(h=>h.id),...(s.junctions??[]).map(h=>h.id)]),a=()=>{let h=1;for(;i.has(`J${h}`);)h++;const y=`J${h}`;return i.add(y),y},l=h=>{const y=a();return s={...s,junctions:[...s.junctions??[],{id:y,layout:{at:h}}]},y},d=h=>{if("end"in h)return h.end;if("junctionAt"in h)return l(h.junctionAt);const y=(s.wires??[]).find(b=>b.id===h.onWire),w=l(h.at);if(!y)return w;const $=(s.wires??[]).filter(b=>b.id!==h.onWire),k=(b,S)=>({id:Je(b,S),ends:[b,S]});return s={...s,wires:Ko($,[k(y.ends[0],w),k(w,y.ends[1])])},w},u=d(n),f=d(o);if(u===null||f===null||u===f)return s;const m=Je(u,f),p=s.wires??[];return p.some(h=>h.id===m)?s:{...s,wires:[...p,{id:m,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(d=>d.id===n))return r;const i=o&&o.length>=2?os(o):null,a=i&&i.length>=2?i:null,l=s.map(d=>{if(d.id!==n)return d;if(a)return{...d,path:a};const{path:u,...f}=d;return f});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var a;const s=((a=r.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?tt(a.buses.get(n).geometry):{at:[0,0],span:320}),d={at:o.at??l.at,span:o.span??l.span,...o.rot!==void 0?{rot:o.rot}:l.rot?{rot:l.rot}:{}};return{...i,layout:d}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=T$(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const a=s.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...r,annotations:a}:r})},deleteAnnotation:n=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:ns(()=>localStorage),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 I$(e){return Array.from(new Set(e))}function gn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function Ko(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 Lt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function tt(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Zb=null;function Vo(e){Zb=e}function Ze(){return Zb}const Xt=10;function Qb(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function de(e){return Qb()?Math.round(e/Xt)*Xt:e}const P$=30,O$=144;function ew(e,t){const n=Ke[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=B$(r,t);if(!s){const y=tw(n),w=y?[de(t[0])-y.x,de(t[1])-y.y]:[de(t[0]),de(t[1])];return{newElementId:o.addElement(e,w),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,d=L$(n,l),u=Nt(r,e),f=n.terminals.find(y=>y.id===d),m=l==="x"?t[0]:a[0],p=l==="y"?t[1]:a[1],h=f?[de(m)-f.x,de(p)-f.y]:[de(t[0]),de(t[1])];return o.dispatch(y=>{const w={id:u,kind:e},$={at:h},k=`${u}.${d}`,b={id:Je(i,k),ends:[i,k]};return{...y,elements:[...y.elements,w],wires:[...y.wires??[],b],layout:{...y.layout??{},[u]:$}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function B$(e,t){const n=x.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let d;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,m=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,p=Math.abs(t[1]-a[1]);d=Math.sqrt(m*m+p*p)}else{const u=a[1]-l/2,f=a[1]+l/2,m=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,p=Math.abs(t[0]-a[0]);d=Math.sqrt(p*p+m*m)}d<=P$&&(!o||d<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:d})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function L$(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 tw(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function nw(e,t){const n=x.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const p=i[0]-a/2,h=i[0]+a/2,y=Math.max(p,Math.min(h,t[0])),w=i[1],$=t[1]>=w?"s":"n";return{ref:e,world:[y,w],orientation:$,isBus:!0,busId:e}}const l=i[1]-a/2,d=i[1]+a/2,u=Math.max(l,Math.min(d,t[1])),f=i[0],m=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:m,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const z$={n:"s",s:"n",e:"w",w:"e"};function ow(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=z$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Uo(i,n,t.world);for(let l=1;l<s.length;l++){const d=s[l],u=Uo(d,n,t.world);u<a&&(a=u,i=d)}return i}function Uo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function R$(e,t,n){const o=Ke[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=nw(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],d=a*a+l*l<=O$,u=[de(n[0]),de(n[1])],f=ow(o,i,u),m=d?i.world:u,p=[de(m[0]-f.x),de(m[1]-f.y)],h=Nt(s,e);return r.dispatch(y=>{const w={id:h,kind:e},$={at:p},k=`${h}.${f.id}`,b=i.isBus&&i.busId?i.busId:t,S={id:Je(b,k),ends:[b,k]};return{...y,elements:[...y.elements,w],wires:[...y.wires??[],S],layout:{...y.layout??{},[h]:$}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const Zt=9,Yt=7;function Qt(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=D$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function tn(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 D$(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 F$(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=x(r=>r.editingElement);return c.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var u;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??en(r.libraryDef),a=tn(i,s),l=i.anchor??"start";if(o===r.element.id)return c.jsx(H$,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const d=Qt(r,n);return d.length===0?null:c.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:d.map((f,m)=>c.jsx("text",{x:0,y:m*Zt,textAnchor:l,className:"ole-annotation-text",children:f},m))},r.element.id)})})}const yn=200,xn=9;function H$({elementId:e,currentName:t,world:n,anchor:o}){const r=O.useRef(null);O.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const d=document.createRange();d.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(d)},[e]);function s(){var m;const l=x.getState(),d=l.diagram.elements.find(p=>p.id===e);if(!d){l.setEditingElement(null);return}const u=(((m=r.current)==null?void 0:m.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==d.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),c.jsx("foreignObject",{x:a,y:n[1]-xn,width:yn,height:xn*2.2,className:"ole-element-name-editor",children:c.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${xn}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 rw=8,Kt=1.25;function W$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:c.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?c.jsx(G$,{ann:o},o.id):c.jsx(q$,{ann:o,isSelected:t===o.id},o.id))})}function q$({ann:e,isSelected:t}){const n=e.fontSize??rw,o=e.text===""?[""]:e.text.split(`
198
- `),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Kt;return c.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&c.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,className:"ole-free-annotation-halo"}),o.map((i,a)=>c.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Kt,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function G$({ann:e}){const t=O.useRef(null),n=e.fontSize??rw;O.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(l)},[e.id]);function o(){var d;const a=x.getState(),l=(((d=t.current)==null?void 0:d.innerText)??"").replace(/\u00a0/g," ").trimEnd();l===""?a.deleteAnnotation(e.id):l!==e.text&&a.updateAnnotation(e.id,{text:l}),a.setEditingAnnotation(null),l!==""&&a.setSelectedAnnotation(e.id),a.activeTool==="text"&&a.setActiveTool("select")}function r(a){if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return c.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:c.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:Kt,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*Kt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const X$=20;function Y$(){const e=x(u=>u.selection),t=x(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,a=i/2,l=r==="x"?[s[0]-a,s[1]]:[s[0],s[1]-a],d=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return c.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[c.jsx(Jo,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),c.jsx(Jo,{x:d[0],y:d[1],busId:n,side:"end",axis:r})]})}function Jo({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=O.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=x.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const m=s.screenToSvg(u.clientX,u.clientY),p=r==="x"?m[0]-f.startSvg[0]:m[1]-f.startSvg[1],h=Qb()?Math.round(p/Xt)*Xt:p,y=f.startSpan+(o==="end"?h:-h);if(y<X$)return;const w=r==="x"?[f.startAt[0]+h/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+h/2];x.getState().updateBus(n,{span:y,at:w})},d=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return c.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:d,onPointerCancel:d})}const Bn=.5;function jt(e,t){return Math.abs(e[1]-t[1])<Bn?"h":"v"}function K$(){const e=x(a=>a.selectedWire),t=x(a=>a.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let a=1;a<r-1;a++){const l=jt(o[a-1],o[a]),d=jt(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,m=u&&l==="v"||f&&d==="v",p=u&&l==="h"||f&&d==="h";m&&p||s.push(c.jsx(V$,{wireId:e,index:a,xLocked:m,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],d=o[a+1];Math.abs(l[0]-d[0])<Bn&&Math.abs(l[1]-d[1])<Bn||i.push(c.jsx(U$,{wireId:e,segIndex:a,axis:jt(l,d)},`m-${a}`))}return c.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function V$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=O.useRef(null),i=x(h=>{var y;return(y=h.internal.wireRenders.get(e))==null?void 0:y.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],d=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!r))return;const y=x.getState().internal.wireRenders.get(e);y&&(s.current={pointerId:h.pointerId,startPath:y.path.map(w=>[w[0],w[1]]),startSvg:r.screenToSvg(h.clientX,h.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=d,h.target.setPointerCapture(h.pointerId))},f=h=>{const y=s.current;if(!y||h.pointerId!==y.pointerId||!r)return;const w=r.screenToSvg(h.clientX,h.clientY),$=y.startPath,k=y.index;if(k<=0||k>=$.length-1)return;const b=$[k],S=[y.xLocked?b[0]:de(b[0]+(w[0]-y.startSvg[0])),y.yLocked?b[1]:de(b[1]+(w[1]-y.startSvg[1]))];if(S[0]===b[0]&&S[1]===b[1])return;const C=$.map(V=>[V[0],V[1]]);C[k]=S;const R=jt($[k-1],$[k]);k-1>0&&(R==="h"?C[k-1]=[$[k-1][0],S[1]]:C[k-1]=[S[0],$[k-1][1]]);const X=jt($[k],$[k+1]);k+1<$.length-1&&(X==="h"?C[k+1]=[$[k+1][0],S[1]]:C[k+1]=[S[0],$[k+1][1]]),x.getState().updateWirePath(e,C)},m=h=>{const y=s.current;!y||h.pointerId!==y.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),s.current=null,document.body.style.cursor="")},p=h=>{h.stopPropagation(),h.preventDefault();const y=x.getState().internal.wireRenders.get(e);if(!y||y.path.length<=2||t<=0||t>=y.path.length-1)return;const w=y.path.filter(($,k)=>k!==t);x.getState().updateWirePath(e,w)};return c.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:d},onPointerDown:u,onPointerMove:f,onPointerUp:m,onPointerCancel:m,onDoubleClick:p})}function U$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=O.useRef(null),s=x(h=>{var y;return(y=h.internal.wireRenders.get(e))==null?void 0:y.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,d=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!o))return;const y=x.getState().internal.wireRenders.get(e);y&&(r.current={pointerId:h.pointerId,startPath:y.path.map(w=>[w[0],w[1]]),startSvg:o.screenToSvg(h.clientX,h.clientY),axis:n,segIndex:t},document.body.style.cursor=u,h.currentTarget.setPointerCapture(h.pointerId))},m=h=>{const y=r.current;if(!y||h.pointerId!==y.pointerId||!o)return;const w=o.screenToSvg(h.clientX,h.clientY),$=y.startPath,k=y.segIndex;if(k>=$.length-1)return;const b=$[k],S=$[k+1],C=[];for(let R=0;R<=k;R++)C.push($[R]);if(y.axis==="h"){const R=de(b[1]+(w[1]-y.startSvg[1]));C.push([b[0],R]),C.push([S[0],R])}else{const R=de(b[0]+(w[0]-y.startSvg[0]));C.push([R,b[1]]),C.push([R,S[1]])}for(let R=k+1;R<$.length;R++)C.push($[R]);x.getState().updateWirePath(e,C)},p=h=>{const y=r.current;if(!y||h.pointerId!==y.pointerId)return;const w=h.currentTarget;w.hasPointerCapture(h.pointerId)&&w.releasePointerCapture(h.pointerId),r.current=null,document.body.style.cursor=""};return c.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:m,onPointerUp:p,onPointerCancel:p,children:[c.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:d,r:8}),c.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:d,r:3.5})]})}const J$=3,bn=12;function Z$(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)!l.includes(".")&&e.has(l)&&i.add(l)}return c.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:d,at:u,span:f}=l,m=f/2,p=d==="x"?u[0]-m:u[0],h=d==="x"?u[1]:u[1]-m,y=d==="x"?u[0]+m:u[0],w=d==="x"?u[1]:u[1]+m,$=s.has(a.id),k=i.has(a.id),b=r.get(a.id)??void 0,S=bn/2,C=d==="x"?u[0]-m:u[0]-S,R=d==="x"?u[1]-S:u[1]-m,X=d==="x"?f:bn,V=d==="x"?bn:f;return c.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":b,"data-selected":$?"true":void 0,"data-node-related":k?"true":void 0,className:"ole-bus",children:[c.jsx("rect",{x:C,y:R,width:X,height:V,fill:"transparent",className:"ole-bus-hit"}),c.jsx("line",{x1:p,y1:h,x2:y,y2:w,stroke:"currentColor",strokeWidth:J$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function Q$(){const e=x(a=>a.busbarDrawStart),t=x(a=>a.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return c.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[c.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),c.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),c.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const eS=4,tS=9;function nS(){const e=x(a=>a.internal.junctions),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)i.add(l)}return c.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l})=>{const d=r.get(a.id)??void 0;return c.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":d,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[c.jsx("circle",{cx:l[0],cy:l[1],r:tS,fill:"transparent",className:"ole-junction-hit"}),c.jsx("circle",{cx:l[0],cy:l[1],r:eS,className:"ole-junction-dot"})]},a.id)})})}function Ye(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function oS(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function rS({lib:e}){const t=oS(e.viewBox);return t?c.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function sS(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),r=x(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const d=l.indexOf(".");d>0&&i.add(l.slice(0,d))}}return c.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const d=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element",children:[c.jsx(rS,{lib:a.libraryDef}),c.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element ole-element--unknown",children:[c.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),c.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let sw=null;const Ln=new Set;function zt(e){sw=e;for(const t of Ln)t(e)}function iS(){return sw}function aS(e){return Ln.add(e),()=>{Ln.delete(e)}}function lS(){const[e,t]=O.useState(iS());return O.useEffect(()=>aS(t),[]),!e||e.w===0&&e.h===0?null:c.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function cS(){const e=x(d=>d.activeTool),t=x(d=>d.placeKind),n=x(d=>d.cursorSvg),o=x(d=>d.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Jb(t);if(!r)return null;let s=null,i=null;if(o){const d=nw(o,n);d&&(s=ow(r,d,n),i={source:d.world,pin:n})}else s=tw(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return c.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),c.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:c.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function dS(){const e=x(r=>r.selection),t=x(r=>r.internal.elements),n=x(r=>r.internal.layout),o=x(r=>r.internal.buses);return e.length===0?null:c.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:d,at:u,span:f}=s.geometry,m=f/2,p=d==="x"?u[0]-m:u[0]-4,h=d==="x"?u[1]-4:u[1]-m,y=d==="x"?f:8,w=d==="x"?8:f;return c.jsx("rect",{x:p,y:h,width:y,height:w,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=uS(i.libraryDef.viewBox);return l?c.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ye(a)},r):null})})}function uS(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 fS(){const e=x(s=>s.internal.terminals),t=x(s=>s.internal.terminalToNode),n=x(s=>s.wireFromTerminal),o=x(s=>s.selection),r=new Set(o);return c.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),a=i!==void 0,l=n===s.ref,d=r.has(s.elementId);return c.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":a?"true":"false","data-active":l?"true":void 0,"data-on-selected":d?"true":void 0,className:"ole-terminal"},s.ref)})})}function mS(){const e=x(i=>i.internal.wireRenders),t=x(i=>i.internal.terminalToNode),n=x(i=>i.diagram.wires),o=x(i=>i.selectedWire),r=x(i=>i.selectedNode),s=new Map;for(const i of n??[]){const a=t.get(i.ends[0]);a&&s.set(i.id,a)}return c.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:Array.from(e.values()).flatMap(i=>{const a=i.path;if(a.length<2)return[];const l=a.map(m=>`${m[0]},${m[1]}`).join(" "),d=s.get(i.wireId),u=o===i.wireId,f=r!=null&&r===d;return[c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,className:"ole-wire-hit",points:l},`hit-${i.wireId}`),c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,"data-manual":i.userEdited?"true":void 0,"data-selected":u||f?"true":void 0,className:"ole-wire",points:l},i.wireId)]})})}let Ue=null;const zn=new Set;function Re(e){if(!(e===null&&Ue===null||e&&Ue&&e.ref===Ue.ref&&e.world[0]===Ue.world[0]&&e.world[1]===Ue.world[1])){Ue=e;for(const t of zn)t(e)}}function hS(){return Ue}function pS(e){return zn.add(e),()=>{zn.delete(e)}}function gS(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=O.useState(hS());if(O.useEffect(()=>pS(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 c.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[c.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),c.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&c.jsxs(c.Fragment,{children:[c.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&&c.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function Qe(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function lt(e){var t;return((t=Qe(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function yS(e){var t;return((t=Qe(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function xS(e){var t;return((t=Qe(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function it(e){var r;const t=(r=Qe(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=xS(e);if(n)return n;const o=yS(e);return o||null}function nn(e){var t;return((t=Qe(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Rn(e){var t;return((t=Qe(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Vt(e){var t;return((t=Qe(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function iw(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function bS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function aw(){const e=x.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function wS(){O.useEffect(()=>{const e=t=>{if(bS(t.target))return;const n=t.metaKey||t.ctrlKey,o=x.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=x.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"j":case"J":o.setActiveTool("junction");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":aw();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Dn=null;const Fn=new Set;function vS(e){if(e!==Dn){Dn=e;for(const t of Fn)t(e)}}function kS(){return Dn}function _S(e){return Fn.add(e),()=>{Fn.delete(e)}}const Zo="ole-hover-element-host",$S="ole-hover-terminal-on",SS="ole-hover-node-on";function jS(e){O.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,m,p)=>{for(const h of f)h.classList.remove(p);f.clear();for(const h of m)h.classList.add(p),f.add(h)},a=f=>{var p,h;if(f===n)return;n&&((p=t.querySelector(`[data-element-id="${Rt(n)}"]`))==null||p.classList.remove(Zo)),f&&((h=t.querySelector(`[data-element-id="${Rt(f)}"]`))==null||h.classList.add(Zo));const m=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Rt(f)}"]`)):[];i(r,m,$S),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),vS(f)},l=f=>{if(f===o)return;const m=f?Array.from(t.querySelectorAll(`[data-node-id="${Rt(f)}"]`)):[];i(s,m,SS),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},d=f=>{a(lt(f.target));const m=it(f.target);let p=null;m?p=x.getState().internal.terminalToNode.get(m)??null:p=nn(f.target),l(p)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",d),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",d),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function Rt(e){return e.replace(/(["\\])/g,"\\$1")}function lw(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const m=a[0]-l/2,p=a[0]+l/2,h=Math.max(m,Math.min(p,t[0]));return{ref:e,world:[h,a[1]],isBus:!0}}const d=a[1]-l/2,u=a[1]+l/2,f=Math.max(d,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 Qo=3;let ce=null,Ne=null,Me=null,he=null;const ES={id:"select",cursor:"default",onPointerDown(e,t){var p,h,y,w,$,k,b;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Vt(e.target);if(o){e.preventDefault(),e.stopPropagation();const S=(p=n.diagram.annotations)==null?void 0:p.find(C=>C.id===o);if(!S)return;n.setSelectedAnnotation(o),he={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[S.at[0],S.at[1]],moved:!1};return}const s=(e.target instanceof Element?(h=e.target.closest("[data-terminal-id]"))==null?void 0:h.getAttribute("data-terminal-id"):null)?it(e.target):null;if(s){const S=s.indexOf("."),C=S>0?s.slice(0,S):"";if(C&&n.selection.includes(C)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((w=(y=e.target).hasPointerCapture)!=null&&w.call(y,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Me={pointerId:e.pointerId,fromRef:s};return}}let i=lt(e.target);if(!i){const S=Rn(e.target);if(S&&typeof document<"u"){const C=document.elementsFromPoint(e.clientX,e.clientY);for(const R of C){const X=(k=($=R.closest)==null?void 0:$.call(R,"[data-bus-id]"))==null?void 0:k.getAttribute("data-bus-id");if(!X)continue;const V=(b=n.diagram.wires)==null?void 0:b.find(te=>te.id===S);V&&(V.ends[0]===X||V.ends[1]===X)&&(i=X);break}}}if(!i){const S=Rn(e.target);if(S){if(e.preventDefault(),e.altKey){const C=nn(e.target);if(C){n.setSelectedNode(C);return}}n.setSelectedWire(S);return}e.shiftKey||n.clearSelection(),Ne={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const a=n.selection;e.shiftKey?n.toggleInSelection(i):a.includes(i)||n.setSelection([i]);const l=e.shiftKey?x.getState().selection:a.includes(i)?a:[i];if(l.length===0)return;const d=x.getState().internal,u=new Map,f=new Map,m=new Map;for(const S of l){const C=d.buses.get(S);if(C){f.set(S,[C.geometry.at[0],C.geometry.at[1]]);continue}const R=d.junctions.get(S);if(R){m.set(S,[R.world[0],R.world[1]]);continue}const X=d.layout.get(S);X&&u.set(S,{...X})}u.size===0&&f.size===0&&m.size===0||(ce={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:f,junctionOriginals:m,moved:!1},e.preventDefault())},onPointerMove(e,t){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));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Me&&e.pointerId===Me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?it(o):null;if(!r||r===Me.fromRef){Re(null);return}Re(lw(r,n));return}if(ce&&e.pointerId===ce.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.startSvg[0]),r=de(n[1]-ce.startSvg[1]);!ce.moved&&(o!==0||r!==0)&&(ce.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ce.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ye(l))}for(const s of ce.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of ce.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Ne&&e.pointerId===Ne.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);zt(er(Ne.startSvg,n));return}},onPointerUp(e,t){if(he&&e.pointerId===he.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-he.startSvg[0]),r=de(n[1]-he.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);s&&s.removeAttribute("transform"),he.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(he.id,{at:[he.origin[0]+o,he.origin[1]+r]}),he=null;return}if(Me&&e.pointerId===Me.pointerId){const n=x.getState(),o=Me.fromRef;Me=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Re(null);const r=it(e.target);r&&r!==o&&n.addWire(o,r);return}if(ce&&e.pointerId===ce.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ce.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.startSvg[0]),r=de(n[1]-ce.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ce.originals.keys())s.set(i,[o,r]);for(const i of ce.busOriginals.keys())s.set(i,[o,r]);for(const i of ce.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ce.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}for(const s of ce.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}}ce=null;return}if(Ne&&e.pointerId===Ne.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=er(Ne.startSvg,n);if(o.w>=Qo||o.h>=Qo){const r=NS(o);if(Ne.shiftKey){const s=new Set(Ne.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}zt(null),Ne=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(he&&e.pointerId===he.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}he=null}if(ce&&e.pointerId===ce.pointerId){for(const[l,d]of ce.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",Ye(d))}for(const l of ce.busOriginals.keys()){const d=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);d&&d.removeAttribute("transform")}for(const l of ce.junctionOriginals.keys()){const d=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);d&&d.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}ce=null}if(Me&&e.pointerId===Me.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setCursorSvg(null),Re(null),Me=null}if(Ne&&e.pointerId===Ne.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}zt(null),Ne=null}},onDoubleClick(e){const t=x.getState(),n=Vt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=lt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ce=null,Ne=null,he=null,Me){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Re(null),Me=null}zt(null)}};function er(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 NS(e){const{internal:t}=x.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=TS(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([f,m])=>MS([f,m],r));let a=1/0,l=-1/0,d=1/0,u=-1/0;for(const[f,m]of i)f<a&&(a=f),f>l&&(l=f),m<d&&(d=m),m>u&&(u=m);l>=e.x&&a<=e.x+e.w&&u>=e.y&&d<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,d=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,m=s==="x"?i[1]:i[1]+l;u>=e.x&&d<=e.x+e.w&&m>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function MS(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 TS(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 AS=4;let se=null;const CS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=lt(e.target);let r=null;if(o){const s=x.getState();s.selection.includes(o)||s.setSelection([o]);const i=x.getState().selection,a=x.getState().internal,l=new Map,d=new Map;for(const u of i){const f=a.buses.get(u);if(f){d.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const m=a.layout.get(u);m&&l.set(u,{...m})}(l.size>0||d.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:d})}se={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(!se||e.pointerId!==se.pointerId)return;const n=e.clientX-se.startX,o=e.clientY-se.startY;if(!se.moved&&Math.hypot(n,o)>AS){se.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(se.moved){if(se.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=de(r[0]-se.elementDrag.startSvg[0]),i=de(r[1]-se.elementDrag.startSvg[1]);for(const[a,l]of se.elementDrag.originals){const d=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);if(!d)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};d.setAttribute("transform",Ye(u))}for(const a of se.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:se.startTx+n,ty:se.startTy+o})}},onPointerUp(e,t){if(!(!se||e.pointerId!==se.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",se.elementDrag&&se.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-se.elementDrag.startSvg[0]),r=de(n[1]-se.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of se.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of se.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of se.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${vt(s)}"]`);i&&i.removeAttribute("transform")}}else se.moved||IS(se.startTarget);se=null}},onPointerCancel(e,t){if(se!=null&&se.elementDrag){for(const[n,o]of se.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);r&&r.setAttribute("transform",Ye(o))}for(const n of se.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);o&&o.removeAttribute("transform")}}se=null},onDeactivate(){se=null}};function IS(e){if(!e)return;const t=x.getState(),n=Vt(e);if(n){t.setSelectedAnnotation(n);return}const o=lt(e);if(o){t.setSelection([o]);return}const r=nn(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function vt(e){return e.replace(/(["\\])/g,"\\$1")}const _t={tight:1024,compact:720,dense:520,mini:380},tr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return tr[e]>=tr[t]}function PS(e){return e>=_t.tight?"full":e>=_t.compact?"tight":e>=_t.dense?"compact":e>=_t.mini?"dense":"mini"}const cw=O.createContext("full");function Ve(){return O.useContext(cw)}function OS(e){const[t,n]=O.useState(null);return O.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function dw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<_t.dense}function on(){dw()&&x.getState().setActiveTool("pan")}function BS(){dw()&&x.getState().setPlaceKind(null)}const nr=10,Dt=e=>Math.round(e/nr)*nr,LS=16;function uw(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],d=a-s,u=l-i,f=d*d+u*u,m=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*d+(t[1]-i)*u)/f)),p=s+m*d,h=i+m*u,y=(p-t[0])**2+(h-t[1])**2;y<o&&(o=y,n=[p,h])}return n}function or(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function zS(e,t){const n=x.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=uw(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 wn(e,t,n){const o=e?it(e):null;if(o){const a=lw(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?Rn(e):null,s=null;if(r){const a=x.getState().internal.wireRenders.get(r);s=a?uw(a.path,t):t}else{const a=zS(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[Dt(s[0]),Dt(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Dt(t[0]),Dt(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function vn(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+LS,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function RS(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function rr(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 DS={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),Re(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=vn(t,e.clientX,e.clientY),r=wn(e.target instanceof Element?e.target:null,n,o),s=x.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=or(e.clientX,e.clientY),i=wn(s,r,vn(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Re(rr(a,i)?null:RS(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Re(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=or(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=wn(s,r,vn(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};rr(a,i)||(n.connectWire(o.spec,i.spec),on())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Re(null)}},sr=10;let kt=!1;function ir(){setTimeout(()=>BS(),0)}const FS={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=x.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),kt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=it(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const a=x.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);ew(n,r),kt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([ar(n[0]),ar(n[1])])},onPointerUp(e,t){const n=x.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);R$(r,o,s),ir();return}kt&&(kt=!1,ir())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),kt=!1}};function ar(e){return Math.round(e/sr)*sr}const lr=10,cr=20;function nt(e){return Math.round(e/lr)*lr}const HS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[nt(n[0]),nt(n[1])];x.getState().setBusbarDrawStart(o),x.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([nt(n[0]),nt(n[1])])},onPointerUp(e,t){const n=x.getState().busbarDrawStart;if(x.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=nt(o[0]),s=nt(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let d,u,f;if(l){if(u=Math.abs(i),u<cr)return;d=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<cr)return;d=90,f=[n[0],(n[1]+s)/2]}x.getState().addBus(f,u,d),on()},onPointerLeave(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},dr=10,ur=e=>Math.round(e/dr)*dr,WS={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().addJunction([ur(n[0]),ur(n[1])]),on()}},qS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Vt(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),on()}},GS={select:ES,pan:CS,wire:DS,place:FS,busbar:HS,junction:WS,text:qS};function XS(e,t){const n=x(o=>o.activeTool);O.useEffect(()=>{var m;const o=e.current;if(!o)return;const r=GS[n],s={viewport:t,hostEl:o};(m=r.onActivate)==null||m.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=p=>{var h;return(h=r.onPointerDown)==null?void 0:h.call(r,p,s)},a=p=>{var h;return(h=r.onPointerMove)==null?void 0:h.call(r,p,s)},l=p=>{var h;return(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},d=p=>{var h;return r.onPointerCancel?r.onPointerCancel(p,s):(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},u=p=>{var h;return(h=r.onPointerLeave)==null?void 0:h.call(r,p,s)},f=p=>{var h;return(h=r.onDoubleClick)==null?void 0:h.call(r,p,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",d),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",f),()=>{var p;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",d),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",f),(p=r.onDeactivate)==null||p.call(r,s),o.style.cursor=""}},[n,e,t])}let Hn=1;const Wn=new Set;function YS(e){if(e!==Hn){Hn=e;for(const t of Wn)t(e)}}function KS(){return Hn}function VS(e){return Wn.add(e),()=>{Wn.delete(e)}}const kn=.1,_n=8,US=1.0015,JS=1.02;function ZS(e,t,n={tx:0,ty:0,scale:1}){const o=O.useRef({...n}),r=O.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),YS(o.current.scale),r.current.size>0){const l={...o.current};for(const d of r.current)d(l)}};return O.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,d=0,u=0,f=0,m=0,p=!1;const h=new Map;let y=null,w=!1;const $=()=>{if(h.size<2){y=null;return}const D=[...h.values()],W=D[1].x-D[0].x,ye=D[1].y-D[0].y,ue=Math.hypot(W,ye)||1,pe=i.getBoundingClientRect();y={startDist:ue,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(D[0].x+D[1].x)/2-pe.left,startMidY:(D[0].y+D[1].y)/2-pe.top}},k=D=>{if(D.pointerType==="touch"){if(h.set(D.pointerId,{x:D.clientX,y:D.clientY}),h.size>=2&&!w){w=!0;for(const W of h.keys())W!==D.pointerId&&iw(i,W);$()}if(w){D.stopPropagation(),D.preventDefault();try{i.setPointerCapture(D.pointerId)}catch{}}}},b=D=>{if(D.pointerType!=="touch"||!h.has(D.pointerId)||(h.set(D.pointerId,{x:D.clientX,y:D.clientY}),!w||!y))return;D.stopPropagation();const W=[...h.values()];if(W.length<2)return;const ye=W[1].x-W[0].x,ue=W[1].y-W[0].y,pe=Math.hypot(ye,ue)||1,ne=i.getBoundingClientRect(),re=(W[0].x+W[1].x)/2-ne.left,ge=(W[0].y+W[1].y)/2-ne.top,xe=pe/y.startDist,_e=$n(y.startScale*xe,kn,_n),Ee=_e/y.startScale;o.current.tx=y.startMidX-(y.startMidX-y.startTx)*Ee+(re-y.startMidX),o.current.ty=y.startMidY-(y.startMidY-y.startTy)*Ee+(ge-y.startMidY),o.current.scale=_e,s()},S=D=>{var W;if(D.pointerType==="touch"&&h.has(D.pointerId)&&(h.delete(D.pointerId),w)){if(D.stopPropagation(),(W=i.hasPointerCapture)!=null&&W.call(i,D.pointerId))try{i.releasePointerCapture(D.pointerId)}catch{}h.size>=2?$():y=null,h.size===0&&(w=!1)}},C=D=>{D.preventDefault();const W=i.getBoundingClientRect(),ye=D.clientX-W.left,ue=D.clientY-W.top,pe=D.ctrlKey||D.metaKey;if(D.deltaX===0||pe){const ge=Math.pow(pe?JS:US,-D.deltaY),xe=$n(o.current.scale*ge,kn,_n),_e=xe/o.current.scale;o.current.tx=ye-(ye-o.current.tx)*_e,o.current.ty=ue-(ue-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=D.deltaX,o.current.ty-=D.deltaY;s()},R=D=>{const W=D.button===1,ye=p&&D.button===0;!W&&!ye||(D.preventDefault(),a=!0,l=D.pointerId,d=D.clientX,u=D.clientY,f=o.current.tx,m=o.current.ty,i.setPointerCapture(D.pointerId),i.style.cursor="grabbing")},X=D=>{!a||D.pointerId!==l||(o.current.tx=f+(D.clientX-d),o.current.ty=m+(D.clientY-u),s())},V=D=>{a&&D.pointerId===l&&(a=!1,i.releasePointerCapture(D.pointerId),i.style.cursor=p?"grab":"")},te=D=>{if(D.code==="Space"&&!p){const W=D.target;if(W&&(W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable))return;p=!0,i.style.cursor="grab",D.preventDefault()}},ae=D=>{D.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",C,{passive:!1}),i.addEventListener("pointerdown",R),i.addEventListener("pointermove",X),i.addEventListener("pointerup",V),i.addEventListener("pointercancel",V),i.addEventListener("pointerdown",k,{capture:!0}),i.addEventListener("pointermove",b,{capture:!0}),i.addEventListener("pointerup",S,{capture:!0}),i.addEventListener("pointercancel",S,{capture:!0}),window.addEventListener("keydown",te),window.addEventListener("keyup",ae),s(),()=>{i.removeEventListener("wheel",C),i.removeEventListener("pointerdown",R),i.removeEventListener("pointermove",X),i.removeEventListener("pointerup",V),i.removeEventListener("pointercancel",V),i.removeEventListener("pointerdown",k,{capture:!0}),i.removeEventListener("pointermove",b,{capture:!0}),i.removeEventListener("pointerup",S,{capture:!0}),i.removeEventListener("pointercancel",S,{capture:!0}),window.removeEventListener("keydown",te),window.removeEventListener("keyup",ae)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const d=l.getBoundingClientRect(),u=(i-d.left-o.current.tx)/o.current.scale,f=(a-d.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=$n(i.scale,kn,_n)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function $n(e,t,n){return e<t?t:e>n?n:e}const fw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ot=fw?"⌘":"Ctrl+",QS=fw?"⇧":"Shift+",Sn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],e4=18;function t4(e){for(const t of Sn)if(t*e>=e4)return t;return Sn[Sn.length-1]}function n4(){const e=ie(),t=O.useRef(null),n=O.useRef(null),o=O.useRef(null),r=ZS(t,n);XS(t,r),jS(t),O.useEffect(()=>(Vo(r),()=>Vo(null)),[r]),O.useEffect(()=>{const u=f=>{const m=o.current;if(!m)return;const h=t4(f.scale)*f.scale;m.setAttribute("width",String(h)),m.setAttribute("height",String(h)),m.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Vv(),i=O.useCallback((u,f,m)=>{const p=x.getState(),h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){aw();return}const y=lt(m);if(y)p.selection.includes(y)||p.setSelection([y]);else{const R=nn(m);R&&p.selectedNode!==R&&p.setSelectedNode(R)}const w=x.getState(),$=w.selection.length>0,k=w.selectedNode!=null,b=!!w.clipboard,S=w.diagram.elements.length>0,C=[{label:e("menu.undo"),shortcut:`${ot}Z`,icon:Kn,onSelect:()=>x.getState().undo(),disabled:w.past.length===0},{label:e("menu.redo"),shortcut:`${ot}${QS}Z`,icon:Yn,onSelect:()=>x.getState().redo(),disabled:w.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ot}X`,icon:Fr,onSelect:()=>x.getState().cutSelection(),disabled:!$},{label:e("menu.copy"),shortcut:`${ot}C`,icon:Lr,onSelect:()=>x.getState().copySelection(),disabled:!$},{label:e("menu.paste"),shortcut:`${ot}V`,icon:Br,onSelect:()=>x.getState().pasteClipboard(),disabled:!b},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Dr,onSelect:()=>x.getState().rotateSelection(90),disabled:!$},{label:e("menu.mirror"),shortcut:"M",icon:zr,onSelect:()=>x.getState().mirrorSelection(),disabled:!$},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ot}A`,icon:gv,onSelect:()=>{const R=x.getState();R.setSelection(R.diagram.elements.map(X=>X.id))},disabled:!S},{type:"separator"},{label:e(k&&!$?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Wr,destructive:!0,onSelect:()=>k&&!$?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!$&&!k}];s.open(u,f,C)},[s,e]);O.useEffect(()=>{const u=t.current;if(!u)return;const f=700,m=4;let p,h=null;const y=()=>{p!==void 0&&window.clearTimeout(p),p=void 0,h=null},w=b=>{b.pointerType==="touch"&&(y(),h={pointerId:b.pointerId,x:b.clientX,y:b.clientY,target:b.target},p=window.setTimeout(()=>{const S=h;h=null,p=void 0,S&&(iw(u,S.pointerId),i(S.x,S.y,S.target))},f))},$=b=>{if(!h||b.pointerId!==h.pointerId)return;const S=b.clientX-h.x,C=b.clientY-h.y;Math.hypot(S,C)>m&&y()},k=b=>{!h||b.pointerId!==h.pointerId||y()};return u.addEventListener("pointerdown",w),u.addEventListener("pointermove",$),u.addEventListener("pointerup",k),u.addEventListener("pointercancel",k),()=>{y(),u.removeEventListener("pointerdown",w),u.removeEventListener("pointermove",$),u.removeEventListener("pointerup",k),u.removeEventListener("pointercancel",k)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const m=r.screenToSvg(u.clientX,u.clientY);ew(f,m)},d=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return c.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:d,children:c.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("defs",{children:c.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:c.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),c.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),c.jsxs("g",{ref:n,className:"ole-viewport",children:[c.jsx(Z$,{}),c.jsx(mS,{}),c.jsx(nS,{}),c.jsx(sS,{}),c.jsx(F$,{}),c.jsx(W$,{}),c.jsx(dS,{}),c.jsx(Y$,{}),c.jsx(K$,{}),c.jsx(fS,{}),c.jsx(gS,{}),c.jsx(Q$,{}),c.jsx(cS,{}),c.jsx(lS,{})]})]})})}const fr=60,o4=.1,r4=8,s4=8;function i4(e,t,n){return e<t?t:e>n?n:e}function a4(){return document.querySelector(".ole-canvas-root")}function Zn(){const e=Ze(),t=a4();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,a=-1/0;for(const $ of o){const k=$.getBoundingClientRect();k.width===0&&k.height===0||(k.left<r&&(r=k.left),k.top<s&&(s=k.top),k.right>i&&(i=k.right),k.bottom>a&&(a=k.bottom))}if(r===1/0)return!1;const[l,d]=e.screenToSvg(r,s),[u,f]=e.screenToSvg(i,a),m=Math.max(u-l,1),p=Math.max(f-d,1),h=i4(Math.min((n.width-fr*2)/m,(n.height-fr*2)/p),o4,r4),y=(l+u)/2,w=(d+f)/2;return e.setViewport({tx:n.width/2-h*y,ty:n.height/2-h*w,scale:h}),!0}function Qn(){let e=s4;const t=()=>{Zn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const mr=10,l4=100;function c4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function d4(){const[e,t]=O.useState(kS()),[n,o]=O.useState(!1),[r,s]=O.useState(null),i=O.useRef(null),a=O.useRef(void 0),[l]=O.useState(c4);O.useEffect(()=>_S(h=>t(h)),[]),O.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),l4),()=>window.clearTimeout(a.current)},[e]);const d=x(h=>e?h.diagram.elements.find(y=>y.id===e)??null:null);if(O.useLayoutEffect(()=>{if(!n||!e)return;let h=0,y=-1,w=-1;const $=()=>{const k=document.querySelector(`[data-element-id="${u4(e)}"]`),b=i.current;if(k&&b){const S=k.getBoundingClientRect();let C=S.bottom+mr;C+b.offsetHeight>window.innerHeight-4&&(C=S.top-b.offsetHeight-mr);let R=S.left+S.width/2-b.offsetWidth/2;R=Math.max(4,Math.min(R,window.innerWidth-b.offsetWidth-4)),(C!==y||R!==w)&&(s({top:C,left:R}),y=C,w=R)}h=requestAnimationFrame($)};return h=requestAnimationFrame($),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!d)return null;const u=Ke[d.kind],f=d.name??d.id,m=(u==null?void 0:u.name)??d.kind,p=d.name&&d.name!==d.id;return typeof document>"u"?null:Ir.createPortal(c.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[c.jsx("span",{className:"font-medium text-foreground",children:f}),p&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:d.id}),c.jsx("span",{className:"text-muted-foreground/80",children:"·"}),c.jsx("span",{className:"text-muted-foreground",children:m})]}),document.body)}function u4(e){return e.replace(/(["\\])/g,"\\$1")}function f4({width:e,children:t}){const n=e==null?"full":PS(e);return c.jsx(cw.Provider,{value:n,children:t})}function hr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function m4(...e){return t=>{let n=!1;const o=e.map(r=>{const s=hr(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():hr(e[r],null)}}}}var h4=Symbol.for("react.lazy"),Ut=ke[" use ".trim().toString()];function p4(e){return typeof e=="object"&&e!==null&&"then"in e}function mw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===h4&&"_payload"in e&&p4(e._payload)}function g4(e){const t=x4(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;mw(s)&&typeof Ut=="function"&&(s=Ut(s._payload));const a=ke.Children.toArray(s),l=a.find(w4);if(l){const d=l.props.children,u=a.map(f=>f===l?ke.Children.count(d)>1?ke.Children.only(null):ke.isValidElement(d)?d.props.children:null:f);return c.jsx(t,{...i,ref:r,children:ke.isValidElement(d)?ke.cloneElement(d,void 0,u):null})}return c.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var y4=g4("Slot");function x4(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(mw(r)&&typeof Ut=="function"&&(r=Ut(r._payload)),ke.isValidElement(r)){const i=k4(r),a=v4(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?m4(o,i):i),ke.cloneElement(r,a)}return ke.Children.count(r)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var b4=Symbol("radix.slottable");function w4(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===b4}function v4(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 k4(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 pr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,gr=Xr,_4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return gr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(d=>{const u=n==null?void 0:n[d],f=s==null?void 0:s[d];if(u===null)return null;const m=pr(u)||pr(f);return r[d][m]}),a=n&&Object.entries(n).reduce((d,u)=>{let[f,m]=u;return m===void 0||(d[f]=m),d},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,u)=>{let{class:f,className:m,...p}=u;return Object.entries(p).every(h=>{let[y,w]=h;return Array.isArray(w)?w.includes({...s,...a}[y]):{...s,...a}[y]===w})?[...d,f,m]:d},[]);return gr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},$4=_4("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ae=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?y4:"button";return c.jsx(i,{className:je($4({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const S4=350;function Ce({content:e,children:t,disabled:n,delayMs:o=S4}){const r=O.useRef(null),s=O.useRef(null),[i,a]=O.useState(!1),[l,d]=O.useState(null),u=O.useId(),f=O.useRef(void 0),m=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(f.current),a(!1)};O.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const $=r.current.getBoundingClientRect(),k=s.current.getBoundingClientRect(),b=8;let S="top",C=$.top-k.height-b;C<4&&(S="bottom",C=$.bottom+b);let R=$.left+$.width/2-k.width/2;R=Math.max(4,Math.min(R,window.innerWidth-k.width-4)),d({top:C,left:R,side:S})},[i,e]),O.useEffect(()=>()=>window.clearTimeout(f.current),[]),O.useEffect(()=>{if(!i)return;const $=b=>{b.key==="Escape"&&a(!1)},k=()=>a(!1);return window.addEventListener("keydown",$),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("keydown",$),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i]);const h=t,y=h.props,w=O.cloneElement(h,{ref:$=>{r.current=$;const k=h.ref;typeof k=="function"?k($):k&&typeof k=="object"&&(k.current=$)},onPointerEnter:$=>{var k;(k=y.onPointerEnter)==null||k.call(y,$),m()},onPointerLeave:$=>{var k;(k=y.onPointerLeave)==null||k.call(y,$),p()},onFocus:$=>{var k;(k=y.onFocus)==null||k.call(y,$),m()},onBlur:$=>{var k;(k=y.onBlur)==null||k.call(y,$),p()},"aria-describedby":i?u:y["aria-describedby"]});return c.jsxs(c.Fragment,{children:[w,i&&typeof document<"u"&&Ir.createPortal(c.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const yr=12,j4=56;function E4(){var $;const e=ie(),t=x(k=>k.selection),n=x(k=>k.selectedNode),o=x(k=>k.selectedWire),r=x(k=>k.activeTool),s=x(k=>k.rotateSelection),i=x(k=>k.mirrorSelection),a=x(k=>k.deleteSelection),l=x(k=>k.deleteSelectedNode),d=x(k=>k.deleteSelectedWire),u=x(k=>k.resetWirePath),f=x(k=>k.internal.wireRenders),m=o!=null&&(($=f.get(o))==null?void 0:$.userEdited)===!0,p=O.useRef(null);O.useEffect(()=>{const k=p.current;if(!k)return;const b=t.length>0,S=!b&&o!=null,C=!b&&!S&&n!=null;if(!((b||S||C)&&(r==="select"||r==="pan"))){k.style.display="none";return}k.style.display="flex";let X=0,V="";const te=()=>{let ae=1/0,D=-1/0,W=1/0,ye=-1/0,ue=!1;const pe=ne=>{ne.width===0&&ne.height===0||(ne.left<ae&&(ae=ne.left),ne.right>D&&(D=ne.right),ne.top<W&&(W=ne.top),ne.bottom>ye&&(ye=ne.bottom),ue=!0)};if(b)for(const ne of t){const re=document.querySelector(`[data-element-id="${CSS.escape(ne)}"]`);re&&pe(re.getBoundingClientRect())}else if(S&&o){const ne=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ne&&pe(ne.getBoundingClientRect())}else if(C&&n){const ne=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const re of ne)pe(re.getBoundingClientRect())}if(ue){const ne=(ae+D)/2;let re=W-yr,ge="-100%";re<j4&&(re=ye+yr,ge="0%");const xe=`translate3d(${ne}px, ${re}px, 0) translate(-50%, ${ge})`;xe!==V&&(k.style.transform=xe,V=xe)}X=requestAnimationFrame(te)};return X=requestAnimationFrame(te),()=>cancelAnimationFrame(X)},[t,n,o,r]);const h=t.length===0&&o!=null,y=t.length===0&&!h&&n!=null,w=y||h;return c.jsxs("div",{ref:p,role:"toolbar","aria-label":e(h?"ctx.ariaWire":y?"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&&c.jsxs(c.Fragment,{children:[c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{children:c.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:c.jsx(pv,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!w&&c.jsxs(c.Fragment,{children:[c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:c.jsx(Dr,{})})}),c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:c.jsx(zr,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.delete")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),c.jsx("div",{className:"text-muted-foreground",children:e(h?"ctx.deleteHintWire":y?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>h?d():y?l():a(),"aria-label":e("ctx.delete"),children:c.jsx(Wr,{})})})]})}function eo({open:e,onOpenChange:t,trigger:n,children:o}){const r=O.useRef(null);return O.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),c.jsxs("div",{ref:r,className:"relative",children:[n,e&&c.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const hw="ole-panel-open";function N4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(hw);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 xr(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(hw,JSON.stringify(t))}catch{}}const Mt=Jt((e,t)=>({...N4(),setOutlineOpen:n=>{e({outlineOpen:n}),xr(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),xr(t())}})),Wt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],pw=.1,gw=8,yw="ole-grid";function M4(){try{const e=window.localStorage.getItem(yw);return e==null?!0:e==="1"}catch{return!0}}function T4(e){try{window.localStorage.setItem(yw,e?"1":"0")}catch{}}function A4(e,t,n){return e<t?t:e>n?n:e}function xw(){return document.querySelector(".ole-canvas-root")}function to(e){const t=Ze(),n=xw();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=A4(e,pw,gw),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function C4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=Wt.find(o=>o>t+1e-6)??gw;to(n)}function I4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=pw;for(let o=Wt.length-1;o>=0;o--)if(Wt[o]<t-1e-6){n=Wt[o];break}to(n)}const P4={off:"id",id:"all",all:"off"};function O4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=P4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function bw(){const[e,t]=O.useState(()=>M4());return O.useEffect(()=>{const n=xw();n==null||n.classList.toggle("hide-grid",!e),T4(e)},[e]),O.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function ww(){const e=ie();return c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:I4,"aria-label":e("view.zoomOut"),children:c.jsx(Xn,{})})})}function vw(){const e=ie();return c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:C4,"aria-label":e("view.zoomIn"),children:c.jsx(mv,{})})})}function kw(){const e=ie(),[t,n]=O.useState(KS);return O.useEffect(()=>VS(n),[]),c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.reset")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:c.jsxs("button",{type:"button",onClick:()=>to(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function _w(){const e=ie();return c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.fit")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:Zn,"aria-label":e("view.fit"),children:c.jsx(dv,{})})})}function $w({grid:e,setGrid:t}){const n=ie();return c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),c.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:je(!e&&"text-muted-foreground/60"),children:c.jsx(lv,{})})})}function Sw(){const e=ie(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return c.jsx(Ce,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:O4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:je(t==="off"&&"text-muted-foreground/60"),children:c.jsx(qr,{})})})}function B4({stacked:e}={}){const t=ie(),[n,o]=O.useState(!1),[r,s]=bw(),i=c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:t("view.menu")}),c.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?c.jsx(Ce,{content:i,children:c.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:je("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[c.jsx(Nn,{className:"size-4"}),c.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):c.jsx(Ce,{content:i,children:c.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:c.jsx(Nn,{})})});return c.jsx(eo,{open:n,onOpenChange:o,trigger:a,children:c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx(kw,{}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(ww,{}),c.jsx(vw,{})]}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(_w,{}),c.jsx($w,{grid:r,setGrid:s}),c.jsx(Sw,{})]})]})})}function L4(){const e=Ve();return Oe(e,"dense")?null:c.jsx(z4,{tier:e})}function z4({tier:e}){const t=Oe(e,"tight"),[n,o]=bw();return c.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:c.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[c.jsx(ww,{}),!t&&c.jsx(kw,{}),c.jsx(vw,{}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),c.jsx(_w,{}),c.jsx($w,{grid:n,setGrid:o}),c.jsx(Sw,{})]})})}const br=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:uv,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:cv,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Xn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:nv,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Hr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Or,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:qr,switchTo:"text",iconOnly:!0}];function R4(){const e=ie(),t=x(u=>u.activeTool),n=x(u=>u.placeKind),o=x(u=>u.placeFromTerminal),r=x(u=>u.wireDragFrom),s=x(u=>u.busbarDrawStart),i=x(u=>u.selection.length>0||u.selectedNode!=null);let a=null,l=!1;switch(t){case"select":a=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(l=!0);break;case"pan":a=e("mode.pan");break;case"wire":a=e(r?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(s?"mode.busDragging":"mode.busInit"),l=!0;break;case"junction":a=e("mode.junction"),l=!0;break;case"place":n?o?a=e("mode.placeFromTerm"):a=e("mode.placeNormal"):a=e("mode.placeNoKind"),l=!0;break;case"text":a=e("mode.text"),l=!0;break}if(!a)return null;const d=e(t==="select"?"mode.escSelect":"mode.escOther");return c.jsxs("div",{className:"ole-glass pointer-events-none flex items-center gap-2 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground shadow-sm",children:[c.jsx("span",{children:a}),l&&c.jsxs("span",{className:"text-muted-foreground/70",children:["· ",d]})]})}function D4(){const e=ie(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ve(),d=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),m=f?br.filter(h=>h.id!=="select"&&h.id!=="text"):br,p=h=>t===h.switchTo;return c.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))"},children:[u&&c.jsx(R4,{}),c.jsxs("div",{className:je("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&&c.jsx(F4,{stacked:!0}),m.map(h=>{const y=h.icon,w=p(h),$=h.id==="place"&&w&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return c.jsxs(O.Fragment,{children:[c.jsx(at,{icon:y,label:e(h.labelKey),hotkey:h.hotkey,active:w,iconOnly:!f&&(h.iconOnly||d),stacked:f,description:$,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!f&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!f&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?c.jsx(W4,{stacked:!0}):c.jsxs(c.Fragment,{children:[c.jsx(at,{icon:Kn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),c.jsx(at,{icon:Yn,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),c.jsx(H4,{iconOnly:d})]}),f&&c.jsx(B4,{stacked:!0})]})]})}function F4({stacked:e}){const t=ie(),n=Mt(r=>r.outlineOpen),o=Mt(r=>r.toggleOutline);return c.jsx(at,{icon:Rr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function at({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const d=c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:t}),n&&c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&c.jsx("div",{className:"text-muted-foreground",children:l})]});return c.jsx(Ce,{content:d,disabled:r,children:c.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:je("rounded-md font-medium transition-colors",i?"flex h-12 w-12 flex-col items-center justify-center gap-0.5 text-[10px] leading-tight":"flex h-9 items-center gap-1.5 text-xs",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[c.jsxs("span",{className:"relative inline-flex shrink-0",children:[c.jsx(e,{className:"size-4"}),n&&!i&&c.jsx("span",{"aria-hidden":!0,className:je("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?c.jsx("span",{className:"max-w-full truncate",children:t}):!s&&c.jsx("span",{children:t})]})})}function jw(){const e=x(r=>r.diagram.elements),t=x(r=>r.diagram.layout),n=x(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function H4({iconOnly:e}){const t=ie(),[n,o]=O.useState(!1),r=jw(),s=i=>()=>{o(!1),i()};return c.jsxs(eo,{open:n,onOpenChange:o,trigger:c.jsx(at,{icon:$t,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[c.jsx(Te,{onClick:s(()=>x.getState().autoArrangeAll()),icon:c.jsx($t,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Te,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:c.jsx($t,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:c.jsx(qt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),c.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(qt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function W4({stacked:e}){const t=ie(),[n,o]=O.useState(!1),r=x(m=>m.past.length),s=x(m=>m.future.length),i=x(m=>m.undo),a=x(m=>m.redo),l=x(m=>m.selection.length>0),d=x(m=>m.clipboard!=null),u=jw(),f=m=>()=>{o(!1),m()};return c.jsxs(eo,{open:n,onOpenChange:o,trigger:c.jsx(at,{icon:Nn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[c.jsx(Te,{onClick:f(i),icon:c.jsx(Kn,{}),disabled:r===0,children:t("tool.undo")}),c.jsx(Te,{onClick:f(a),icon:c.jsx(Yn,{}),disabled:s===0,children:t("tool.redo")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Te,{onClick:f(()=>x.getState().cutSelection()),icon:c.jsx(Fr,{}),disabled:!l,children:t("menu.cut")}),c.jsx(Te,{onClick:f(()=>x.getState().copySelection()),icon:c.jsx(Lr,{}),disabled:!l,children:t("menu.copy")}),c.jsx(Te,{onClick:f(()=>x.getState().pasteClipboard()),icon:c.jsx(Br,{}),disabled:!d,children:t("menu.paste")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Te,{onClick:f(()=>x.getState().autoArrangeAll()),icon:c.jsx($t,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Te,{onClick:f(()=>x.getState().autoArrangeSelection()),icon:c.jsx($t,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),c.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedAll()),icon:c.jsx(qt,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),c.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(qt,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Te({children:e,icon:t,onClick:n,disabled:o}){return c.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:je("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,c.jsx("span",{className:"flex-1",children:e})]})}function q4(){const e=Mt(r=>r.outlineOpen),t=Mt(r=>r.setOutlineOpen),n=Ve();return Oe(n,"dense")?e?c.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:c.jsx(wr,{onClose:()=>t(!1),sheet:!0})}):null:c.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?c.jsx(wr,{onClose:()=>t(!1)}):c.jsx(G4,{onClick:()=>t(!0)})})}function G4({onClick:e}){const t=ie(),n=Ve(),o=Oe(n,"compact");return c.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:je("ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",o?"w-12 justify-center":"gap-2 px-3"),children:[c.jsx(Rr,{className:"size-4 shrink-0"}),!o&&c.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function wr({onClose:e,sheet:t}){const n=ie(),o=x(d=>d.diagram.elements),r=x(d=>d.activeTool==="place"),s=Ve(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return c.jsxs("aside",{className:je("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:l},children:[c.jsxs("button",{type:"button",onClick:e,"aria-label":n("outline.collapseAria"),title:n("outline.collapse"),className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-muted/40",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&c.jsx(Y4,{children:o.length}),c.jsx(fv,{className:"size-3.5 text-muted-foreground"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?c.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):c.jsx("ul",{className:"space-y-px",children:o.map(d=>c.jsx(X4,{element:d},d.id))})})]})}function X4({element:e}){const t=Ke[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return c.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[c.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&c.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),c.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function Y4({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const K4={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},V4={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current","resistor.name":"Resistor (R)","capacitor.name":"Capacitor (C)","diode.name":"Diode (D)","indicator-light.name":"Indicator light (HL)","push-button.name":"Push-button (SB)","relay-coil.name":"Relay coil (KA)","make-contact.name":"NO contact (NO)","break-contact.name":"NC contact (NC)","bell.name":"Bell (HA)","terminal.name":"Terminal / junction (X)","fuse-switch-disconnector.name":"Fuse switch-disconnector","socket-outlet.name":"Socket outlet / connector","inductor.name":"Inductor (L)","voltage-regulator.name":"Voltage regulator (T)","dc-motor.name":"DC motor (M)","heater.name":"Heating element (EH)","selector-switch.name":"Selector switch (SA)","limit-switch.name":"Limit switch (SQ)","proximity-switch.name":"Proximity switch (SQ)","time-relay.name":"Time relay (KT)","buzzer.name":"Buzzer (HA)","siren.name":"Siren (HA)","thermocouple.name":"Thermocouple (BT)","thyristor.name":"Thyristor / SCR (V)","triac.name":"Triac (V)","zener-diode.name":"Zener diode (D)","igbt.name":"IGBT","plc.name":"PLC / controller","ups.name":"UPS","power-supply.name":"Power supply (PS)","genset.name":"Generator set (G)","protective-relay.name":"Protective relay","overcurrent-relay.name":"Overcurrent relay (50/51)","undervoltage-relay.name":"Undervoltage relay (27)","reverse-power-relay.name":"Reverse-power relay (32)","distance-relay.name":"Distance relay (21)","phase-failure-relay.name":"Phase-failure relay","buchholz-relay.name":"Buchholz relay (63)","power-factor-meter.name":"Power-factor meter (cosφ)","synchronoscope.name":"Synchronoscope","varmeter.name":"Varmeter (var)","resistor.desc":"General resistor / current-limiting / braking resistor.","capacitor.desc":"General / filter / DC-bus capacitor. Use shunt capacitor for PF correction.","diode.desc":"Rectifier / freewheeling / protection diode. t1 = anode (top), t2 = cathode (bottom).","indicator-light.desc":"Signal / status indicator light.","push-button.desc":"Manual push-button, automatic return (NO make).","relay-coil.desc":"Relay / contactor operating coil (box).","make-contact.desc":"Normally-open auxiliary contact (make).","break-contact.desc":"Normally-closed auxiliary contact (break).","bell.desc":"Signal bell / alarm bell.","terminal.desc":"Terminal / junction box / connection node.","fuse-switch-disconnector.desc":"On-load fuse switch-disconnector.","socket-outlet.desc":"Power socket outlet / multipole connector.","inductor.desc":"General inductor / coil / choke.","voltage-regulator.desc":"Adjustable induction / autotransformer voltage regulator.","dc-motor.desc":"DC motor (series-field general symbol).","heater.desc":"Resistive heating element / heating load.","selector-switch.desc":"Selector / changeover switch (rotary, stay-put).","limit-switch.desc":"Travel / position switch (NO, mechanically operated).","proximity-switch.desc":"Proximity sensor / contactless proximity switch.","time-relay.desc":"Time-delay (slow-operating) relay coil.","buzzer.desc":"Signal buzzer.","siren.desc":"Audible siren / alarm.","thermocouple.desc":"Thermocouple temperature sensor.","thyristor.desc":"Reverse-blocking triode thyristor / SCR. t1 = anode (top), t2 = cathode (bottom).","triac.desc":"Bidirectional triode thyristor (TRIAC).","zener-diode.desc":"Zener / voltage-regulator diode. t1 = anode (top), t2 = cathode (bottom).","igbt.desc":"N-channel enhancement IGBT. t1 = collector (top), t2 = emitter (bottom), t_g = gate.","plc.desc":"Programmable logic controller (PLC).","ups.desc":"Online / standby uninterruptible power supply.","power-supply.desc":"AC→DC switched-mode / DC power supply. t_ac top (~), t_dc bottom (=).","genset.desc":"Diesel / gas generator set.","protective-relay.desc":"Measuring / protective relay, general symbol (IEC 60617).","overcurrent-relay.desc":"Overcurrent protection relay (ANSI 50/51).","undervoltage-relay.desc":"Undervoltage protection relay (ANSI 27).","reverse-power-relay.desc":"Reverse-power / reverse-current protection relay (ANSI 32).","distance-relay.desc":"Distance / under-impedance protection relay (ANSI 21).","phase-failure-relay.desc":"Phase-failure / phase-loss protection relay.","buchholz-relay.desc":"Buchholz / gas relay (ANSI 63).","power-factor-meter.desc":"Power-factor meter (cosφ).","synchronoscope.desc":"Synchronizing indicator / synchronoscope.","varmeter.desc":"Reactive-power meter (var).","make-contact.state.closed":"Closed","break-contact.state.open":"Open","fuse-switch-disconnector.state.open":"Open","selector-switch.state.open":"Open","limit-switch.state.closed":"Closed","resistor.param.R":"Resistance","resistor.param.P":"Rated power","capacitor.param.C":"Capacitance","capacitor.param.Un":"Rated voltage","indicator-light.param.color":"Color","inductor.param.L":"Inductance","inductor.param.In":"Rated current","voltage-regulator.param.ratio":"Regulation range","heater.param.P":"Power","ups.param.S":"Capacity","power-supply.param.Vdc":"Output voltage","genset.param.P":"Power"},vr={zh:K4,en:V4};function U4(e,t){return vr[e][t]??vr.zh[t]}function At(){const e=Tt(t=>t.locale);return(t,n)=>U4(e,t)??n??t}const Ew="ole-palette-collapsed",J4=new Set(["busbar"]),Et=(()=>{const e={};for(const[t,n]of Object.entries(j$)){const o=n.filter(r=>!J4.has(r.id));o.length&&(e[t]=o)}return e})(),Z4=(()=>{const e=new Set(Wo),t=Object.keys(Et).filter(n=>!e.has(n));return[...Wo.filter(n=>{var o;return(o=Et[n])==null?void 0:o.length}),...t]})();function Q4(){try{const e=window.localStorage.getItem(Ew);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 ej(e){try{window.localStorage.setItem(Ew,JSON.stringify([...e]))}catch{}}function tj(){const e=ie(),t=x(f=>f.activeTool==="place"),n=x(f=>f.placeKind),o=x(f=>f.setActiveTool),r=Mt(f=>f.outlineOpen),s=Ve(),i=Oe(s,"dense"),a=68,d=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:a};return c.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:c.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:d?{maxHeight:d}:void 0,children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),c.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:c.jsx(Vn,{className:"size-3.5"})})]}),c.jsx(nj,{sheet:i})]})})}function nj({sheet:e}){const t=ie(),n=At(),[o,r]=O.useState(""),[s,i]=O.useState(()=>Q4()),a=O.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return Et;const m={};for(const[p,h]of Object.entries(Et)){const y=h.filter(w=>{const $=n(`${w.id}.name`,w.name).toLowerCase(),k=n(`${w.id}.desc`,w.description??"").toLowerCase();return $.includes(f)||w.id.toLowerCase().includes(f)||k.includes(f)});y.length&&(m[p]=y)}return m},[o,n]),l=o.trim().length>0,d=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=O.useCallback((f,m)=>{i(p=>{const h=new Set(p);return m?h.delete(f):h.add(f),ej(h),h})},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-2 pb-1.5 pt-2",children:c.jsx(oj,{value:o,onChange:r})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:d?c.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):Z4.map(f=>{var w;const m=a[f];if(!(m!=null&&m.length))return null;const p=((w=Et[f])==null?void 0:w.length)??m.length,h=t(`cat.${f}`),y=l||!s.has(f);return c.jsxs("details",{open:y,className:"group mb-2 last:mb-0",onToggle:$=>{l||u(f,$.currentTarget.open)},children:[c.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:[c.jsx(tv,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),c.jsx("span",{className:"flex-1",children:h}),c.jsx(sj,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),c.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map($=>c.jsx(rj,{entry:$,sheet:e},$.id))})]},f)})})]})}function oj({value:e,onChange:t}){const n=ie();return c.jsxs("div",{className:"relative",children:[c.jsx(hv,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),c.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&c.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Vn,{className:"size-3"})})]})}function rj({entry:e,sheet:t}){const n=ie(),o=At(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(f=>f.setActiveTool),a=x(f=>f.activeTool==="place"&&f.placeKind===e.id),l=x(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),d=O.useRef(null);O.useEffect(()=>{var f;l&&((f=d.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const m=document.createElement("div");m.className="ole-glass",m.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),m.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(m),f.dataTransfer.setDragImage(m,32,32),setTimeout(()=>m.remove(),0)};return c.jsxs("li",{ref:d,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[c.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:c.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),c.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function sj({children:e}){return c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const qn="ole-onboarding-dismissed";function ij(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qn)==="1"}catch{return!1}}function kr(e){try{e?window.localStorage.setItem(qn,"1"):window.localStorage.removeItem(qn)}catch{}}const _r=Jt(e=>({dismissed:ij(),dismiss:()=>{kr(!0),e({dismissed:!0})},reset:()=>{kr(!1),e({dismissed:!1})}}));function aj(){const e=ie(),t=_r(o=>o.dismissed),n=_r(o=>o.dismiss);return t?null:c.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),c.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:c.jsx(Vn,{className:"size-3.5"})})]}),c.jsxs("ol",{className:"mt-3 space-y-2.5",children:[c.jsx(jn,{n:1,icon:c.jsx(Xn,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),c.jsx(jn,{n:2,icon:c.jsx(Hr,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),c.jsx(jn,{n:3,icon:c.jsx(Or,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),c.jsx("button",{type:"button",onClick:n,className:"pointer-events-auto mt-4 w-full rounded-md bg-primary py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("onboard.dismiss")})]})}function jn({n:e,icon:t,title:n,body:o}){return c.jsxs("li",{className:"flex items-start gap-2.5",children:[c.jsx("span",{className:"mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklch,var(--selection)_18%,transparent)] font-mono text-[10px] font-semibold tabular-nums text-[var(--selection)]","aria-hidden":!0,children:e}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[c.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),c.jsx("span",{children:n})]}),c.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function lj(){const e=ie(),t=x(m=>m.selection),n=x(m=>m.diagram.elements),o=x(m=>m.diagram.buses),r=x(m=>m.diagram.junctions),s=x(m=>m.selectedNode),i=x(m=>m.selectedWire);if(i)return c.jsx(hj,{wireId:i});if(s)return c.jsx(gj,{nodeId:s});if(t.length===0)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const a=t[0],l=(o??[]).find(m=>m.id===a);if(l)return c.jsx(fj,{bus:l});const d=(r??[]).find(m=>m.id===a);if(d)return c.jsx(pj,{junction:d});const u=n.find(m=>m.id===a);if(!u)return null;const f=Ke[u.kind];return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(ut,{label:e("props.name"),value:u.name??"",placeholder:u.id,onCommit:m=>x.getState().updateElement(a,{name:m.trim()===""?void 0:m.trim()})}),c.jsx(no,{label:e("props.note"),value:u.note??"",onCommit:m=>x.getState().updateElement(a,{note:m.trim()===""?void 0:m.trim()})}),(f==null?void 0:f.state)&&f.state.length>0&&c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:f.state.map(m=>c.jsx(yj,{id:a,element:u,field:m},m.name))}),c.jsx(cj,{id:a,element:u,schema:(f==null?void 0:f.params)??[]})]})}function cj({id:e,element:t,schema:n}){const o=new Set(n.map(s=>s.name)),r=t.params?Object.entries(t.params).filter(([s])=>!o.has(s)):[];return n.length===0&&r.length===0?null:c.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>c.jsx(dj,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>c.jsx(uj,{id:e,element:t,fieldKey:s,value:i},s))]})}function dj({id:e,element:t,field:n}){var l;const o=ie(),r=At(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=d=>{const u={...t.params??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(dt,{label:i,children:c.jsx(oo,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?c.jsx(rn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):c.jsx(ut,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:d=>a(d.trim()===""?void 0:d)})}function uj({id:e,element:t,fieldKey:n,value:o}){const r=ie(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,x.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?c.jsx(dt,{label:n,children:c.jsx(oo,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?c.jsx(rn,{label:n,value:o,onCommit:s}):c.jsx(ut,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function fj({bus:e}){const t=ie(),n=e.id,o=r=>{const s=r.trim();Gn(n,{name:s===""?void 0:s})};return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(ut,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),c.jsx(no,{label:t("props.note"),value:e.note??"",onCommit:r=>Gn(n,{note:r.trim()===""?void 0:r.trim()})}),c.jsx(mj,{bus:e})]})}function mj({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Gn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:c.jsx(rn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Gn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function hj({wireId:e}){const t=ie(),n=x(w=>w.diagram.wires),o=x(w=>w.diagram.elements),r=x(w=>w.diagram.buses),s=x(w=>w.diagram.junctions),i=x(w=>w.internal.terminalToNode),a=x(w=>w.setSelectedNode),l=(n??[]).find(w=>w.id===e);if(!l)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const d=i.get(l.ends[0]),u=new Map(o.map(w=>[w.id,w])),f=new Map((r??[]).map(w=>[w.id,w])),m=new Map((s??[]).map(w=>[w.id,w])),p=w=>{if(!w.includes(".")){const C=f.get(w);if(C)return{id:w,label:C.name??w};const R=m.get(w);return{id:w,label:(R==null?void 0:R.name)??w}}const $=w.indexOf("."),k=w.slice(0,$),b=w.slice($+1),S=u.get(k);return{id:k,label:(S==null?void 0:S.name)??k,pin:b}},h=p(l.ends[0]),y=p(l.ends[1]);return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),c.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,y].map((w,$)=>c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([w.id]),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:w.id}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:w.label}),w.pin&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:w.pin})]},$))}),d&&c.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>a(d),children:t("props.selectWholeNode")})]})}function pj({junction:e}){var r;const t=ie(),n=x(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return c.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),c.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),c.jsx(ut,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>x.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),c.jsx(no,{label:t("props.note"),value:e.note??"",onCommit:s=>x.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})}),o&&c.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[c.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),c.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function gj({nodeId:e}){const t=ie(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const d=a.slice(0,l),u=a.slice(l+1),f=s.get(d)??[];f.push(u),s.set(d,f)}const i=new Map(o.map(a=>[a.id,a]));return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),c.jsx("div",{className:"font-mono text-[12px]",children:n.id}),c.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const d=i.get(a);return c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(d==null?void 0:d.name)??""}),c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function dt({label:e,children:t}){return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),c.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function ut({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=O.useState(t),a=O.useRef(null);return O.useEffect(()=>i(t),[t]),c.jsx(dt,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:je("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function no({label:e,value:t,onCommit:n}){const[o,r]=O.useState(t);return O.useEffect(()=>r(t),[t]),c.jsx(dt,{label:e,children:c.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function rn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=O.useState(String(t)),a=O.useRef(null);return O.useEffect(()=>i(String(t)),[t]),c.jsx(dt,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:je("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 font-mono text-[11px] tabular-nums focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function oo({active:e,onClick:t,children:n}){return c.jsx("button",{type:"button",onClick:t,className:je("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 yj({id:e,element:t,field:n}){var l;const o=ie(),s=At()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=d=>{const u={...t.state??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(dt,{label:s,children:c.jsx(oo,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?c.jsx(rn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):c.jsx(ut,{label:s,value:typeof i=="string"?i:"",onCommit:d=>a(d.trim()===""?void 0:d)})}function xj(){const e=ie(),t=At(),n=x(f=>f.selection),o=x(f=>f.selectedNode),r=x(f=>f.selectedWire),s=x(f=>f.diagram.elements),i=x(f=>f.diagram.buses),a=Ve(),l=Oe(a,"dense");if(n.length===0&&!o&&!r)return null;let d=e("props.title"),u=null;if(r)d=e("props.wire");else if(o)d=e("props.node");else if(n.length===1){const f=n[0],m=(i??[]).find(p=>p.id===f);if(m)d=m.name??e("props.bus");else{const p=s.find(h=>h.id===f);if(p){const h=Ke[p.kind];d=h?t(`${h.id}.name`,h.name):p.kind}}}else u=n.length;return c.jsxs("aside",{className:je("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",l?"w-48":"w-56"),style:{top:`calc(${l?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:d}),u!=null&&c.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e("props.nSelected",{n:u})})]}),c.jsx(lj,{})]})}function bj(){O.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function wj(){bj();const e=O.useRef(null),t=OS(e);return c.jsx(Uv,{children:c.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:c.jsxs(f4,{width:t,children:[c.jsx(n4,{}),c.jsx(q4,{}),c.jsx(xj,{}),c.jsx(D4,{}),c.jsx(L4,{}),c.jsx(E4,{}),c.jsx(tj,{}),c.jsx(aj,{}),c.jsx(d4,{})]})})})}const vj="ole-theme";function kj(){try{const e=window.localStorage.getItem(vj);return e==="light"||e==="dark"?e:null}catch{return null}}function _j(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function $j(){return typeof window>"u"?"light":kj()??(_j()?"dark":"light")}function Nw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Sj({className:e,diagram:t,locale:n,theme:o}){return O.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),O.useEffect(()=>{n&&Tt.getState().setLocale(n)},[n]),O.useEffect(()=>{o&&Nw(o)},[o]),O.useEffect(()=>{Qn()},[]),wS(),c.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:c.jsx(wj,{})})}const Mw={"application/json":[".json"]},Tw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Aw=e=>e instanceof DOMException&&e.name==="AbortError";function $r(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 jj(e){return JSON.stringify(e,null,2)+`
199
- `}async function Ej(){if(Tw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:we("topbar.file.fileDescription"),accept:Mw}]})}catch(n){if(Aw(n))return null;throw n}const t=await e.getFile();return{diagram:$r(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:$r(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function Sr(e,t,n={}){const o=jj(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Tw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:we("topbar.file.fileDescription"),accept:Mw}]})}catch(l){if(Aw(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 Nj(){const e=ie(),t=x(f=>f.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=Mj(),[a,l]=O.useState(!1),d=O.useRef(null);O.useEffect(()=>{const f=m=>{if(!(m.metaKey||m.ctrlKey))return;const p=m.key.toLowerCase();p==="o"?(m.preventDefault(),r()):p==="s"&&(m.preventDefault(),m.shiftKey?i():s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,s,i]),O.useEffect(()=>{if(!a)return;const f=p=>{d.current&&!d.current.contains(p.target)&&l(!1)},m=p=>{p.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",m)}},[a]);const u=f=>()=>{l(!1),f()};return c.jsxs("div",{ref:d,className:"relative",children:[c.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(f=>!f),children:[c.jsx(jo,{}),e("topbar.file.label")]}),a&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-44 rounded-md border border-border p-1 shadow-md",children:[c.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),c.jsx(Ft,{onClick:u(o),icon:c.jsx(iv,{}),children:e("topbar.file.new")}),c.jsx(Ft,{onClick:u(r),icon:c.jsx(jo,{}),hint:"⌘O",children:e("topbar.file.open")}),c.jsx(Ft,{onClick:u(s),icon:c.jsx(Eo,{}),hint:"⌘S",children:e("topbar.file.save")}),c.jsx(Ft,{onClick:u(i),icon:c.jsx(Eo,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function Ft({children:e,icon:t,hint:n,onClick:o}){return c.jsxs("button",{type:"button",role:"menuitem",onClick:o,className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[t,c.jsx("span",{className:"flex-1",children:e}),n&&c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function Mj(){const e=ie(),t=x(l=>l.loadDiagramFromFile),n=x(l=>l.setFileSession),o=x(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=x.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await Ej();l&&(t(l.diagram,l.session),Qn())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:d}=x.getState(),u=await Sr(l,d);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:d}=x.getState(),u=await Sr(l,d,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const En="WIRES",Fe="ELEMENTS",jr="LABELS",Er="ANNOTATIONS",Nr=32,Mr=64,Tj=8,Aj=1.25,Cj=6;function Cw(e,t={}){const n=new Gj(t.precision??6);n.header(t.title),n.tables([{name:En,color:7},{name:Fe,color:7},{name:jr,color:8},{name:Er,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(En,r.path.map(Ie),!1);for(const{geometry:r}of e.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,d=s==="x"?[i[0]-l,i[1]]:[i[0],i[1]-l],u=s==="x"?[i[0]+l,i[1]]:[i[0],i[1]+l];n.lwpolyline(En,[d,u].map(Ie),!1)}for(const r of e.elements.values()){const s=e.layout.get(r.element.id),i=r.libraryDef;!s||!i||Ij(n,i.svg,s)}const o=t.labelMode??"all";if(o!=="off")for(const r of e.elements.values()){const s=e.layout.get(r.element.id);if(!s||!r.libraryDef)continue;const i=Qt(r,o);if(i.length===0)continue;const a=r.libraryDef.label??en(r.libraryDef),[l,d]=tn(a,s);for(let u=0;u<i.length;u++){const[f,m]=Ie([l,d+u*Zt]);n.text(jr,[f,m],i[u],Yt,0,!1)}}for(const r of t.annotations??[]){if(!r.text)continue;const s=r.fontSize??Tj,i=r.text.split(`
200
- `);for(let a=0;a<i.length;a++){const[l,d]=Ie([r.at[0],r.at[1]+(a+1)*s*Aj]);n.text(Er,[l,d],i[a],s,0,!1)}}return n.endEntities(),n.toString()}async function Iw(e,t="diagram.dxf",n){const o=Cw(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 Ij(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":Pj(e,i,n);break;case"polyline":Tr(e,i,n,!1);break;case"polygon":Tr(e,i,n,!0);break;case"rect":Oj(e,i,n);break;case"circle":Bj(e,i,n);break;case"ellipse":Lj(e,i,n);break;case"path":Fj(e,i,n);break;case"text":Dj(e,i,n);break}}function Pj(e,t,n){const o=ve(t,"x1"),r=ve(t,"y1"),s=ve(t,"x2"),i=ve(t,"y2"),a=Ie(De([o,r],n)),l=Ie(De([s,i],n));e.line(Fe,a,l)}function Tr(e,t,n,o){const r=qj(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>Ie(De(i,n)));e.lwpolyline(Fe,s,o)}function Oj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=ve(t,"width"),i=ve(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(d=>Ie(De(d,n)));e.lwpolyline(Fe,l,!0)}function Bj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"r"),i=Ie(De([o,r],n));e.circle(Fe,i,s)}function Lj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"rx"),i=ve(t,"ry");if(Math.abs(s-i)<1e-6){zj(e,o,r,s,n);return}Rj(e,o,r,s,i,n)}function zj(e,t,n,o,r){const s=Ie(De([t,n],r));e.circle(Fe,s,o)}function Rj(e,t,n,o,r,s){const i=[];for(let a=0;a<Mr;a++){const l=a/Mr*Math.PI*2;i.push(Ie(De([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Fe,i,!0)}function Dj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||Cj,i=(t.textContent??"").trim();if(!i)return;const a=Ie(De([o,r],n));e.text(Fe,a,i,s,n.rot,n.mirror)}function Fj(e,t,n){const o=t.getAttribute("d")??"",r=Hj(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Fe,i.map(l=>Ie(De(l,n))),!1),i=[]};for(const l of r)if(l.cmd==="M")a(),s=[l.args[0],l.args[1]],i.push(s);else if(l.cmd==="A"&&s){const[d,u,,f,m,p,h]=l.args,y=Wj(s,[p,h],d,u,f!==0,m!==0);if(y)for(let w=1;w<=Nr;w++){const $=y.theta1+y.delta*w/Nr;i.push([y.cx+d*Math.cos($),y.cy+u*Math.sin($)])}else i.push([p,h]);s=[p,h]}a()}function Hj(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 Wj(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,d]=t;if(i===l&&a===d)return null;const u=(i-l)/2,f=(a-d)/2;let m=Math.abs(n),p=Math.abs(o);const h=m*m,y=p*p,w=u*u/h+f*f/y;if(w>1){const W=Math.sqrt(w);m*=W,p*=W}const $=r===s?-1:1,k=m*m*p*p-m*m*f*f-p*p*u*u,b=m*m*f*f+p*p*u*u,S=$*Math.sqrt(Math.max(0,k/b)),C=S*(m*f)/p,R=S*-(p*u)/m,X=C+(i+l)/2,V=R+(a+d)/2,te=(W,ye,ue,pe)=>{const ne=W*ue+ye*pe,re=Math.hypot(W,ye)*Math.hypot(ue,pe);let ge=Math.acos(Math.max(-1,Math.min(1,ne/re)));return W*pe-ye*ue<0&&(ge=-ge),ge},ae=te(1,0,(u-C)/m,(f-R)/p);let D=te((u-C)/m,(f-R)/p,(-u-C)/m,(-f-R)/p);return!s&&D>0?D-=2*Math.PI:s&&D<0&&(D+=2*Math.PI),{cx:X,cy:V,theta1:ae,delta:D}}function De(e,t){return Pe(e,t)}function Ie(e){return[e[0],-e[1]]}function ve(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function qj(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 Gj{constructor(t){gt(this,"out",[]);gt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
196
+ */const Vn=oe("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Xr(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Xr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Yr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Xr(e))&&(o&&(o+=" "),o+=t);return o}const Un="-",xv=e=>{const t=wv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Un);return a[0]===""&&a.length!==1&&a.shift(),Kr(a,t)||bv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Kr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Kr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(Un);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},No=/^\[(.+)\]$/,bv=e=>{if(No.test(e)){const t=No.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},wv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return kv(Object.entries(e.classGroups),n).forEach(([s,i])=>{Mn(i,o,s,t)}),o},Mn=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:Mo(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(vv(r)){Mn(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{Mn(i,Mo(t,s),n,o)})})},Mo=(e,t)=>{let n=e;return t.split(Un).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},vv=e=>e.isThemeGetter,kv=(e,t)=>t?e.map(([n,o])=>{const r=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,a])=>[t+i,a])):s);return[n,r]}):e,_v=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return r(s,i),i},set(s,i){n.has(s)?n.set(s,i):r(s,i)}}},Vr="!",$v=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,u=0,f;for(let b=0;b<a.length;b++){let $=a[b];if(c===0){if($===r&&(o||a.slice(b,b+s)===t)){l.push(a.slice(u,b)),u=b+s;continue}if($==="/"){f=b;continue}}$==="["?c++:$==="]"&&c--}const m=l.length===0?a:a.substring(u),p=m.startsWith(Vr),h=p?m.substring(1):m,g=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:g}};return n?a=>n({className:a,parseClassName:i}):i},Sv=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},jv=e=>({cache:_v(e.cacheSize),parseClassName:$v(e),...xv(e)}),Ev=/\s+/,Nv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(Ev);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:p}=n(c);let h=!!p,g=o(h?m.substring(0,p):m);if(!g){if(!h){a=c+(a.length>0?" "+a:a);continue}if(g=o(m),!g){a=c+(a.length>0?" "+a:a);continue}h=!1}const b=Sv(u).join(":"),$=f?b+Vr:b,k=$+g;if(s.includes(k))continue;s.push(k);const w=r(g,h);for(let S=0;S<w.length;++S){const C=w[S];s.push($+C)}a=c+(a.length>0?" "+a:a)}return a};function Mv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ur(t))&&(o&&(o+=" "),o+=n);return o}const Ur=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Ur(e[o]))&&(n&&(n+=" "),n+=t);return n};function Tv(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((u,f)=>f(u),e());return n=jv(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const u=Nv(l,n);return r(l,u),u}return function(){return s(Mv.apply(null,arguments))}}const fe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Jr=/^\[(?:([a-z-]+):)?(.+)\]$/i,Av=/^\d+\/\d+$/,Cv=new Set(["px","full","screen"]),Iv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Pv=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ov=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Bv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Lv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Le=e=>st(e)||Cv.has(e)||Av.test(e),We=e=>ct(e,"length",Gv),st=e=>!!e&&!Number.isNaN(Number(e)),fn=e=>ct(e,"number",st),yt=e=>!!e&&Number.isInteger(Number(e)),zv=e=>e.endsWith("%")&&st(e.slice(0,-1)),ee=e=>Jr.test(e),qe=e=>Iv.test(e),Rv=new Set(["length","size","percentage"]),Dv=e=>ct(e,Rv,Zr),Fv=e=>ct(e,"position",Zr),Hv=new Set(["image","url"]),Wv=e=>ct(e,Hv,Yv),qv=e=>ct(e,"",Xv),xt=()=>!0,ct=(e,t,n)=>{const o=Jr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},Gv=e=>Pv.test(e)&&!Ov.test(e),Zr=()=>!1,Xv=e=>Bv.test(e),Yv=e=>Lv.test(e),Kv=()=>{const e=fe("colors"),t=fe("spacing"),n=fe("blur"),o=fe("brightness"),r=fe("borderColor"),s=fe("borderRadius"),i=fe("borderSpacing"),a=fe("borderWidth"),l=fe("contrast"),c=fe("grayscale"),u=fe("hueRotate"),f=fe("invert"),m=fe("gap"),p=fe("gradientColorStops"),h=fe("gradientColorStopPositions"),g=fe("inset"),b=fe("margin"),$=fe("opacity"),k=fe("padding"),w=fe("saturate"),S=fe("scale"),C=fe("sepia"),R=fe("skew"),X=fe("space"),V=fe("translate"),te=()=>["auto","contain","none"],ae=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",ee,t],W=()=>[ee,t],ye=()=>["",Le,We],ue=()=>["auto",st,ee],pe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],re=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ge=()=>["start","end","center","between","around","evenly","stretch"],xe=()=>["","0",ee],_e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Ee=()=>[st,ee];return{cacheSize:500,separator:":",theme:{colors:[xt],spacing:[Le,We],blur:["none","",qe,ee],brightness:Ee(),borderColor:[e],borderRadius:["none","","full",qe,ee],borderSpacing:W(),borderWidth:ye(),contrast:Ee(),grayscale:xe(),hueRotate:Ee(),invert:xe(),gap:W(),gradientColorStops:[e],gradientColorStopPositions:[zv,We],inset:D(),margin:D(),opacity:Ee(),padding:W(),saturate:Ee(),scale:Ee(),sepia:xe(),skew:Ee(),space:W(),translate:W()},classGroups:{aspect:[{aspect:["auto","square","video",ee]}],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:[...pe(),ee]}],overflow:[{overflow:ae()}],"overflow-x":[{"overflow-x":ae()}],"overflow-y":[{"overflow-y":ae()}],overscroll:[{overscroll:te()}],"overscroll-x":[{"overscroll-x":te()}],"overscroll-y":[{"overscroll-y":te()}],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,ee]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ee]}],grow:[{grow:xe()}],shrink:[{shrink:xe()}],order:[{order:["first","last","none",yt,ee]}],"grid-cols":[{"grid-cols":[xt]}],"col-start-end":[{col:["auto",{span:["full",yt,ee]},ee]}],"col-start":[{"col-start":ue()}],"col-end":[{"col-end":ue()}],"grid-rows":[{"grid-rows":[xt]}],"row-start-end":[{row:["auto",{span:[yt,ee]},ee]}],"row-start":[{"row-start":ue()}],"row-end":[{"row-end":ue()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ee]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ee]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...ge()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ge(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ge(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[k]}],px:[{px:[k]}],py:[{py:[k]}],ps:[{ps:[k]}],pe:[{pe:[k]}],pt:[{pt:[k]}],pr:[{pr:[k]}],pb:[{pb:[k]}],pl:[{pl:[k]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[X]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[X]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ee,t]}],"min-w":[{"min-w":[ee,t,"min","max","fit"]}],"max-w":[{"max-w":[ee,t,"none","full","min","max","fit","prose",{screen:[qe]},qe]}],h:[{h:[ee,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ee,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ee,t,"auto","min","max","fit"]}],"font-size":[{text:["base",qe,We]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",fn]}],"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",ee]}],"line-clamp":[{"line-clamp":["none",st,fn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Le,ee]}],"list-image":[{"list-image":["none",ee]}],"list-style-type":[{list:["none","disc","decimal",ee]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[$]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[$]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Le,We]}],"underline-offset":[{"underline-offset":["auto",Le,ee]}],"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:W()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ee]}],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",ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[$]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...pe(),Fv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Dv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Wv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[$]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[$]}],"divide-style":[{divide:ne()}],"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:["",...ne()]}],"outline-offset":[{"outline-offset":[Le,ee]}],"outline-w":[{outline:[Le,We]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:ye()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[$]}],"ring-offset-w":[{"ring-offset":[Le,We]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",qe,qv]}],"shadow-color":[{shadow:[xt]}],opacity:[{opacity:[$]}],"mix-blend":[{"mix-blend":[...re(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":re()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",qe,ee]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[C]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[$]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[C]}],"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",ee]}],duration:[{duration:Ee()}],ease:[{ease:["linear","in","out","in-out",ee]}],delay:[{delay:Ee()}],animate:[{animate:["none","spin","ping","pulse","bounce",ee]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[yt,ee]}],"translate-x":[{"translate-x":[V]}],"translate-y":[{"translate-y":[V]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ee]}],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",ee]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":W()}],"scroll-mx":[{"scroll-mx":W()}],"scroll-my":[{"scroll-my":W()}],"scroll-ms":[{"scroll-ms":W()}],"scroll-me":[{"scroll-me":W()}],"scroll-mt":[{"scroll-mt":W()}],"scroll-mr":[{"scroll-mr":W()}],"scroll-mb":[{"scroll-mb":W()}],"scroll-ml":[{"scroll-ml":W()}],"scroll-p":[{"scroll-p":W()}],"scroll-px":[{"scroll-px":W()}],"scroll-py":[{"scroll-py":W()}],"scroll-ps":[{"scroll-ps":W()}],"scroll-pe":[{"scroll-pe":W()}],"scroll-pt":[{"scroll-pt":W()}],"scroll-pr":[{"scroll-pr":W()}],"scroll-pb":[{"scroll-pb":W()}],"scroll-pl":[{"scroll-pl":W()}],"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",ee]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Le,We,fn]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Vv=Tv(Kv);function je(...e){return Vv(Yr(e))}const Qr=O.createContext(null);function Uv(){const e=O.useContext(Qr);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const Pt=8;function Jv({children:e}){const[t,n]=O.useState({open:!1,x:0,y:0,items:[]}),[o,r]=O.useState(null),s=O.useRef(null),i=O.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=O.useCallback((c,u,f)=>{r(null),n({open:!0,x:c,y:u,items:f})},[]),l=O.useMemo(()=>({open:a,close:i}),[a,i]);return O.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+c.width>window.innerWidth-Pt&&(u=Math.max(Pt,t.x-c.width)),f+c.height>window.innerHeight-Pt&&(f=Math.max(Pt,t.y-c.height)),r({left:u,top:f})},[t]),O.useEffect(()=>{if(!t.open)return;const c=p=>{s.current&&!s.current.contains(p.target)&&i()},u=p=>{p.key==="Escape"&&(p.preventDefault(),i())},f=()=>i(),m=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",m),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",m)}},[t.open,i]),d.jsxs(Qr.Provider,{value:l,children:[e,t.open&&d.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:c=>c.preventDefault(),children:t.items.map((c,u)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:je("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 To=e=>{let t;const n=new Set,o=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const m=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,m))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,r,a);return a},Zv=(e=>e?To(e):To),Qv=e=>e;function e2(e,t=Qv){const n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),O.useCallback(()=>t(e.getInitialState()),[e,t]));return O.useDebugValue(n),n}const Ao=e=>{const t=Zv(e),n=o=>e2(t,o);return Object.assign(n,t),n},Jt=(e=>e?Ao(e):Ao),Co={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.junction":"接线柱","props.junctionPos":"位置","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从端子/母线/接线柱拖出;拖到空白处会自动新建接线柱,拖到已有连线上可打接点","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"放一个器件","onboard.step1.body":"切到 元件 工具(P),从左侧元件库选一种拖到画布","onboard.step2.title":"拉线连接","onboard.step2.body":"用 连线 工具(W)从一个引脚拖到另一个引脚;拖到空白处会自动新建接线柱","onboard.step3.title":"需要共用排时才用母线","onboard.step3.body":"多条回路共用一条母排时,用 母线 工具(B)画一段;普通点对点连线不需要母线","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.junction":"Junction","props.junctionPos":"Position","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.junction":"Click the canvas to drop a junction","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Place a component","onboard.step1.body":"Pick the Place tool (P) and drag a kind from the library onto the canvas","onboard.step2.title":"Wire it up","onboard.step2.body":"Use the Wire tool (W): drag from one pin to another — drag into empty space to drop a junction","onboard.step3.title":"Busbars are for shared rails","onboard.step3.body":"When several circuits share one rail, draw a busbar (B); plain point-to-point wiring needs no bus","onboard.dismiss":"Got it"}},es="ole-locale";function t2(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(es);if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&typeof navigator.language=="string"?navigator.language.toLowerCase().startsWith("zh")?"zh":"en":"zh"}function Io(e){try{window.localStorage.setItem(es,e)}catch{}}const Tt=Jt((e,t)=>({locale:t2(),setLocale:n=>{Io(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";Io(n),e({locale:n})}}));function ts(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function ns(e,t){return Co[e][t]??Co.zh[t]??t}function we(e,t){return ts(ns(Tt.getState().locale,e),t)}function ie(){const e=Tt(t=>t.locale);return(t,n)=>ts(ns(e,t),n)}function os(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var s;const i=l=>l===null?null:JSON.parse(l,void 0),a=(s=n.getItem(r))!=null?s:null;return a instanceof Promise?a.then(i):i(a)},setItem:(r,s)=>n.setItem(r,JSON.stringify(s,void 0)),removeItem:r=>n.removeItem(r)}}const Tn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Tn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Tn(o)(n)}}}},n2=(e,t)=>(n,o,r)=>{let s={storage:os(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,$)=>({...$,...b}),...t},i=!1,a=0;const l=new Set,c=new Set;let u=s.storage;if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...b)},o,r);const f=()=>{const b=s.partialize({...o()});return u.setItem(s.name,{state:b,version:s.version})},m=r.setState;r.setState=(b,$)=>(m(b,$),f());const p=e((...b)=>(n(...b),f()),o,r);r.getInitialState=()=>p;let h;const g=()=>{var b,$;if(!u)return;const k=++a;i=!1,l.forEach(S=>{var C;return S((C=o())!=null?C:p)});const w=(($=s.onRehydrateStorage)==null?void 0:$.call(s,(b=o())!=null?b:p))||void 0;return Tn(u.getItem.bind(u))(s.name).then(S=>{if(S)if(typeof S.version=="number"&&S.version!==s.version){if(s.migrate){const C=s.migrate(S.state,S.version);return C instanceof Promise?C.then(R=>[!0,R]):[!0,C]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,S.state];return[!1,void 0]}).then(S=>{var C;if(k!==a)return;const[R,X]=S;if(h=s.merge(X,(C=o())!=null?C:p),n(h,!0),R)return f()}).then(()=>{k===a&&(w==null||w(o(),void 0),h=o(),i=!0,c.forEach(S=>S(h)))}).catch(S=>{k===a&&(w==null||w(void 0,S))})};return r.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},s.skipHydration||g(),h||p},o2=n2,ze=.5;function rs(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<ze&&Math.abs(s[1]-e[r][1])<ze||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],a=Math.abs(s[0]-i[0]),l=Math.abs(s[1]-i[1]);if(a>ze&&l>ze){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<ze?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<ze&&Math.abs(i[0]-a[0])<ze,c=Math.abs(s[1]-i[1])<ze&&Math.abs(i[1]-a[1])<ze;l||c||o.push(i)}return o.push(n[n.length-1]),o}function ss(){return{elements:new Map,buses:new Map,junctions:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function is(e){return{at:(e==null?void 0:e.at)??[0,0],rot:(e==null?void 0:e.rot)??0,mirror:(e==null?void 0:e.mirror)??!1}}function An(e){return e===90||e===270?"y":"x"}function Pe(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const r2={n:"e",e:"s",s:"w",w:"n"},s2={n:"n",s:"s",e:"w",w:"e"};function St(e,t){let n=t.mirror?s2[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=r2[n];return n}function Cn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class as{constructor(){gt(this,"parent",new Map);gt(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const Po=["n","e","s","w"],Oo={n:"s",s:"n",e:"w",w:"e"};function Ot(e,t){const n=Po.indexOf(e),r=((Po.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const mn=320,Bt=220,bt=260,hn=720,wt=30,Bo=30,Ge=80,Lo=10,i2=60,a2=520,l2=80,c2=80,zo=8,Ro=new Set(["source","renewable"]);function d2(e){var bo,wo,vo,ko,_o,$o;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),u=new Map,f=new Set(i.keys()),m=new Set(a.keys()),p=new Map;for(const y of t)p.set(y.id,y);const h=new Map;for(const y of n)h.set(y.id,y);const g=y=>{const v=p.get(y);if(v)return s.get(v.kind)},b=new Set(n.map(y=>y.id)),$=y=>b.has(y),k=new Set(o.map(y=>y.id)),w=new Set(o.filter(y=>{var v;return(v=y.layout)==null?void 0:v.at}).map(y=>y.id)),S=new as;for(const y of r)S.add(y.ends[0]),S.add(y.ends[1]),S.union(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(v)for(const j of v.terminals)S.add(`${y.id}.${j.id}`)}for(const y of n)S.add(y.id);const C=[];for(const[,y]of S.groups())y.length>=2&&C.push(y);const R=new Map;for(const y of C)for(const v of y)R.set(v,[y]);const X=new Map;for(const y of C){const v=y.filter($);if(v.length!==0)for(const j of v){const N=y.filter(_=>_!==j),E=X.get(j)??[];E.push(...N),X.set(j,E)}}{const j=A=>p.has(A)&&!!g(A),N=A=>{if($(A))return null;if(k.has(A))return A;const M=A.indexOf(".");return M>0?A.slice(0,M):null},E=new Map,_=new Set,T=(A,M)=>{E.has(A)||E.set(A,new Set),E.has(M)||E.set(M,new Set),A!==M&&(E.get(A).add(M),E.get(M).add(A))};for(const A of C){const M=[];let B=!1;for(const H of A){if($(H)){B=!0;continue}const J=N(H);J&&M.push(J)}const L=[...new Set(M)];for(const H of L)E.has(H)||E.set(H,new Set),B&&_.add(H);const F=L.filter(H=>k.has(H)),q=L.filter(H=>!k.has(H));if(F.length>0){for(const H of F)for(const J of q)T(H,J);for(let H=0;H<F.length;H++)for(let J=H+1;J<F.length;J++)T(F[H],F[J])}else for(let H=0;H<q.length;H++)for(let J=H+1;J<q.length;J++)T(q[H],q[J])}const z=(A,M)=>{const B=g(A);if(!B)return null;for(const L of B.terminals){const F=`${A}.${L.id}`;for(const q of R.get(F)??[])for(const H of q)if(N(H)===M)return L}return null},I=A=>{const M=K=>{var Q;return((Q=E.get(K))==null?void 0:Q.size)??0},B=K=>{var Q;return((Q=g(K))==null?void 0:Q.category)??""},L=K=>{const Q=B(K);return Q==="source"?0:Q==="renewable"?1:2+Math.min(M(K),9)/10},F=A.filter(j).sort((K,Q)=>L(K)-L(Q)||K.localeCompare(Q))[0];if(!F)return;const q=new Map([[F,null]]),H=new Map([[F,0]]),J=new Map,Z=[],G=[F],Y=new Set([F]);for(;G.length;){const K=G.shift();Z.push(K);for(const Q of[...E.get(K)??[]].sort(($e,Se)=>$e.localeCompare(Se)))Y.has(Q)||(Y.add(Q),q.set(Q,K),H.set(Q,(H.get(K)??0)+1),J.has(K)||J.set(K,[]),J.get(K).push(Q),G.push(Q))}let U=0;const le=new Map,be=K=>{const Q=J.get(K)??[];if(Q.length===0){le.set(K,U++);return}for(const Se of Q)be(Se);const $e=Q.map(Se=>le.get(Se));le.set(K,$e.reduce((Se,It)=>Se+It,0)/$e.length)};be(F);for(const K of Z){const Q=me(mn+(le.get(K)??0)*160),$e=me(Bt+(H.get(K)??0)*140);if(k.has(K)){u.set(K,[Q,$e]);continue}let Se=0;const It=q.get(K)??null;if(It){const pt=z(K,It);pt&&(Se=Ot(pt.orientation,"n"))}else{const pt=(J.get(K)??[])[0],So=pt?z(K,pt):null;So&&(Se=Ot(So.orientation,"s"))}l.set(K,{at:[Q,$e],rot:Se,mirror:!1}),f.add(K)}},P=new Set;for(const A of E.keys()){if(P.has(A))continue;const M=[],B=[A];for(P.add(A);B.length;){const L=B.pop();M.push(L);for(const F of E.get(L)??[])P.has(F)||(P.add(F),B.push(F))}M.length<2||M.some(L=>_.has(L))||M.some(L=>l.has(L)||w.has(L))||M.some(j)&&I(M)}}const V=new Map;for(const y of C){const v=y.filter($);if(v.length!==0)for(const j of y){if($(j))continue;const N=j.indexOf(".");if(N<0)continue;const E=j.slice(0,N),_=j.slice(N+1),T=V.get(E)??[];for(const z of v)T.some(I=>I.busId===z&&I.pin===_)||T.push({busId:z,pin:_});V.set(E,T)}}const te=[],ae=new Set;for(const[y,v]of V)if(new Set(v.map(N=>N.busId)).size>=2){const N=((wo=s.get(((bo=p.get(y))==null?void 0:bo.kind)??""))==null?void 0:wo.category)==="transformer"?"vertical":"horizontal";te.push({elementId:y,attachments:v,orientation:N}),N==="vertical"&&ae.add(y)}const D=new Map,W=(y,v)=>{y!==v&&(D.has(y)||D.set(y,new Set),D.has(v)||D.set(v,new Set),D.get(y).add(v),D.get(v).add(y))};for(const y of r)W(y.ends[0],y.ends[1]);for(const y of t){const v=s.get(y.kind);if(!v||v.terminals.length<2)continue;const j=v.terminals.map(N=>`${y.id}.${N.id}`);for(let N=0;N<j.length;N++)for(let E=N+1;E<j.length;E++)W(j[N],j[E])}for(const y of t){if(ae.has(y.id))continue;const v=s.get(y.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const j=v.terminals.map(_=>`${y.id}.${_.id}`),N=new Map;for(const _ of j){const T=_.slice(y.id.length+1);N.set(T,new Set);const z=new Set(j.filter(A=>A!==_)),I=new Set([_]),P=[_];for(;P.length>0;){const A=P.shift();if($(A)){N.get(T).add(A);continue}const M=D.get(A);if(M)for(const B of M)I.has(B)||z.has(B)||(I.add(B),P.push(B))}}const E=new Set;for(const _ of N.values())for(const T of _)E.add(T);if(E.size>=2){const _=[];for(const[T,z]of N)for(const I of z)_.push({busId:I,pin:T});te.push({elementId:y.id,attachments:_,orientation:"vertical"}),ae.add(y.id)}}const ye=(y,v)=>{var z;const j=g(v),N=j?j.terminals.map(I=>`${v}.${I.id}`):[],E=y,_=new Set([E,...N]),T=[E];for(;T.length>0;){const I=T.shift(),P=I.indexOf(".");if(P>0){const M=I.slice(0,P),B=p.get(M);if(B){const L=(z=s.get(B.kind))==null?void 0:z.category;if(L&&Ro.has(L))return!0}}const A=D.get(I);if(A)for(const M of A)_.has(M)||(_.add(M),T.push(M))}return!1};for(const y of te){if(y.orientation!=="horizontal")continue;const v=new Set(y.attachments.map(N=>N.busId));let j=0;for(const N of v)ye(N,y.elementId)&&j++;j===1&&(y.orientation="vertical",ae.add(y.elementId))}for(const y of t){if(ae.has(y.id)||y.kind!=="breaker")continue;const v=s.get(y.kind);if(!v||v.terminals.length!==2)continue;const j=v.terminals.map(_=>`${y.id}.${_.id}`),N=new Map;for(const _ of j){const T=_.slice(y.id.length+1),z=new Set(j.filter(A=>A!==_)),I=new Set([_]),P=[_];for(;P.length>0;){const A=P.shift();if($(A)){N.set(T,A);break}const M=D.get(A);if(M)for(const B of M){if(I.has(B)||z.has(B))continue;const L=B.indexOf(".");if(L>0){const F=B.slice(0,L);if(F!==y.id){const q=p.get(F),H=q?s.get(q.kind):void 0;if((H==null?void 0:H.category)==="transformer")continue}}I.add(B),P.push(B)}}}if(new Set(N.values()).size>=2){const _=[];for(const[T,z]of N)_.push({busId:z,pin:T});te.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ue=new Map;for(const y of n)ue.set(y.id,new Map);for(const y of te){const v=Array.from(new Set(y.attachments.map(j=>j.busId)));for(const j of v)for(const N of v)j!==N&&((vo=ue.get(j))==null||vo.set(N,y))}const pe=y=>{var j;const v=(j=s.get(y))==null?void 0:j.category;return v?Ro.has(v):!1},ne=[];for(const y of n){const v=X.get(y.id);if(v)for(const j of v){if($(j))continue;const N=j.indexOf(".");if(N<0)continue;const E=j.slice(0,N),_=p.get(E);if(_&&pe(_.kind)){ne.push(y.id);break}}}ne.length===0&&n.length>0&&ne.push(n[0].id);const re=new Map;for(const y of ne)re.set(y,0);{const y=[...ne];for(;y.length>0;){const v=y.shift(),j=re.get(v),N=ue.get(v);if(N)for(const[E,_]of N){if(re.has(E))continue;const T=_.orientation==="horizontal"?j:j+1;re.set(E,T),y.push(E)}}}for(const y of n){if(re.has(y.id))continue;const v=re.size===0?-1:Math.max(...Array.from(re.values()));re.set(y.id,v+1)}const ge=new Map;for(const y of n){const v=re.get(y.id),j=ge.get(v)??[];j.push(y.id),ge.set(v,j)}const xe=[...ge.keys()].sort((y,v)=>y-v),_e=(y,v,j)=>{const N=`${y.elementId}.${j}`,E=v,_=g(y.elementId),T=new Set;if(_)for(const M of _.terminals)M.id!==j&&T.add(`${y.elementId}.${M.id}`);const z=new Set([N]),I=[{ref:N,dist:0}],P=new Map,A=(M,B,L,F)=>{z.add(M),P.set(M,B),I.push({ref:M,dist:F+L})};for(;I.length>0;){const{ref:M,dist:B}=I.shift();if(M===E){const H=P.get(E);let J;if(H){const Z=H.indexOf(".");if(Z>0){const G=H.slice(0,Z);G!==y.elementId&&(J=G)}}return{extent:B,head:J}}const L=M.indexOf(".");if(L<0)continue;const F=M.slice(0,L),q=M.slice(L+1);if(!$(F)&&!ae.has(F)){const H=g(F),J=H==null?void 0:H.terminals.find(Z=>Z.id===q);if(H&&J)for(const Z of H.terminals){if(Z.id===q)continue;const G=`${F}.${Z.id}`;z.has(G)||T.has(G)||A(G,M,Math.abs(J.y-Z.y),B)}}for(const H of R.get(M)??[])for(const J of H){if(J===M||z.has(J)||T.has(J))continue;const Z=$(M)||$(J);A(J,M,Z?Bo:wt,B)}}return{extent:0}},Ee=(y,v)=>{var M,B,L;const j=(M=ue.get(y))==null?void 0:M.get(v);if(!j||j.orientation==="horizontal")return bt;const N=g(j.elementId);if(!N)return bt;const E=(B=j.attachments.find(F=>F.busId===y))==null?void 0:B.pin,_=(L=j.attachments.find(F=>F.busId===v))==null?void 0:L.pin;if(!E||!_)return bt;const T=N.terminals.find(F=>F.id===E),z=N.terminals.find(F=>F.id===_);if(!T||!z)return bt;const I=Math.abs(z.y-T.y),P=_e(j,y,E).extent,A=_e(j,v,_).extent;return P+I+A},sn=new Map;for(const y of te){if(y.orientation!=="vertical")continue;const v=y.attachments.slice().sort((z,I)=>(re.get(z.busId)??0)-(re.get(I.busId)??0));if(v.length<2)continue;const j=v[0].busId,N=v[1].busId,E=v[0].pin,T=_e(y,j,E).head??y.elementId;sn.set(T,{lowerBusId:N})}const so=30,io=y=>{const v=g(y);return Math.max((v==null?void 0:v.width)??Ge,Ge)},Dw=2,ao=(y,v,j,N=0)=>{const E=g(v);let _=io(v);if(E&&!j.has(v)&&N<Dw){j.add(v);let T=0;for(const z of E.terminals){const I=`${v}.${z.id}`;if(I!==y)for(const P of R.get(I)??[]){const A=new Set;let M=!1;for(const L of P){if(L===I)continue;if($(L)){M=!0;continue}const F=L.indexOf(".");if(F<0)continue;const q=L.slice(0,F);q===v||j.has(q)||ae.has(q)||A.add(q)}if(M||A.size===0)continue;let B=0;for(const L of A){const F=[...P].find(q=>q.indexOf(".")>0&&q.slice(0,q.indexOf("."))===L);B+=(F?ao(F,L,j,N+1):io(L))+so}T=Math.max(T,B-so)}}j.delete(v),_=Math.max(_,T)}return _},ft=320,et=new Map,lo=(y,v)=>{if(!ae.has(y))return!1;const j=te.find(T=>T.elementId===y),N=j==null?void 0:j.attachments.find(T=>T.busId!==v);if(!N)return!1;const E=re.get(v)??0;return(re.get(N.busId)??0)<E},mt=(y,v,j)=>{const N=sn.get(y);if(N){const _=et.get(N.lowerBusId);if(_!==void 0)return Math.max(v,_+Ge)}let E=0;return j&&(E=ao(j,y,new Set)),Math.max(v,Ge,E)},co=(y,v)=>{if(et.has(y))return et.get(y);if(v.has(y))return ft;v.add(y);const j=X.get(y)??[];let N=0,E=0;for(const T of j){if($(T))continue;const z=T.indexOf(".");if(z<0)continue;const I=T.slice(0,z),P=T.slice(z+1);if(lo(I,y))continue;const A=g(I);if(!A)continue;const M=A.terminals.find(F=>F.id===P);if(!M)continue;const B=sn.get(I);B&&co(B.lowerBusId,v);const L=mt(I,A.width,`${I}.${P}`);M.y>0?N+=L:E+=L}const _=Math.max(ft,Math.max(N,E)+Ge);return et.set(y,_),v.delete(y),_};for(const y of n)co(y.id,new Set);const He=new Map,Fw=(y,v,j)=>{const N=g(v);if(!N)return;const E=`${v}.${j}`,_=N.terminals.filter(I=>I.id!==j).map(I=>`${v}.${I.id}`);if(_.length===0)return;const T=new Set([E,..._]),z=_.slice();for(;z.length>0;){const I=z.shift();if($(I)&&I!==y){const A=c.get(I);return A?A.at[0]:void 0}for(const A of R.get(I)??[])for(const M of A)M===I||T.has(M)||(T.add(M),z.push(M));const P=I.indexOf(".");if(P>0){const A=I.slice(0,P);if(!$(A)){const M=g(A);if(M)for(const B of M.terminals){const L=`${A}.${B.id}`;T.has(L)||(T.add(L),z.push(L))}}}}},Hw=y=>{const v=X.get(y);if(!v||v.length===0)return;const j=c.get(y);if(!j)return;const N=v.flatMap(M=>{if($(M))return[];const B=M.indexOf(".");if(B<0)return[];const L=M.slice(0,B),F=M.slice(B+1);if(l.has(L))return[];if(lo(L,y))return[];const q=g(L);if(!q)return[];const H=q.terminals.find(J=>J.id===F);return H?[{elId:L,lib:q,localTerm:H,isLinker:ae.has(L),busFacingRef:`${L}.${F}`}]:[]});if(N.length===0)return;const E=[],_=[];for(const M of N)M.localTerm.y>0?E.push(M):_.push(M);const T=M=>M.reduce((B,L)=>B+mt(L.elId,L.lib.width,L.busFacingRef),0),z=Math.max(T(E),T(_))+Ge,I=Math.max(j.span,z);I!==j.span&&!m.has(y)&&c.set(y,{...j,span:I});const P=c.get(y),A=(M,B)=>{if(M.length===0)return;const L=new Map;for(const Y of M){const U=Fw(y,Y.elId,Y.localTerm.id);U!==void 0&&L.set(Y.elId,U)}M.sort((Y,U)=>{const le=L.get(Y.elId)??P.at[0],be=L.get(U.elId)??P.at[0];if(le!==be)return le-be;const K=mt(Y.elId,Y.lib.width,Y.busFacingRef);return mt(U.elId,U.lib.width,U.busFacingRef)-K});const F=M.map(Y=>mt(Y.elId,Y.lib.width,Y.busFacingRef)),q=F.reduce((Y,U)=>Y+U,0),H=Math.max(I,q),J=(H-q)/(M.length+1);let Z=P.at[0]-H/2+J;const G=P.at[1]+B*Bo;for(let Y=0;Y<M.length;Y++){const U=M[Y],le=F[Y],be=Z+le/2;U.isLinker?He.has(U.elId)||He.set(U.elId,be):l.set(U.elId,{at:[me(be-U.localTerm.x),me(G-U.localTerm.y)],rot:0,mirror:!1}),Z+=le+J}};A(E,-1),A(_,1)},Ww=y=>{if(l.has(y.elementId)||y.orientation==="horizontal")return;const v=g(y.elementId);if(!v)return;const j=y.attachments.filter(Z=>c.has(Z.busId));if(j.length<2)return;const N=j.slice().sort((Z,G)=>(re.get(Z.busId)??0)-(re.get(G.busId)??0)),E=N[0].busId,_=c.get(E),T=N[0].pin,z=N[N.length-1].pin,I=v.terminals.find(Z=>Z.id===T),P=v.terminals.find(Z=>Z.id===z);if(!I||!P)return;const A=I.y<=P.y?0:180,M=re.get(E)??0,B=j.filter(Z=>(re.get(Z.busId)??0)===M),L=[];let F=0;for(const Z of B){const G=_e(y,Z.busId,Z.pin);F=Math.max(F,G.extent);const Y=G.head?l.get(G.head):void 0;Y?L.push(Y.at[0]):He.has(y.elementId)?L.push(He.get(y.elementId)):L.push(c.get(Z.busId).at[0])}let q;L.length>0?q=L.reduce((Z,G)=>Z+G,0)/L.length:He.has(y.elementId)?q=He.get(y.elementId):q=_.at[0];const H=_.at[1]+F,J=A===0?[me(q-I.x),me(H-I.y)]:[me(q+I.x),me(H+I.y)];if(l.set(y.elementId,{at:J,rot:A,mirror:!1}),B.length>1){const Z=l.get(y.elementId),G=Pe([I.x,I.y],Z),Y=St(I.orientation,Z);qw(`${y.elementId}.${T}`,G,Y,q)}},qw=(y,v,j,N)=>{const E=new Set([y]);let _=y,T=v,z=j;for(;;){const I=R.get(_)??[];let P,A=!1;for(const Q of I){if(Q.length>=3){A=!0;break}const $e=Q.find(Se=>Se!==_);if(!(!$e||E.has($e))){if($($e)){A=!0;break}P=$e;break}}if(A||!P)break;const M=P.indexOf(".");if(M<0)break;const B=P.slice(0,M),L=P.slice(M+1);if($(B)||ae.has(B)||l.has(B))break;const F=g(B);if(!F)break;const q=F.terminals.find(Q=>Q.id===L);if(!q)break;const H=Cn(z),J=[T[0]+H[0]*wt,T[1]+H[1]*wt],Z=Oo[z],G=Ot(q.orientation,Z),Y=Pe([q.x,q.y],{at:[0,0],rot:G,mirror:!1}),U=[me(N-Y[0]),me(J[1]-Y[1])];l.set(B,{at:U,rot:G,mirror:!1}),E.add(P);const le=F.terminals.find(Q=>Q.id!==L);if(!le)break;const be=`${B}.${le.id}`;E.add(be);const K={at:U,rot:G,mirror:!1};T=Pe([le.x,le.y],K),z=St(le.orientation,K),_=be}},Gw=y=>{if(l.has(y.elementId)||y.orientation!=="horizontal")return;const v=g(y.elementId);if(!v)return;const j=y.attachments.filter(B=>c.has(B.busId));if(j.length<2)return;const N=j.map(B=>{const L=_e(y,B.busId,B.pin),F=L.head?l.get(L.head):void 0,q=F?F.at[0]:c.get(B.busId).at[0];return{att:B,x:q,extent:L.extent}});N.sort((B,L)=>B.x-L.x);const E=N[0],_=N[N.length-1],T=v.terminals.find(B=>B.id===E.att.pin),z=v.terminals.find(B=>B.id===_.att.pin);if(!T||!z)return;const I=T.y<=z.y?270:90,P=(E.x+_.x)/2,M=c.get(E.att.busId).at[1]+Math.max(E.extent,_.extent);l.set(y.elementId,{at:[me(P),me(M)],rot:I,mirror:!1})},uo=100;let Ct=Bt;for(let y=0;y<xe.length;y++){const v=xe[y],j=ge.get(v);let N;if(y===0)N=Bt;else{const _=ge.get(xe[y-1]);let T=0;for(const z of _)for(const I of j)(ko=ue.get(z))!=null&&ko.get(I)&&(T=Math.max(T,Ee(z,I)));T===0&&(T=bt),N=Ct+T}Ct=N;let E=mn;for(const _ of j){if(c.has(_)){Ct=Math.max(Ct,c.get(_).at[1]);continue}let T;if(y>0){const I=ge.get(xe[y-1]),P=[];for(const A of I){const M=(_o=ue.get(A))==null?void 0:_o.get(_);if(!M||M.orientation!=="vertical")continue;const B=($o=M.attachments.find(F=>F.busId===A))==null?void 0:$o.pin;if(!B)continue;const L=_e(M,A,B);L.head&&l.has(L.head)?P.push(l.get(L.head).at[0]):He.has(M.elementId)?P.push(He.get(M.elementId)):P.push(c.get(A).at[0])}P.length>0&&(T=P.reduce((A,M)=>A+M,0)/P.length)}if(T===void 0){const I=et.get(_)??hn;T=E+I/2,E+=I+uo}const z=et.get(_)??hn;c.set(_,{at:[me(T),me(N)],rot:0,span:z,axis:An(0)})}for(const _ of j)Hw(_);if(y>0)for(const _ of te)l.has(_.elementId)||!_.attachments.some(z=>j.includes(z.busId))||Ww(_);for(const _ of te)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>j.includes(z.busId))||Gw(_)}if(n.length===0&&l.size<t.length){const y=E=>{const _=new Set,T=g(E);if(!T)return _;for(const z of T.terminals){const I=`${E}.${z.id}`;for(const P of R.get(I)??[])for(const A of P){if(A===I||$(A))continue;const M=A.indexOf(".");if(M<0)continue;const B=A.slice(0,M);B!==E&&_.add(B)}}return _},v=new Set,j=[];for(const E of t){if(v.has(E.id)||!g(E.id))continue;const _=[],T=[E.id];for(v.add(E.id);T.length>0;){const z=T.pop();_.push(z);for(const I of y(z))v.has(I)||(v.add(I),T.push(I))}_.length>=2&&j.push(_)}let N=mn;for(const E of j){if(E.some(P=>l.has(P)))continue;E.sort((P,A)=>{var q,H;const M=pe(((q=p.get(P))==null?void 0:q.kind)??"")?0:1,B=pe(((H=p.get(A))==null?void 0:H.kind)??"")?0:1;if(M!==B)return M-B;const L=y(P).size,F=y(A).size;return L!==F?L-F:P.localeCompare(A)});const _=E[0],T=g(_);if(!T)continue;const z=T.terminals.slice().sort((P,A)=>A.y-P.y)[0],I=z?Pe([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[me(N-I[0]),me(Bt-I[1])],rot:0,mirror:!1}),N+=Math.max(hn,E.length*Ge)+uo}}const Xw=y=>{if($(y))return c.has(y);const v=y.indexOf(".");return v<0?!1:l.has(y.slice(0,v))};let an=!0,Yw=t.length+4;for(;an&&Yw-- >0;){an=!1;for(const y of C){if(y.length<2)continue;const v=[],j=new Map;for(const G of y){if($(G))continue;const Y=G.indexOf(".");if(Y<0)continue;const U=G.slice(0,Y),le=G.slice(Y+1);if(l.has(U)){v.push(G);continue}if(ae.has(U)||j.has(U))continue;const be=g(U);if(!be)continue;const K=be.terminals.find(Q=>Q.id===le);K&&j.set(U,{ref:G,elId:U,lib:be,localTerm:K})}if(j.size===0||v.length===0)continue;const N=[...j.values()],E=new Map;for(const G of N)for(const Y of R.get(G.ref)??[])for(const U of Y){if(U===G.ref||$(U)||!Xw(U))continue;const le=U;E.set(le,(E.get(le)??0)+1)}let _;if(E.size>0){let G=-1;for(const[Y,U]of E)(U>G||U===G&&(_===void 0||Y<_))&&(G=U,_=Y)}if(_||(_=[...v].sort()[0]),!_)continue;const T=_.indexOf("."),z=_.slice(0,T),I=_.slice(T+1),P=g(z),A=l.get(z);if(!P||!A)continue;const M=P.terminals.find(G=>G.id===I);if(!M)continue;const B=Pe([M.x,M.y],A),L=St(M.orientation,A),F=Cn(L),q=[-F[1],F[0]];N.sort((G,Y)=>G.elId.localeCompare(Y.elId));const H=N.map(G=>Math.max(G.lib.width,Ge));let Z=-H.reduce((G,Y)=>G+Y,0)/2;for(let G=0;G<N.length;G++){const Y=N[G],U=H[G],le=Z+U/2;Z+=U;const be=Oo[L],K=Ot(Y.localTerm.orientation,be),Q=Pe([Y.localTerm.x,Y.localTerm.y],{at:[0,0],rot:K,mirror:!1}),$e=[B[0]+F[0]*wt+q[0]*le,B[1]+F[1]*wt+q[1]*le],Se=[me($e[0]-Q[0]),me($e[1]-Q[1])];l.set(Y.elId,{at:Se,rot:K,mirror:!1}),an=!0}}}const ht=y=>{const v=l.get(y),j=g(y);if(!v||!j)return null;const N=j.viewBox.split(/\s+/).map(Number);if(N.length<4||N.some(M=>Number.isNaN(M))){const M=j.width/2;return{min:v.at[0]-M,max:v.at[0]+M}}const[E,_,T,z]=N,I=[[E,_],[E+T,_],[E,_+z],[E+T,_+z]];let P=1/0,A=-1/0;for(const M of I){const B=Pe(M,v);P=Math.min(P,B[0]),A=Math.max(A,B[0])}return{min:P,max:A}},ln=y=>{const v=new Set,j=g(y);if(!j)return v;for(const N of j.terminals){const E=`${y}.${N.id}`;for(const _ of R.get(E)??[])for(const T of _){if(T===E||$(T))continue;const z=T.indexOf(".");if(z<0)continue;const I=T.slice(0,z);I!==y&&v.add(I)}}return v},fo=40,cn=y=>{const v=l.get(y),j=g(y);if(!v||!j)return null;const N=j.viewBox.split(/\s+/).map(Number);if(N.length<4||N.some(M=>Number.isNaN(M))){const M=j.height/2;return{min:v.at[1]-M,max:v.at[1]+M}}const[E,_,T,z]=N,I=[[E,_],[E+T,_],[E,_+z],[E+T,_+z]];let P=1/0,A=-1/0;for(const M of I){const B=Pe(M,v);P=Math.min(P,B[1]),A=Math.max(A,B[1])}return{min:P,max:A}},Kw=(y,v)=>{const j=new Set,N=[];for(const E of X.get(y)??[]){if($(E))continue;const _=E.indexOf(".");if(_<0)continue;const T=E.slice(0,_),z=l.get(T);!z||z.at[1]>=v-1||j.has(T)||(j.add(T),N.push(T))}for(;N.length>0;){const E=N.pop();for(const _ of ln(E)){if(j.has(_))continue;const T=l.get(_);!T||T.at[1]>=v-1||(j.add(_),N.push(_))}}return j},mo=(y,v,j)=>{const N=new Set([y]),E=[y];for(;E.length>0;){const _=E.pop();for(const T of ln(_))T===v||N.has(T)||!j.has(T)||(N.add(T),E.push(T))}return N},ho=(y,v)=>{let j=y.length*y.length+8,N=!1,E=!0;for(;E&&j-- >0;){E=!1;for(let _=0;_<y.length&&!E;_++)for(let T=_+1;T<y.length;T++){const z=y[_],I=y[T],P=ht(z),A=ht(I),M=cn(z),B=cn(I);if(!P||!A||!M||!B)continue;const L=Math.min(P.max,A.max)-Math.max(P.min,A.min),F=Math.min(M.max,B.max)-Math.max(M.min,B.min);if(L<=0||F<=0)continue;const q=mo(z,I,v),H=mo(I,z,v);if(q.has(I)||H.has(z))continue;const J=![...q].some(K=>f.has(K)),Z=![...H].some(K=>f.has(K));if(!J&&!Z)continue;const G=(P.min+P.max)/2,Y=(A.min+A.max)/2;let U,le;J&&(!Z||q.size<=H.size)?(U=q,le=G<=Y?-1:1):(U=H,le=Y<=G?-1:1);const be=me(le*(L+fo));if(be!==0){for(const K of U){const Q=l.get(K);Q&&l.set(K,{...Q,at:[Q.at[0]+be,Q.at[1]]})}N=!0,E=!0;break}}}return N};for(const y of n){const v=c.get(y.id);if(!v)continue;const j=Kw(y.id,v.at[1]);if(j.size<2)continue;const N=[...j];if(ho(N,j)){let _=1/0,T=-1/0;for(const z of N){const I=ht(z);I&&(_=Math.min(_,I.min),T=Math.max(T,I.max))}if(Number.isFinite(_)){const I=N.some(A=>f.has(A))?0:me(v.at[0]-(_+T)/2);if(I!==0)for(const A of N){const M=l.get(A);M&&l.set(A,{...M,at:[M.at[0]+I,M.at[1]]})}const P=T-_+fo;if(P>v.span&&!m.has(y.id)){const A=c.get(y.id);c.set(y.id,{...A,span:P})}}}}const po=()=>{const v=t.map(N=>N.id).filter(N=>l.has(N)).map(N=>({x:ht(N),y:cn(N)})).filter(N=>N.x&&N.y);let j=0;for(let N=0;N<v.length;N++)for(let E=N+1;E<v.length;E++){const _=Math.min(v[N].x.max,v[E].x.max)-Math.max(v[N].x.min,v[E].x.min),T=Math.min(v[N].y.max,v[E].y.max)-Math.max(v[N].y.min,v[E].y.min);_>1&&T>1&&j++}return j},Vw=po(),go=new Map;for(const[y,v]of l)go.set(y,{...v,at:[...v.at]});const yo=new Map;for(const[y,v]of c)yo.set(y,{...v,at:[...v.at]});const dn=120,xo=new Map;{const y=new Map,v=new Map,j=[];for(const E of n)for(const _ of X.get(E.id)??[]){if($(_))continue;const T=_.indexOf(".");if(T<0)continue;const z=_.slice(0,T);l.has(z)&&j.push({el:z,bus:E.id,d:1})}j.sort((E,_)=>E.d-_.d);let N=0;for(;N<j.length;){const{el:E,bus:_,d:T}=j[N++],z=y.get(E);if(z===void 0)y.set(E,T),v.set(E,_);else if(T===z&&v.get(E)!==_){v.set(E,null);continue}else continue;for(const I of ln(E))l.has(I)&&(y.has(I)||j.push({el:I,bus:_,d:T+1}))}for(const[E,_]of v)_&&xo.set(E,_)}for(const y of xe){const v=(ge.get(y)??[]).filter(P=>c.has(P));if(v.length<2||v.some(P=>m.has(P)))continue;const j=[];let N=0;for(const P of v){const A=c.get(P),M=[];let B=1/0,L=-1/0;for(const[F,q]of xo){if(q!==P)continue;const H=ht(F);H&&(M.push(F),B=Math.min(B,H.min),L=Math.max(L,H.max))}Number.isFinite(B)||(B=A.at[0]-ft/2,L=A.at[0]+ft/2),j.push({busId:P,min:B,max:L,members:M}),N+=L-B}if(j.some(P=>P.members.some(A=>f.has(A))))continue;let E=1/0,_=-1/0;for(const P of j)E=Math.min(E,P.min),_=Math.max(_,P.max);const T=_-E,z=N+dn*(j.length-1);if(!(T>z+dn))continue;j.sort((P,A)=>(P.min+P.max)/2-(A.min+A.max)/2);let I=E;for(const P of j){const A=me(I-P.min);if(A!==0){const M=c.get(P.busId);c.set(P.busId,{...M,at:[M.at[0]+A,M.at[1]]});for(const B of P.members){const L=l.get(B);L&&l.set(B,{...L,at:[L.at[0]+A,L.at[1]]})}P.min+=A,P.max+=A}I=P.max+dn}for(const P of j){const A=c.get(P.busId),M=Math.max(ft,P.max-P.min);M<A.span&&c.set(P.busId,{...A,span:M})}}{const y=t.map(j=>j.id).filter(j=>l.has(j)),v=new Set(y);ho(y,v)}if(po()>Vw){l.clear();for(const[y,v]of go)l.set(y,v);c.clear();for(const[y,v]of yo)c.set(y,v)}let un=0;for(const y of t){if(l.has(y.id))continue;const v=un%zo,j=Math.floor(un/zo);l.set(y.id,{at:[me(i2+v*l2),me(a2+j*c2)],rot:0,mirror:!1}),un++}return{devices:l,buses:c,junctions:u}}function me(e){return Math.round(e/Lo)*Lo}function u2(e,t){const n=e.ends[0],o=e.ends[1],r=Do(n,t),s=Do(o,t);if(r||s){const l=r?n:o,u=pn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:m,at:p,span:h}=f.geometry,g=h/2;let b;if(m==="x")b=[Gt(u[0],p[0]-g,p[0]+g),p[1]];else{const $=Gt(u[1],p[1]-g,p[1]+g);b=[p[0],$]}return{wireId:e.id,path:Ho(u,b)}}const i=pn(n,t),a=pn(o,t);return!i||!a?null:{wireId:e.id,path:Ho(i,a)}}function Do(e,t){return!e.includes(".")&&t.buses.has(e)}function pn(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 Fo(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[Gt(t[0],i[0]-l,i[0]+l),i[1]];const c=Gt(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 Ho(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Gt(e,t,n){return e<t?t:e>n?n:e}const ls="ammeter",cs="电流表 (A)",ds="measurement",us="-22 -42 44 44",fs=44,ms=44,hs='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-15" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">A</text>',ps=[{id:"t_top",x:0,y:-40,orientation:"n"}],gs={kind:"inline"},f2={id:ls,name:cs,category:ds,viewBox:us,width:fs,height:ms,svg:hs,terminals:ps,source:gs},m2=Object.freeze(Object.defineProperty({__proto__:null,category:ds,default:f2,height:ms,id:ls,name:cs,source:gs,svg:hs,terminals:ps,viewBox:us,width:fs},Symbol.toStringTag,{value:"Module"})),ys="arc-suppression-coil",xs="消弧线圈",bs="grounding",ws="中性点谐振接地:电感线圈连接到地",vs="-12 -32 24 67",ks=24,_s=67,$s='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',Ss=[{id:"t_top",x:0,y:-30,orientation:"n"}],js={kind:"inline"},h2={id:ys,name:xs,category:bs,description:ws,viewBox:vs,width:ks,height:_s,svg:$s,terminals:Ss,source:js},p2=Object.freeze(Object.defineProperty({__proto__:null,category:bs,default:h2,description:ws,height:_s,id:ys,name:xs,source:js,svg:$s,terminals:Ss,viewBox:vs,width:ks},Symbol.toStringTag,{value:"Module"})),Es="arrester",Ns="避雷器 (FBL)",Ms="protection",Ts="-7 -22 14 44",As=14,Cs=44,Is='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Ps=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Os={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},g2={id:Es,name:Ns,category:Ms,viewBox:Ts,width:As,height:Cs,svg:Is,terminals:Ps,source:Os},y2=Object.freeze(Object.defineProperty({__proto__:null,category:Ms,default:g2,height:Cs,id:Es,name:Ns,source:Os,svg:Is,terminals:Ps,viewBox:Ts,width:As},Symbol.toStringTag,{value:"Module"})),Bs="async-motor",Ls="异步电动机",zs="load",Rs="-62 -82 64 84",Ds=64,Fs=84,Hs='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',Ws=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],qs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},x2={id:Bs,name:Ls,category:zs,viewBox:Rs,width:Ds,height:Fs,svg:Hs,terminals:Ws,source:qs},b2=Object.freeze(Object.defineProperty({__proto__:null,category:zs,default:x2,height:Fs,id:Bs,name:Ls,source:qs,svg:Hs,terminals:Ws,viewBox:Rs,width:Ds},Symbol.toStringTag,{value:"Module"})),Gs="autotransformer",Xs="自耦变压器",Ys="transformer",Ks="-62 -112 64 144",Vs=64,Us=144,Js='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-110" x2="-30" y2="-90" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -30 A 30 60 0 0 0 -30 -90" fill="none" stroke="black" stroke-width="1"/>',Zs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Qs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},w2={id:Gs,name:Xs,category:Ys,viewBox:Ks,width:Vs,height:Us,svg:Js,terminals:Zs,source:Qs},v2=Object.freeze(Object.defineProperty({__proto__:null,category:Ys,default:w2,height:Us,id:Gs,name:Xs,source:Qs,svg:Js,terminals:Zs,viewBox:Ks,width:Vs},Symbol.toStringTag,{value:"Module"})),ei="battery",ti="电池储能",ni="storage",oi="-12 -12 29 24",ri=29,si=24,ii='<line x1="-10" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-10" x2="5" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="0" x2="15" y2="0" fill="none" stroke="black" stroke-width="1"/>',ai=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],li=[{name:"E",label:"容量",type:"number",unit:"kWh"}],ci={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},k2={id:ei,name:ti,category:ni,viewBox:oi,width:ri,height:si,svg:ii,terminals:ai,params:li,source:ci},_2=Object.freeze(Object.defineProperty({__proto__:null,category:ni,default:k2,height:si,id:ei,name:ti,params:li,source:ci,svg:ii,terminals:ai,viewBox:oi,width:ri},Symbol.toStringTag,{value:"Module"})),di="bell",ui="电铃 (HA)",fi="control",mi="信号电铃 / 警铃。",hi="-32 -32 44 44",pi=44,gi=44,yi='<line x1="-30" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -10 A 20 20 0 0 0 -30 -10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',xi=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],bi={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},$2={id:di,name:ui,category:fi,description:mi,viewBox:hi,width:pi,height:gi,svg:yi,terminals:xi,source:bi},S2=Object.freeze(Object.defineProperty({__proto__:null,category:fi,default:$2,description:mi,height:gi,id:di,name:ui,source:bi,svg:yi,terminals:xi,viewBox:hi,width:pi},Symbol.toStringTag,{value:"Module"})),wi="break-contact",vi="常闭触点 (NC)",ki="control",_i="常闭辅助触点 (break contact)。",$i="-2 -42 14 64",Si=14,ji=64,Ei='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',Ni=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Mi=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ti={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},j2={id:wi,name:vi,category:ki,description:_i,viewBox:$i,width:Si,height:ji,svg:Ei,terminals:Ni,state:Mi,source:Ti},E2=Object.freeze(Object.defineProperty({__proto__:null,category:ki,default:j2,description:_i,height:ji,id:wi,name:vi,source:Ti,state:Mi,svg:Ei,terminals:Ni,viewBox:$i,width:Si},Symbol.toStringTag,{value:"Module"})),Ai="breaker",Ci="断路器 (QF)",Ii="switching",Pi="-7 -22 15 46",Oi=15,Bi=46,Li='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',zi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ri=[{name:"open",type:"boolean",default:!1,label:"断开"}],Di={x:6,y:-2,anchor:"start"},Fi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},N2={id:Ai,name:Ci,category:Ii,viewBox:Pi,width:Oi,height:Bi,svg:Li,terminals:zi,state:Ri,label:Di,source:Fi},M2=Object.freeze(Object.defineProperty({__proto__:null,category:Ii,default:N2,height:Bi,id:Ai,label:Di,name:Ci,source:Fi,state:Ri,svg:Li,terminals:zi,viewBox:Pi,width:Oi},Symbol.toStringTag,{value:"Module"})),Hi="buchholz-relay",Wi="瓦斯继电器 (63)",qi="protection",Gi="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Xi="-22 -62 44 64",Yi=44,Ki=64,Vi='<rect x="-20" y="-60" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-20" width="10" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-55" x2="0" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -50 A 10 5 0 0 0 0 -40" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -40 A 10 5 0 0 0 0 -50" fill="none" stroke="black" stroke-width="1"/>',Ui=[{id:"t_top",x:0,y:-60,orientation:"n"}],Ji={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_18/en_60617_07_18_01.elmt",qetEnglishName:"Buchholz protective device; Gas relay"},T2={id:Hi,name:Wi,category:qi,description:Gi,viewBox:Xi,width:Yi,height:Ki,svg:Vi,terminals:Ui,source:Ji},A2=Object.freeze(Object.defineProperty({__proto__:null,category:qi,default:T2,description:Gi,height:Ki,id:Hi,name:Wi,source:Ji,svg:Vi,terminals:Ui,viewBox:Xi,width:Yi},Symbol.toStringTag,{value:"Module"})),Zi="busbar",Qi="母线段",ea="busbar",ta="可拉伸单母线段,多设备挂接",na="-42 -4 84 8",oa=84,ra=8,sa='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',ia=[{id:"tap",x:0,y:0,orientation:"n"}],aa={axis:"x",minLength:20,naturalSpan:80},la=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],ca={x:0,y:-6,anchor:"middle"},da={kind:"inline"},C2={id:Zi,name:Qi,category:ea,description:ta,viewBox:na,width:oa,height:ra,svg:sa,terminals:ia,stretchable:aa,params:la,label:ca,source:da},I2=Object.freeze(Object.defineProperty({__proto__:null,category:ea,default:C2,description:ta,height:ra,id:Zi,label:ca,name:Qi,params:la,source:da,stretchable:aa,svg:sa,terminals:ia,viewBox:na,width:oa},Symbol.toStringTag,{value:"Module"})),ua="buzzer",fa="蜂鸣器 (HA)",ma="control",ha="信号蜂鸣器。",pa="-32 -52 44 64",ga=44,ya=64,xa='<line x1="-30" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><path d="M -30 -30 A 20 20 0 0 0 10 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-12" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-12" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',ba=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],wa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},P2={id:ua,name:fa,category:ma,description:ha,viewBox:pa,width:ga,height:ya,svg:xa,terminals:ba,source:wa},O2=Object.freeze(Object.defineProperty({__proto__:null,category:ma,default:P2,description:ha,height:ya,id:ua,name:fa,source:wa,svg:xa,terminals:ba,viewBox:pa,width:ga},Symbol.toStringTag,{value:"Module"})),va="capacitor",ka="电容 (C)",_a="passive",$a="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",Sa="-7 -23 14 27",ja=14,Ea=27,Na='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',Ma=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],Ta=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],Aa={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},B2={id:va,name:ka,category:_a,description:$a,viewBox:Sa,width:ja,height:Ea,svg:Na,terminals:Ma,params:Ta,source:Aa},L2=Object.freeze(Object.defineProperty({__proto__:null,category:_a,default:B2,description:$a,height:Ea,id:va,name:ka,params:Ta,source:Aa,svg:Na,terminals:Ma,viewBox:Sa,width:ja},Symbol.toStringTag,{value:"Module"})),Ca="contactor",Ia="接触器 (KM)",Pa="motor-control",Oa="主回路接触器, 通常配热继电器和电机使用。",Ba="-10 -42 15 64",La=15,za=64,Ra='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',Da=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Fa=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ha={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_02.elmt",qetEnglishName:"Contactor; Main make contact of a contactor"},z2={id:Ca,name:Ia,category:Pa,description:Oa,viewBox:Ba,width:La,height:za,svg:Ra,terminals:Da,state:Fa,source:Ha},R2=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:z2,description:Oa,height:za,id:Ca,name:Ia,source:Ha,state:Fa,svg:Ra,terminals:Da,viewBox:Ba,width:La},Symbol.toStringTag,{value:"Module"})),Wa="converter-bidir",qa="双向变流器 (PCS)",Ga="renewable",Xa="储能变流器:双向 AC ↔ DC",Ya="-42 -42 44 48",Ka=44,Va=48,Ua='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-6" x2="-14" y2="-6" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-6" x2="-4" y2="-6" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/><polyline points="-28,-4 -32,0 -28,4" fill="none" stroke="black" stroke-width="1"/><polyline points="-16,-4 -12,0 -16,4" fill="none" stroke="black" stroke-width="1"/>',Ja=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Za=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Qa={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},D2={id:Wa,name:qa,category:Ga,description:Xa,viewBox:Ya,width:Ka,height:Va,svg:Ua,terminals:Ja,params:Za,source:Qa},F2=Object.freeze(Object.defineProperty({__proto__:null,category:Ga,default:D2,description:Xa,height:Va,id:Wa,name:qa,params:Za,source:Qa,svg:Ua,terminals:Ja,viewBox:Ya,width:Ka},Symbol.toStringTag,{value:"Module"})),el="ct",tl="电流互感器 (CT)",nl="instrument-transformer",ol="-42 -62 54 64",rl=54,sl=64,il='<line x1="-30" y1="-60" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-30" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-20" x2="5" y2="-40" fill="none" stroke="black" stroke-width="1"/>',al=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],ll={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},H2={id:el,name:tl,category:nl,viewBox:ol,width:rl,height:sl,svg:il,terminals:al,source:ll},W2=Object.freeze(Object.defineProperty({__proto__:null,category:nl,default:H2,height:sl,id:el,name:tl,source:ll,svg:il,terminals:al,viewBox:ol,width:rl},Symbol.toStringTag,{value:"Module"})),cl="dc-combiner",dl="直流汇流箱",ul="renewable",fl="光伏组串汇流箱 (4 路输入示例)。",ml="-27 -32 54 64",hl=54,pl=64,gl='<rect x="-25" y="-15" width="50" height="30" fill="none" stroke="black" stroke-width="1"/><line x1="-18" y1="-30" x2="-18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="-6" y1="-30" x2="-6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-30" x2="6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="18" y1="-30" x2="18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><text x="-9" y="5" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">DC</text>',yl=[{id:"t_s1",x:-18,y:-30,orientation:"n"},{id:"t_s2",x:-6,y:-30,orientation:"n"},{id:"t_s3",x:6,y:-30,orientation:"n"},{id:"t_s4",x:18,y:-30,orientation:"n"},{id:"t_dc",x:0,y:30,orientation:"s"}],xl={kind:"inline"},q2={id:cl,name:dl,category:ul,description:fl,viewBox:ml,width:hl,height:pl,svg:gl,terminals:yl,source:xl},G2=Object.freeze(Object.defineProperty({__proto__:null,category:ul,default:q2,description:fl,height:pl,id:cl,name:dl,source:xl,svg:gl,terminals:yl,viewBox:ml,width:hl},Symbol.toStringTag,{value:"Module"})),bl="dc-disconnector",wl="直流隔离开关",vl="switching",kl="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",_l="-12 -32 30 64",$l=30,Sl=64,jl='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-4" x2="14" y2="-4" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-1" x2="9" y2="-1" stroke="black" stroke-width="0.8" fill="none"/><line x1="11" y1="-1" x2="14" y2="-1" stroke="black" stroke-width="0.8" fill="none"/>',El=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Nl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ml={kind:"inline"},X2={id:bl,name:wl,category:vl,description:kl,viewBox:_l,width:$l,height:Sl,svg:jl,terminals:El,state:Nl,source:Ml},Y2=Object.freeze(Object.defineProperty({__proto__:null,category:vl,default:X2,description:kl,height:Sl,id:bl,name:wl,source:Ml,state:Nl,svg:jl,terminals:El,viewBox:_l,width:$l},Symbol.toStringTag,{value:"Module"})),Tl="dc-motor",Al="直流电机 (M)",Cl="load",Il="直流电动机 (串励通用符号)。",Pl="-72 -82 89 84",Ol=89,Bl=84,Ll='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',zl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Rl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},K2={id:Tl,name:Al,category:Cl,description:Il,viewBox:Pl,width:Ol,height:Bl,svg:Ll,terminals:zl,source:Rl},V2=Object.freeze(Object.defineProperty({__proto__:null,category:Cl,default:K2,description:Il,height:Bl,id:Tl,name:Al,source:Rl,svg:Ll,terminals:zl,viewBox:Pl,width:Ol},Symbol.toStringTag,{value:"Module"})),Dl="diode",Fl="二极管 (D)",Hl="passive",Wl="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",ql="-12 -42 24 44",Gl=24,Xl=44,Yl='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/>',Kl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Vl={x:6,y:-20,anchor:"start"},Ul={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},U2={id:Dl,name:Fl,category:Hl,description:Wl,viewBox:ql,width:Gl,height:Xl,svg:Yl,terminals:Kl,label:Vl,source:Ul},J2=Object.freeze(Object.defineProperty({__proto__:null,category:Hl,default:U2,description:Wl,height:Xl,id:Dl,label:Vl,name:Fl,source:Ul,svg:Yl,terminals:Kl,viewBox:ql,width:Gl},Symbol.toStringTag,{value:"Module"})),Jl="disconnector",Zl="隔离开关 (QS)",Ql="switching",ec="-10 -42 15 64",tc=15,nc=64,oc='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="-20" x2="3" y2="-20" fill="none" stroke="black" stroke-width="1"/>',rc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],sc=[{name:"open",type:"boolean",default:!1,label:"断开"}],ic={x:6,y:-10,anchor:"start"},ac={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},Z2={id:Jl,name:Zl,category:Ql,viewBox:ec,width:tc,height:nc,svg:oc,terminals:rc,state:sc,label:ic,source:ac},Q2=Object.freeze(Object.defineProperty({__proto__:null,category:Ql,default:Z2,height:nc,id:Jl,label:ic,name:Zl,source:ac,state:sc,svg:oc,terminals:rc,viewBox:ec,width:tc},Symbol.toStringTag,{value:"Module"})),lc="distance-relay",cc="距离继电器 (21)",dc="protection",uc="距离 / 低阻抗保护继电器 (ANSI 21)。",fc="-62 -42 64 44",mc=64,hc=44,pc='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-42" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Z &lt;</text>',gc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],yc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},ek={id:lc,name:cc,category:dc,description:uc,viewBox:fc,width:mc,height:hc,svg:pc,terminals:gc,source:yc},tk=Object.freeze(Object.defineProperty({__proto__:null,category:dc,default:ek,description:uc,height:hc,id:lc,name:cc,source:yc,svg:pc,terminals:gc,viewBox:fc,width:mc},Symbol.toStringTag,{value:"Module"})),xc="earth",bc="接地",wc="busbar",vc="-12 -17 24 34",kc=24,_c=34,$c='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',Sc=[{id:"t1",x:0,y:-15,orientation:"n"}],jc={kind:"elmt",path:"91_en_60617/en_60617_02/en_60617_02_15/en_60617_02_15_01.elmt",qetEnglishName:"Earth or ground, general symbol"},nk={id:xc,name:bc,category:wc,viewBox:vc,width:kc,height:_c,svg:$c,terminals:Sc,source:jc},ok=Object.freeze(Object.defineProperty({__proto__:null,category:wc,default:nk,height:_c,id:xc,name:bc,source:jc,svg:$c,terminals:Sc,viewBox:vc,width:kc},Symbol.toStringTag,{value:"Module"})),Ec="earthing-switch",Nc="接地刀闸 (QE)",Mc="switching",Tc="隔离开关 + 接地连接,单端口",Ac="-12 -32 24 64",Cc=24,Ic=64,Pc='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="-12" x2="-9" y2="9" stroke="black" stroke-width="1" fill="none"/><line x1="-3" y1="-12" x2="3" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-10" y1="14" x2="10" y2="14" stroke="black" stroke-width="1" fill="none"/><line x1="-7" y1="19" x2="7" y2="19" stroke="black" stroke-width="1" fill="none"/><line x1="-4" y1="24" x2="4" y2="24" stroke="black" stroke-width="1" fill="none"/><line x1="-1.5" y1="29" x2="1.5" y2="29" stroke="black" stroke-width="1" fill="none"/>',Oc=[{id:"t_top",x:0,y:-30,orientation:"n"}],Bc=[{name:"open",type:"boolean",default:!0,label:"断开"}],Lc={x:12,y:-8,anchor:"start"},zc={kind:"inline"},rk={id:Ec,name:Nc,category:Mc,description:Tc,viewBox:Ac,width:Cc,height:Ic,svg:Pc,terminals:Oc,state:Bc,label:Lc,source:zc},sk=Object.freeze(Object.defineProperty({__proto__:null,category:Mc,default:rk,description:Tc,height:Ic,id:Ec,label:Lc,name:Nc,source:zc,state:Bc,svg:Pc,terminals:Oc,viewBox:Ac,width:Cc},Symbol.toStringTag,{value:"Module"})),Rc="energy-meter",Dc="电能表 (Wh)",Fc="measurement",Hc="有功电能表 (kWh) — 服务入口 / 子表。",Wc="-22 -36 44 72",qc=44,Gc=72,Xc='<text x="-10" y="19.2" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Wh</text><rect x="-20" y="-10" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Yc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Kc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},ik={id:Rc,name:Dc,category:Fc,description:Hc,viewBox:Wc,width:qc,height:Gc,svg:Xc,terminals:Yc,source:Kc},ak=Object.freeze(Object.defineProperty({__proto__:null,category:Fc,default:ik,description:Hc,height:Gc,id:Rc,name:Dc,source:Kc,svg:Xc,terminals:Yc,viewBox:Wc,width:qc},Symbol.toStringTag,{value:"Module"})),Vc="ev-charger",Uc="EV 充电桩",Jc="load",Zc="电动汽车充电站 / 充电桩。",Qc="-17 -27 34 49",ed=34,td=49,nd='<line x1="0" y1="-25" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-15" y="-15" width="30" height="35" fill="none" stroke="black" stroke-width="1"/><rect x="-9" y="-8" width="14" height="6" fill="none" stroke="black" stroke-width="0.8"/><rect x="5" y="-7" width="2" height="4" fill="black"/><text x="-9" y="13" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">EV</text>',od=[{id:"t_top",x:0,y:-25,orientation:"n"}],rd={kind:"inline"},lk={id:Vc,name:Uc,category:Jc,description:Zc,viewBox:Qc,width:ed,height:td,svg:nd,terminals:od,source:rd},ck=Object.freeze(Object.defineProperty({__proto__:null,category:Jc,default:lk,description:Zc,height:td,id:Vc,name:Uc,source:rd,svg:nd,terminals:od,viewBox:Qc,width:ed},Symbol.toStringTag,{value:"Module"})),sd="frequency-meter",id="频率表 (Hz)",ad="measurement",ld="-22 -42 44 44",cd=44,dd=44,ud='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Hz</text>',fd=[{id:"t_top",x:0,y:-40,orientation:"n"}],md={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},dk={id:sd,name:id,category:ad,viewBox:ld,width:cd,height:dd,svg:ud,terminals:fd,source:md},uk=Object.freeze(Object.defineProperty({__proto__:null,category:ad,default:dk,height:dd,id:sd,name:id,source:md,svg:ud,terminals:fd,viewBox:ld,width:cd},Symbol.toStringTag,{value:"Module"})),hd="fuse-switch-disconnector",pd="熔断器式隔离开关",gd="switching",yd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",xd="-8 -32 12 64",bd=12,wd=64,vd='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',kd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],_d=[{name:"open",type:"boolean",default:!1,label:"断开"}],$d={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},fk={id:hd,name:pd,category:gd,description:yd,viewBox:xd,width:bd,height:wd,svg:vd,terminals:kd,state:_d,source:$d},mk=Object.freeze(Object.defineProperty({__proto__:null,category:gd,default:fk,description:yd,height:wd,id:hd,name:pd,source:$d,state:_d,svg:vd,terminals:kd,viewBox:xd,width:bd},Symbol.toStringTag,{value:"Module"})),Sd="fuse",jd="熔断器 (FU)",Ed="switching",Nd="-7 -32 14 64",Md=14,Td=64,Ad='<line x1="0" y1="-30" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-15" width="10" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Cd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Id=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Pd={x:7,y:-2,anchor:"start"},Od={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},hk={id:Sd,name:jd,category:Ed,viewBox:Nd,width:Md,height:Td,svg:Ad,terminals:Cd,state:Id,label:Pd,source:Od},pk=Object.freeze(Object.defineProperty({__proto__:null,category:Ed,default:hk,height:Td,id:Sd,label:Pd,name:jd,source:Od,state:Id,svg:Ad,terminals:Cd,viewBox:Nd,width:Md},Symbol.toStringTag,{value:"Module"})),Bd="generator",Ld="发电机 (G)",zd="source",Rd="-42 -42 44 44",Dd=44,Fd=44,Hd='<rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-24" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text>',Wd=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],qd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},gk={id:Bd,name:Ld,category:zd,viewBox:Rd,width:Dd,height:Fd,svg:Hd,terminals:Wd,source:qd},yk=Object.freeze(Object.defineProperty({__proto__:null,category:zd,default:gk,height:Fd,id:Bd,name:Ld,source:qd,svg:Hd,terminals:Wd,viewBox:Rd,width:Dd},Symbol.toStringTag,{value:"Module"})),Gd="genset",Xd="发电机组 (G)",Yd="source",Kd="柴油 / 燃气发电机组。",Vd="-28 -22 56 64",Ud=56,Jd=64,Zd='<rect x="-26" y="-20" width="52" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">GEN</text><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Qd=[{id:"t_out",x:0,y:40,orientation:"s"}],eu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],tu={kind:"inline"},xk={id:Gd,name:Xd,category:Yd,description:Kd,viewBox:Vd,width:Ud,height:Jd,svg:Zd,terminals:Qd,params:eu,source:tu},bk=Object.freeze(Object.defineProperty({__proto__:null,category:Yd,default:xk,description:Kd,height:Jd,id:Gd,name:Xd,params:eu,source:tu,svg:Zd,terminals:Qd,viewBox:Vd,width:Ud},Symbol.toStringTag,{value:"Module"})),nu="gfci-breaker",ou="GFCI 断路器 (RCBO)",ru="protection",su="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",iu="-18 -22 22 44",au=22,lu=44,cu='<text x="-14" y="13.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">IΔ</text><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="-5,-10 0,10 0,20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-4" x2="-8" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="-4" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="-4" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><path d="M -8 1 A 2.5 3.5 0 0 0 -13 1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="1" x2="-2" y2="1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="1" x2="-13" y2="1" fill="none" stroke="black" stroke-width="0.4"/>',du=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],uu=[{name:"open",type:"boolean",default:!1,label:"断开"}],fu=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],mu={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},wk={id:nu,name:ou,category:ru,description:su,viewBox:iu,width:au,height:lu,svg:cu,terminals:du,state:uu,params:fu,source:mu},vk=Object.freeze(Object.defineProperty({__proto__:null,category:ru,default:wk,description:su,height:lu,id:nu,name:ou,params:fu,source:mu,state:uu,svg:cu,terminals:du,viewBox:iu,width:au},Symbol.toStringTag,{value:"Module"})),hu="grid-source",pu="系统电源",gu="source",yu="无穷大母线 / 外部电网",xu="-16 -31 32 53",bu=32,wu=53,vu='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',ku=[{id:"t_bottom",x:0,y:20,orientation:"s"}],_u={kind:"inline"},kk={id:hu,name:pu,category:gu,description:yu,viewBox:xu,width:bu,height:wu,svg:vu,terminals:ku,source:_u},_k=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:kk,description:yu,height:wu,id:hu,name:pu,source:_u,svg:vu,terminals:ku,viewBox:xu,width:bu},Symbol.toStringTag,{value:"Module"})),$u="grounding-transformer",Su="接地变 (Z形)",ju="grounding",Eu="星-曲折接线变压器,中性点接地用",Nu="-62 -152 64 164",Mu=64,Tu=164,Au='<line x1="-30" y1="-40" x2="-35" y2="-35" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-25" y2="-35" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-35" x2="-40" y2="-38" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-150" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-35" x2="-25" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-30" y2="-45" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-45" x2="-25" y2="-48" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-130" x2="-20" y2="-140" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-135" x2="-20" y2="-145" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="5" x2="-20" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-85" x2="-30" y2="-95" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-20" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-40" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-40" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/>',Cu=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Iu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},$k={id:$u,name:Su,category:ju,description:Eu,viewBox:Nu,width:Mu,height:Tu,svg:Au,terminals:Cu,source:Iu},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:ju,default:$k,description:Eu,height:Tu,id:$u,name:Su,source:Iu,svg:Au,terminals:Cu,viewBox:Nu,width:Mu},Symbol.toStringTag,{value:"Module"})),Pu="heater",Ou="电加热器 (EH)",Bu="load",Lu="电阻加热元件 / 电热负荷。",zu="-22 -7 54 14",Ru=54,Du=14,Fu='<line x1="-20" y1="0" x2="-10" y2="0" fill="none" stroke="black" stroke-width="1"/><rect x="-10" y="-5" width="30" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="0" x2="30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-5" x2="-5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-5" x2="5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="15" y1="-5" x2="15" y2="5" fill="none" stroke="black" stroke-width="1"/>',Hu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Wu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],qu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},jk={id:Pu,name:Ou,category:Bu,description:Lu,viewBox:zu,width:Ru,height:Du,svg:Fu,terminals:Hu,params:Wu,source:qu},Ek=Object.freeze(Object.defineProperty({__proto__:null,category:Bu,default:jk,description:Lu,height:Du,id:Pu,name:Ou,params:Wu,source:qu,svg:Fu,terminals:Hu,viewBox:zu,width:Ru},Symbol.toStringTag,{value:"Module"})),Gu="igbt",Xu="绝缘栅双极晶体管 (IGBT)",Yu="passive",Ku="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Vu="-32 -32 54 74",Uu=54,Ju=74,Zu='<line x1="0" y1="25" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polyline points="-30,20 -5,20 -5,-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="20" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="20" y2="40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="15" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-25" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-8" x2="0" y2="8" fill="none" stroke="black" stroke-width="1"/><polyline points="10,-24 8,-21 12,-22" fill="none" stroke="black" stroke-width="1"/><polyline points="10,25 11,29 8,27" fill="none" stroke="black" stroke-width="1"/>',Qu=[{id:"t1",x:20,y:-30,orientation:"n"},{id:"t2",x:20,y:40,orientation:"s"},{id:"t_g",x:-30,y:20,orientation:"w"}],ef={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_05/en_60617_05_05_19.elmt",qetEnglishName:"Insulated-gate bipolar transistor (IGBT) enhancement type, N channel"},Nk={id:Gu,name:Xu,category:Yu,description:Ku,viewBox:Vu,width:Uu,height:Ju,svg:Zu,terminals:Qu,source:ef},Mk=Object.freeze(Object.defineProperty({__proto__:null,category:Yu,default:Nk,description:Ku,height:Ju,id:Gu,name:Xu,source:ef,svg:Zu,terminals:Qu,viewBox:Vu,width:Uu},Symbol.toStringTag,{value:"Module"})),tf="indicator-light",nf="指示灯 (HL)",of="control",rf="信号 / 状态指示灯。",sf="-12 -22 24 24",af=24,lf=24,cf='<ellipse cx="0" cy="-10" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-3" x2="7" y2="-17" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-17" x2="7" y2="-3" fill="none" stroke="black" stroke-width="1"/>',df=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],uf=[{name:"color",label:"颜色",type:"string"}],ff={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},Tk={id:tf,name:nf,category:of,description:rf,viewBox:sf,width:af,height:lf,svg:cf,terminals:df,params:uf,source:ff},Ak=Object.freeze(Object.defineProperty({__proto__:null,category:of,default:Tk,description:rf,height:lf,id:tf,name:nf,params:uf,source:ff,svg:cf,terminals:df,viewBox:sf,width:af},Symbol.toStringTag,{value:"Module"})),mf="inductor",hf="电感 (L)",pf="passive",gf="通用电感 / 线圈 / 扼流圈。",yf="-17 -32 34 64",xf=34,bf=64,wf='<line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><path d="M 0 15 A 15 15 0 1 0 -15 0" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',vf=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],kf=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],_f={x:6,y:0,anchor:"start"},$f={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},Ck={id:mf,name:hf,category:pf,description:gf,viewBox:yf,width:xf,height:bf,svg:wf,terminals:vf,params:kf,label:_f,source:$f},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:pf,default:Ck,description:gf,height:bf,id:mf,label:_f,name:hf,params:kf,source:$f,svg:wf,terminals:vf,viewBox:yf,width:xf},Symbol.toStringTag,{value:"Module"})),Sf="inverter",jf="逆变器 (DC→AC)",Ef="renewable",Nf="-42 -42 44 44",Mf=44,Tf=44,Af='<path d="M -15 -8 A 5 2.5 0 0 0 -25 -8" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><path d="M -15 -8 A 5 2.5 0 0 0 -5 -8" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/>',Cf=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],If={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},Pk={id:Sf,name:jf,category:Ef,viewBox:Nf,width:Mf,height:Tf,svg:Af,terminals:Cf,source:If},Ok=Object.freeze(Object.defineProperty({__proto__:null,category:Ef,default:Pk,height:Tf,id:Sf,name:jf,source:If,svg:Af,terminals:Cf,viewBox:Nf,width:Mf},Symbol.toStringTag,{value:"Module"})),Pf="limit-switch",Of="限位开关 (SQ)",Bf="control",Lf="行程 / 位置开关 (常开, 机械操作)。",zf="-10 -42 12 64",Rf=12,Df=64,Ff='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-13" x2="-7" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-12" x2="-3" y2="-8" fill="none" stroke="black" stroke-width="1"/>',Hf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Wf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],qf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},Bk={id:Pf,name:Of,category:Bf,description:Lf,viewBox:zf,width:Rf,height:Df,svg:Ff,terminals:Hf,state:Wf,source:qf},Lk=Object.freeze(Object.defineProperty({__proto__:null,category:Bf,default:Bk,description:Lf,height:Df,id:Pf,name:Of,source:qf,state:Wf,svg:Ff,terminals:Hf,viewBox:zf,width:Rf},Symbol.toStringTag,{value:"Module"})),Gf="load-switch",Xf="负荷开关",Yf="switching",Kf="-10 -42 14 64",Vf=14,Uf=64,Jf='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',Zf=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Qf=[{name:"open",type:"boolean",default:!1,label:"断开"}],em={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},zk={id:Gf,name:Xf,category:Yf,viewBox:Kf,width:Vf,height:Uf,svg:Jf,terminals:Zf,state:Qf,source:em},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:Yf,default:zk,height:Uf,id:Gf,name:Xf,source:em,state:Qf,svg:Jf,terminals:Zf,viewBox:Kf,width:Vf},Symbol.toStringTag,{value:"Module"})),tm="load",nm="负荷",om="load",rm="抽象负荷(电流流出箭头)",sm="-8 -22 16 46",im=16,am=46,lm='<line x1="0" y1="-20" x2="0" y2="10" stroke="black" stroke-width="1" fill="none"/><polygon points="-6,10 6,10 0,22" fill="black" stroke="black" stroke-width="1"/>',cm=[{id:"t_top",x:0,y:-20,orientation:"n"}],dm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],um={x:6,y:0,anchor:"start"},fm={kind:"inline"},Dk={id:tm,name:nm,category:om,description:rm,viewBox:sm,width:im,height:am,svg:lm,terminals:cm,params:dm,label:um,source:fm},Fk=Object.freeze(Object.defineProperty({__proto__:null,category:om,default:Dk,description:rm,height:am,id:tm,label:um,name:nm,params:dm,source:fm,svg:lm,terminals:cm,viewBox:sm,width:im},Symbol.toStringTag,{value:"Module"})),mm="make-contact",hm="常开触点 (NO)",pm="control",gm="常开辅助触点 (make contact)。",ym="-10 -42 12 64",xm=12,bm=64,wm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',vm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],km=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],_m={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_01.elmt",qetEnglishName:"Make contact, general symbol; Switch, general symbol"},Hk={id:mm,name:hm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,state:km,source:_m},Wk=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:Hk,description:gm,height:bm,id:mm,name:hm,source:_m,state:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),$m="motor-starter",Sm="电机启动器",jm="motor-control",Em="电机启动器 (IEC 60617 通用符号)。",Nm="-22 -27 44 54",Mm=44,Tm=54,Am='<rect x="-20" y="-20" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,-20 0,-10 20,-20" fill="none" stroke="black" stroke-width="1"/>',Cm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Im={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},qk={id:$m,name:Sm,category:jm,description:Em,viewBox:Nm,width:Mm,height:Tm,svg:Am,terminals:Cm,source:Im},Gk=Object.freeze(Object.defineProperty({__proto__:null,category:jm,default:qk,description:Em,height:Tm,id:$m,name:Sm,source:Im,svg:Am,terminals:Cm,viewBox:Nm,width:Mm},Symbol.toStringTag,{value:"Module"})),Pm="ngr",Om="中性点电阻 (NGR)",Bm="grounding",Lm="小电阻接地:连接变压器中性点到地",zm="-12 -32 24 62",Rm=24,Dm=62,Fm='<line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><rect x="-6" y="-15" width="12" height="22" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="7" x2="0" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="15" x2="10" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="19" x2="7" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="23" x2="4" y2="23" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="27" x2="1.5" y2="27" fill="none" stroke="black" stroke-width="1"/>',Hm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Wm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],qm={kind:"inline"},Xk={id:Pm,name:Om,category:Bm,description:Lm,viewBox:zm,width:Rm,height:Dm,svg:Fm,terminals:Hm,params:Wm,source:qm},Yk=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:Xk,description:Lm,height:Dm,id:Pm,name:Om,params:Wm,source:qm,svg:Fm,terminals:Hm,viewBox:zm,width:Rm},Symbol.toStringTag,{value:"Module"})),Gm="overcurrent-relay",Xm="过流继电器 (50/51)",Ym="protection",Km="过电流保护继电器 (ANSI 50/51)。",Vm="-62 -62 64 64",Um=64,Jm=64,Zm='<rect x="-60" y="-60" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-48" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">5...10A</text>',Qm=[{id:"t_top",x:-30,y:-60,orientation:"n"}],eh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Kk={id:Gm,name:Xm,category:Ym,description:Km,viewBox:Vm,width:Um,height:Jm,svg:Zm,terminals:Qm,source:eh},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:Ym,default:Kk,description:Km,height:Jm,id:Gm,name:Xm,source:eh,svg:Zm,terminals:Qm,viewBox:Vm,width:Um},Symbol.toStringTag,{value:"Module"})),th="phase-failure-relay",nh="断相继电器",oh="protection",rh="断相 / 缺相保护继电器。",sh="-62 -42 64 44",ih=64,ah=44,lh='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">m &lt; 3</text>',ch=[{id:"t_top",x:-30,y:-40,orientation:"n"}],dh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Uk={id:th,name:nh,category:oh,description:rh,viewBox:sh,width:ih,height:ah,svg:lh,terminals:ch,source:dh},Jk=Object.freeze(Object.defineProperty({__proto__:null,category:oh,default:Uk,description:rh,height:ah,id:th,name:nh,source:dh,svg:lh,terminals:ch,viewBox:sh,width:ih},Symbol.toStringTag,{value:"Module"})),uh="plc",fh="PLC / 控制器",mh="control",hh="可编程逻辑控制器 (PLC)。",ph="-24 -42 48 84",gh=48,yh=84,xh='<rect x="-22" y="-22" width="44" height="44" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">PLC</text><line x1="0" y1="-40" x2="0" y2="-22" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="22" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',bh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],wh={kind:"inline"},Zk={id:uh,name:fh,category:mh,description:hh,viewBox:ph,width:gh,height:yh,svg:xh,terminals:bh,source:wh},Qk=Object.freeze(Object.defineProperty({__proto__:null,category:mh,default:Zk,description:hh,height:yh,id:uh,name:fh,source:wh,svg:xh,terminals:bh,viewBox:ph,width:gh},Symbol.toStringTag,{value:"Module"})),vh="power-factor-meter",kh="功率因数表 (cosφ)",_h="measurement",$h="功率因数表 (cosφ)。",Sh="-22 -42 44 44",jh=44,Eh=44,Nh='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-14" y="-6.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">cos φ</text>',Mh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Th={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},e_={id:vh,name:kh,category:_h,description:$h,viewBox:Sh,width:jh,height:Eh,svg:Nh,terminals:Mh,source:Th},t_=Object.freeze(Object.defineProperty({__proto__:null,category:_h,default:e_,description:$h,height:Eh,id:vh,name:kh,source:Th,svg:Nh,terminals:Mh,viewBox:Sh,width:jh},Symbol.toStringTag,{value:"Module"})),Ah="power-supply",Ch="开关电源 (PS)",Ih="source",Ph="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Oh="-24 -42 48 84",Bh=48,Lh=84,zh='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="8" y="15" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">=</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Rh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],Dh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Fh={kind:"inline"},n_={id:Ah,name:Ch,category:Ih,description:Ph,viewBox:Oh,width:Bh,height:Lh,svg:zh,terminals:Rh,params:Dh,source:Fh},o_=Object.freeze(Object.defineProperty({__proto__:null,category:Ih,default:n_,description:Ph,height:Lh,id:Ah,name:Ch,params:Dh,source:Fh,svg:zh,terminals:Rh,viewBox:Oh,width:Bh},Symbol.toStringTag,{value:"Module"})),Hh="protective-relay",Wh="保护继电器",qh="protection",Gh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Xh="-32 -42 64 44",Yh=64,Kh=44,Vh='<polygon points="-2,-22 2,-22 0,-25" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-22 -2,-19 -6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="2,-22 2,-19 6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-19 0,-17 -3,-15" fill="black" stroke="black" stroke-width="1"/><polygon points="0,-17 2,-19 4,-15" fill="black" stroke="black" stroke-width="1"/><rect x="-2" y="-22" width="4" height="4" rx="0" ry="0" fill="black" stroke="black" stroke-width="1"/><rect x="-30" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Uh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Jh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_16/en_60617_07_16_01.elmt",qetEnglishName:"Measuring relay; Device related to a measuring relay"},r_={id:Hh,name:Wh,category:qh,description:Gh,viewBox:Xh,width:Yh,height:Kh,svg:Vh,terminals:Uh,source:Jh},s_=Object.freeze(Object.defineProperty({__proto__:null,category:qh,default:r_,description:Gh,height:Kh,id:Hh,name:Wh,source:Jh,svg:Vh,terminals:Uh,viewBox:Xh,width:Yh},Symbol.toStringTag,{value:"Module"})),Zh="proximity-switch",Qh="接近开关 (SQ)",e0="control",t0="接近传感器 / 无触点接近开关。",n0="-12 -32 24 64",o0=24,r0=64,s0='<line x1="0" y1="-30" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 -10,0 0,10 10,0" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-6" x2="-4" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-6" x2="4" y2="6" fill="none" stroke="black" stroke-width="1"/>',i0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],a0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},i_={id:Zh,name:Qh,category:e0,description:t0,viewBox:n0,width:o0,height:r0,svg:s0,terminals:i0,source:a0},a_=Object.freeze(Object.defineProperty({__proto__:null,category:e0,default:i_,description:t0,height:r0,id:Zh,name:Qh,source:a0,svg:s0,terminals:i0,viewBox:n0,width:o0},Symbol.toStringTag,{value:"Module"})),l0="pt",c0="电压互感器 (PT)",d0="instrument-transformer",u0="-22 -42 44 115",f0=44,m0=115,h0='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',p0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],g0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},l_={id:l0,name:c0,category:d0,viewBox:u0,width:f0,height:m0,svg:h0,terminals:p0,source:g0},c_=Object.freeze(Object.defineProperty({__proto__:null,category:d0,default:l_,height:m0,id:l0,name:c0,source:g0,svg:h0,terminals:p0,viewBox:u0,width:f0},Symbol.toStringTag,{value:"Module"})),y0="push-button",x0="按钮 (SB)",b0="control",w0="手动按钮, 自动复位 (常开 make)。",v0="-37 -42 39 64",k0=39,_0=64,$0='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',S0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],j0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_02.elmt",qetEnglishName:"Switch, manually operated, push-button, automatic return"},d_={id:y0,name:x0,category:b0,description:w0,viewBox:v0,width:k0,height:_0,svg:$0,terminals:S0,source:j0},u_=Object.freeze(Object.defineProperty({__proto__:null,category:b0,default:d_,description:w0,height:_0,id:y0,name:x0,source:j0,svg:$0,terminals:S0,viewBox:v0,width:k0},Symbol.toStringTag,{value:"Module"})),E0="pv",N0="光伏组件",M0="renewable",T0="-33 -22 85 64",A0=85,C0=64,I0='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',P0=[{id:"t_dc",x:50,y:10,orientation:"e"}],O0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},f_={id:E0,name:N0,category:M0,viewBox:T0,width:A0,height:C0,svg:I0,terminals:P0,source:O0},m_=Object.freeze(Object.defineProperty({__proto__:null,category:M0,default:f_,height:C0,id:E0,name:N0,source:O0,svg:I0,terminals:P0,viewBox:T0,width:A0},Symbol.toStringTag,{value:"Module"})),B0="rcd",L0="剩余电流装置 (RCD)",z0="protection",R0="不带过流保护的剩余电流断路器 (IEC 61008)。",D0="-12 -22 19 44",F0=19,H0=44,W0='<line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="0,20 0,10 -7,-9" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="13" rx="4.5" ry="2" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,0 -10,0 -10,13 -5,13" fill="none" stroke="black" stroke-width="0.4" stroke-dasharray="4 2"/>',q0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],G0=[{name:"open",type:"boolean",default:!1,label:"断开"}],X0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Y0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},h_={id:B0,name:L0,category:z0,description:R0,viewBox:D0,width:F0,height:H0,svg:W0,terminals:q0,state:G0,params:X0,source:Y0},p_=Object.freeze(Object.defineProperty({__proto__:null,category:z0,default:h_,description:R0,height:H0,id:B0,name:L0,params:X0,source:Y0,state:G0,svg:W0,terminals:q0,viewBox:D0,width:F0},Symbol.toStringTag,{value:"Module"})),K0="recloser",V0="重合闸 (Recloser)",U0="protection",J0="中压自动重合闸开关。",Z0="-12 -32 36 64",Q0=36,ep=64,tp='<line x1="0" y1="-30" x2="0" y2="-10" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-13" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-8" x2="2" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-12" x2="2" y2="-8" stroke="black" stroke-width="1" fill="none"/><path d="M 13 -12 A 7 7 0 1 1 6 -5" fill="none" stroke="black" stroke-width="0.8"/><polygon points="4,-7 6,-5 8,-3" fill="black"/><text x="14" y="6" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">AR</text>',np=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],op=[{name:"open",type:"boolean",default:!1,label:"断开"}],rp={kind:"inline"},g_={id:K0,name:V0,category:U0,description:J0,viewBox:Z0,width:Q0,height:ep,svg:tp,terminals:np,state:op,source:rp},y_=Object.freeze(Object.defineProperty({__proto__:null,category:U0,default:g_,description:J0,height:ep,id:K0,name:V0,source:rp,state:op,svg:tp,terminals:np,viewBox:Z0,width:Q0},Symbol.toStringTag,{value:"Module"})),sp="rectifier",ip="整流器 (AC→DC)",ap="renewable",lp="-42 -42 44 44",cp=44,dp=44,up='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/>',fp=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],mp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},x_={id:sp,name:ip,category:ap,viewBox:lp,width:cp,height:dp,svg:up,terminals:fp,source:mp},b_=Object.freeze(Object.defineProperty({__proto__:null,category:ap,default:x_,height:dp,id:sp,name:ip,source:mp,svg:up,terminals:fp,viewBox:lp,width:cp},Symbol.toStringTag,{value:"Module"})),hp="relay-coil",pp="继电器线圈 (KA)",gp="control",yp="继电器 / 接触器操作线圈 (方框)。",xp="-22 -22 44 44",bp=44,wp=44,vp='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/>',kp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_p={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_01.elmt",qetEnglishName:"Operating device, general symbol; Relay coil, general symbol"},w_={id:hp,name:pp,category:gp,description:yp,viewBox:xp,width:bp,height:wp,svg:vp,terminals:kp,source:_p},v_=Object.freeze(Object.defineProperty({__proto__:null,category:gp,default:w_,description:yp,height:wp,id:hp,name:pp,source:_p,svg:vp,terminals:kp,viewBox:xp,width:bp},Symbol.toStringTag,{value:"Module"})),$p="resistor",Sp="电阻 (R)",jp="passive",Ep="通用电阻 / 限流 / 制动电阻。",Np="-6 -23 12 35",Mp=12,Tp=35,Ap='<line x1="0" y1="-10" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="10" x2="4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-10" x2="-4" y2="10" fill="none" stroke="black" stroke-width="1"/>',Cp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Ip=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Pp={x:6,y:0,anchor:"start"},Op={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},k_={id:$p,name:Sp,category:jp,description:Ep,viewBox:Np,width:Mp,height:Tp,svg:Ap,terminals:Cp,params:Ip,label:Pp,source:Op},__=Object.freeze(Object.defineProperty({__proto__:null,category:jp,default:k_,description:Ep,height:Tp,id:$p,label:Pp,name:Sp,params:Ip,source:Op,svg:Ap,terminals:Cp,viewBox:Np,width:Mp},Symbol.toStringTag,{value:"Module"})),Bp="reverse-power-relay",Lp="逆功率继电器 (32)",zp="protection",Rp="逆功率 / 逆流保护继电器 (ANSI 32)。",Dp="-62 -42 64 44",Fp=64,Hp=44,Wp='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">I</text><polygon points="-15,-20 -30,-20 -24,-22 -24,-18 -30,-20 -24,-20" fill="black" stroke="black" stroke-width="1"/>',qp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Gp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},$_={id:Bp,name:Lp,category:zp,description:Rp,viewBox:Dp,width:Fp,height:Hp,svg:Wp,terminals:qp,source:Gp},S_=Object.freeze(Object.defineProperty({__proto__:null,category:zp,default:$_,description:Rp,height:Hp,id:Bp,name:Lp,source:Gp,svg:Wp,terminals:qp,viewBox:Dp,width:Fp},Symbol.toStringTag,{value:"Module"})),Xp="selector-switch",Yp="选择开关 (SA)",Kp="switching",Vp="转换 / 选择开关 (旋转操作, 保位)。",Up="-34 -42 36 64",Jp=36,Zp=64,Qp='<line x1="-32" y1="-10" x2="-2" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-32" y1="-15" x2="-32" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',eg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],tg=[{name:"open",type:"boolean",default:!1,label:"断开"}],ng={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_04.elmt",qetEnglishName:"Switch, manually operated, turning, stay-put"},j_={id:Xp,name:Yp,category:Kp,description:Vp,viewBox:Up,width:Jp,height:Zp,svg:Qp,terminals:eg,state:tg,source:ng},E_=Object.freeze(Object.defineProperty({__proto__:null,category:Kp,default:j_,description:Vp,height:Zp,id:Xp,name:Yp,source:ng,state:tg,svg:Qp,terminals:eg,viewBox:Up,width:Jp},Symbol.toStringTag,{value:"Module"})),og="series-reactor",rg="串联电抗器",sg="compensation",ig="与并联电抗器同符号;通过用法区分。",ag="-62 -82 64 104",lg=64,cg=104,dg='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',ug=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],fg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},N_={id:og,name:rg,category:sg,description:ig,viewBox:ag,width:lg,height:cg,svg:dg,terminals:ug,source:fg},M_=Object.freeze(Object.defineProperty({__proto__:null,category:sg,default:N_,description:ig,height:cg,id:og,name:rg,source:fg,svg:dg,terminals:ug,viewBox:ag,width:lg},Symbol.toStringTag,{value:"Module"})),mg="shunt-capacitor",hg="并联电容器",pg="compensation",gg="-7 -23 14 27",yg=14,xg=27,bg='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',wg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],vg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],kg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},T_={id:mg,name:hg,category:pg,viewBox:gg,width:yg,height:xg,svg:bg,terminals:wg,params:vg,source:kg},A_=Object.freeze(Object.defineProperty({__proto__:null,category:pg,default:T_,height:xg,id:mg,name:hg,params:vg,source:kg,svg:bg,terminals:wg,viewBox:gg,width:yg},Symbol.toStringTag,{value:"Module"})),_g="shunt-reactor",$g="并联电抗器",Sg="compensation",jg="-62 -82 64 104",Eg=64,Ng=104,Mg='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',Tg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Ag={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},C_={id:_g,name:$g,category:Sg,viewBox:jg,width:Eg,height:Ng,svg:Mg,terminals:Tg,source:Ag},I_=Object.freeze(Object.defineProperty({__proto__:null,category:Sg,default:C_,height:Ng,id:_g,name:$g,source:Ag,svg:Mg,terminals:Tg,viewBox:jg,width:Eg},Symbol.toStringTag,{value:"Module"})),Cg="siren",Ig="警笛 (HA)",Pg="control",Og="声响警笛 / 报警器。",Bg="-32 -42 44 54",Lg=44,zg=54,Rg='<line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="10,-10 -30,-10 -10,-40" fill="none" stroke="black" stroke-width="1"/>',Dg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Fg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},P_={id:Cg,name:Ig,category:Pg,description:Og,viewBox:Bg,width:Lg,height:zg,svg:Rg,terminals:Dg,source:Fg},O_=Object.freeze(Object.defineProperty({__proto__:null,category:Pg,default:P_,description:Og,height:zg,id:Cg,name:Ig,source:Fg,svg:Rg,terminals:Dg,viewBox:Bg,width:Lg},Symbol.toStringTag,{value:"Module"})),Hg="socket-outlet",Wg="插座 / 连接器",qg="load",Gg="电源插座 / 多极连接器。",Xg="-7 -2 13 34",Yg=13,Kg=34,Vg='<line x1="-5" y1="13" x2="4" y2="20" fill="none" stroke="black" stroke-width="0.4"/><line x1="-1" y1="12" x2="-1" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="9" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="12" x2="1" y2="19" fill="none" stroke="black" stroke-width="1"/><path d="M 3 13 A 3 3 0 0 0 -3 13" fill="none" stroke="black" stroke-width="1"/>',Ug=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Jg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
197
+ unifilar`},B_={id:Hg,name:Wg,category:qg,description:Gg,viewBox:Xg,width:Yg,height:Kg,svg:Vg,terminals:Ug,source:Jg},L_=Object.freeze(Object.defineProperty({__proto__:null,category:qg,default:B_,description:Gg,height:Kg,id:Hg,name:Wg,source:Jg,svg:Vg,terminals:Ug,viewBox:Xg,width:Yg},Symbol.toStringTag,{value:"Module"})),Zg="soft-starter",Qg="软启动器",e1="motor-control",t1="电机软启动器 (晶闸管降压启动)。",n1="-22 -42 44 84",o1=44,r1=84,s1='<rect x="-20" y="-20" width="40" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-12" y1="-12" x2="12" y2="12" stroke="black" stroke-width="1" fill="none"/><polygon points="4,8 12,12 8,4" fill="none" stroke="black" stroke-width="1"/><text x="-12" y="-2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">SS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',i1=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],a1={kind:"inline"},z_={id:Zg,name:Qg,category:e1,description:t1,viewBox:n1,width:o1,height:r1,svg:s1,terminals:i1,source:a1},R_=Object.freeze(Object.defineProperty({__proto__:null,category:e1,default:z_,description:t1,height:r1,id:Zg,name:Qg,source:a1,svg:s1,terminals:i1,viewBox:n1,width:o1},Symbol.toStringTag,{value:"Module"})),l1="sync-motor",c1="同步电动机",d1="load",u1="-62 -82 64 114",f1=64,m1=114,h1='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',p1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],g1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},D_={id:l1,name:c1,category:d1,viewBox:u1,width:f1,height:m1,svg:h1,terminals:p1,source:g1},F_=Object.freeze(Object.defineProperty({__proto__:null,category:d1,default:D_,height:m1,id:l1,name:c1,source:g1,svg:h1,terminals:p1,viewBox:u1,width:f1},Symbol.toStringTag,{value:"Module"})),y1="synchronoscope",x1="同步表",b1="measurement",w1="同步指示器 / 同步表。",v1="-22 -42 44 44",k1=44,_1=44,$1='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',S1=[{id:"t_top",x:0,y:-40,orientation:"n"}],j1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},H_={id:y1,name:x1,category:b1,description:w1,viewBox:v1,width:k1,height:_1,svg:$1,terminals:S1,source:j1},W_=Object.freeze(Object.defineProperty({__proto__:null,category:b1,default:H_,description:w1,height:_1,id:y1,name:x1,source:j1,svg:$1,terminals:S1,viewBox:v1,width:k1},Symbol.toStringTag,{value:"Module"})),E1="terminal",N1="接线端子 / 节点 (X)",M1="busbar",T1="接线端子 / 接线盒 / 汇接节点。",A1="-5 -5 10 10",C1=10,I1=10,P1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',O1=[{id:"t_top",x:0,y:-2.5,orientation:"n"},{id:"t_bottom",x:0,y:2.5,orientation:"s"},{id:"t_left",x:-2.5,y:0,orientation:"w"},{id:"t_right",x:2.5,y:0,orientation:"e"}],B1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},q_={id:E1,name:N1,category:M1,description:T1,viewBox:A1,width:C1,height:I1,svg:P1,terminals:O1,source:B1},G_=Object.freeze(Object.defineProperty({__proto__:null,category:M1,default:q_,description:T1,height:I1,id:E1,name:N1,source:B1,svg:P1,terminals:O1,viewBox:A1,width:C1},Symbol.toStringTag,{value:"Module"})),L1="thermal-overload",z1="热过载继电器",R1="motor-control",D1="电机热过载保护继电器, 通常串接在接触器和电机之间。",F1="-9 -32 19 64",H1=19,W1=64,q1='<line x1="0" y1="-30" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-7" y="-15" width="14" height="30" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,-10 -1,-5 -4,0 -1,5 -4,10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',G1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],X1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],Y1={kind:"inline"},X_={id:L1,name:z1,category:R1,description:D1,viewBox:F1,width:H1,height:W1,svg:q1,terminals:G1,state:X1,source:Y1},Y_=Object.freeze(Object.defineProperty({__proto__:null,category:R1,default:X_,description:D1,height:W1,id:L1,name:z1,source:Y1,state:X1,svg:q1,terminals:G1,viewBox:F1,width:H1},Symbol.toStringTag,{value:"Module"})),K1="thermocouple",V1="热电偶 (BT)",U1="measurement",J1="热电偶温度传感器。",Z1="-26 -42 52 46",Q1=52,ey=46,ty='<ellipse cx="0" cy="0" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/><polyline points="-10,-40 -10,-15 0,0 10,-15 10,-40" fill="none" stroke="black" stroke-width="1"/><line x1="-24" y1="-16" x2="-16" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="16" y1="-16" x2="24" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-20" x2="20" y2="-12" fill="none" stroke="black" stroke-width="1"/>',ny=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],oy={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},K_={id:K1,name:V1,category:U1,description:J1,viewBox:Z1,width:Q1,height:ey,svg:ty,terminals:ny,source:oy},V_=Object.freeze(Object.defineProperty({__proto__:null,category:U1,default:K_,description:J1,height:ey,id:K1,name:V1,source:oy,svg:ty,terminals:ny,viewBox:Z1,width:Q1},Symbol.toStringTag,{value:"Module"})),ry="thyristor",sy="晶闸管 (V)",iy="passive",ay="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ly="-22 -42 34 44",cy=34,dy=44,uy='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-20" x2="-10" y2="-20" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,0 -7,0 -4,-10" fill="none" stroke="black" stroke-width="1"/>',fy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],my={x:6,y:-20,anchor:"start"},hy={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},U_={id:ry,name:sy,category:iy,description:ay,viewBox:ly,width:cy,height:dy,svg:uy,terminals:fy,label:my,source:hy},J_=Object.freeze(Object.defineProperty({__proto__:null,category:iy,default:U_,description:ay,height:dy,id:ry,label:my,name:sy,source:hy,svg:uy,terminals:fy,viewBox:ly,width:cy},Symbol.toStringTag,{value:"Module"})),py="time-relay",gy="时间继电器 (KT)",yy="control",xy="延时 (缓动) 继电器线圈。",by="-32 -22 54 44",wy=54,vy=44,ky='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><rect x="-30" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="10" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/>',_y=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],$y={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},Z_={id:py,name:gy,category:yy,description:xy,viewBox:by,width:wy,height:vy,svg:ky,terminals:_y,source:$y},Q_=Object.freeze(Object.defineProperty({__proto__:null,category:yy,default:Z_,description:xy,height:vy,id:py,name:gy,source:$y,svg:ky,terminals:_y,viewBox:by,width:wy},Symbol.toStringTag,{value:"Module"})),Sy="transfer-switch",jy="切换开关 (ATS)",Ey="switching",Ny="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",My="-27 -32 51 64",Ty=51,Ay=64,Cy='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',Iy=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],Py=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Oy={kind:"inline"},e$={id:Sy,name:jy,category:Ey,description:Ny,viewBox:My,width:Ty,height:Ay,svg:Cy,terminals:Iy,state:Py,source:Oy},t$=Object.freeze(Object.defineProperty({__proto__:null,category:Ey,default:e$,description:Ny,height:Ay,id:Sy,name:jy,source:Oy,state:Py,svg:Cy,terminals:Iy,viewBox:My,width:Ty},Symbol.toStringTag,{value:"Module"})),By="transformer-2w",Ly="双绕组变压器",zy="transformer",Ry="-62 -142 64 144",Dy=64,Fy=144,Hy='<ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-140" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/>',Wy=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],qy=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],Gy={x:4,y:-68,anchor:"start"},Xy={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_01.elmt",qetEnglishName:"Transformer with two windings, general symbol"},n$={id:By,name:Ly,category:zy,viewBox:Ry,width:Dy,height:Fy,svg:Hy,terminals:Wy,params:qy,label:Gy,source:Xy},o$=Object.freeze(Object.defineProperty({__proto__:null,category:zy,default:n$,height:Fy,id:By,label:Gy,name:Ly,params:qy,source:Xy,svg:Hy,terminals:Wy,viewBox:Ry,width:Dy},Symbol.toStringTag,{value:"Module"})),Yy="transformer-3w",Ky="三绕组变压器",Vy="transformer",Uy="-82 -131 114 133",Jy=114,Zy=133,Qy='<ellipse cx="-30" cy="-80" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-31" y1="-129" x2="-31" y2="-109" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-50" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-20" x2="-50" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',ex=[{id:"t1",x:-31,y:-129,orientation:"n"},{id:"t_low_left",x:-50,y:0,orientation:"s"},{id:"t_low_right",x:0,y:0,orientation:"s"}],tx={x:4,y:-64,anchor:"start"},nx={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},r$={id:Yy,name:Ky,category:Vy,viewBox:Uy,width:Jy,height:Zy,svg:Qy,terminals:ex,label:tx,source:nx},s$=Object.freeze(Object.defineProperty({__proto__:null,category:Vy,default:r$,height:Zy,id:Yy,label:tx,name:Ky,source:nx,svg:Qy,terminals:ex,viewBox:Uy,width:Jy},Symbol.toStringTag,{value:"Module"})),ox="triac",rx="双向晶闸管 (V)",sx="passive",ix="双向三极晶闸管 (TRIAC)。",ax="-22 -42 44 44",lx=44,cx=44,dx='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,-30 0,-30 -10,-10" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-30" x2="-10" y2="-30" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 10,-30 20,-10" fill="none" stroke="black" stroke-width="1"/><polyline points="20,0 18,0 14,-10" fill="none" stroke="black" stroke-width="1"/>',ux=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fx={x:6,y:-20,anchor:"start"},mx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},i$={id:ox,name:rx,category:sx,description:ix,viewBox:ax,width:lx,height:cx,svg:dx,terminals:ux,label:fx,source:mx},a$=Object.freeze(Object.defineProperty({__proto__:null,category:sx,default:i$,description:ix,height:cx,id:ox,label:fx,name:rx,source:mx,svg:dx,terminals:ux,viewBox:ax,width:lx},Symbol.toStringTag,{value:"Module"})),hx="undervoltage-relay",px="欠压继电器 (27)",gx="protection",yx="欠电压保护继电器 (ANSI 27)。",xx="-62 -82 64 84",bx=64,wx=84,vx='<rect x="-60" y="-80" width="60" height="80" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-49" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">130 %</text><text x="-55" y="-32.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">50...80 V</text><text x="-41" y="-53.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">U &lt;</text>',kx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],_x={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},l$={id:hx,name:px,category:gx,description:yx,viewBox:xx,width:bx,height:wx,svg:vx,terminals:kx,source:_x},c$=Object.freeze(Object.defineProperty({__proto__:null,category:gx,default:l$,description:yx,height:wx,id:hx,name:px,source:_x,svg:vx,terminals:kx,viewBox:xx,width:bx},Symbol.toStringTag,{value:"Module"})),$x="ups",Sx="不间断电源 (UPS)",jx="source",Ex="在线 / 后备式不间断电源。",Nx="-26 -42 52 84",Mx=52,Tx=84,Ax='<rect x="-24" y="-20" width="48" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">UPS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Cx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Ix=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Px={kind:"inline"},d$={id:$x,name:Sx,category:jx,description:Ex,viewBox:Nx,width:Mx,height:Tx,svg:Ax,terminals:Cx,params:Ix,source:Px},u$=Object.freeze(Object.defineProperty({__proto__:null,category:jx,default:d$,description:Ex,height:Tx,id:$x,name:Sx,params:Ix,source:Px,svg:Ax,terminals:Cx,viewBox:Nx,width:Mx},Symbol.toStringTag,{value:"Module"})),Ox="varmeter",Bx="无功功率表 (var)",Lx="measurement",zx="无功功率表 (var)。",Rx="-22 -42 44 44",Dx=44,Fx=44,Hx='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">var</text>',Wx=[{id:"t_top",x:0,y:-40,orientation:"n"}],qx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},f$={id:Ox,name:Bx,category:Lx,description:zx,viewBox:Rx,width:Dx,height:Fx,svg:Hx,terminals:Wx,source:qx},m$=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:f$,description:zx,height:Fx,id:Ox,name:Bx,source:qx,svg:Hx,terminals:Wx,viewBox:Rx,width:Dx},Symbol.toStringTag,{value:"Module"})),Gx="vfd",Xx="变频器 (VFD)",Yx="motor-control",Kx="Variable Frequency Drive — 异步电动机调速。",Vx="-24 -42 48 84",Ux=48,Jx=84,Zx='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="6" y="14" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~f</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Qx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],eb={kind:"inline"},h$={id:Gx,name:Xx,category:Yx,description:Kx,viewBox:Vx,width:Ux,height:Jx,svg:Zx,terminals:Qx,source:eb},p$=Object.freeze(Object.defineProperty({__proto__:null,category:Yx,default:h$,description:Kx,height:Jx,id:Gx,name:Xx,source:eb,svg:Zx,terminals:Qx,viewBox:Vx,width:Ux},Symbol.toStringTag,{value:"Module"})),tb="voltage-regulator",nb="调压器 (T)",ob="transformer",rb="可调感应调压器 / 自耦调压器。",sb="-17 -32 38 64",ib=38,ab=64,lb='<line x1="-5" y1="21" x2="5" y2="17" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-16.05" x2="4.95" y2="-20.05" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-5" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="0" rx="15" ry="15" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-20.05" x2="4.95" y2="-24.05" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="23" x2="5" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-18.05" x2="4.95" y2="-22.05" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="25" x2="5" y2="21" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="15" x2="15" y2="-15" fill="none" stroke="black" stroke-width="1"/><polygon points="13,-16 16,-13 19,-19" fill="black" stroke="black" stroke-width="0.4"/>',cb=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],db=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],ub={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},g$={id:tb,name:nb,category:ob,description:rb,viewBox:sb,width:ib,height:ab,svg:lb,terminals:cb,params:db,source:ub},y$=Object.freeze(Object.defineProperty({__proto__:null,category:ob,default:g$,description:rb,height:ab,id:tb,name:nb,params:db,source:ub,svg:lb,terminals:cb,viewBox:sb,width:ib},Symbol.toStringTag,{value:"Module"})),fb="voltmeter",mb="电压表 (V)",hb="measurement",pb="-22 -42 44 44",gb=44,yb=44,xb='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-4" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">V</text>',bb=[{id:"t_top",x:0,y:-40,orientation:"n"}],wb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},x$={id:fb,name:mb,category:hb,viewBox:pb,width:gb,height:yb,svg:xb,terminals:bb,source:wb},b$=Object.freeze(Object.defineProperty({__proto__:null,category:hb,default:x$,height:yb,id:fb,name:mb,source:wb,svg:xb,terminals:bb,viewBox:pb,width:gb},Symbol.toStringTag,{value:"Module"})),vb="wattmeter",kb="功率表 (W)",_b="measurement",$b="-22 -42 44 44",Sb=44,jb=44,Eb='<rect x="-20" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-6" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">W</text>',Nb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Mb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},w$={id:vb,name:kb,category:_b,viewBox:$b,width:Sb,height:jb,svg:Eb,terminals:Nb,source:Mb},v$=Object.freeze(Object.defineProperty({__proto__:null,category:_b,default:w$,height:jb,id:vb,name:kb,source:Mb,svg:Eb,terminals:Nb,viewBox:$b,width:Sb},Symbol.toStringTag,{value:"Module"})),Tb="wind-turbine",Ab="风力发电机",Cb="renewable",Ib="风机:发电机 + 三叶轮标记",Pb="-22 -46 44 68",Ob=44,Bb=68,Lb='<circle cx="0" cy="0" r="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="16">G</text><line x1="0" y1="-20" x2="0" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-32" x2="-10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="0" y2="-44" fill="none" stroke="black" stroke-width="1.5"/>',zb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Rb={kind:"inline"},k$={id:Tb,name:Ab,category:Cb,description:Ib,viewBox:Pb,width:Ob,height:Bb,svg:Lb,terminals:zb,source:Rb},_$=Object.freeze(Object.defineProperty({__proto__:null,category:Cb,default:k$,description:Ib,height:Bb,id:Tb,name:Ab,source:Rb,svg:Lb,terminals:zb,viewBox:Pb,width:Ob},Symbol.toStringTag,{value:"Module"})),Db="zener-diode",Fb="稳压二极管 (D)",Hb="passive",Wb="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",qb="-12 -42 24 44",Gb=24,Xb=44,Yb='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-15" x2="-10" y2="-10" fill="none" stroke="black" stroke-width="1"/>',Kb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Vb={x:6,y:-20,anchor:"start"},Ub={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},$$={id:Db,name:Fb,category:Hb,description:Wb,viewBox:qb,width:Gb,height:Xb,svg:Yb,terminals:Kb,label:Vb,source:Ub},S$=Object.freeze(Object.defineProperty({__proto__:null,category:Hb,default:$$,description:Wb,height:Xb,id:Db,label:Vb,name:Fb,source:Ub,svg:Yb,terminals:Kb,viewBox:qb,width:Gb},Symbol.toStringTag,{value:"Module"})),j$=Object.assign({"./ammeter.json":m2,"./arc-suppression-coil.json":p2,"./arrester.json":y2,"./async-motor.json":b2,"./autotransformer.json":v2,"./battery.json":_2,"./bell.json":S2,"./break-contact.json":E2,"./breaker.json":M2,"./buchholz-relay.json":A2,"./busbar.json":I2,"./buzzer.json":O2,"./capacitor.json":L2,"./contactor.json":R2,"./converter-bidir.json":F2,"./ct.json":W2,"./dc-combiner.json":G2,"./dc-disconnector.json":Y2,"./dc-motor.json":V2,"./diode.json":J2,"./disconnector.json":Q2,"./distance-relay.json":tk,"./earth.json":ok,"./earthing-switch.json":sk,"./energy-meter.json":ak,"./ev-charger.json":ck,"./frequency-meter.json":uk,"./fuse-switch-disconnector.json":mk,"./fuse.json":pk,"./generator.json":yk,"./genset.json":bk,"./gfci-breaker.json":vk,"./grid-source.json":_k,"./grounding-transformer.json":Sk,"./heater.json":Ek,"./igbt.json":Mk,"./indicator-light.json":Ak,"./inductor.json":Ik,"./inverter.json":Ok,"./limit-switch.json":Lk,"./load-switch.json":Rk,"./load.json":Fk,"./make-contact.json":Wk,"./motor-starter.json":Gk,"./ngr.json":Yk,"./overcurrent-relay.json":Vk,"./phase-failure-relay.json":Jk,"./plc.json":Qk,"./power-factor-meter.json":t_,"./power-supply.json":o_,"./protective-relay.json":s_,"./proximity-switch.json":a_,"./pt.json":c_,"./push-button.json":u_,"./pv.json":m_,"./rcd.json":p_,"./recloser.json":y_,"./rectifier.json":b_,"./relay-coil.json":v_,"./resistor.json":__,"./reverse-power-relay.json":S_,"./selector-switch.json":E_,"./series-reactor.json":M_,"./shunt-capacitor.json":A_,"./shunt-reactor.json":I_,"./siren.json":O_,"./socket-outlet.json":L_,"./soft-starter.json":R_,"./sync-motor.json":F_,"./synchronoscope.json":W_,"./terminal.json":G_,"./thermal-overload.json":Y_,"./thermocouple.json":V_,"./thyristor.json":J_,"./time-relay.json":Q_,"./transfer-switch.json":t$,"./transformer-2w.json":o$,"./transformer-3w.json":s$,"./triac.json":a$,"./undervoltage-relay.json":c$,"./ups.json":u$,"./varmeter.json":m$,"./vfd.json":p$,"./voltage-regulator.json":y$,"./voltmeter.json":b$,"./wattmeter.json":v$,"./wind-turbine.json":_$,"./zener-diode.json":S$}),Jb=Object.values(j$).map(e=>e.default),Ke=Object.fromEntries(Jb.map(e=>[e.id,e])),Wo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],E$=(()=>{var t;const e={};for(const n of Jb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),In=new Map(Object.entries(Ke));function Zb(e){return Ke[e]}function N$(e){const n=[...e].sort().join("|");let o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const M$=320;function Xe(e){var h,g,b,$,k;const t=ss(),n=new Map;e.elements.forEach((w,S)=>{if(n.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/elements/${S}`});return}n.set(w.id,w);const C=In.get(w.kind);C||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:w.kind})} (id=${w.id})`,pointer:`/elements/${S}`}),t.elements.set(w.id,{element:w,libraryDef:C})});const o=new Map,r=new Map;(e.buses??[]).forEach((w,S)=>{if(n.has(w.id)||o.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/buses/${S}`});return}if(o.set(w.id,w),w.layout){const C=w.layout.rot??0;r.set(w.id,{at:w.layout.at,span:w.layout.span,rot:C,axis:An(C)})}});const s=new Map;(e.junctions??[]).forEach((w,S)=>{if(n.has(w.id)||o.has(w.id)||s.has(w.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:w.id}),pointer:`/junctions/${S}`});return}s.set(w.id,w)});const i=w=>!w.includes(".")&&o.has(w),a=w=>!w.includes(".")&&s.has(w),l=(w,S)=>{if(i(w)||a(w))return!0;const C=w.indexOf(".");if(C<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:w}),pointer:S}),!1;const R=w.slice(0,C),X=w.slice(C+1),V=t.elements.get(R);if(!V)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:R}),pointer:S}),!1;if(!V.libraryDef)return!1;if(!V.libraryDef.terminals.find(te=>te.id===X)){const te=V.libraryDef.terminals.map(ae=>ae.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:R,kind:V.element.kind,pin:X,available:te}),pointer:S}),!1}return!0},c=[];(e.wires??[]).forEach((w,S)=>{const C=`/wires/${S}`,R=l(w.ends[0],C),X=l(w.ends[1],C);R&&X&&c.push(w)});const u=new Map;if(e.layout)for(const[w,S]of Object.entries(e.layout))t.elements.has(w)?u.set(w,is(S)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:w}),pointer:`/layout/${w}`});const f=d2({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:In,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[w,S]of f.buses){const C=o.get(w);C&&t.buses.set(w,{bus:C,geometry:S})}for(const[w,S]of o)t.buses.has(w)||t.buses.set(w,{bus:S,geometry:{at:((h=S.layout)==null?void 0:h.at)??[0,0],span:((g=S.layout)==null?void 0:g.span)??M$,rot:((b=S.layout)==null?void 0:b.rot)??0,axis:An((($=S.layout)==null?void 0:$.rot)??0)}});for(const w of t.elements.values()){if(!w.libraryDef)continue;const S=t.layout.get(w.element.id);if(!S)continue;const C=[];for(const R of w.libraryDef.terminals){const X=`${w.element.id}.${R.id}`,V=Pe([R.x,R.y],S),te=St(R.orientation,S);t.terminals.set(X,{ref:X,elementId:w.element.id,pin:R.id,world:V,orientation:te}),C.push(X)}t.elementToTerminals.set(w.element.id,C)}const m=w=>{if(!w.includes(".")){const C=t.buses.get(w);return C?C.geometry.at:null}const S=t.terminals.get(w);return S?S.world:null};for(const[w,S]of s){let C;if((k=S.layout)!=null&&k.at)C=[S.layout.at[0],S.layout.at[1]];else if(f.junctions.has(w))C=f.junctions.get(w);else{const R=[];for(const X of c){const[V,te]=X.ends,ae=V===w?te:te===w?V:null;if(ae===null)continue;const D=m(ae);D&&R.push(D)}C=R.length?[R.reduce((X,V)=>X+V[0],0)/R.length,R.reduce((X,V)=>X+V[1],0)/R.length]:[0,0]}t.junctions.set(w,{junction:S,world:C})}const p=new as;for(const w of c)p.add(w.ends[0]),p.add(w.ends[1]),p.union(w.ends[0],w.ends[1]);for(const[,w]of p.groups()){const S=N$(w);t.nodes.set(S,{id:S,terminals:w});for(const C of w)t.terminalToNode.set(C,S)}for(const w of t.elements.values()){const S=t.elementToTerminals.get(w.element.id)??[];if(S.length===0)continue;S.some(R=>t.terminalToNode.has(R))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w.element.id})})}for(const w of t.buses.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of t.junctions.keys())t.terminalToNode.has(w)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:w})});for(const w of c){if(w.path&&w.path.length>=2){const C=w.path,R=C.length>=2?C[1]:null,X=C.length>=2?C[C.length-2]:null,V=Fo(w.ends[0],R,t),te=Fo(w.ends[1],X,t);if(V&&te){const ae=[[V[0],V[1]],...C.slice(1,-1).map(W=>[W[0],W[1]]),[te[0],te[1]]],D=rs(ae);if(D.length>=2){t.wireRenders.set(w.id,{wireId:w.id,path:D,userEdited:!0});continue}}}const S=u2(w,t);S&&t.wireRenders.set(w.id,S)}return t}const T$={earth:"GND",breaker:"QF",disconnector:"QS","earthing-switch":"QE","load-switch":"QL",fuse:"FU","transformer-2w":"T","transformer-3w":"T",autotransformer:"AT",ct:"CT",pt:"PT",generator:"G","sync-motor":"M","async-motor":"M","grid-source":"L",load:"L",battery:"BAT","shunt-reactor":"LR","series-reactor":"LR","shunt-capacitor":"C",arrester:"FBL","grounding-transformer":"TG",ngr:"NGR","arc-suppression-coil":"ASC",pv:"PV","wind-turbine":"WT",rectifier:"RT",inverter:"INV","converter-bidir":"PCS"},qo="B",Go="J";function Jn(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Nt(e,t){const n=T$[t]??t,o=Jn(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Pn(e){const t=Jn(e);let n=1;for(;t.has(`${qo}${n}`);)n++;return`${qo}${n}`}function On(e){const t=Jn(e);let n=1;for(;t.has(`${Go}${n}`);)n++;return`${Go}${n}`}function A$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Je(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}const Xo={version:"1",elements:[]},C$=100,Yo=20;function I$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=Jt()(o2((e,t)=>({diagram:Xo,internal:Xe(Xo),fileSession:null,activeTool:I$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal: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}),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:r}=t(),s=n(o);if(s===o)return;const i=r.length>=C$?r.slice(1):r;e({diagram:s,internal:Xe(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:Xe(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:Xe(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:P$(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var m;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>s.has(p.id)).map(p=>{var g;const h=structuredClone(p);if(!h.layout){const b=(g=r.junctions.get(p.id))==null?void 0:g.world;b&&(h.layout={at:[b[0],b[1]]})}return h}),c={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const h=(m=o.layout)==null?void 0:m[p];if(h){c[p]=structuredClone(h);continue}const g=r.layout.get(p);g&&(c[p]=Lt(g))}const u={};for(const p of n){const h=r.buses.get(p);h&&(u[p]=tt(h.geometry))}const f=(o.wires??[]).filter(p=>p.ends.every(h=>s.has(gn(h)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,junctions:l,placements:c,busLayouts:u,wires:f},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0&&n.junctions.length===0)return;const s=o+1,i=Yo*s,a=Yo*s,l=new Map;let c=r;for(const f of n.elements){const m=Nt(c,f.kind);l.set(f.id,m),c={...c,elements:[...c.elements,{id:m,kind:f.kind}]}}for(const f of n.buses){const m=Pn(c);l.set(f.id,m),c={...c,buses:[...c.buses??[],{id:m}]}}for(const f of n.junctions){const m=On(c);l.set(f.id,m),c={...c,junctions:[...c.junctions??[],{id:m}]}}const u=f=>{const m=f.indexOf("."),p=m<0?f:f.slice(0,m),h=l.get(p);return h?m<0?h:`${h}${f.slice(m)}`:f};t().dispatch(f=>{const m=n.elements.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w}),p=n.buses.map(k=>{const w=structuredClone(k);w.id=l.get(k.id);const S=n.busLayouts[k.id];return S&&(w.layout={...S,at:[S.at[0]+i,S.at[1]+a]}),w}),h=n.junctions.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w.layout&&(w.layout={at:[w.layout.at[0]+i,w.layout.at[1]+a]}),w}),g={...f.layout??{}};for(const[k,w]of l){const S=n.placements[k];S&&(g[w]={...S,at:[S.at[0]+i,S.at[1]+a]})}const b=n.wires.map(k=>{const w=[u(k.ends[0]),u(k.ends[1])];return{id:Je(w[0],w[1]),ends:w}}),$=Ko(f.wires??[],b);return{...f,elements:[...f.elements,...m],buses:p.length?[...f.buses??[],...p]:f.buses,junctions:h.length?[...f.junctions??[],...h]:f.junctions,wires:$.length?$:void 0,layout:Object.keys(g).length?g:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:u,...f}=c;return f});return{...i,buses:a}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const l={};for(const[c,u]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:u,...f}=c;return f}return c});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const c=n.layout.get(l.id);c&&(s[l.id]=Lt(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,bus:l})}),Object.keys(s).length===0&&i.length===0)return o;let a=o.buses;return i.length>0&&a&&(a=a.map(l=>{const c=n.buses.get(l.id);return!l.layout&&c?{...l,layout:tt(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(c=r.buses)!=null&&c.find(m=>m.id===u&&m.layout)||a.set(u,tt(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=Lt(f))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const m=o.layout.get(u),p=s[u]??(m?Lt(m):{at:[0,0]});s[u]={...p,at:[p.at[0]+f[0],p.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const m=u.layout??tt(o.buses.get(u.id).geometry);return{...u,layout:{...m,at:[m.at[0]+f[0],m.at[1]+f[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(u=>{var p,h;const f=a.get(u.id);if(!f)return u;const m=((p=u.layout)==null?void 0:p.at)??((h=o.junctions.get(u.id))==null?void 0:h.world)??[0,0];return{...u,layout:{at:[m[0]+f[0],m[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(u=>!o.has(u.id)),i=(r.buses??[]).filter(u=>!o.has(u.id)),a=(r.junctions??[]).filter(u=>!o.has(u.id)),l=(r.wires??[]).filter(u=>!o.has(gn(u.ends[0]))&&!o.has(gn(u.ends[1]))),c=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([u])=>!o.has(u))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:a.length?a:void 0,wires:l.length?l:void 0,layout:c&&Object.keys(c).length?c:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const a=i.indexOf(".");a>0&&s.add(i.slice(0,a))}t().dispatch(i=>{const a=(i.wires??[]).filter(c=>c.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const c of s){if(l[c])continue;const u=o.layout.get(c);if(!u)continue;const f={at:u.at};u.rot&&(f.rot=u.rot),u.mirror&&(f.mirror=u.mirror),l[c]=f}return{...i,wires:a.length?a:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const a of r.terminals){const l=a.indexOf(".");l>0&&i.add(a.slice(0,l))}t().dispatch(a=>{const l={...a.layout??{}};for(const u of i){if(l[u])continue;const f=o.layout.get(u);if(!f)continue;const m={at:f.at};f.rot&&(m.rot=f.rot),f.mirror&&(m.mirror=f.mirror),l[u]=m}const c=(a.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...a,wires:c.length?c:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var c,u,f,m;const i={...s.layout??{}},a=new Map;for(const p of o){if(r.junctions.has(p))continue;if(r.buses.has(p)){const b=r.buses.get(p),k=(((((f=(u=(c=s.buses)==null?void 0:c.find(w=>w.id===p))==null?void 0:u.layout)==null?void 0:f.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(p,k);continue}const h=i[p]??{at:((m=r.layout.get(p))==null?void 0:m.at)??[0,0]},g=(((h.rot??0)+n)%360+360)%360;i[p]={...h,rot:g}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??tt(r.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a)||o.junctions.has(a))continue;const l=s[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};s[a]={...l,mirror:!(l.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=Nt(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=Pn(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=On(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=Je(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(a=>a.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(h=>h.id),...(s.buses??[]).map(h=>h.id),...(s.junctions??[]).map(h=>h.id)]),a=()=>{let h=1;for(;i.has(`J${h}`);)h++;const g=`J${h}`;return i.add(g),g},l=h=>{const g=a();return s={...s,junctions:[...s.junctions??[],{id:g,layout:{at:h}}]},g},c=h=>{if("end"in h)return h.end;if("junctionAt"in h)return l(h.junctionAt);const g=(s.wires??[]).find(w=>w.id===h.onWire),b=l(h.at);if(!g)return b;const $=(s.wires??[]).filter(w=>w.id!==h.onWire),k=(w,S)=>({id:Je(w,S),ends:[w,S]});return s={...s,wires:Ko($,[k(g.ends[0],b),k(b,g.ends[1])])},b},u=c(n),f=c(o);if(u===null||f===null||u===f)return s;const m=Je(u,f),p=s.wires??[];return p.some(h=>h.id===m)?s:{...s,wires:[...p,{id:m,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?rs(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:u,...f}=c;return f});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var a;const s=((a=r.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?tt(a.buses.get(n).geometry):{at:[0,0],span:320}),c={at:o.at??l.at,span:o.span??l.span,...o.rot!==void 0?{rot:o.rot}:l.rot?{rot:l.rot}:{}};return{...i,layout:c}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=A$(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const a=s.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...r,annotations:a}:r})},deleteAnnotation:n=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:os(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=Xe(e.diagram))}}));function P$(e){return Array.from(new Set(e))}function gn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function Ko(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 Lt(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function tt(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Qb=null;function Vo(e){Qb=e}function Ze(){return Qb}const Xt=10;function ew(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function de(e){return ew()?Math.round(e/Xt)*Xt:e}const O$=30,B$=144;function tw(e,t){const n=Ke[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=L$(r,t);if(!s){const g=nw(n),b=g?[de(t[0])-g.x,de(t[1])-g.y]:[de(t[0]),de(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=z$(n,l),u=Nt(r,e),f=n.terminals.find(g=>g.id===c),m=l==="x"?t[0]:a[0],p=l==="y"?t[1]:a[1],h=f?[de(m)-f.x,de(p)-f.y]:[de(t[0]),de(t[1])];return o.dispatch(g=>{const b={id:u,kind:e},$={at:h},k=`${u}.${c}`,w={id:Je(i,k),ends:[i,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],w],layout:{...g.layout??{},[u]:$}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function L$(e,t){const n=x.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let c;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,m=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,p=Math.abs(t[1]-a[1]);c=Math.sqrt(m*m+p*p)}else{const u=a[1]-l/2,f=a[1]+l/2,m=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,p=Math.abs(t[0]-a[0]);c=Math.sqrt(p*p+m*m)}c<=O$&&(!o||c<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function z$(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,r)=>t==="x"?o.y-r.y:o.x-r.x)[0].id}function nw(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function ow(e,t){const n=x.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const p=i[0]-a/2,h=i[0]+a/2,g=Math.max(p,Math.min(h,t[0])),b=i[1],$=t[1]>=b?"s":"n";return{ref:e,world:[g,b],orientation:$,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,u=Math.max(l,Math.min(c,t[1])),f=i[0],m=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:m,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const R$={n:"s",s:"n",e:"w",w:"e"};function rw(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=R$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Uo(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],u=Uo(c,n,t.world);u<a&&(a=u,i=c)}return i}function Uo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function D$(e,t,n){const o=Ke[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=ow(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=B$,u=[de(n[0]),de(n[1])],f=rw(o,i,u),m=c?i.world:u,p=[de(m[0]-f.x),de(m[1]-f.y)],h=Nt(s,e);return r.dispatch(g=>{const b={id:h,kind:e},$={at:p},k=`${h}.${f.id}`,w=i.isBus&&i.busId?i.busId:t,S={id:Je(w,k),ends:[w,k]};return{...g,elements:[...g.elements,b],wires:[...g.wires??[],S],layout:{...g.layout??{},[h]:$}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const Zt=9,Yt=7;function Qt(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=F$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function tn(e,t){let n=e.x,o=e.y;switch(t.mirror&&(n=-n),t.rot){case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function F$(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function H$(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=x(r=>r.editingElement);return d.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var u;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??en(r.libraryDef),a=tn(i,s),l=i.anchor??"start";if(o===r.element.id)return d.jsx(W$,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const c=Qt(r,n);return c.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:c.map((f,m)=>d.jsx("text",{x:0,y:m*Zt,textAnchor:l,className:"ole-annotation-text",children:f},m))},r.element.id)})})}const yn=200,xn=9;function W$({elementId:e,currentName:t,world:n,anchor:o}){const r=O.useRef(null);O.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(c)},[e]);function s(){var m;const l=x.getState(),c=l.diagram.elements.find(p=>p.id===e);if(!c){l.setEditingElement(null);return}const u=(((m=r.current)==null?void 0:m.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==c.name&&l.updateElement(e,{name:f}),l.setEditingElement(null)}function i(l){if(l.key==="Escape"||l.key==="Enter"&&!l.shiftKey){l.preventDefault(),s();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=yn/2:o==="end"&&(a-=yn),d.jsx("foreignObject",{x:a,y:n[1]-xn,width:yn,height:xn*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:`${xn}px`,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",display:"inline-block",minWidth:"20px",lineHeight:1.1,textAlign:o==="middle"?"center":o==="end"?"right":"left",whiteSpace:"nowrap",cursor:"text"},children:t})})}const sw=8,Kt=1.25;function q$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?d.jsx(X$,{ann:o},o.id):d.jsx(G$,{ann:o,isSelected:t===o.id},o.id))})}function G$({ann:e,isSelected:t}){const n=e.fontSize??sw,o=e.text===""?[""]:e.text.split(`
198
+ `),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Kt;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*Kt,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function X$({ann:e}){const t=O.useRef(null),n=e.fontSize??sw;O.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)},[e.id]);function o(){var c;const a=x.getState(),l=(((c=t.current)==null?void 0:c.innerText)??"").replace(/\u00a0/g," ").trimEnd();l===""?a.deleteAnnotation(e.id):l!==e.text&&a.updateAnnotation(e.id,{text:l}),a.setEditingAnnotation(null),l!==""&&a.setSelectedAnnotation(e.id),a.activeTool==="text"&&a.setActiveTool("select")}function r(a){if(a.key==="Escape"){a.preventDefault(),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:d.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:Kt,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*Kt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const Y$=20;function K$(){const e=x(u=>u.selection),t=x(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,a=i/2,l=r==="x"?[s[0]-a,s[1]]:[s[0],s[1]-a],c=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(Jo,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(Jo,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function Jo({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=O.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=x.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const m=s.screenToSvg(u.clientX,u.clientY),p=r==="x"?m[0]-f.startSvg[0]:m[1]-f.startSvg[1],h=ew()?Math.round(p/Xt)*Xt:p,g=f.startSpan+(o==="end"?h:-h);if(g<Y$)return;const b=r==="x"?[f.startAt[0]+h/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+h/2];x.getState().updateBus(n,{span:g,at:b})},c=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const Bn=.5;function jt(e,t){return Math.abs(e[1]-t[1])<Bn?"h":"v"}function V$(){const e=x(a=>a.selectedWire),t=x(a=>a.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let a=1;a<r-1;a++){const l=jt(o[a-1],o[a]),c=jt(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,m=u&&l==="v"||f&&c==="v",p=u&&l==="h"||f&&c==="h";m&&p||s.push(d.jsx(U$,{wireId:e,index:a,xLocked:m,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<Bn&&Math.abs(l[1]-c[1])<Bn||i.push(d.jsx(J$,{wireId:e,segIndex:a,axis:jt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function U$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=O.useRef(null),i=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!r))return;const g=x.getState().internal.wireRenders.get(e);g&&(s.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:r.screenToSvg(h.clientX,h.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,h.target.setPointerCapture(h.pointerId))},f=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId||!r)return;const b=r.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.index;if(k<=0||k>=$.length-1)return;const w=$[k],S=[g.xLocked?w[0]:de(w[0]+(b[0]-g.startSvg[0])),g.yLocked?w[1]:de(w[1]+(b[1]-g.startSvg[1]))];if(S[0]===w[0]&&S[1]===w[1])return;const C=$.map(V=>[V[0],V[1]]);C[k]=S;const R=jt($[k-1],$[k]);k-1>0&&(R==="h"?C[k-1]=[$[k-1][0],S[1]]:C[k-1]=[S[0],$[k-1][1]]);const X=jt($[k],$[k+1]);k+1<$.length-1&&(X==="h"?C[k+1]=[$[k+1][0],S[1]]:C[k+1]=[S[0],$[k+1][1]]),x.getState().updateWirePath(e,C)},m=h=>{const g=s.current;!g||h.pointerId!==g.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),s.current=null,document.body.style.cursor="")},p=h=>{h.stopPropagation(),h.preventDefault();const g=x.getState().internal.wireRenders.get(e);if(!g||g.path.length<=2||t<=0||t>=g.path.length-1)return;const b=g.path.filter(($,k)=>k!==t);x.getState().updateWirePath(e,b)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:u,onPointerMove:f,onPointerUp:m,onPointerCancel:m,onDoubleClick:p})}function J$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=O.useRef(null),s=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,c=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!o))return;const g=x.getState().internal.wireRenders.get(e);g&&(r.current={pointerId:h.pointerId,startPath:g.path.map(b=>[b[0],b[1]]),startSvg:o.screenToSvg(h.clientX,h.clientY),axis:n,segIndex:t},document.body.style.cursor=u,h.currentTarget.setPointerCapture(h.pointerId))},m=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId||!o)return;const b=o.screenToSvg(h.clientX,h.clientY),$=g.startPath,k=g.segIndex;if(k>=$.length-1)return;const w=$[k],S=$[k+1],C=[];for(let R=0;R<=k;R++)C.push($[R]);if(g.axis==="h"){const R=de(w[1]+(b[1]-g.startSvg[1]));C.push([w[0],R]),C.push([S[0],R])}else{const R=de(w[0]+(b[0]-g.startSvg[0]));C.push([R,w[1]]),C.push([R,S[1]])}for(let R=k+1;R<$.length;R++)C.push($[R]);x.getState().updateWirePath(e,C)},p=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId)return;const b=h.currentTarget;b.hasPointerCapture(h.pointerId)&&b.releasePointerCapture(h.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:m,onPointerUp:p,onPointerCancel:p,children:[d.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:c,r:8}),d.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:c,r:3.5})]})}const Z$=3,bn=12;function Q$(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)!l.includes(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:u,span:f}=l,m=f/2,p=c==="x"?u[0]-m:u[0],h=c==="x"?u[1]:u[1]-m,g=c==="x"?u[0]+m:u[0],b=c==="x"?u[1]:u[1]+m,$=s.has(a.id),k=i.has(a.id),w=r.get(a.id)??void 0,S=bn/2,C=c==="x"?u[0]-m:u[0]-S,R=c==="x"?u[1]-S:u[1]-m,X=c==="x"?f:bn,V=c==="x"?bn:f;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":w,"data-selected":$?"true":void 0,"data-node-related":k?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:C,y:R,width:X,height:V,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:p,y1:h,x2:g,y2:b,stroke:"currentColor",strokeWidth:Z$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function eS(){const e=x(a=>a.busbarDrawStart),t=x(a=>a.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return d.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[d.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),d.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),d.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const tS=4,nS=9;function oS(){const e=x(a=>a.internal.junctions),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)i.add(l)}return d.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l})=>{const c=r.get(a.id)??void 0;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":c,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[d.jsx("circle",{cx:l[0],cy:l[1],r:nS,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:tS,className:"ole-junction-dot"})]},a.id)})})}function Ye(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function rS(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 sS({lib:e}){const t=rS(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 iS(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),r=x(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const c=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element",children:[d.jsx(sS,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:Ye(l),className:"ole-element ole-element--unknown",children:[d.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),d.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let iw=null;const Ln=new Set;function zt(e){iw=e;for(const t of Ln)t(e)}function aS(){return iw}function lS(e){return Ln.add(e),()=>{Ln.delete(e)}}function cS(){const[e,t]=O.useState(aS());return O.useEffect(()=>lS(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 dS(){const e=x(c=>c.activeTool),t=x(c=>c.placeKind),n=x(c=>c.cursorSvg),o=x(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Zb(t);if(!r)return null;let s=null,i=null;if(o){const c=ow(o,n);c&&(s=rw(r,c,n),i={source:c.world,pin:n})}else s=nw(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return d.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),d.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),d.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:d.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function uS(){const e=x(r=>r.selection),t=x(r=>r.internal.elements),n=x(r=>r.internal.layout),o=x(r=>r.internal.buses);return e.length===0?null:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:u,span:f}=s.geometry,m=f/2,p=c==="x"?u[0]-m:u[0]-4,h=c==="x"?u[1]-4:u[1]-m,g=c==="x"?f:8,b=c==="x"?8:f;return d.jsx("rect",{x:p,y:h,width:g,height:b,fill:"none",className:"ole-selection-rect"},r)}const i=t.get(r),a=n.get(r);if(!(i!=null&&i.libraryDef)||!a)return null;const l=fS(i.libraryDef.viewBox);return l?d.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ye(a)},r):null})})}function fS(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function mS(){const e=x(s=>s.internal.terminals),t=x(s=>s.internal.terminalToNode),n=x(s=>s.wireFromTerminal),o=x(s=>s.selection),r=new Set(o);return d.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),a=i!==void 0,l=n===s.ref,c=r.has(s.elementId);return d.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":a?"true":"false","data-active":l?"true":void 0,"data-on-selected":c?"true":void 0,className:"ole-terminal"},s.ref)})})}const Zo=4;function hS(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 pS(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],u=Math.hypot(l,c)||1,f=l/u,m=c/u,p=g=>(g[0]-s[0])*f+(g[1]-s[1])*m,h=a.slice().sort((g,b)=>p(g)-p(b));for(const g of h){const b=p(g),$=Math.max(0,b-Zo),k=Math.min(u,b+Zo);o.push([s[0]+f*$,s[1]+m*$]),n.push(o),o=[[s[0]+f*k,s[1]+m*k]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function gS(){const e=x(c=>c.internal.wireRenders),t=x(c=>c.internal.terminalToNode),n=x(c=>c.diagram.wires),o=x(c=>c.selectedWire),r=x(c=>c.selectedNode),s=new Map;for(const c of n??[]){const u=t.get(c.ends[0]);u&&s.set(c.id,u)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const u=s.get(c.wireId);for(let f=0;f<c.path.length-1;f++)a.push({wireId:c.wireId,node:u,i:f,a:c.path[f],b:c.path[f+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const f=a[c],m=a[u];if(f.wireId===m.wireId||!(f.node&&m.node&&f.node!==m.node))continue;const p=hS(f.a,f.b,m.a,m.b);if(!p)continue;const h=f.wireId<m.wireId?f:m;let g=l.get(h.wireId);g||(g=new Map,l.set(h.wireId,g));const b=g.get(h.i)??[];b.push(p),g.set(h.i,b)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const u=c.path,f=u.map(k=>`${k[0]},${k[1]}`).join(" "),m=s.get(c.wireId),p=o===c.wireId,h=r!=null&&r===m,g=p||h?"true":void 0,b=l.get(c.wireId),$=b?pS(u,b):[u];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,className:"ole-wire-hit",points:f},`hit-${c.wireId}`),...$.map((k,w)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,"data-manual":c.userEdited?"true":void 0,"data-selected":g,className:"ole-wire",points:k.map(S=>`${S[0]},${S[1]}`).join(" ")},`${c.wireId}-${w}`))]})})}let Ue=null;const zn=new Set;function Re(e){if(!(e===null&&Ue===null||e&&Ue&&e.ref===Ue.ref&&e.world[0]===Ue.world[0]&&e.world[1]===Ue.world[1])){Ue=e;for(const t of zn)t(e)}}function yS(){return Ue}function xS(e){return zn.add(e),()=>{zn.delete(e)}}function bS(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=O.useState(yS());if(O.useEffect(()=>xS(o),[]),!e||!t)return null;const r=e.world,s=(n==null?void 0:n.world[0])??t[0],i=(n==null?void 0:n.world[1])??t[1],a=(n==null?void 0:n.create)==="junction";return d.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[d.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?7:8,className:"ole-wire-preview-target-ring","data-create":a?"true":void 0}),!a&&d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function Qe(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function lt(e){var t;return((t=Qe(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function wS(e){var t;return((t=Qe(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function vS(e){var t;return((t=Qe(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function it(e){var r;const t=(r=Qe(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=vS(e);if(n)return n;const o=wS(e);return o||null}function nn(e){var t;return((t=Qe(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Rn(e){var t;return((t=Qe(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Vt(e){var t;return((t=Qe(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function aw(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function kS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function lw(){const e=x.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function _S(){O.useEffect(()=>{const e=t=>{if(kS(t.target))return;const n=t.metaKey||t.ctrlKey,o=x.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=x.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"j":case"J":o.setActiveTool("junction");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":lw();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Dn=null;const Fn=new Set;function $S(e){if(e!==Dn){Dn=e;for(const t of Fn)t(e)}}function SS(){return Dn}function jS(e){return Fn.add(e),()=>{Fn.delete(e)}}const Qo="ole-hover-element-host",ES="ole-hover-terminal-on",NS="ole-hover-node-on";function MS(e){O.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,m,p)=>{for(const h of f)h.classList.remove(p);f.clear();for(const h of m)h.classList.add(p),f.add(h)},a=f=>{var p,h;if(f===n)return;n&&((p=t.querySelector(`[data-element-id="${Rt(n)}"]`))==null||p.classList.remove(Qo)),f&&((h=t.querySelector(`[data-element-id="${Rt(f)}"]`))==null||h.classList.add(Qo));const m=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Rt(f)}"]`)):[];i(r,m,ES),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),$S(f)},l=f=>{if(f===o)return;const m=f?Array.from(t.querySelectorAll(`[data-node-id="${Rt(f)}"]`)):[];i(s,m,NS),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=f=>{a(lt(f.target));const m=it(f.target);let p=null;m?p=x.getState().internal.terminalToNode.get(m)??null:p=nn(f.target),l(p)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function Rt(e){return e.replace(/(["\\])/g,"\\$1")}function cw(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const m=a[0]-l/2,p=a[0]+l/2,h=Math.max(m,Math.min(p,t[0]));return{ref:e,world:[h,a[1]],isBus:!0}}const c=a[1]-l/2,u=a[1]+l/2,f=Math.max(c,Math.min(u,t[1]));return{ref:e,world:[a[0],f],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const er=3;let ce=null,Ne=null,Me=null,he=null;const TS={id:"select",cursor:"default",onPointerDown(e,t){var p,h,g,b,$,k,w;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Vt(e.target);if(o){e.preventDefault(),e.stopPropagation();const S=(p=n.diagram.annotations)==null?void 0:p.find(C=>C.id===o);if(!S)return;n.setSelectedAnnotation(o),he={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[S.at[0],S.at[1]],moved:!1};return}const s=(e.target instanceof Element?(h=e.target.closest("[data-terminal-id]"))==null?void 0:h.getAttribute("data-terminal-id"):null)?it(e.target):null;if(s){const S=s.indexOf("."),C=S>0?s.slice(0,S):"";if(C&&n.selection.includes(C)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((b=(g=e.target).hasPointerCapture)!=null&&b.call(g,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Me={pointerId:e.pointerId,fromRef:s};return}}let i=lt(e.target);if(!i){const S=Rn(e.target);if(S&&typeof document<"u"){const C=document.elementsFromPoint(e.clientX,e.clientY);for(const R of C){const X=(k=($=R.closest)==null?void 0:$.call(R,"[data-bus-id]"))==null?void 0:k.getAttribute("data-bus-id");if(!X)continue;const V=(w=n.diagram.wires)==null?void 0:w.find(te=>te.id===S);V&&(V.ends[0]===X||V.ends[1]===X)&&(i=X);break}}}if(!i){const S=Rn(e.target);if(S){if(e.preventDefault(),e.altKey){const C=nn(e.target);if(C){n.setSelectedNode(C);return}}n.setSelectedWire(S);return}e.shiftKey||n.clearSelection(),Ne={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const a=n.selection;e.shiftKey?n.toggleInSelection(i):a.includes(i)||n.setSelection([i]);const l=e.shiftKey?x.getState().selection:a.includes(i)?a:[i];if(l.length===0)return;const c=x.getState().internal,u=new Map,f=new Map,m=new Map;for(const S of l){const C=c.buses.get(S);if(C){f.set(S,[C.geometry.at[0],C.geometry.at[1]]);continue}const R=c.junctions.get(S);if(R){m.set(S,[R.world[0],R.world[1]]);continue}const X=c.layout.get(S);X&&u.set(S,{...X})}u.size===0&&f.size===0&&m.size===0||(ce={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:f,junctionOriginals:m,moved:!1},e.preventDefault())},onPointerMove(e,t){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));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Me&&e.pointerId===Me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?it(o):null;if(!r||r===Me.fromRef){Re(null);return}Re(cw(r,n));return}if(ce&&e.pointerId===ce.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.startSvg[0]),r=de(n[1]-ce.startSvg[1]);!ce.moved&&(o!==0||r!==0)&&(ce.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of ce.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ye(l))}for(const s of ce.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of ce.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Ne&&e.pointerId===Ne.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);zt(tr(Ne.startSvg,n));return}},onPointerUp(e,t){if(he&&e.pointerId===he.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-he.startSvg[0]),r=de(n[1]-he.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);s&&s.removeAttribute("transform"),he.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(he.id,{at:[he.origin[0]+o,he.origin[1]+r]}),he=null;return}if(Me&&e.pointerId===Me.pointerId){const n=x.getState(),o=Me.fromRef;Me=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Re(null);const r=it(e.target);r&&r!==o&&n.addWire(o,r);return}if(ce&&e.pointerId===ce.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),ce.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.startSvg[0]),r=de(n[1]-ce.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ce.originals.keys())s.set(i,[o,r]);for(const i of ce.busOriginals.keys())s.set(i,[o,r]);for(const i of ce.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of ce.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}for(const s of ce.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.removeAttribute("transform")}}ce=null;return}if(Ne&&e.pointerId===Ne.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=tr(Ne.startSvg,n);if(o.w>=er||o.h>=er){const r=AS(o);if(Ne.shiftKey){const s=new Set(Ne.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}zt(null),Ne=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(he&&e.pointerId===he.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(he.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}he=null}if(ce&&e.pointerId===ce.pointerId){for(const[l,c]of ce.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",Ye(c))}for(const l of ce.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of ce.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{}ce=null}if(Me&&e.pointerId===Me.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setCursorSvg(null),Re(null),Me=null}if(Ne&&e.pointerId===Ne.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}zt(null),Ne=null}},onDoubleClick(e){const t=x.getState(),n=Vt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=lt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(ce=null,Ne=null,he=null,Me){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Re(null),Me=null}zt(null)}};function tr(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 AS(e){const{internal:t}=x.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=IS(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([f,m])=>CS([f,m],r));let a=1/0,l=-1/0,c=1/0,u=-1/0;for(const[f,m]of i)f<a&&(a=f),f>l&&(l=f),m<c&&(c=m),m>u&&(u=m);l>=e.x&&a<=e.x+e.w&&u>=e.y&&c<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,m=s==="x"?i[1]:i[1]+l;u>=e.x&&c<=e.x+e.w&&m>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function CS(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 IS(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 PS=4;let se=null;const OS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=lt(e.target);let r=null;if(o){const s=x.getState();s.selection.includes(o)||s.setSelection([o]);const i=x.getState().selection,a=x.getState().internal,l=new Map,c=new Map;for(const u of i){const f=a.buses.get(u);if(f){c.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const m=a.layout.get(u);m&&l.set(u,{...m})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}se={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(!se||e.pointerId!==se.pointerId)return;const n=e.clientX-se.startX,o=e.clientY-se.startY;if(!se.moved&&Math.hypot(n,o)>PS){se.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(se.moved){if(se.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=de(r[0]-se.elementDrag.startSvg[0]),i=de(r[1]-se.elementDrag.startSvg[1]);for(const[a,l]of se.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);if(!c)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",Ye(u))}for(const a of se.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${vt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:se.startTx+n,ty:se.startTy+o})}},onPointerUp(e,t){if(!(!se||e.pointerId!==se.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",se.elementDrag&&se.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-se.elementDrag.startSvg[0]),r=de(n[1]-se.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of se.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of se.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of se.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${vt(s)}"]`);i&&i.removeAttribute("transform")}}else se.moved||BS(se.startTarget);se=null}},onPointerCancel(e,t){if(se!=null&&se.elementDrag){for(const[n,o]of se.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);r&&r.setAttribute("transform",Ye(o))}for(const n of se.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${vt(n)}"]`);o&&o.removeAttribute("transform")}}se=null},onDeactivate(){se=null}};function BS(e){if(!e)return;const t=x.getState(),n=Vt(e);if(n){t.setSelectedAnnotation(n);return}const o=lt(e);if(o){t.setSelection([o]);return}const r=nn(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function vt(e){return e.replace(/(["\\])/g,"\\$1")}const _t={tight:1024,compact:720,dense:520,mini:380},nr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return nr[e]>=nr[t]}function LS(e){return e>=_t.tight?"full":e>=_t.compact?"tight":e>=_t.dense?"compact":e>=_t.mini?"dense":"mini"}const dw=O.createContext("full");function Ve(){return O.useContext(dw)}function zS(e){const[t,n]=O.useState(null);return O.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function uw(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<_t.dense}function on(){uw()&&x.getState().setActiveTool("pan")}function RS(){uw()&&x.getState().setPlaceKind(null)}const or=10,Dt=e=>Math.round(e/or)*or,DS=16;function fw(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,u=l-i,f=c*c+u*u,m=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*u)/f)),p=s+m*c,h=i+m*u,g=(p-t[0])**2+(h-t[1])**2;g<o&&(o=g,n=[p,h])}return n}function rr(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function FS(e,t){const n=x.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=fw(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 wn(e,t,n){const o=e?it(e):null;if(o){const a=cw(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?Rn(e):null,s=null;if(r){const a=x.getState().internal.wireRenders.get(r);s=a?fw(a.path,t):t}else{const a=FS(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[Dt(s[0]),Dt(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[Dt(t[0]),Dt(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function vn(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+DS,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function HS(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function sr(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 WS={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),Re(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=vn(t,e.clientX,e.clientY),r=wn(e.target instanceof Element?e.target:null,n,o),s=x.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=rr(e.clientX,e.clientY),i=wn(s,r,vn(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Re(sr(a,i)?null:HS(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Re(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=rr(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=wn(s,r,vn(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};sr(a,i)||(n.connectWire(o.spec,i.spec),on())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Re(null)}},ir=10;let kt=!1;function ar(){setTimeout(()=>RS(),0)}const qS={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=x.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),kt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=it(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const a=x.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);tw(n,r),kt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([lr(n[0]),lr(n[1])])},onPointerUp(e,t){const n=x.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);D$(r,o,s),ar();return}kt&&(kt=!1,ar())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),kt=!1}};function lr(e){return Math.round(e/ir)*ir}const cr=10,dr=20;function nt(e){return Math.round(e/cr)*cr}const GS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[nt(n[0]),nt(n[1])];x.getState().setBusbarDrawStart(o),x.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([nt(n[0]),nt(n[1])])},onPointerUp(e,t){const n=x.getState().busbarDrawStart;if(x.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=nt(o[0]),s=nt(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,u,f;if(l){if(u=Math.abs(i),u<dr)return;c=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<dr)return;c=90,f=[n[0],(n[1]+s)/2]}x.getState().addBus(f,u,c),on()},onPointerLeave(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},ur=10,fr=e=>Math.round(e/ur)*ur,XS={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().addJunction([fr(n[0]),fr(n[1])]),on()}},YS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Vt(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),on()}},KS={select:TS,pan:OS,wire:WS,place:qS,busbar:GS,junction:XS,text:YS};function VS(e,t){const n=x(o=>o.activeTool);O.useEffect(()=>{var m;const o=e.current;if(!o)return;const r=KS[n],s={viewport:t,hostEl:o};(m=r.onActivate)==null||m.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=p=>{var h;return(h=r.onPointerDown)==null?void 0:h.call(r,p,s)},a=p=>{var h;return(h=r.onPointerMove)==null?void 0:h.call(r,p,s)},l=p=>{var h;return(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},c=p=>{var h;return r.onPointerCancel?r.onPointerCancel(p,s):(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},u=p=>{var h;return(h=r.onPointerLeave)==null?void 0:h.call(r,p,s)},f=p=>{var h;return(h=r.onDoubleClick)==null?void 0:h.call(r,p,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",c),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",f),()=>{var p;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",c),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",f),(p=r.onDeactivate)==null||p.call(r,s),o.style.cursor=""}},[n,e,t])}let Hn=1;const Wn=new Set;function US(e){if(e!==Hn){Hn=e;for(const t of Wn)t(e)}}function JS(){return Hn}function ZS(e){return Wn.add(e),()=>{Wn.delete(e)}}const kn=.1,_n=8,QS=1.0015,e4=1.02;function t4(e,t,n={tx:0,ty:0,scale:1}){const o=O.useRef({...n}),r=O.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),US(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return O.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,u=0,f=0,m=0,p=!1;const h=new Map;let g=null,b=!1;const $=()=>{if(h.size<2){g=null;return}const D=[...h.values()],W=D[1].x-D[0].x,ye=D[1].y-D[0].y,ue=Math.hypot(W,ye)||1,pe=i.getBoundingClientRect();g={startDist:ue,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(D[0].x+D[1].x)/2-pe.left,startMidY:(D[0].y+D[1].y)/2-pe.top}},k=D=>{if(D.pointerType==="touch"){if(h.set(D.pointerId,{x:D.clientX,y:D.clientY}),h.size>=2&&!b){b=!0;for(const W of h.keys())W!==D.pointerId&&aw(i,W);$()}if(b){D.stopPropagation(),D.preventDefault();try{i.setPointerCapture(D.pointerId)}catch{}}}},w=D=>{if(D.pointerType!=="touch"||!h.has(D.pointerId)||(h.set(D.pointerId,{x:D.clientX,y:D.clientY}),!b||!g))return;D.stopPropagation();const W=[...h.values()];if(W.length<2)return;const ye=W[1].x-W[0].x,ue=W[1].y-W[0].y,pe=Math.hypot(ye,ue)||1,ne=i.getBoundingClientRect(),re=(W[0].x+W[1].x)/2-ne.left,ge=(W[0].y+W[1].y)/2-ne.top,xe=pe/g.startDist,_e=$n(g.startScale*xe,kn,_n),Ee=_e/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*Ee+(re-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*Ee+(ge-g.startMidY),o.current.scale=_e,s()},S=D=>{var W;if(D.pointerType==="touch"&&h.has(D.pointerId)&&(h.delete(D.pointerId),b)){if(D.stopPropagation(),(W=i.hasPointerCapture)!=null&&W.call(i,D.pointerId))try{i.releasePointerCapture(D.pointerId)}catch{}h.size>=2?$():g=null,h.size===0&&(b=!1)}},C=D=>{D.preventDefault();const W=i.getBoundingClientRect(),ye=D.clientX-W.left,ue=D.clientY-W.top,pe=D.ctrlKey||D.metaKey;if(D.deltaX===0||pe){const ge=Math.pow(pe?e4:QS,-D.deltaY),xe=$n(o.current.scale*ge,kn,_n),_e=xe/o.current.scale;o.current.tx=ye-(ye-o.current.tx)*_e,o.current.ty=ue-(ue-o.current.ty)*_e,o.current.scale=xe}else o.current.tx-=D.deltaX,o.current.ty-=D.deltaY;s()},R=D=>{const W=D.button===1,ye=p&&D.button===0;!W&&!ye||(D.preventDefault(),a=!0,l=D.pointerId,c=D.clientX,u=D.clientY,f=o.current.tx,m=o.current.ty,i.setPointerCapture(D.pointerId),i.style.cursor="grabbing")},X=D=>{!a||D.pointerId!==l||(o.current.tx=f+(D.clientX-c),o.current.ty=m+(D.clientY-u),s())},V=D=>{a&&D.pointerId===l&&(a=!1,i.releasePointerCapture(D.pointerId),i.style.cursor=p?"grab":"")},te=D=>{if(D.code==="Space"&&!p){const W=D.target;if(W&&(W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable))return;p=!0,i.style.cursor="grab",D.preventDefault()}},ae=D=>{D.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",C,{passive:!1}),i.addEventListener("pointerdown",R),i.addEventListener("pointermove",X),i.addEventListener("pointerup",V),i.addEventListener("pointercancel",V),i.addEventListener("pointerdown",k,{capture:!0}),i.addEventListener("pointermove",w,{capture:!0}),i.addEventListener("pointerup",S,{capture:!0}),i.addEventListener("pointercancel",S,{capture:!0}),window.addEventListener("keydown",te),window.addEventListener("keyup",ae),s(),()=>{i.removeEventListener("wheel",C),i.removeEventListener("pointerdown",R),i.removeEventListener("pointermove",X),i.removeEventListener("pointerup",V),i.removeEventListener("pointercancel",V),i.removeEventListener("pointerdown",k,{capture:!0}),i.removeEventListener("pointermove",w,{capture:!0}),i.removeEventListener("pointerup",S,{capture:!0}),i.removeEventListener("pointercancel",S,{capture:!0}),window.removeEventListener("keydown",te),window.removeEventListener("keyup",ae)}},[]),{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=$n(i.scale,kn,_n)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function $n(e,t,n){return e<t?t:e>n?n:e}const mw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ot=mw?"⌘":"Ctrl+",n4=mw?"⇧":"Shift+",Sn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],o4=18;function r4(e){for(const t of Sn)if(t*e>=o4)return t;return Sn[Sn.length-1]}function s4(){const e=ie(),t=O.useRef(null),n=O.useRef(null),o=O.useRef(null),r=t4(t,n);VS(t,r),MS(t),O.useEffect(()=>(Vo(r),()=>Vo(null)),[r]),O.useEffect(()=>{const u=f=>{const m=o.current;if(!m)return;const h=r4(f.scale)*f.scale;m.setAttribute("width",String(h)),m.setAttribute("height",String(h)),m.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Uv(),i=O.useCallback((u,f,m)=>{const p=x.getState(),h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){lw();return}const g=lt(m);if(g)p.selection.includes(g)||p.setSelection([g]);else{const R=nn(m);R&&p.selectedNode!==R&&p.setSelectedNode(R)}const b=x.getState(),$=b.selection.length>0,k=b.selectedNode!=null,w=!!b.clipboard,S=b.diagram.elements.length>0,C=[{label:e("menu.undo"),shortcut:`${ot}Z`,icon:Kn,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${ot}${n4}Z`,icon:Yn,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ot}X`,icon:Hr,onSelect:()=>x.getState().cutSelection(),disabled:!$},{label:e("menu.copy"),shortcut:`${ot}C`,icon:zr,onSelect:()=>x.getState().copySelection(),disabled:!$},{label:e("menu.paste"),shortcut:`${ot}V`,icon:Lr,onSelect:()=>x.getState().pasteClipboard(),disabled:!w},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Fr,onSelect:()=>x.getState().rotateSelection(90),disabled:!$},{label:e("menu.mirror"),shortcut:"M",icon:Rr,onSelect:()=>x.getState().mirrorSelection(),disabled:!$},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ot}A`,icon:yv,onSelect:()=>{const R=x.getState();R.setSelection(R.diagram.elements.map(X=>X.id))},disabled:!S},{type:"separator"},{label:e(k&&!$?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:qr,destructive:!0,onSelect:()=>k&&!$?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!$&&!k}];s.open(u,f,C)},[s,e]);O.useEffect(()=>{const u=t.current;if(!u)return;const f=700,m=4;let p,h=null;const g=()=>{p!==void 0&&window.clearTimeout(p),p=void 0,h=null},b=w=>{w.pointerType==="touch"&&(g(),h={pointerId:w.pointerId,x:w.clientX,y:w.clientY,target:w.target},p=window.setTimeout(()=>{const S=h;h=null,p=void 0,S&&(aw(u,S.pointerId),i(S.x,S.y,S.target))},f))},$=w=>{if(!h||w.pointerId!==h.pointerId)return;const S=w.clientX-h.x,C=w.clientY-h.y;Math.hypot(S,C)>m&&g()},k=w=>{!h||w.pointerId!==h.pointerId||g()};return u.addEventListener("pointerdown",b),u.addEventListener("pointermove",$),u.addEventListener("pointerup",k),u.addEventListener("pointercancel",k),()=>{g(),u.removeEventListener("pointerdown",b),u.removeEventListener("pointermove",$),u.removeEventListener("pointerup",k),u.removeEventListener("pointercancel",k)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const m=r.screenToSvg(u.clientX,u.clientY);tw(f,m)},c=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(Q$,{}),d.jsx(gS,{}),d.jsx(oS,{}),d.jsx(iS,{}),d.jsx(H$,{}),d.jsx(q$,{}),d.jsx(uS,{}),d.jsx(K$,{}),d.jsx(V$,{}),d.jsx(mS,{}),d.jsx(bS,{}),d.jsx(eS,{}),d.jsx(dS,{}),d.jsx(cS,{})]})]})})}const mr=60,i4=.1,a4=8,l4=8;function c4(e,t,n){return e<t?t:e>n?n:e}function d4(){return document.querySelector(".ole-canvas-root")}function Zn(){const e=Ze(),t=d4();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,a=-1/0;for(const $ of o){const k=$.getBoundingClientRect();k.width===0&&k.height===0||(k.left<r&&(r=k.left),k.top<s&&(s=k.top),k.right>i&&(i=k.right),k.bottom>a&&(a=k.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[u,f]=e.screenToSvg(i,a),m=Math.max(u-l,1),p=Math.max(f-c,1),h=c4(Math.min((n.width-mr*2)/m,(n.height-mr*2)/p),i4,a4),g=(l+u)/2,b=(c+f)/2;return e.setViewport({tx:n.width/2-h*g,ty:n.height/2-h*b,scale:h}),!0}function Qn(){let e=l4;const t=()=>{Zn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const hr=10,u4=100;function f4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function m4(){const[e,t]=O.useState(SS()),[n,o]=O.useState(!1),[r,s]=O.useState(null),i=O.useRef(null),a=O.useRef(void 0),[l]=O.useState(f4);O.useEffect(()=>jS(h=>t(h)),[]),O.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),u4),()=>window.clearTimeout(a.current)},[e]);const c=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(O.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,b=-1;const $=()=>{const k=document.querySelector(`[data-element-id="${h4(e)}"]`),w=i.current;if(k&&w){const S=k.getBoundingClientRect();let C=S.bottom+hr;C+w.offsetHeight>window.innerHeight-4&&(C=S.top-w.offsetHeight-hr);let R=S.left+S.width/2-w.offsetWidth/2;R=Math.max(4,Math.min(R,window.innerWidth-w.offsetWidth-4)),(C!==g||R!==b)&&(s({top:C,left:R}),g=C,b=R)}h=requestAnimationFrame($)};return h=requestAnimationFrame($),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!c)return null;const u=Ke[c.kind],f=c.name??c.id,m=(u==null?void 0:u.name)??c.kind,p=c.name&&c.name!==c.id;return typeof document>"u"?null:Pr.createPortal(d.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[d.jsx("span",{className:"font-medium text-foreground",children:f}),p&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id}),d.jsx("span",{className:"text-muted-foreground/80",children:"·"}),d.jsx("span",{className:"text-muted-foreground",children:m})]}),document.body)}function h4(e){return e.replace(/(["\\])/g,"\\$1")}function p4({width:e,children:t}){const n=e==null?"full":LS(e);return d.jsx(dw.Provider,{value:n,children:t})}function pr(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function g4(...e){return t=>{let n=!1;const o=e.map(r=>{const s=pr(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<o.length;r++){const s=o[r];typeof s=="function"?s():pr(e[r],null)}}}}var y4=Symbol.for("react.lazy"),Ut=ke[" use ".trim().toString()];function x4(e){return typeof e=="object"&&e!==null&&"then"in e}function hw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===y4&&"_payload"in e&&x4(e._payload)}function b4(e){const t=v4(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;hw(s)&&typeof Ut=="function"&&(s=Ut(s._payload));const a=ke.Children.toArray(s),l=a.find(_4);if(l){const c=l.props.children,u=a.map(f=>f===l?ke.Children.count(c)>1?ke.Children.only(null):ke.isValidElement(c)?c.props.children:null:f);return d.jsx(t,{...i,ref:r,children:ke.isValidElement(c)?ke.cloneElement(c,void 0,u):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var w4=b4("Slot");function v4(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(hw(r)&&typeof Ut=="function"&&(r=Ut(r._payload)),ke.isValidElement(r)){const i=S4(r),a=$4(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?g4(o,i):i),ke.cloneElement(r,a)}return ke.Children.count(r)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var k4=Symbol("radix.slottable");function _4(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===k4}function $4(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 S4(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const gr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,yr=Yr,j4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return yr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const u=n==null?void 0:n[c],f=s==null?void 0:s[c];if(u===null)return null;const m=gr(u)||gr(f);return r[c][m]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,m]=u;return m===void 0||(c[f]=m),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:m,...p}=u;return Object.entries(p).every(h=>{let[g,b]=h;return Array.isArray(b)?b.includes({...s,...a}[g]):{...s,...a}[g]===b})?[...c,f,m]:c},[]);return yr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},E4=j4("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ae=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?w4:"button";return d.jsx(i,{className:je(E4({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const N4=350;function Ce({content:e,children:t,disabled:n,delayMs:o=N4}){const r=O.useRef(null),s=O.useRef(null),[i,a]=O.useState(!1),[l,c]=O.useState(null),u=O.useId(),f=O.useRef(void 0),m=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(f.current),a(!1)};O.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const $=r.current.getBoundingClientRect(),k=s.current.getBoundingClientRect(),w=8;let S="top",C=$.top-k.height-w;C<4&&(S="bottom",C=$.bottom+w);let R=$.left+$.width/2-k.width/2;R=Math.max(4,Math.min(R,window.innerWidth-k.width-4)),c({top:C,left:R,side:S})},[i,e]),O.useEffect(()=>()=>window.clearTimeout(f.current),[]),O.useEffect(()=>{if(!i)return;const $=w=>{w.key==="Escape"&&a(!1)},k=()=>a(!1);return window.addEventListener("keydown",$),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("keydown",$),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i]);const h=t,g=h.props,b=O.cloneElement(h,{ref:$=>{r.current=$;const k=h.ref;typeof k=="function"?k($):k&&typeof k=="object"&&(k.current=$)},onPointerEnter:$=>{var k;(k=g.onPointerEnter)==null||k.call(g,$),m()},onPointerLeave:$=>{var k;(k=g.onPointerLeave)==null||k.call(g,$),p()},onFocus:$=>{var k;(k=g.onFocus)==null||k.call(g,$),m()},onBlur:$=>{var k;(k=g.onBlur)==null||k.call(g,$),p()},"aria-describedby":i?u:g["aria-describedby"]});return d.jsxs(d.Fragment,{children:[b,i&&typeof document<"u"&&Pr.createPortal(d.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const xr=12,M4=56;function T4(){var $;const e=ie(),t=x(k=>k.selection),n=x(k=>k.selectedNode),o=x(k=>k.selectedWire),r=x(k=>k.activeTool),s=x(k=>k.rotateSelection),i=x(k=>k.mirrorSelection),a=x(k=>k.deleteSelection),l=x(k=>k.deleteSelectedNode),c=x(k=>k.deleteSelectedWire),u=x(k=>k.resetWirePath),f=x(k=>k.internal.wireRenders),m=o!=null&&(($=f.get(o))==null?void 0:$.userEdited)===!0,p=O.useRef(null);O.useEffect(()=>{const k=p.current;if(!k)return;const w=t.length>0,S=!w&&o!=null,C=!w&&!S&&n!=null;if(!((w||S||C)&&(r==="select"||r==="pan"))){k.style.display="none";return}k.style.display="flex";let X=0,V="";const te=()=>{let ae=1/0,D=-1/0,W=1/0,ye=-1/0,ue=!1;const pe=ne=>{ne.width===0&&ne.height===0||(ne.left<ae&&(ae=ne.left),ne.right>D&&(D=ne.right),ne.top<W&&(W=ne.top),ne.bottom>ye&&(ye=ne.bottom),ue=!0)};if(w)for(const ne of t){const re=document.querySelector(`[data-element-id="${CSS.escape(ne)}"]`);re&&pe(re.getBoundingClientRect())}else if(S&&o){const ne=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ne&&pe(ne.getBoundingClientRect())}else if(C&&n){const ne=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const re of ne)pe(re.getBoundingClientRect())}if(ue){const ne=(ae+D)/2;let re=W-xr,ge="-100%";re<M4&&(re=ye+xr,ge="0%");const xe=`translate3d(${ne}px, ${re}px, 0) translate(-50%, ${ge})`;xe!==V&&(k.style.transform=xe,V=xe)}X=requestAnimationFrame(te)};return X=requestAnimationFrame(te),()=>cancelAnimationFrame(X)},[t,n,o,r]);const h=t.length===0&&o!=null,g=t.length===0&&!h&&n!=null,b=g||h;return d.jsxs("div",{ref:p,role:"toolbar","aria-label":e(h?"ctx.ariaWire":g?"ctx.ariaNode":"ctx.ariaElement"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-30 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[h&&m&&o&&d.jsxs(d.Fragment,{children:[d.jsx(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(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx(gv,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&d.jsxs(d.Fragment,{children:[d.jsx(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(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:d.jsx(Fr,{})})}),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(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Rr,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(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(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>h?c():g?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(qr,{})})})]})}function eo({open:e,onOpenChange:t,trigger:n,children:o}){const r=O.useRef(null);return O.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),d.jsxs("div",{ref:r,className:"relative",children:[n,e&&d.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const pw="ole-panel-open";function A4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(pw);if(!e)return{outlineOpen:!1};const t=JSON.parse(e);return typeof t!="object"||t===null?{outlineOpen:!1}:{outlineOpen:t.outline===!0}}catch{return{outlineOpen:!1}}}function br(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(pw,JSON.stringify(t))}catch{}}const Mt=Jt((e,t)=>({...A4(),setOutlineOpen:n=>{e({outlineOpen:n}),br(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),br(t())}})),Wt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],gw=.1,yw=8,xw="ole-grid";function C4(){try{const e=window.localStorage.getItem(xw);return e==null?!0:e==="1"}catch{return!0}}function I4(e){try{window.localStorage.setItem(xw,e?"1":"0")}catch{}}function P4(e,t,n){return e<t?t:e>n?n:e}function bw(){return document.querySelector(".ole-canvas-root")}function to(e){const t=Ze(),n=bw();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=P4(e,gw,yw),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function O4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=Wt.find(o=>o>t+1e-6)??yw;to(n)}function B4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=gw;for(let o=Wt.length-1;o>=0;o--)if(Wt[o]<t-1e-6){n=Wt[o];break}to(n)}const L4={off:"id",id:"all",all:"off"};function z4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=L4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function ww(){const[e,t]=O.useState(()=>C4());return O.useEffect(()=>{const n=bw();n==null||n.classList.toggle("hide-grid",!e),I4(e)},[e]),O.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function vw(){const e=ie();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(Ae,{variant:"ghost",size:"icon",onClick:B4,"aria-label":e("view.zoomOut"),children:d.jsx(Xn,{})})})}function kw(){const e=ie();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(Ae,{variant:"ghost",size:"icon",onClick:O4,"aria-label":e("view.zoomIn"),children:d.jsx(hv,{})})})}function _w(){const e=ie(),[t,n]=O.useState(JS);return O.useEffect(()=>ZS(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:()=>to(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function $w(){const e=ie();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(Ae,{variant:"ghost",size:"icon",onClick:Zn,"aria-label":e("view.fit"),children:d.jsx(uv,{})})})}function Sw({grid:e,setGrid:t}){const n=ie();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(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:je(!e&&"text-muted-foreground/60"),children:d.jsx(cv,{})})})}function jw(){const e=ie(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Ce,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:z4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:je(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Gr,{})})})}function R4({stacked:e}={}){const t=ie(),[n,o]=O.useState(!1),[r,s]=ww(),i=d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:t("view.menu")}),d.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?d.jsx(Ce,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:je("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(Nn,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Ce,{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(Nn,{})})});return d.jsx(eo,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(_w,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(vw,{}),d.jsx(kw,{})]}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx($w,{}),d.jsx(Sw,{grid:r,setGrid:s}),d.jsx(jw,{})]})]})})}function D4(){const e=Ve();return Oe(e,"dense")?null:d.jsx(F4,{tier:e})}function F4({tier:e}){const t=Oe(e,"tight"),[n,o]=ww();return d.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:d.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[d.jsx(vw,{}),!t&&d.jsx(_w,{}),d.jsx(kw,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx($w,{}),d.jsx(Sw,{grid:n,setGrid:o}),d.jsx(jw,{})]})})}const wr=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:fv,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:dv,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Xn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:ov,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Wr,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Br,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Gr,switchTo:"text",iconOnly:!0}];function H4(){const e=ie(),t=x(u=>u.activeTool),n=x(u=>u.placeKind),o=x(u=>u.placeFromTerminal),r=x(u=>u.wireDragFrom),s=x(u=>u.busbarDrawStart),i=x(u=>u.selection.length>0||u.selectedNode!=null);let a=null,l=!1;switch(t){case"select":a=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(l=!0);break;case"pan":a=e("mode.pan");break;case"wire":a=e(r?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(s?"mode.busDragging":"mode.busInit"),l=!0;break;case"junction":a=e("mode.junction"),l=!0;break;case"place":n?o?a=e("mode.placeFromTerm"):a=e("mode.placeNormal"):a=e("mode.placeNoKind"),l=!0;break;case"text":a=e("mode.text"),l=!0;break}if(!a)return null;const c=e(t==="select"?"mode.escSelect":"mode.escOther");return d.jsxs("div",{className:"ole-glass pointer-events-none flex items-center gap-2 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground shadow-sm",children:[d.jsx("span",{children:a}),l&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",c]})]})}function W4(){const e=ie(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ve(),c=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),m=f?wr.filter(h=>h.id!=="select"&&h.id!=="text"):wr,p=h=>t===h.switchTo;return d.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))"},children:[u&&d.jsx(H4,{}),d.jsxs("div",{className:je("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(q4,{stacked:!0}),m.map(h=>{const g=h.icon,b=p(h),$=h.id==="place"&&b&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return d.jsxs(O.Fragment,{children:[d.jsx(at,{icon:g,label:e(h.labelKey),hotkey:h.hotkey,active:b,iconOnly:!f&&(h.iconOnly||c),stacked:f,description:$,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?d.jsx(X4,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(at,{icon:Kn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(at,{icon:Yn,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(G4,{iconOnly:c})]}),f&&d.jsx(R4,{stacked:!0})]})]})}function q4({stacked:e}){const t=ie(),n=Mt(r=>r.outlineOpen),o=Mt(r=>r.toggleOutline);return d.jsx(at,{icon:Dr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function at({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(Ce,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:je("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:je("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function Ew(){const e=x(r=>r.diagram.elements),t=x(r=>r.diagram.layout),n=x(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function G4({iconOnly:e}){const t=ie(),[n,o]=O.useState(!1),r=Ew(),s=i=>()=>{o(!1),i()};return d.jsxs(eo,{open:n,onOpenChange:o,trigger:d.jsx(at,{icon:$t,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:d.jsx($t,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:d.jsx(qt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(qt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function X4({stacked:e}){const t=ie(),[n,o]=O.useState(!1),r=x(m=>m.past.length),s=x(m=>m.future.length),i=x(m=>m.undo),a=x(m=>m.redo),l=x(m=>m.selection.length>0),c=x(m=>m.clipboard!=null),u=Ew(),f=m=>()=>{o(!1),m()};return d.jsxs(eo,{open:n,onOpenChange:o,trigger:d.jsx(at,{icon:Nn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[d.jsx(Te,{onClick:f(i),icon:d.jsx(Kn,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Te,{onClick:f(a),icon:d.jsx(Yn,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:f(()=>x.getState().cutSelection()),icon:d.jsx(Hr,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Te,{onClick:f(()=>x.getState().copySelection()),icon:d.jsx(zr,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Te,{onClick:f(()=>x.getState().pasteClipboard()),icon:d.jsx(Lr,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Te,{onClick:f(()=>x.getState().autoArrangeAll()),icon:d.jsx($t,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Te,{onClick:f(()=>x.getState().autoArrangeSelection()),icon:d.jsx($t,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedAll()),icon:d.jsx(qt,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),d.jsx(Te,{onClick:f(()=>x.getState().fillUnplacedSelection()),icon:d.jsx(qt,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Te({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:je("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 Y4(){const e=Mt(r=>r.outlineOpen),t=Mt(r=>r.setOutlineOpen),n=Ve();return Oe(n,"dense")?e?d.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:d.jsx(vr,{onClose:()=>t(!1),sheet:!0})}):null:d.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?d.jsx(vr,{onClose:()=>t(!1)}):d.jsx(K4,{onClick:()=>t(!0)})})}function K4({onClick:e}){const t=ie(),n=Ve(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:je("ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",o?"w-12 justify-center":"gap-2 px-3"),children:[d.jsx(Dr,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function vr({onClose:e,sheet:t}){const n=ie(),o=x(c=>c.diagram.elements),r=x(c=>c.activeTool==="place"),s=Ve(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:je("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(U4,{children:o.length}),d.jsx(mv,{className:"size-3.5 text-muted-foreground"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?d.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):d.jsx("ul",{className:"space-y-px",children:o.map(c=>d.jsx(V4,{element:c},c.id))})})]})}function V4({element:e}){const t=Ke[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function U4({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 J4={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},Z4={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current","resistor.name":"Resistor (R)","capacitor.name":"Capacitor (C)","diode.name":"Diode (D)","indicator-light.name":"Indicator light (HL)","push-button.name":"Push-button (SB)","relay-coil.name":"Relay coil (KA)","make-contact.name":"NO contact (NO)","break-contact.name":"NC contact (NC)","bell.name":"Bell (HA)","terminal.name":"Terminal / junction (X)","fuse-switch-disconnector.name":"Fuse switch-disconnector","socket-outlet.name":"Socket outlet / connector","inductor.name":"Inductor (L)","voltage-regulator.name":"Voltage regulator (T)","dc-motor.name":"DC motor (M)","heater.name":"Heating element (EH)","selector-switch.name":"Selector switch (SA)","limit-switch.name":"Limit switch (SQ)","proximity-switch.name":"Proximity switch (SQ)","time-relay.name":"Time relay (KT)","buzzer.name":"Buzzer (HA)","siren.name":"Siren (HA)","thermocouple.name":"Thermocouple (BT)","thyristor.name":"Thyristor / SCR (V)","triac.name":"Triac (V)","zener-diode.name":"Zener diode (D)","igbt.name":"IGBT","plc.name":"PLC / controller","ups.name":"UPS","power-supply.name":"Power supply (PS)","genset.name":"Generator set (G)","protective-relay.name":"Protective relay","overcurrent-relay.name":"Overcurrent relay (50/51)","undervoltage-relay.name":"Undervoltage relay (27)","reverse-power-relay.name":"Reverse-power relay (32)","distance-relay.name":"Distance relay (21)","phase-failure-relay.name":"Phase-failure relay","buchholz-relay.name":"Buchholz relay (63)","power-factor-meter.name":"Power-factor meter (cosφ)","synchronoscope.name":"Synchronoscope","varmeter.name":"Varmeter (var)","resistor.desc":"General resistor / current-limiting / braking resistor.","capacitor.desc":"General / filter / DC-bus capacitor. Use shunt capacitor for PF correction.","diode.desc":"Rectifier / freewheeling / protection diode. t1 = anode (top), t2 = cathode (bottom).","indicator-light.desc":"Signal / status indicator light.","push-button.desc":"Manual push-button, automatic return (NO make).","relay-coil.desc":"Relay / contactor operating coil (box).","make-contact.desc":"Normally-open auxiliary contact (make).","break-contact.desc":"Normally-closed auxiliary contact (break).","bell.desc":"Signal bell / alarm bell.","terminal.desc":"Terminal / junction box / connection node.","fuse-switch-disconnector.desc":"On-load fuse switch-disconnector.","socket-outlet.desc":"Power socket outlet / multipole connector.","inductor.desc":"General inductor / coil / choke.","voltage-regulator.desc":"Adjustable induction / autotransformer voltage regulator.","dc-motor.desc":"DC motor (series-field general symbol).","heater.desc":"Resistive heating element / heating load.","selector-switch.desc":"Selector / changeover switch (rotary, stay-put).","limit-switch.desc":"Travel / position switch (NO, mechanically operated).","proximity-switch.desc":"Proximity sensor / contactless proximity switch.","time-relay.desc":"Time-delay (slow-operating) relay coil.","buzzer.desc":"Signal buzzer.","siren.desc":"Audible siren / alarm.","thermocouple.desc":"Thermocouple temperature sensor.","thyristor.desc":"Reverse-blocking triode thyristor / SCR. t1 = anode (top), t2 = cathode (bottom).","triac.desc":"Bidirectional triode thyristor (TRIAC).","zener-diode.desc":"Zener / voltage-regulator diode. t1 = anode (top), t2 = cathode (bottom).","igbt.desc":"N-channel enhancement IGBT. t1 = collector (top), t2 = emitter (bottom), t_g = gate.","plc.desc":"Programmable logic controller (PLC).","ups.desc":"Online / standby uninterruptible power supply.","power-supply.desc":"AC→DC switched-mode / DC power supply. t_ac top (~), t_dc bottom (=).","genset.desc":"Diesel / gas generator set.","protective-relay.desc":"Measuring / protective relay, general symbol (IEC 60617).","overcurrent-relay.desc":"Overcurrent protection relay (ANSI 50/51).","undervoltage-relay.desc":"Undervoltage protection relay (ANSI 27).","reverse-power-relay.desc":"Reverse-power / reverse-current protection relay (ANSI 32).","distance-relay.desc":"Distance / under-impedance protection relay (ANSI 21).","phase-failure-relay.desc":"Phase-failure / phase-loss protection relay.","buchholz-relay.desc":"Buchholz / gas relay (ANSI 63).","power-factor-meter.desc":"Power-factor meter (cosφ).","synchronoscope.desc":"Synchronizing indicator / synchronoscope.","varmeter.desc":"Reactive-power meter (var).","make-contact.state.closed":"Closed","break-contact.state.open":"Open","fuse-switch-disconnector.state.open":"Open","selector-switch.state.open":"Open","limit-switch.state.closed":"Closed","resistor.param.R":"Resistance","resistor.param.P":"Rated power","capacitor.param.C":"Capacitance","capacitor.param.Un":"Rated voltage","indicator-light.param.color":"Color","inductor.param.L":"Inductance","inductor.param.In":"Rated current","voltage-regulator.param.ratio":"Regulation range","heater.param.P":"Power","ups.param.S":"Capacity","power-supply.param.Vdc":"Output voltage","genset.param.P":"Power"},kr={zh:J4,en:Z4};function Q4(e,t){return kr[e][t]??kr.zh[t]}function At(){const e=Tt(t=>t.locale);return(t,n)=>Q4(e,t)??n??t}const Nw="ole-palette-collapsed",ej=new Set(["busbar"]),Et=(()=>{const e={};for(const[t,n]of Object.entries(E$)){const o=n.filter(r=>!ej.has(r.id));o.length&&(e[t]=o)}return e})(),tj=(()=>{const e=new Set(Wo),t=Object.keys(Et).filter(n=>!e.has(n));return[...Wo.filter(n=>{var o;return(o=Et[n])==null?void 0:o.length}),...t]})();function nj(){try{const e=window.localStorage.getItem(Nw);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function oj(e){try{window.localStorage.setItem(Nw,JSON.stringify([...e]))}catch{}}function rj(){const e=ie(),t=x(f=>f.activeTool==="place"),n=x(f=>f.placeKind),o=x(f=>f.setActiveTool),r=Mt(f=>f.outlineOpen),s=Ve(),i=Oe(s,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:a};return d.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:d.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:d.jsx(Vn,{className:"size-3.5"})})]}),d.jsx(sj,{sheet:i})]})})}function sj({sheet:e}){const t=ie(),n=At(),[o,r]=O.useState(""),[s,i]=O.useState(()=>nj()),a=O.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return Et;const m={};for(const[p,h]of Object.entries(Et)){const g=h.filter(b=>{const $=n(`${b.id}.name`,b.name).toLowerCase(),k=n(`${b.id}.desc`,b.description??"").toLowerCase();return $.includes(f)||b.id.toLowerCase().includes(f)||k.includes(f)});g.length&&(m[p]=g)}return m},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=O.useCallback((f,m)=>{i(p=>{const h=new Set(p);return m?h.delete(f):h.add(f),oj(h),h})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(ij,{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")}):tj.map(f=>{var b;const m=a[f];if(!(m!=null&&m.length))return null;const p=((b=Et[f])==null?void 0:b.length)??m.length,h=t(`cat.${f}`),g=l||!s.has(f);return d.jsxs("details",{open:g,className:"group mb-2 last:mb-0",onToggle:$=>{l||u(f,$.currentTarget.open)},children:[d.jsxs("summary",{className:"flex cursor-pointer select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:[d.jsx(nv,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:h}),d.jsx(lj,{children:l&&m.length!==p?`${m.length}/${p}`:p})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map($=>d.jsx(aj,{entry:$,sheet:e},$.id))})]},f)})})]})}function ij({value:e,onChange:t}){const n=ie();return d.jsxs("div",{className:"relative",children:[d.jsx(pv,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),d.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&d.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Vn,{className:"size-3"})})]})}function aj({entry:e,sheet:t}){const n=ie(),o=At(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(f=>f.setActiveTool),a=x(f=>f.activeTool==="place"&&f.placeKind===e.id),l=x(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),c=O.useRef(null);O.useEffect(()=>{var f;l&&((f=c.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const m=document.createElement("div");m.className="ole-glass",m.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),m.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(m),f.dataTransfer.setDragImage(m,32,32),setTimeout(()=>m.remove(),0)};return d.jsxs("li",{ref:c,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function lj({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 qn="ole-onboarding-dismissed";function cj(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qn)==="1"}catch{return!1}}function _r(e){try{e?window.localStorage.setItem(qn,"1"):window.localStorage.removeItem(qn)}catch{}}const $r=Jt(e=>({dismissed:cj(),dismiss:()=>{_r(!0),e({dismissed:!0})},reset:()=>{_r(!1),e({dismissed:!1})}}));function dj(){const e=ie(),t=$r(o=>o.dismissed),n=$r(o=>o.dismiss);return t?null:d.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),d.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Vn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(jn,{n:1,icon:d.jsx(Wr,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(jn,{n:2,icon:d.jsx(Br,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(jn,{n:3,icon:d.jsx(Xn,{}),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 jn({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 uj(){const e=ie(),t=x(m=>m.selection),n=x(m=>m.diagram.elements),o=x(m=>m.diagram.buses),r=x(m=>m.diagram.junctions),s=x(m=>m.selectedNode),i=x(m=>m.selectedWire);if(i)return d.jsx(yj,{wireId:i});if(s)return d.jsx(bj,{nodeId:s});if(t.length===0)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const a=t[0],l=(o??[]).find(m=>m.id===a);if(l)return d.jsx(pj,{bus:l});const c=(r??[]).find(m=>m.id===a);if(c)return d.jsx(xj,{junction:c});const u=n.find(m=>m.id===a);if(!u)return null;const f=Ke[u.kind];return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(ut,{label:e("props.name"),value:u.name??"",placeholder:u.id,onCommit:m=>x.getState().updateElement(a,{name:m.trim()===""?void 0:m.trim()})}),d.jsx(no,{label:e("props.note"),value:u.note??"",onCommit:m=>x.getState().updateElement(a,{note:m.trim()===""?void 0:m.trim()})}),(f==null?void 0:f.state)&&f.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:f.state.map(m=>d.jsx(wj,{id:a,element:u,field:m},m.name))}),d.jsx(fj,{id:a,element:u,schema:(f==null?void 0:f.params)??[]})]})}function fj({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(mj,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(hj,{id:e,element:t,fieldKey:s,value:i},s))]})}function mj({id:e,element:t,field:n}){var l;const o=ie(),r=At(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const u={...t.params??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,x.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(dt,{label:i,children:d.jsx(oo,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?d.jsx(rn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):d.jsx(ut,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function hj({id:e,element:t,fieldKey:n,value:o}){const r=ie(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,x.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?d.jsx(dt,{label:n,children:d.jsx(oo,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(rn,{label:n,value:o,onCommit:s}):d.jsx(ut,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function pj({bus:e}){const t=ie(),n=e.id,o=r=>{const s=r.trim();Gn(n,{name:s===""?void 0:s})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(ut,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(no,{label:t("props.note"),value:e.note??"",onCommit:r=>Gn(n,{note:r.trim()===""?void 0:r.trim()})}),d.jsx(gj,{bus:e})]})}function gj({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Gn(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(rn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Gn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function yj({wireId:e}){const t=ie(),n=x(b=>b.diagram.wires),o=x(b=>b.diagram.elements),r=x(b=>b.diagram.buses),s=x(b=>b.diagram.junctions),i=x(b=>b.internal.terminalToNode),a=x(b=>b.setSelectedNode),l=(n??[]).find(b=>b.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),u=new Map(o.map(b=>[b.id,b])),f=new Map((r??[]).map(b=>[b.id,b])),m=new Map((s??[]).map(b=>[b.id,b])),p=b=>{if(!b.includes(".")){const C=f.get(b);if(C)return{id:b,label:C.name??b};const R=m.get(b);return{id:b,label:(R==null?void 0:R.name)??b}}const $=b.indexOf("."),k=b.slice(0,$),w=b.slice($+1),S=u.get(k);return{id:k,label:(S==null?void 0:S.name)??k,pin:w}},h=p(l.ends[0]),g=p(l.ends[1]);return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),d.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((b,$)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([b.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:b.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:b.label}),b.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:b.pin})]},$))}),c&&d.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>a(c),children:t("props.selectWholeNode")})]})}function xj({junction:e}){var r;const t=ie(),n=x(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),d.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),d.jsx(ut,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>x.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(no,{label:t("props.note"),value:e.note??"",onCommit:s=>x.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})}),o&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[d.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),d.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function bj({nodeId:e}){const t=ie(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const c=a.slice(0,l),u=a.slice(l+1),f=s.get(c)??[];f.push(u),s.set(c,f)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function dt({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function ut({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=O.useState(t),a=O.useRef(null);return O.useEffect(()=>i(t),[t]),d.jsx(dt,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:je("h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",o&&"pr-8")}),o&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function no({label:e,value:t,onCommit:n}){const[o,r]=O.useState(t);return O.useEffect(()=>r(t),[t]),d.jsx(dt,{label:e,children:d.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function rn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=O.useState(String(t)),a=O.useRef(null);return O.useEffect(()=>i(String(t)),[t]),d.jsx(dt,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var c,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:je("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 oo({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:je("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 wj({id:e,element:t,field:n}){var l;const o=ie(),s=At()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const u={...t.state??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,x.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(dt,{label:s,children:d.jsx(oo,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(rn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(ut,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function vj(){const e=ie(),t=At(),n=x(f=>f.selection),o=x(f=>f.selectedNode),r=x(f=>f.selectedWire),s=x(f=>f.diagram.elements),i=x(f=>f.diagram.buses),a=Ve(),l=Oe(a,"dense");if(n.length===0&&!o&&!r)return null;let c=e("props.title"),u=null;if(r)c=e("props.wire");else if(o)c=e("props.node");else if(n.length===1){const f=n[0],m=(i??[]).find(p=>p.id===f);if(m)c=m.name??e("props.bus");else{const p=s.find(h=>h.id===f);if(p){const h=Ke[p.kind];c=h?t(`${h.id}.name`,h.name):p.kind}}}else u=n.length;return d.jsxs("aside",{className:je("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",l?"w-48":"w-56"),style:{top:`calc(${l?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:c}),u!=null&&d.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e("props.nSelected",{n:u})})]}),d.jsx(uj,{})]})}function kj(){O.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function _j(){kj();const e=O.useRef(null),t=zS(e);return d.jsx(Jv,{children:d.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(p4,{width:t,children:[d.jsx(s4,{}),d.jsx(Y4,{}),d.jsx(vj,{}),d.jsx(W4,{}),d.jsx(D4,{}),d.jsx(T4,{}),d.jsx(rj,{}),d.jsx(dj,{}),d.jsx(m4,{})]})})})}const $j="ole-theme";function Sj(){try{const e=window.localStorage.getItem($j);return e==="light"||e==="dark"?e:null}catch{return null}}function jj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function Ej(){return typeof window>"u"?"light":Sj()??(jj()?"dark":"light")}function Mw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Nj({className:e,diagram:t,locale:n,theme:o}){return O.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),O.useEffect(()=>{n&&Tt.getState().setLocale(n)},[n]),O.useEffect(()=>{o&&Mw(o)},[o]),O.useEffect(()=>{Qn()},[]),_S(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(_j,{})})}const Tw={"application/json":[".json"]},Aw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Cw=e=>e instanceof DOMException&&e.name==="AbortError";function Sr(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(we("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(we("io.notObject"));const n=t;if(n.version!=="1")throw new Error(we("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(we("io.elementsMissing"));return n}function Mj(e){return JSON.stringify(e,null,2)+`
199
+ `}async function Tj(){if(Aw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:we("topbar.file.fileDescription"),accept:Tw}]})}catch(n){if(Cw(n))return null;throw n}const t=await e.getFile();return{diagram:Sr(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:Sr(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function jr(e,t,n={}){const o=Mj(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Aw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:we("topbar.file.fileDescription"),accept:Tw}]})}catch(l){if(Cw(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const r=URL.createObjectURL(new Blob([o],{type:"application/json"})),s=document.createElement("a");return s.href=r,s.download=(t==null?void 0:t.name)??"diagram.json",s.click(),URL.revokeObjectURL(r),t??{name:"diagram.json"}}function Aj(){const e=ie(),t=x(f=>f.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=Cj(),[a,l]=O.useState(!1),c=O.useRef(null);O.useEffect(()=>{const f=m=>{if(!(m.metaKey||m.ctrlKey))return;const p=m.key.toLowerCase();p==="o"?(m.preventDefault(),r()):p==="s"&&(m.preventDefault(),m.shiftKey?i():s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,s,i]),O.useEffect(()=>{if(!a)return;const f=p=>{c.current&&!c.current.contains(p.target)&&l(!1)},m=p=>{p.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",m)}},[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(jo,{}),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(Ft,{onClick:u(o),icon:d.jsx(av,{}),children:e("topbar.file.new")}),d.jsx(Ft,{onClick:u(r),icon:d.jsx(jo,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(Ft,{onClick:u(s),icon:d.jsx(Eo,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(Ft,{onClick:u(i),icon:d.jsx(Eo,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function Ft({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 Cj(){const e=ie(),t=x(l=>l.loadDiagramFromFile),n=x(l=>l.setFileSession),o=x(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=x.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await Tj();l&&(t(l.diagram,l.session),Qn())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=x.getState(),u=await jr(l,c);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:c}=x.getState(),u=await jr(l,c,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const En="WIRES",Fe="ELEMENTS",Er="LABELS",Nr="ANNOTATIONS",Mr=32,Tr=64,Ij=8,Pj=1.25,Oj=6;function Iw(e,t={}){const n=new Kj(t.precision??6);n.header(t.title),n.tables([{name:En,color:7},{name:Fe,color:7},{name:Er,color:8},{name:Nr,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(En,r.path.map(Ie),!1);for(const{geometry:r}of e.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?[i[0]-l,i[1]]:[i[0],i[1]-l],u=s==="x"?[i[0]+l,i[1]]:[i[0],i[1]+l];n.lwpolyline(En,[c,u].map(Ie),!1)}for(const r of e.elements.values()){const s=e.layout.get(r.element.id),i=r.libraryDef;!s||!i||Bj(n,i.svg,s)}const o=t.labelMode??"all";if(o!=="off")for(const r of e.elements.values()){const s=e.layout.get(r.element.id);if(!s||!r.libraryDef)continue;const i=Qt(r,o);if(i.length===0)continue;const a=r.libraryDef.label??en(r.libraryDef),[l,c]=tn(a,s);for(let u=0;u<i.length;u++){const[f,m]=Ie([l,c+u*Zt]);n.text(Er,[f,m],i[u],Yt,0,!1)}}for(const r of t.annotations??[]){if(!r.text)continue;const s=r.fontSize??Ij,i=r.text.split(`
200
+ `);for(let a=0;a<i.length;a++){const[l,c]=Ie([r.at[0],r.at[1]+(a+1)*s*Pj]);n.text(Nr,[l,c],i[a],s,0,!1)}}return n.endEntities(),n.toString()}async function Pw(e,t="diagram.dxf",n){const o=Iw(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 Bj(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":Lj(e,i,n);break;case"polyline":Ar(e,i,n,!1);break;case"polygon":Ar(e,i,n,!0);break;case"rect":zj(e,i,n);break;case"circle":Rj(e,i,n);break;case"ellipse":Dj(e,i,n);break;case"path":qj(e,i,n);break;case"text":Wj(e,i,n);break}}function Lj(e,t,n){const o=ve(t,"x1"),r=ve(t,"y1"),s=ve(t,"x2"),i=ve(t,"y2"),a=Ie(De([o,r],n)),l=Ie(De([s,i],n));e.line(Fe,a,l)}function Ar(e,t,n,o){const r=Yj(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>Ie(De(i,n)));e.lwpolyline(Fe,s,o)}function zj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=ve(t,"width"),i=ve(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(c=>Ie(De(c,n)));e.lwpolyline(Fe,l,!0)}function Rj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"r"),i=Ie(De([o,r],n));e.circle(Fe,i,s)}function Dj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"rx"),i=ve(t,"ry");if(Math.abs(s-i)<1e-6){Fj(e,o,r,s,n);return}Hj(e,o,r,s,i,n)}function Fj(e,t,n,o,r){const s=Ie(De([t,n],r));e.circle(Fe,s,o)}function Hj(e,t,n,o,r,s){const i=[];for(let a=0;a<Tr;a++){const l=a/Tr*Math.PI*2;i.push(Ie(De([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Fe,i,!0)}function Wj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||Oj,i=(t.textContent??"").trim();if(!i)return;const a=Ie(De([o,r],n));e.text(Fe,a,i,s,n.rot,n.mirror)}function qj(e,t,n){const o=t.getAttribute("d")??"",r=Gj(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Fe,i.map(l=>Ie(De(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,m,p,h]=l.args,g=Xj(s,[p,h],c,u,f!==0,m!==0);if(g)for(let b=1;b<=Mr;b++){const $=g.theta1+g.delta*b/Mr;i.push([g.cx+c*Math.cos($),g.cy+u*Math.sin($)])}else i.push([p,h]);s=[p,h]}a()}function Gj(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 Xj(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 m=Math.abs(n),p=Math.abs(o);const h=m*m,g=p*p,b=u*u/h+f*f/g;if(b>1){const W=Math.sqrt(b);m*=W,p*=W}const $=r===s?-1:1,k=m*m*p*p-m*m*f*f-p*p*u*u,w=m*m*f*f+p*p*u*u,S=$*Math.sqrt(Math.max(0,k/w)),C=S*(m*f)/p,R=S*-(p*u)/m,X=C+(i+l)/2,V=R+(a+c)/2,te=(W,ye,ue,pe)=>{const ne=W*ue+ye*pe,re=Math.hypot(W,ye)*Math.hypot(ue,pe);let ge=Math.acos(Math.max(-1,Math.min(1,ne/re)));return W*pe-ye*ue<0&&(ge=-ge),ge},ae=te(1,0,(u-C)/m,(f-R)/p);let D=te((u-C)/m,(f-R)/p,(-u-C)/m,(-f-R)/p);return!s&&D>0?D-=2*Math.PI:s&&D<0&&(D+=2*Math.PI),{cx:X,cy:V,theta1:ae,delta:D}}function De(e,t){return Pe(e,t)}function Ie(e){return[e[0],-e[1]]}function ve(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function Yj(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 Kj{constructor(t){gt(this,"out",[]);gt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
201
201
  ${this.fmt(n)}
202
- `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,Ar(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i){this.g(0,"TEXT"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,Ar(o)),s!==0&&this.g(50,s),i&&this.g(71,2)}}function Ar(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const Xj="http://www.w3.org/2000/svg",Ht=24,Pw=8,Ow=1.25;function ro(e,t={}){const n=Yj(e,t),o=Math.floor(n.minX-Ht),r=Math.floor(n.minY-Ht),s=Math.ceil(n.maxX+Ht)-o,i=Math.ceil(n.maxY+Ht)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${Xj}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${rt(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const f of e.wireRenders.values()){if(f.path.length<2)continue;const m=f.path.map(([p,h])=>`${p},${h}`).join(" ");l.push(` <polyline points="${m}"/>`)}l.push(" </g>");for(const{bus:f,geometry:m}of e.buses.values()){const{axis:p,at:h,span:y}=m,w=y/2,$=p==="x"?h[0]-w:h[0],k=p==="x"?h[1]:h[1]-w,b=p==="x"?h[0]+w:h[0],S=p==="x"?h[1]:h[1]+w;l.push(` <line id="${rt(f.id)}" x1="${$}" y1="${k}" x2="${b}" y2="${S}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:f,world:m}of e.junctions.values())l.push(` <circle id="${rt(f.id)}" cx="${m[0]}" cy="${m[1]}" r="3.5" fill="black"/>`);for(const f of e.elements.values()){if(!f.libraryDef)continue;const m=e.layout.get(f.element.id);m&&(l.push(` <g id="${rt(f.element.id)}" transform="${Ye(m)}">`),l.push(` ${f.libraryDef.svg}`),l.push(" </g>"))}const d=t.labelMode??"all";if(d!=="off"){const f=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Yt}" paint-order="stroke" stroke="${f}" stroke-width="2" stroke-linejoin="round">`);for(const m of e.elements.values()){const p=e.layout.get(m.element.id);if(!p||!m.libraryDef)continue;const h=Qt(m,d);if(h.length===0)continue;const y=m.libraryDef.label??en(m.libraryDef),[w,$]=tn(y,p),k=y.anchor??"start";for(let b=0;b<h.length;b++)l.push(` <text x="${w}" y="${$+b*Zt}" text-anchor="${k}">${rt(h[b])}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){const f=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${f}" stroke-width="2" stroke-linejoin="round">`);for(const m of u){if(!m.text)continue;const p=m.fontSize??Pw,h=m.text.split(`
203
- `);for(let y=0;y<h.length;y++){const w=m.at[1]+p*.85+y*p*Ow;l.push(` <text x="${m.at[0]}" y="${w}" font-size="${p}">${rt(h[y])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
204
- `)}function Yj(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(l,d)=>{l<n&&(n=l),l>r&&(r=l),d<o&&(o=d),d>s&&(s=d)};for(const l of e.terminals.values())i(l.world[0],l.world[1]);for(const l of e.junctions.values())i(l.world[0],l.world[1]);for(const l of e.elements.values()){const d=e.layout.get(l.element.id),u=l.libraryDef;if(!d||!u)continue;const f=Kj(u.viewBox);if(!f){i(d.at[0],d.at[1]);continue}const m=[[f.x,f.y],[f.x+f.w,f.y],[f.x,f.y+f.h],[f.x+f.w,f.y+f.h]];for(const p of m){const[h,y]=Pe(p,d);i(h,y)}}for(const{geometry:l}of e.buses.values()){const{axis:d,at:u,span:f}=l,m=f/2;d==="x"?(i(u[0]-m,u[1]),i(u[0]+m,u[1])):(i(u[0],u[1]-m),i(u[0],u[1]+m))}for(const l of e.wireRenders.values())for(const[d,u]of l.path)i(d,u);const a=t.labelMode??"all";if(a!=="off")for(const l of e.elements.values()){const d=e.layout.get(l.element.id);if(!d||!l.libraryDef)continue;const u=Qt(l,a);if(u.length===0)continue;const f=l.libraryDef.label??en(l.libraryDef),[m,p]=tn(f,d),h=Cr(u,Yt),y=u.length*Zt,w=f.anchor??"start",$=w==="middle"?m-h/2:w==="end"?m-h:m;i($,p-Yt),i($+h,p+y)}for(const l of t.annotations??[]){if(!l.text)continue;const d=l.fontSize??Pw,u=l.text.split(`
205
- `),f=Cr(u,d),m=u.length*d*Ow;i(l.at[0],l.at[1]),i(l.at[0]+f,l.at[1]+m)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function Cr(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 Kj(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function rt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function Bw(e,t="diagram.svg",n){const o=ro(e,n);zw(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function Lw(e,t="diagram.png",n){const o=ro(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 Vj(s),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*r),a.height=Math.round(i.naturalHeight*r);const l=a.getContext("2d");if(!l)throw new Error("canvas 2d context unavailable");n!=null&&n.background&&n.background!=="transparent"&&(l.fillStyle=n.background,l.fillRect(0,0,a.width,a.height)),l.drawImage(i,0,0,a.width,a.height);const d=await new Promise((u,f)=>{a.toBlob(m=>m?u(m):f(new Error("toBlob failed")),"image/png")});zw(d,t)}finally{URL.revokeObjectURL(s)}}function Vj(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 zw(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Uj(){const e=ie(),[t,n]=O.useState(!1),o=O.useRef(null);O.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var f,m,p,h;n(!1);const{internal:i,diagram:a,fileSession:l}=x.getState(),d=((f=l==null?void 0:l.name)==null?void 0:f.replace(/\.json$/i,""))??((m=a.meta)==null?void 0:m.title)??"diagram",u={title:(p=a.meta)==null?void 0:p.title,labelMode:(h=a.meta)==null?void 0:h.labelMode,annotations:a.annotations};s==="svg"?Bw(i,`${d}.svg`,u):s==="png"?Lw(i,`${d}.png`,{...u,scale:2}).catch(y=>{console.error(y),alert(e("topbar.export.pngFailed",{err:y.message}))}):Iw(i,`${d}.dxf`,u).catch(y=>{console.error(y),alert(e("topbar.export.dxfFailed",{err:y.message}))})};return c.jsxs("div",{ref:o,className:"relative",children:[c.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[c.jsx(ov,{}),e("topbar.export.label")]}),t&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(av,{}),c.jsx("span",{className:"flex-1",children:"SVG"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(sv,{}),c.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(rv,{}),c.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=Uj;exports.FileMenu=Nj;exports.LIBRARY=In;exports.OneLineEditor=Sj;exports.applyTheme=Nw;exports.buildExportDxf=Cw;exports.buildExportSvg=ro;exports.compile=Xe;exports.downloadDxf=Iw;exports.downloadPng=Lw;exports.downloadSvg=Bw;exports.emptyInternalModel=rs;exports.fitToContent=Zn;exports.fitToContentSoon=Qn;exports.getInitialTheme=$j;exports.getLibraryEntry=Jb;exports.newBusId=Pn;exports.newElementId=Nt;exports.newJunctionId=On;exports.orientationVec=Cn;exports.resolvePlacement=ss;exports.transformOrientation=St;exports.transformPoint=Pe;exports.useEditorStore=x;exports.useLocale=Tt;exports.wireIdFromEnds=Je;
202
+ `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,Cr(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i){this.g(0,"TEXT"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,Cr(o)),s!==0&&this.g(50,s),i&&this.g(71,2)}}function Cr(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const Vj="http://www.w3.org/2000/svg",Ht=24,Ow=8,Bw=1.25;function ro(e,t={}){const n=Uj(e,t),o=Math.floor(n.minX-Ht),r=Math.floor(n.minY-Ht),s=Math.ceil(n.maxX+Ht)-o,i=Math.ceil(n.maxY+Ht)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${Vj}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${rt(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const f of e.wireRenders.values()){if(f.path.length<2)continue;const m=f.path.map(([p,h])=>`${p},${h}`).join(" ");l.push(` <polyline points="${m}"/>`)}l.push(" </g>");for(const{bus:f,geometry:m}of e.buses.values()){const{axis:p,at:h,span:g}=m,b=g/2,$=p==="x"?h[0]-b:h[0],k=p==="x"?h[1]:h[1]-b,w=p==="x"?h[0]+b:h[0],S=p==="x"?h[1]:h[1]+b;l.push(` <line id="${rt(f.id)}" x1="${$}" y1="${k}" x2="${w}" y2="${S}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:f,world:m}of e.junctions.values())l.push(` <circle id="${rt(f.id)}" cx="${m[0]}" cy="${m[1]}" r="3.5" fill="black"/>`);for(const f of e.elements.values()){if(!f.libraryDef)continue;const m=e.layout.get(f.element.id);m&&(l.push(` <g id="${rt(f.element.id)}" transform="${Ye(m)}">`),l.push(` ${f.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const f=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Yt}" paint-order="stroke" stroke="${f}" stroke-width="2" stroke-linejoin="round">`);for(const m of e.elements.values()){const p=e.layout.get(m.element.id);if(!p||!m.libraryDef)continue;const h=Qt(m,c);if(h.length===0)continue;const g=m.libraryDef.label??en(m.libraryDef),[b,$]=tn(g,p),k=g.anchor??"start";for(let w=0;w<h.length;w++)l.push(` <text x="${b}" y="${$+w*Zt}" text-anchor="${k}">${rt(h[w])}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){const f=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${f}" stroke-width="2" stroke-linejoin="round">`);for(const m of u){if(!m.text)continue;const p=m.fontSize??Ow,h=m.text.split(`
203
+ `);for(let g=0;g<h.length;g++){const b=m.at[1]+p*.85+g*p*Bw;l.push(` <text x="${m.at[0]}" y="${b}" font-size="${p}">${rt(h[g])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
204
+ `)}function Uj(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(l,c)=>{l<n&&(n=l),l>r&&(r=l),c<o&&(o=c),c>s&&(s=c)};for(const l of e.terminals.values())i(l.world[0],l.world[1]);for(const l of e.junctions.values())i(l.world[0],l.world[1]);for(const l of e.elements.values()){const c=e.layout.get(l.element.id),u=l.libraryDef;if(!c||!u)continue;const f=Jj(u.viewBox);if(!f){i(c.at[0],c.at[1]);continue}const m=[[f.x,f.y],[f.x+f.w,f.y],[f.x,f.y+f.h],[f.x+f.w,f.y+f.h]];for(const p of m){const[h,g]=Pe(p,c);i(h,g)}}for(const{geometry:l}of e.buses.values()){const{axis:c,at:u,span:f}=l,m=f/2;c==="x"?(i(u[0]-m,u[1]),i(u[0]+m,u[1])):(i(u[0],u[1]-m),i(u[0],u[1]+m))}for(const l of e.wireRenders.values())for(const[c,u]of l.path)i(c,u);const a=t.labelMode??"all";if(a!=="off")for(const l of e.elements.values()){const c=e.layout.get(l.element.id);if(!c||!l.libraryDef)continue;const u=Qt(l,a);if(u.length===0)continue;const f=l.libraryDef.label??en(l.libraryDef),[m,p]=tn(f,c),h=Ir(u,Yt),g=u.length*Zt,b=f.anchor??"start",$=b==="middle"?m-h/2:b==="end"?m-h:m;i($,p-Yt),i($+h,p+g)}for(const l of t.annotations??[]){if(!l.text)continue;const c=l.fontSize??Ow,u=l.text.split(`
205
+ `),f=Ir(u,c),m=u.length*c*Bw;i(l.at[0],l.at[1]),i(l.at[0]+f,l.at[1]+m)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function Ir(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 Jj(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function rt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function Lw(e,t="diagram.svg",n){const o=ro(e,n);Rw(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function zw(e,t="diagram.png",n){const o=ro(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 Zj(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(m=>m?u(m):f(new Error("toBlob failed")),"image/png")});Rw(c,t)}finally{URL.revokeObjectURL(s)}}function Zj(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 Rw(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Qj(){const e=ie(),[t,n]=O.useState(!1),o=O.useRef(null);O.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var f,m,p,h;n(!1);const{internal:i,diagram:a,fileSession:l}=x.getState(),c=((f=l==null?void 0:l.name)==null?void 0:f.replace(/\.json$/i,""))??((m=a.meta)==null?void 0:m.title)??"diagram",u={title:(p=a.meta)==null?void 0:p.title,labelMode:(h=a.meta)==null?void 0:h.labelMode,annotations:a.annotations};s==="svg"?Lw(i,`${c}.svg`,u):s==="png"?zw(i,`${c}.png`,{...u,scale:2}).catch(g=>{console.error(g),alert(e("topbar.export.pngFailed",{err:g.message}))}):Pw(i,`${c}.dxf`,u).catch(g=>{console.error(g),alert(e("topbar.export.dxfFailed",{err:g.message}))})};return d.jsxs("div",{ref:o,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[d.jsx(rv,{}),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(lv,{}),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(iv,{}),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(sv,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=Qj;exports.FileMenu=Aj;exports.LIBRARY=In;exports.OneLineEditor=Nj;exports.applyTheme=Mw;exports.buildExportDxf=Iw;exports.buildExportSvg=ro;exports.compile=Xe;exports.downloadDxf=Pw;exports.downloadPng=zw;exports.downloadSvg=Lw;exports.emptyInternalModel=ss;exports.fitToContent=Zn;exports.fitToContentSoon=Qn;exports.getInitialTheme=Ej;exports.getLibraryEntry=Zb;exports.newBusId=Pn;exports.newElementId=Nt;exports.newJunctionId=On;exports.orientationVec=Cn;exports.resolvePlacement=is;exports.transformOrientation=St;exports.transformPoint=Pe;exports.useEditorStore=x;exports.useLocale=Tt;exports.wireIdFromEnds=Je;
206
206
  //# sourceMappingURL=sldeditor.cjs.map