node-opcua-basic-types 2.64.1 → 2.68.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.
Files changed (47) hide show
  1. package/dist/array.d.ts +16 -16
  2. package/dist/array.js +44 -44
  3. package/dist/attributeIds.d.ts +34 -34
  4. package/dist/attributeIds.js +48 -48
  5. package/dist/boolean.d.ts +9 -9
  6. package/dist/boolean.js +33 -33
  7. package/dist/byte_string.d.ts +11 -11
  8. package/dist/byte_string.js +36 -36
  9. package/dist/date_time.d.ts +6 -6
  10. package/dist/date_time.js +20 -16
  11. package/dist/date_time.js.map +1 -1
  12. package/dist/floats.d.ts +16 -16
  13. package/dist/floats.js +80 -80
  14. package/dist/guid.d.ts +9 -9
  15. package/dist/guid.js +121 -121
  16. package/dist/guid.js.map +1 -1
  17. package/dist/index.d.ts +18 -18
  18. package/dist/index.js +32 -28
  19. package/dist/index.js.map +1 -1
  20. package/dist/integers.d.ts +66 -66
  21. package/dist/integers.js +292 -292
  22. package/dist/locale_id.d.ts +9 -9
  23. package/dist/locale_id.js +18 -18
  24. package/dist/node_id.d.ts +9 -9
  25. package/dist/node_id.js +188 -192
  26. package/dist/node_id.js.map +1 -1
  27. package/dist/round_to_float.d.ts +1 -1
  28. package/dist/round_to_float.js +26 -26
  29. package/dist/status_code.d.ts +4 -4
  30. package/dist/status_code.js +20 -16
  31. package/dist/status_code.js.map +1 -1
  32. package/dist/string.d.ts +12 -12
  33. package/dist/string.js +30 -30
  34. package/dist/utils.d.ts +12 -12
  35. package/dist/utils.js +19 -19
  36. package/package.json +15 -15
  37. package/source/guid.ts +1 -1
  38. package/source/node_id.ts +0 -5
  39. package/dist/localeid.d.ts +0 -9
  40. package/dist/localeid.js +0 -18
  41. package/dist/localeid.js.map +0 -1
  42. package/dist/nodeid.d.ts +0 -9
  43. package/dist/nodeid.js +0 -192
  44. package/dist/nodeid.js.map +0 -1
  45. package/dist/roundToFloat.d.ts +0 -1
  46. package/dist/roundToFloat.js +0 -25
  47. package/dist/roundToFloat.js.map +0 -1
package/dist/utils.js CHANGED
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRandomInt = void 0;
4
- /***
5
- * @module node-opcua-basic-types
6
- */
7
- /**
8
- * return a random integer value in the range of min inclusive and max exclusive
9
- * @method getRandomInt
10
- * @param min
11
- * @param max
12
- * @return {*}
13
- * @private
14
- */
15
- function getRandomInt(min, max) {
16
- // note : Math.random() returns a random number between 0 (inclusive) and 1 (exclusive):
17
- return Math.floor(Math.random() * (max - min)) + min;
18
- }
19
- exports.getRandomInt = getRandomInt;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandomInt = void 0;
4
+ /***
5
+ * @module node-opcua-basic-types
6
+ */
7
+ /**
8
+ * return a random integer value in the range of min inclusive and max exclusive
9
+ * @method getRandomInt
10
+ * @param min
11
+ * @param max
12
+ * @return {*}
13
+ * @private
14
+ */
15
+ function getRandomInt(min, max) {
16
+ // note : Math.random() returns a random number between 0 (inclusive) and 1 (exclusive):
17
+ return Math.floor(Math.random() * (max - min)) + min;
18
+ }
19
+ exports.getRandomInt = getRandomInt;
20
20
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "node-opcua-basic-types",
3
- "version": "2.64.1",
3
+ "version": "2.68.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -basic-types",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc -b",
9
9
  "test": "echo none",
10
- "clean": "node -e \"require('rimraf').sync('dist');\"",
10
+ "clean": "npx rimraf dist *.tsbuildinfo",
11
11
  "lint": "eslint source/*.ts"
12
12
  },
13
13
  "dependencies": {
14
- "node-opcua-assert": "2.64.1",
15
- "node-opcua-binary-stream": "2.64.1",
16
- "node-opcua-buffer-utils": "2.64.1",
17
- "node-opcua-date-time": "2.64.1",
18
- "node-opcua-enum": "2.64.1",
19
- "node-opcua-guid": "2.64.1",
20
- "node-opcua-nodeid": "2.64.1",
21
- "node-opcua-status-code": "2.64.1",
22
- "node-opcua-utils": "2.64.1"
14
+ "node-opcua-assert": "2.66.0",
15
+ "node-opcua-binary-stream": "2.67.0",
16
+ "node-opcua-buffer-utils": "2.67.0",
17
+ "node-opcua-date-time": "2.68.0",
18
+ "node-opcua-enum": "2.67.0",
19
+ "node-opcua-guid": "2.66.0",
20
+ "node-opcua-nodeid": "2.68.0",
21
+ "node-opcua-status-code": "2.67.0",
22
+ "node-opcua-utils": "2.67.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "17.0.21",
26
- "node-opcua-benchmarker": "2.64.1",
27
- "node-opcua-debug": "2.64.1",
25
+ "@types/node": "17.0.23",
26
+ "node-opcua-benchmarker": "2.67.0",
27
+ "node-opcua-debug": "2.68.0",
28
28
  "should": "^13.2.3"
29
29
  },
30
30
  "author": "Etienne Rossignon",
@@ -42,5 +42,5 @@
42
42
  "internet of things"
43
43
  ],
44
44
  "homepage": "http://node-opcua.github.io/",
45
- "gitHead": "b65b8738603cd475d7d99a2b20b0ae9d32b4110c"
45
+ "gitHead": "363b466440d0910acddd0cde2c37792ce4724d76"
46
46
  }
package/source/guid.ts CHANGED
@@ -11,7 +11,7 @@ import { getRandomInt } from "./utils";
11
11
  export { isValidGuid, emptyGuid } from "node-opcua-guid";
12
12
 
13
13
  function toHex(i: number, nb: number): string {
14
- return ("000000000000000" + i.toString(16)).substr(-nb);
14
+ return i.toString(16).padStart(nb, "0");
15
15
  }
16
16
 
17
17
  export type Guid = string;
package/source/node_id.ts CHANGED
@@ -169,11 +169,6 @@ function _decodeNodeId(encodingByte: number, stream: BinaryStream, _nodeId?: Nod
169
169
  default:
170
170
  // istanbul ignore next
171
171
  if (encodingByte !== EnumNodeIdEncoding.Guid) {
172
- /*jslint bitwise: true */
173
- // console.log(" encoding_byte = 0x" + encodingByte.toString(16),
174
- // " bin=", ("0000000000000000" + encodingByte.toString(2)).substr(-16),
175
- // encodingByte, encodingByte & 0x3f);
176
-
177
172
  throw new Error("decodeNodeId: unknown encoding_byte = 0x" + encodingByte.toString(16));
178
173
  }
179
174
  namespace = stream.readUInt16();
@@ -1,9 +0,0 @@
1
- /***
2
- * @module node-opcua-basic-types
3
- */
4
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
5
- import { UAString } from "./string";
6
- export declare function validateLocaleId(value: any): boolean;
7
- export declare type LocaleId = UAString;
8
- export declare function encodeLocaleId(localeId: LocaleId, stream: OutputBinaryStream): void;
9
- export declare function decodeLocaleId(stream: BinaryStream): LocaleId;
package/dist/localeid.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const string_1 = require("./string");
4
- function validateLocaleId(value) {
5
- // TODO : check that localeID is well-formed
6
- // see part 3 $8.4 page 63
7
- return true;
8
- }
9
- exports.validateLocaleId = validateLocaleId;
10
- function encodeLocaleId(localeId, stream) {
11
- return string_1.encodeUAString(localeId, stream);
12
- }
13
- exports.encodeLocaleId = encodeLocaleId;
14
- function decodeLocaleId(stream) {
15
- return string_1.decodeUAString(stream);
16
- }
17
- exports.decodeLocaleId = decodeLocaleId;
18
- //# sourceMappingURL=localeid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localeid.js","sourceRoot":"","sources":["../source/localeid.ts"],"names":[],"mappings":";;AAKA,qCAAoE;AAEpE,SAAgB,gBAAgB,CAAC,KAAU;IACvC,4CAA4C;IAC5C,0BAA0B;IAC1B,OAAO,IAAI,CAAC;AAChB,CAAC;AAJD,4CAIC;AAGD,SAAgB,cAAc,CAAC,QAAkB,EAAE,MAA0B;IACzE,OAAO,uBAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC;AAFD,wCAEC;AAED,SAAgB,cAAc,CAAC,MAAoB;IAC/C,OAAO,uBAAc,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC"}
package/dist/nodeid.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
2
- import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
3
- export declare function isValidNodeId(nodeId: any): boolean;
4
- export declare function randomNodeId(): NodeId;
5
- export declare function encodeNodeId(nodeId: NodeId, stream: OutputBinaryStream): void;
6
- export declare function encodeExpandedNodeId(expandedNodeId: ExpandedNodeId, stream: OutputBinaryStream): void;
7
- export declare function decodeNodeId(stream: BinaryStream): NodeId;
8
- export declare function decodeExpandedNodeId(stream: BinaryStream): ExpandedNodeId;
9
- export { coerceNodeId, coerceExpandedNodeId } from "node-opcua-nodeid";
package/dist/nodeid.js DELETED
@@ -1,192 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /***
4
- * @module node-opcua-basic-types
5
- */
6
- const node_opcua_assert_1 = require("node-opcua-assert");
7
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
8
- const byte_string_1 = require("./byte_string");
9
- const guid_1 = require("./guid");
10
- const integers_1 = require("./integers");
11
- const string_1 = require("./string");
12
- const utils_1 = require("./utils");
13
- function isUInt8(value) {
14
- return value >= 0 && value <= 0xff;
15
- }
16
- function isUInt16(value) {
17
- return value >= 0 && value <= 0xffff;
18
- }
19
- function nodeID_encodingByte(nodeId) {
20
- if (!nodeId) {
21
- return 0;
22
- }
23
- node_opcua_assert_1.assert(nodeId.hasOwnProperty("identifierType"));
24
- let encodingByte = 0;
25
- if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.NUMERIC) {
26
- if (isUInt8(nodeId.value) &&
27
- !nodeId.namespace &&
28
- !nodeId.namespaceUri &&
29
- !nodeId.serverIndex) {
30
- encodingByte = encodingByte | 0 /* TwoBytes */;
31
- }
32
- else if (isUInt16(nodeId.value) &&
33
- isUInt8(nodeId.namespace) &&
34
- !nodeId.namespaceUri &&
35
- !nodeId.serverIndex) {
36
- encodingByte = encodingByte | 1 /* FourBytes */;
37
- }
38
- else {
39
- encodingByte = encodingByte | 2 /* Numeric */;
40
- }
41
- }
42
- else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.STRING) {
43
- encodingByte = encodingByte | 3 /* String */;
44
- }
45
- else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.BYTESTRING) {
46
- encodingByte = encodingByte | 5 /* ByteString */;
47
- }
48
- else if (nodeId.identifierType === node_opcua_nodeid_1.NodeIdType.GUID) {
49
- encodingByte = encodingByte | 4 /* Guid */;
50
- }
51
- if (nodeId.hasOwnProperty("namespaceUri") && nodeId.namespaceUri) {
52
- encodingByte = encodingByte | 128 /* NamespaceUriFlag */;
53
- }
54
- if (nodeId.hasOwnProperty("serverIndex") && nodeId.serverIndex) {
55
- encodingByte = encodingByte | 64 /* ServerIndexFlag */;
56
- }
57
- return encodingByte;
58
- }
59
- function isValidNodeId(nodeId) {
60
- if (nodeId === null || nodeId === void 0) {
61
- return false;
62
- }
63
- return nodeId.hasOwnProperty("identifierType");
64
- }
65
- exports.isValidNodeId = isValidNodeId;
66
- function randomNodeId() {
67
- const value = utils_1.getRandomInt(0, 0xfffff);
68
- const namespace = utils_1.getRandomInt(0, 3);
69
- return node_opcua_nodeid_1.makeNodeId(value, namespace);
70
- }
71
- exports.randomNodeId = randomNodeId;
72
- function _encodeNodeId(encodingByte, nodeId, stream) {
73
- stream.writeUInt8(encodingByte); // encoding byte
74
- /*jslint bitwise: true */
75
- encodingByte &= 0x3f;
76
- switch (encodingByte) {
77
- case 0 /* TwoBytes */:
78
- stream.writeUInt8(nodeId ? nodeId.value : 0);
79
- break;
80
- case 1 /* FourBytes */:
81
- stream.writeUInt8(nodeId.namespace);
82
- stream.writeUInt16(nodeId.value);
83
- break;
84
- case 2 /* Numeric */:
85
- stream.writeUInt16(nodeId.namespace);
86
- stream.writeUInt32(nodeId.value);
87
- break;
88
- case 3 /* String */:
89
- stream.writeUInt16(nodeId.namespace);
90
- string_1.encodeString(nodeId.value, stream);
91
- break;
92
- case 5 /* ByteString */:
93
- stream.writeUInt16(nodeId.namespace);
94
- byte_string_1.encodeByteString(nodeId.value, stream);
95
- break;
96
- default:
97
- node_opcua_assert_1.assert(encodingByte === 4 /* Guid */);
98
- stream.writeUInt16(nodeId.namespace);
99
- guid_1.encodeGuid(nodeId.value, stream);
100
- break;
101
- }
102
- }
103
- function encodeNodeId(nodeId, stream) {
104
- let encodingByte = nodeID_encodingByte(nodeId);
105
- /*jslint bitwise: true */
106
- encodingByte &= 0x3f;
107
- _encodeNodeId(encodingByte, nodeId, stream);
108
- }
109
- exports.encodeNodeId = encodeNodeId;
110
- function encodeExpandedNodeId(expandedNodeId, stream) {
111
- node_opcua_assert_1.assert(expandedNodeId, "encodeExpandedNodeId: must provide a valid expandedNodeId");
112
- const encodingByte = nodeID_encodingByte(expandedNodeId);
113
- _encodeNodeId(encodingByte, expandedNodeId, stream);
114
- if (encodingByte & 128 /* NamespaceUriFlag */) {
115
- string_1.encodeString(expandedNodeId.namespaceUri, stream);
116
- }
117
- if (encodingByte & 64 /* ServerIndexFlag */) {
118
- integers_1.encodeUInt32(expandedNodeId.serverIndex, stream);
119
- }
120
- }
121
- exports.encodeExpandedNodeId = encodeExpandedNodeId;
122
- function _decodeNodeId(encodingByte, stream) {
123
- let value;
124
- let namespace;
125
- let nodeIdType;
126
- /*jslint bitwise: true */
127
- encodingByte &= 0x3f; // 1 to 5
128
- switch (encodingByte) {
129
- case 0 /* TwoBytes */:
130
- value = stream.readUInt8();
131
- nodeIdType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
132
- break;
133
- case 1 /* FourBytes */:
134
- namespace = stream.readUInt8();
135
- value = stream.readUInt16();
136
- nodeIdType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
137
- break;
138
- case 2 /* Numeric */:
139
- namespace = stream.readUInt16();
140
- value = stream.readUInt32();
141
- nodeIdType = node_opcua_nodeid_1.NodeIdType.NUMERIC;
142
- break;
143
- case 3 /* String */:
144
- namespace = stream.readUInt16();
145
- value = string_1.decodeString(stream);
146
- nodeIdType = node_opcua_nodeid_1.NodeIdType.STRING;
147
- break;
148
- case 5 /* ByteString */:
149
- namespace = stream.readUInt16();
150
- value = byte_string_1.decodeByteString(stream);
151
- nodeIdType = node_opcua_nodeid_1.NodeIdType.BYTESTRING;
152
- break;
153
- default:
154
- if (encodingByte !== 4 /* Guid */) {
155
- /*jslint bitwise: true */
156
- // console.log(" encoding_byte = 0x" + encodingByte.toString(16),
157
- // " bin=", ("0000000000000000" + encodingByte.toString(2)).substr(-16),
158
- // encodingByte, encodingByte & 0x3f);
159
- throw new Error(" encoding_byte = " + encodingByte.toString(16));
160
- }
161
- namespace = stream.readUInt16();
162
- value = guid_1.decodeGuid(stream);
163
- nodeIdType = node_opcua_nodeid_1.NodeIdType.GUID;
164
- node_opcua_assert_1.assert(guid_1.isValidGuid(value));
165
- break;
166
- }
167
- return new node_opcua_nodeid_1.NodeId(nodeIdType, value, namespace);
168
- }
169
- function decodeNodeId(stream) {
170
- const encodingByte = stream.readUInt8();
171
- return _decodeNodeId(encodingByte, stream);
172
- }
173
- exports.decodeNodeId = decodeNodeId;
174
- function decodeExpandedNodeId(stream) {
175
- const encodingByte = stream.readUInt8();
176
- const expandedNodeId = _decodeNodeId(encodingByte, stream);
177
- expandedNodeId.namespaceUri = null;
178
- expandedNodeId.serverIndex = 0;
179
- if (encodingByte & 128 /* NamespaceUriFlag */) {
180
- expandedNodeId.namespaceUri = string_1.decodeString(stream);
181
- }
182
- if (encodingByte & 64 /* ServerIndexFlag */) {
183
- expandedNodeId.serverIndex = integers_1.decodeUInt32(stream);
184
- }
185
- const e = expandedNodeId;
186
- return new node_opcua_nodeid_1.ExpandedNodeId(e.identifierType, e.value, e.namespace, e.namespaceUri, e.serverIndex);
187
- }
188
- exports.decodeExpandedNodeId = decodeExpandedNodeId;
189
- var node_opcua_nodeid_2 = require("node-opcua-nodeid");
190
- exports.coerceNodeId = node_opcua_nodeid_2.coerceNodeId;
191
- exports.coerceExpandedNodeId = node_opcua_nodeid_2.coerceExpandedNodeId;
192
- //# sourceMappingURL=nodeid.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodeid.js","sourceRoot":"","sources":["../source/nodeid.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,yDAA2C;AAG3C,yDAAmF;AAEnF,+CAAmE;AACnE,iCAA6D;AAC7D,yCAAwD;AACxD,qCAAsD;AACtD,mCAAuC;AAevC,SAAS,OAAO,CAAC,KAAa;IAC1B,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC;AACvC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC3B,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC;AACzC,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc;IACvC,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,CAAC,CAAC;KACZ;IACD,0BAAM,CAAC,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAEhD,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,IAAI,MAAM,CAAC,cAAc,KAAK,8BAAU,CAAC,OAAO,EAAE;QAC9C,IAAI,OAAO,CAAC,MAAM,CAAC,KAAe,CAAC;YAC/B,CAAC,MAAM,CAAC,SAAS;YACjB,CAAE,MAAyB,CAAC,YAAY;YACxC,CAAE,MAAyB,CAAC,WAAW,EAAE;YACzC,YAAY,GAAG,YAAY,mBAA8B,CAAC;SAC7D;aAAM,IACH,QAAQ,CAAC,MAAM,CAAC,KAAe,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;YACzB,CAAE,MAAyB,CAAC,YAAY;YACxC,CAAE,MAAyB,CAAC,WAAW,EACzC;YACE,YAAY,GAAG,YAAY,oBAA+B,CAAC;SAC9D;aAAM;YACH,YAAY,GAAG,YAAY,kBAA6B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EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;AACrG,CAAC;AAdD,oDAcC;AAED,uDAAuE;AAA9D,2CAAA,YAAY,CAAA;AAAE,mDAAA,oBAAoB,CAAA"}
@@ -1 +0,0 @@
1
- export declare function roundToFloat2(float: number): number;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function roundToFloat2(float) {
4
- if (float === 0) {
5
- return float;
6
- }
7
- // this method artificially rounds a float to 7 significant digit in base 10
8
- // Note:
9
- // this is to overcome the that that Javascript doesn't provide single precision float values (32 bits)
10
- // but only double precision float values
11
- // wikipedia:(http://en.wikipedia.org/wiki/Floating_point)
12
- //
13
- // * Single precision, usually used to represent the "float" type in the C language family
14
- // (though this is not guaranteed). This is a binary format that occupies 32 bits (4 bytes) and its
15
- // significand has a precision of 24 bits (about 7 decimal digits).
16
- // * Double precision, usually used to represent the "double" type in the C language family
17
- // (though this is not guaranteed). This is a binary format that occupies 64 bits (8 bytes) and its
18
- // significand has a precision of 53 bits (about 16 decimal digits).
19
- //
20
- const nbDigits = Math.ceil(Math.log(Math.abs(float)) / Math.log(10));
21
- const scale = Math.pow(10, -nbDigits + 2);
22
- return Math.round(float * scale) / scale;
23
- }
24
- exports.roundToFloat2 = roundToFloat2;
25
- //# sourceMappingURL=roundToFloat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"roundToFloat.js","sourceRoot":"","sources":["../source/roundToFloat.ts"],"names":[],"mappings":";;AAAA,SAAgB,aAAa,CAAC,KAAa;IACvC,IAAI,KAAK,KAAK,CAAC,EAAE;QACb,OAAO,KAAK,CAAC;KAChB;IACD,4EAA4E;IAC5E,QAAQ;IACR,2GAA2G;IAC3G,2CAA2C;IAE3C,0DAA0D;IAC1D,EAAE;IACF,0FAA0F;IAC1F,qGAAqG;IACrG,qEAAqE;IACrE,2FAA2F;IAC3F,qGAAqG;IACrG,sEAAsE;IACtE,EAAE;IACF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAC7C,CAAC;AArBD,sCAqBC"}