@iobroker/adapter-react-v5 0.0.2

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 (264) hide show
  1. package/Components/404.js +155 -0
  2. package/Components/404.js.map +1 -0
  3. package/Components/ColorPicker.js +313 -0
  4. package/Components/ColorPicker.js.map +1 -0
  5. package/Components/ComplexCron.js +606 -0
  6. package/Components/ComplexCron.js.map +1 -0
  7. package/Components/FileBrowser.js +2147 -0
  8. package/Components/FileBrowser.js.map +1 -0
  9. package/Components/FileViewer.js +245 -0
  10. package/Components/FileViewer.js.map +1 -0
  11. package/Components/Icon.js +234 -0
  12. package/Components/Icon.js.map +1 -0
  13. package/Components/IconPicker.js +188 -0
  14. package/Components/IconPicker.js.map +1 -0
  15. package/Components/IconSelector.js +337 -0
  16. package/Components/IconSelector.js.map +1 -0
  17. package/Components/Image.js +215 -0
  18. package/Components/Image.js.map +1 -0
  19. package/Components/Loader.js +134 -0
  20. package/Components/Loader.js.map +1 -0
  21. package/Components/Loaders/PT.css +109 -0
  22. package/Components/Loaders/PT.js +104 -0
  23. package/Components/Loaders/PT.js.map +1 -0
  24. package/Components/Loaders/Vendor.css +13 -0
  25. package/Components/Loaders/Vendor.js +108 -0
  26. package/Components/Loaders/Vendor.js.map +1 -0
  27. package/Components/Logo.js +230 -0
  28. package/Components/Logo.js.map +1 -0
  29. package/Components/MDUtils.js +141 -0
  30. package/Components/MDUtils.js.map +1 -0
  31. package/Components/ObjectBrowser.js +6119 -0
  32. package/Components/ObjectBrowser.js.map +1 -0
  33. package/Components/Router.js +152 -0
  34. package/Components/Router.js.map +1 -0
  35. package/Components/SaveCloseButtons.js +177 -0
  36. package/Components/SaveCloseButtons.js.map +1 -0
  37. package/Components/Schedule.js +1891 -0
  38. package/Components/Schedule.js.map +1 -0
  39. package/Components/SelectWithIcon.js +235 -0
  40. package/Components/SelectWithIcon.js.map +1 -0
  41. package/Components/SimpleCron/cron2text.js +563 -0
  42. package/Components/SimpleCron/cron2text.js.map +1 -0
  43. package/Components/SimpleCron/cronText.js +60 -0
  44. package/Components/SimpleCron/cronText.js.map +1 -0
  45. package/Components/SimpleCron/index.js +861 -0
  46. package/Components/SimpleCron/index.js.map +1 -0
  47. package/Components/SimpleCron/jquery.cron.locale.js +322 -0
  48. package/Components/SimpleCron/jquery.cron.locale.js.map +1 -0
  49. package/Components/TabContainer.js +108 -0
  50. package/Components/TabContainer.js.map +1 -0
  51. package/Components/TabContent.js +96 -0
  52. package/Components/TabContent.js.map +1 -0
  53. package/Components/TabHeader.js +72 -0
  54. package/Components/TabHeader.js.map +1 -0
  55. package/Components/TextWithIcon.js +148 -0
  56. package/Components/TextWithIcon.js.map +1 -0
  57. package/Components/ToggleThemeMenu.js +49 -0
  58. package/Components/ToggleThemeMenu.js.map +1 -0
  59. package/Components/TreeTable.js +1030 -0
  60. package/Components/TreeTable.js.map +1 -0
  61. package/Components/Utils.js +1763 -0
  62. package/Components/Utils.js.map +1 -0
  63. package/Components/copy-to-clipboard.js +183 -0
  64. package/Components/copy-to-clipboard.js.map +1 -0
  65. package/Components/loader.css +222 -0
  66. package/Components/types.d.ts +121 -0
  67. package/Connection.js +3334 -0
  68. package/Connection.js.map +1 -0
  69. package/Dialogs/ComplexCron.js +193 -0
  70. package/Dialogs/ComplexCron.js.map +1 -0
  71. package/Dialogs/Confirm.js +211 -0
  72. package/Dialogs/Confirm.js.map +1 -0
  73. package/Dialogs/Cron.js +254 -0
  74. package/Dialogs/Cron.js.map +1 -0
  75. package/Dialogs/Error.js +137 -0
  76. package/Dialogs/Error.js.map +1 -0
  77. package/Dialogs/Message.js +118 -0
  78. package/Dialogs/Message.js.map +1 -0
  79. package/Dialogs/SelectID.js +313 -0
  80. package/Dialogs/SelectID.js.map +1 -0
  81. package/Dialogs/SimpleCron.js +177 -0
  82. package/Dialogs/SimpleCron.js.map +1 -0
  83. package/Dialogs/TextInput.js +194 -0
  84. package/Dialogs/TextInput.js.map +1 -0
  85. package/GenericApp.js +1022 -0
  86. package/GenericApp.js.map +1 -0
  87. package/LICENSE +22 -0
  88. package/Prompt.js +21 -0
  89. package/Prompt.js.map +1 -0
  90. package/README.md +645 -0
  91. package/Theme.js +422 -0
  92. package/Theme.js.map +1 -0
  93. package/assets/devices/Alarm Systems.svg +19 -0
  94. package/assets/devices/Amplifier.svg +22 -0
  95. package/assets/devices/Awnings.svg +5 -0
  96. package/assets/devices/Battery Status.svg +5 -0
  97. package/assets/devices/Ceiling Spotlights.svg +16 -0
  98. package/assets/devices/Chandelier.svg +7 -0
  99. package/assets/devices/Climate.svg +12 -0
  100. package/assets/devices/Coffee Makers.svg +6 -0
  101. package/assets/devices/Cold Water.svg +31 -0
  102. package/assets/devices/Computer.svg +21 -0
  103. package/assets/devices/Consumption.svg +8 -0
  104. package/assets/devices/Curtains.svg +43 -0
  105. package/assets/devices/Dishwashers.svg +12 -0
  106. package/assets/devices/Doors.svg +6 -0
  107. package/assets/devices/Doorstep.svg +35 -0
  108. package/assets/devices/Dryer.svg +14 -0
  109. package/assets/devices/Fan.svg +20 -0
  110. package/assets/devices/Floor Lamps.svg +5 -0
  111. package/assets/devices/Garage Doors.svg +9 -0
  112. package/assets/devices/Gates.svg +32 -0
  113. package/assets/devices/Hairdryer.svg +23 -0
  114. package/assets/devices/Handle.svg +6 -0
  115. package/assets/devices/Hanging Lamps.svg +9 -0
  116. package/assets/devices/Heater.svg +44 -0
  117. package/assets/devices/Hoods.svg +12 -0
  118. package/assets/devices/Hot Water.svg +10 -0
  119. package/assets/devices/Humidity.svg +41 -0
  120. package/assets/devices/Iron.svg +5 -0
  121. package/assets/devices/Irrigation.svg +42 -0
  122. package/assets/devices/Led Strip.svg +31 -0
  123. package/assets/devices/Light.svg +30 -0
  124. package/assets/devices/Lightings.svg +46 -0
  125. package/assets/devices/Lock.svg +19 -0
  126. package/assets/devices/Louvre.svg +7 -0
  127. package/assets/devices/Mowing Machine.svg +9 -0
  128. package/assets/devices/Music.svg +13 -0
  129. package/assets/devices/Outdoor Blinds.svg +7 -0
  130. package/assets/devices/People.svg +19 -0
  131. package/assets/devices/Pool.svg +8 -0
  132. package/assets/devices/Power Consumption.svg +13 -0
  133. package/assets/devices/Printer.svg +10 -0
  134. package/assets/devices/Pump.svg +10 -0
  135. package/assets/devices/Receiver.svg +19 -0
  136. package/assets/devices/Sconces.svg +10 -0
  137. package/assets/devices/Security.svg +34 -0
  138. package/assets/devices/Shading.svg +5 -0
  139. package/assets/devices/Shutters.svg +11 -0
  140. package/assets/devices/SmokeDetector.svg +13 -0
  141. package/assets/devices/Sockets.svg +13 -0
  142. package/assets/devices/Speaker.svg +35 -0
  143. package/assets/devices/Stove.svg +12 -0
  144. package/assets/devices/Table Lamps.svg +12 -0
  145. package/assets/devices/Temperature Sensors.svg +28 -0
  146. package/assets/devices/Tv.svg +8 -0
  147. package/assets/devices/Vacuum Cleaner.svg +16 -0
  148. package/assets/devices/Ventilation.svg +12 -0
  149. package/assets/devices/Washing Machines.svg +16 -0
  150. package/assets/devices/Water Consumption.svg +6 -0
  151. package/assets/devices/Water Heater.svg +8 -0
  152. package/assets/devices/Water.svg +40 -0
  153. package/assets/devices/Weather.svg +28 -0
  154. package/assets/devices/Window.svg +8 -0
  155. package/assets/devices/list.json +994 -0
  156. package/assets/devices/names.txt +63 -0
  157. package/assets/devices/parseNames.js +34 -0
  158. package/assets/lamp_ceiling.svg +9 -0
  159. package/assets/lamp_table.svg +8 -0
  160. package/assets/no_icon.svg +9 -0
  161. package/assets/rooms/Anteroom.svg +53 -0
  162. package/assets/rooms/Attic.svg +21 -0
  163. package/assets/rooms/Balcony.svg +13 -0
  164. package/assets/rooms/Barn.svg +6 -0
  165. package/assets/rooms/Basement.svg +5 -0
  166. package/assets/rooms/Bathroom.svg +38 -0
  167. package/assets/rooms/Bedroom.svg +5 -0
  168. package/assets/rooms/Boiler Room.svg +13 -0
  169. package/assets/rooms/Carport.svg +17 -0
  170. package/assets/rooms/Cellar.svg +89 -0
  171. package/assets/rooms/Chamber.svg +9 -0
  172. package/assets/rooms/Corridor.svg +53 -0
  173. package/assets/rooms/Dining Area.svg +37 -0
  174. package/assets/rooms/Dining Room.svg +37 -0
  175. package/assets/rooms/Dining.svg +37 -0
  176. package/assets/rooms/Dressing Room.svg +5 -0
  177. package/assets/rooms/Driveway.svg +15 -0
  178. package/assets/rooms/Entrance.svg +44 -0
  179. package/assets/rooms/Equipment Room.svg +15 -0
  180. package/assets/rooms/Front Yard.svg +64 -0
  181. package/assets/rooms/Gallery.svg +14 -0
  182. package/assets/rooms/Garage.svg +20 -0
  183. package/assets/rooms/Garden.svg +13 -0
  184. package/assets/rooms/Ground Floor.svg +95 -0
  185. package/assets/rooms/Guest Bathroom.svg +33 -0
  186. package/assets/rooms/Guest Room.svg +5 -0
  187. package/assets/rooms/Gym.svg +5 -0
  188. package/assets/rooms/Hall.svg +19 -0
  189. package/assets/rooms/Home Theater.svg +8 -0
  190. package/assets/rooms/Kitchen.svg +18 -0
  191. package/assets/rooms/Laundry Room.svg +12 -0
  192. package/assets/rooms/Living Area.svg +11 -0
  193. package/assets/rooms/Living Room.svg +10 -0
  194. package/assets/rooms/Locker Room.svg +17 -0
  195. package/assets/rooms/Nursery.svg +5 -0
  196. package/assets/rooms/Office.svg +8 -0
  197. package/assets/rooms/Outdoors.svg +7 -0
  198. package/assets/rooms/Playroom.svg +6 -0
  199. package/assets/rooms/Pool.svg +8 -0
  200. package/assets/rooms/Rear Wall.svg +30 -0
  201. package/assets/rooms/Second Floor.svg +95 -0
  202. package/assets/rooms/Shed.svg +16 -0
  203. package/assets/rooms/Sleeping Area.svg +22 -0
  204. package/assets/rooms/Stairway.svg +5 -0
  205. package/assets/rooms/Stairwell.svg +15 -0
  206. package/assets/rooms/Storeroom.svg +5 -0
  207. package/assets/rooms/Summer House.svg +27 -0
  208. package/assets/rooms/Swimming Pool.svg +21 -0
  209. package/assets/rooms/Terrace.svg +7 -0
  210. package/assets/rooms/Toilet.svg +10 -0
  211. package/assets/rooms/Upstairs.svg +6 -0
  212. package/assets/rooms/Wardrobe.svg +60 -0
  213. package/assets/rooms/Washroom.svg +20 -0
  214. package/assets/rooms/Wc.svg +10 -0
  215. package/assets/rooms/Windscreen.svg +60 -0
  216. package/assets/rooms/Workshop.svg +23 -0
  217. package/assets/rooms/Workspace.svg +8 -0
  218. package/assets/rooms/list.json +946 -0
  219. package/assets/rooms/names.txt +60 -0
  220. package/assets/rooms/parseNames.js +34 -0
  221. package/gulpfile.js +113 -0
  222. package/i18n/de.json +280 -0
  223. package/i18n/en.json +280 -0
  224. package/i18n/es.json +267 -0
  225. package/i18n/fr.json +267 -0
  226. package/i18n/it.json +267 -0
  227. package/i18n/nl.json +267 -0
  228. package/i18n/pl.json +267 -0
  229. package/i18n/pt.json +267 -0
  230. package/i18n/ru.json +280 -0
  231. package/i18n/zh-cn.json +267 -0
  232. package/i18n.js +171 -0
  233. package/i18n.js.map +1 -0
  234. package/icons/IconAdapter.js +39 -0
  235. package/icons/IconAdapter.js.map +1 -0
  236. package/icons/IconAlias.js +39 -0
  237. package/icons/IconAlias.js.map +1 -0
  238. package/icons/IconChannel.js +80 -0
  239. package/icons/IconChannel.js.map +1 -0
  240. package/icons/IconClearFilter.js +41 -0
  241. package/icons/IconClearFilter.js.map +1 -0
  242. package/icons/IconClosed.js +39 -0
  243. package/icons/IconClosed.js.map +1 -0
  244. package/icons/IconCopy.js +48 -0
  245. package/icons/IconCopy.js.map +1 -0
  246. package/icons/IconDevice.js +147 -0
  247. package/icons/IconDevice.js.map +1 -0
  248. package/icons/IconDocument.js +39 -0
  249. package/icons/IconDocument.js.map +1 -0
  250. package/icons/IconExpert.js +50 -0
  251. package/icons/IconExpert.js.map +1 -0
  252. package/icons/IconFx.js +39 -0
  253. package/icons/IconFx.js.map +1 -0
  254. package/icons/IconInstance.js +39 -0
  255. package/icons/IconInstance.js.map +1 -0
  256. package/icons/IconLogout.js +50 -0
  257. package/icons/IconLogout.js.map +1 -0
  258. package/icons/IconOpen.js +39 -0
  259. package/icons/IconOpen.js.map +1 -0
  260. package/icons/IconState.js +58 -0
  261. package/icons/IconState.js.map +1 -0
  262. package/index.css +55 -0
  263. package/package.json +42 -0
  264. package/types.d.ts +84 -0
@@ -0,0 +1,1763 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _i18n = _interopRequireDefault(require("../i18n"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
+
14
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
+
16
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
+
18
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
+
20
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
+
22
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23
+
24
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
+
26
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
27
+
28
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
+
30
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
31
+
32
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
33
+
34
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
35
+
36
+ var NAMESPACE = 'material';
37
+ var days = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
38
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
39
+ var QUALITY_BITS = {
40
+ 0x00: '0x00 - good',
41
+ 0x01: '0x01 - general problem',
42
+ 0x02: '0x02 - no connection problem',
43
+ 0x10: '0x10 - substitute value from controller',
44
+ 0x20: '0x20 - substitute initial value',
45
+ 0x40: '0x40 - substitute value from device or instance',
46
+ 0x80: '0x80 - substitute value from sensor',
47
+ 0x11: '0x11 - general problem by instance',
48
+ 0x41: '0x41 - general problem by device',
49
+ 0x81: '0x81 - general problem by sensor',
50
+ 0x12: '0x12 - instance not connected',
51
+ 0x42: '0x42 - device not connected',
52
+ 0x82: '0x82 - sensor not connected',
53
+ 0x44: '0x44 - device reports error',
54
+ 0x84: '0x84 - sensor reports error'
55
+ };
56
+
57
+ var Utils = /*#__PURE__*/function () {
58
+ function Utils() {
59
+ _classCallCheck(this, Utils);
60
+ }
61
+
62
+ _createClass(Utils, null, [{
63
+ key: "CapitalWords",
64
+ value:
65
+ /**
66
+ * Capitalize words.
67
+ * @param {string | undefined} name
68
+ * @returns {string}
69
+ */
70
+ function CapitalWords(name) {
71
+ return (name || '').split(/[\s_]/).filter(function (item) {
72
+ return item;
73
+ }).map(function (word) {
74
+ return word ? word[0].toUpperCase() + word.substring(1).toLowerCase() : '';
75
+ }).join(' ');
76
+ }
77
+ }, {
78
+ key: "formatSeconds",
79
+ value: function formatSeconds(seconds) {
80
+ var days = Math.floor(seconds / (3600 * 24));
81
+ seconds %= 3600 * 24;
82
+ var hours = Math.floor(seconds / 3600);
83
+
84
+ if (hours < 10) {
85
+ hours = '0' + hours;
86
+ }
87
+
88
+ seconds %= 3600;
89
+ var minutes = Math.floor(seconds / 60);
90
+
91
+ if (minutes < 10) {
92
+ minutes = '0' + minutes;
93
+ }
94
+
95
+ seconds %= 60;
96
+ seconds = Math.floor(seconds);
97
+
98
+ if (seconds < 10) {
99
+ seconds = '0' + seconds;
100
+ }
101
+
102
+ var text = '';
103
+
104
+ if (days) {
105
+ text += days + ' ' + _i18n["default"].t('daysShortText') + ' ';
106
+ }
107
+
108
+ text += hours + ':' + minutes + ':' + seconds;
109
+ return text;
110
+ }
111
+ /**
112
+ * Get the name of the object by id from the name or description.
113
+ * @param {Record<string, ioBroker.Object>} objects
114
+ * @param {string} id
115
+ * @param {{ name: any; } | ioBroker.Languages | null} settings
116
+ * @param {{ language?: ioBroker.Languages; }} options
117
+ * @param {boolean} [isDesc] Set to true to get the description.
118
+ * @returns {string}
119
+ */
120
+
121
+ }, {
122
+ key: "getObjectName",
123
+ value: function getObjectName(objects, id, settings, options, isDesc) {
124
+ var item = objects[id];
125
+ var text = id;
126
+ var attr = isDesc ? 'desc' : 'name';
127
+
128
+ if (typeof settings === 'string' && !options) {
129
+ options = {
130
+ language: settings
131
+ };
132
+ settings = null;
133
+ }
134
+
135
+ options = options || {};
136
+
137
+ if (!options.language) {
138
+ options.language = objects['system.config'] && objects['system.config'].common && objects['system.config'].common.language || window.sysLang || 'en';
139
+ }
140
+
141
+ if (settings && settings.name) {
142
+ text = settings.name;
143
+
144
+ if (_typeof(text) === 'object') {
145
+ text = text[options.language] || text.en;
146
+ }
147
+ } else if (item && item.common && item.common[attr]) {
148
+ text = item.common[attr];
149
+
150
+ if (attr !== 'desc' && !text && item.common.desc) {
151
+ text = item.common.desc;
152
+ }
153
+
154
+ if (_typeof(text) === 'object') {
155
+ text = text[options.language] || text.en || text.de || text.ru || '';
156
+ }
157
+
158
+ text = (text || '').toString().replace(/[_.]/g, ' ');
159
+
160
+ if (text === text.toUpperCase()) {
161
+ text = text[0] + text.substring(1).toLowerCase();
162
+ }
163
+ } else {
164
+ var pos = id.lastIndexOf('.');
165
+ text = id.substring(pos + 1).replace(/[_.]/g, ' ');
166
+ text = Utils.CapitalWords(text);
167
+ }
168
+
169
+ return text.trim();
170
+ }
171
+ /**
172
+ * Get the name of the object from the name or description.
173
+ * @param {ioBroker.PartialObject} obj
174
+ * @param {{ name: any; } | ioBroker.Languages | null } settings or language
175
+ * @param {{ language?: ioBroker.Languages; } } options
176
+ * @param {boolean} [isDesc] Set to true to get the description.
177
+ * @returns {string}
178
+ */
179
+
180
+ }, {
181
+ key: "getObjectNameFromObj",
182
+ value: function getObjectNameFromObj(obj, settings, options, isDesc) {
183
+ var item = obj;
184
+ var text = obj && obj._id || '';
185
+ var attr = isDesc ? 'desc' : 'name';
186
+
187
+ if (typeof settings === 'string' && !options) {
188
+ options = {
189
+ language: settings
190
+ };
191
+ settings = null;
192
+ }
193
+
194
+ options = options || {};
195
+
196
+ if (settings && settings.name) {
197
+ text = settings.name;
198
+
199
+ if (_typeof(text) === 'object') {
200
+ text = text[options.language] || text.en;
201
+ }
202
+ } else if (item && item.common && item.common[attr]) {
203
+ text = item.common[attr];
204
+
205
+ if (attr !== 'desc' && !text && item.common.desc) {
206
+ text = item.common.desc;
207
+ }
208
+
209
+ if (_typeof(text) === 'object') {
210
+ text = text[options.language] || text.en;
211
+ }
212
+
213
+ text = (text || '').toString().replace(/[_.]/g, ' ');
214
+
215
+ if (text === text.toUpperCase()) {
216
+ text = text[0] + text.substring(1).toLowerCase();
217
+ }
218
+ }
219
+
220
+ return text.trim();
221
+ }
222
+ /**
223
+ * @param {ioBroker.PartialObject | ioBroker.ObjectCommon} obj
224
+ * @param {string} forEnumId
225
+ * @param {{ user: string; }} options
226
+ * @returns {string | null}
227
+ */
228
+
229
+ }, {
230
+ key: "getSettingsOrder",
231
+ value: function getSettingsOrder(obj, forEnumId, options) {
232
+ if (obj && obj.hasOwnProperty('common')) {
233
+ obj = obj.common;
234
+ }
235
+
236
+ var settings;
237
+
238
+ if (obj && obj.custom) {
239
+ settings = (obj.custom || {})[NAMESPACE];
240
+ var user = options.user || 'admin';
241
+
242
+ if (settings && settings[user]) {
243
+ if (forEnumId) {
244
+ if (settings[user].subOrder && settings[user].subOrder[forEnumId]) {
245
+ return JSON.parse(JSON.stringify(settings[user].subOrder[forEnumId]));
246
+ }
247
+ } else {
248
+ if (settings[user].order) {
249
+ return JSON.parse(JSON.stringify(settings[user].order));
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+ return null;
256
+ }
257
+ /**
258
+ * @param {ioBroker.PartialObject | ioBroker.ObjectCommon} obj
259
+ * @param {string} forEnumId
260
+ * @param {{ user: string; }} options
261
+ */
262
+
263
+ }, {
264
+ key: "getSettingsCustomURLs",
265
+ value: function getSettingsCustomURLs(obj, forEnumId, options) {
266
+ if (obj && obj.hasOwnProperty('common')) {
267
+ obj = obj.common;
268
+ }
269
+
270
+ var settings;
271
+
272
+ if (obj && obj.custom) {
273
+ settings = (obj.custom || {})[NAMESPACE];
274
+ var user = options.user || 'admin';
275
+
276
+ if (settings && settings[user]) {
277
+ if (forEnumId) {
278
+ if (settings[user].subURLs && settings[user].subURLs[forEnumId]) {
279
+ return JSON.parse(JSON.stringify(settings[user].subURLs[forEnumId]));
280
+ }
281
+ } else {
282
+ if (settings[user].URLs) {
283
+ return JSON.parse(JSON.stringify(settings[user].URLs));
284
+ }
285
+ }
286
+ }
287
+ }
288
+
289
+ return null;
290
+ }
291
+ /**
292
+ * Reorder the array items in list between source and dest.
293
+ * @param {Iterable<any> | ArrayLike<any>} list
294
+ * @param {number} source
295
+ * @param {number} dest
296
+ */
297
+
298
+ }, {
299
+ key: "reorder",
300
+ value: function reorder(list, source, dest) {
301
+ var result = Array.from(list);
302
+
303
+ var _result$splice = result.splice(source, 1),
304
+ _result$splice2 = _slicedToArray(_result$splice, 1),
305
+ removed = _result$splice2[0];
306
+
307
+ result.splice(dest, 0, removed);
308
+ return result;
309
+ }
310
+ }, {
311
+ key: "getSettings",
312
+ value:
313
+ /**
314
+ * @param {any} obj
315
+ * @param {{ id: any; user: any; name: any; icon: any; color: any; language: ioBroker.Languages; }} options
316
+ * @param {boolean} [defaultEnabling]
317
+ */
318
+ function getSettings(obj, options, defaultEnabling) {
319
+ var settings;
320
+ var id = obj && obj._id || options && options.id;
321
+
322
+ if (obj && obj.hasOwnProperty('common')) {
323
+ obj = obj.common;
324
+ }
325
+
326
+ if (obj && obj.custom) {
327
+ settings = obj.custom || {};
328
+ settings = settings[NAMESPACE] && settings[NAMESPACE][options.user || 'admin'] ? JSON.parse(JSON.stringify(settings[NAMESPACE][options.user || 'admin'])) : {
329
+ enabled: true
330
+ };
331
+ } else {
332
+ settings = {
333
+ enabled: defaultEnabling === undefined ? true : defaultEnabling,
334
+ useCustom: false
335
+ };
336
+ }
337
+
338
+ if (!settings.hasOwnProperty('enabled')) {
339
+ settings.enabled = defaultEnabling === undefined ? true : defaultEnabling;
340
+ }
341
+
342
+ if (false && settings.useCommon) {
343
+ if (obj.color) settings.color = obj.color;
344
+ if (obj.icon) settings.icon = obj.icon;
345
+ if (obj.name) settings.name = obj.name;
346
+ } else {
347
+ if (options) {
348
+ if (!settings.name && options.name) settings.name = options.name;
349
+ if (!settings.icon && options.icon) settings.icon = options.icon;
350
+ if (!settings.color && options.color) settings.color = options.color;
351
+ }
352
+
353
+ if (obj) {
354
+ if (!settings.color && obj.color) settings.color = obj.color;
355
+ if (!settings.icon && obj.icon) settings.icon = obj.icon;
356
+ if (!settings.name && obj.name) settings.name = obj.name;
357
+ }
358
+ }
359
+
360
+ if (_typeof(settings.name) === 'object') {
361
+ settings.name = settings.name[options.language] || settings.name.en;
362
+ settings.name = (settings.name || '').toString().replace(/_/g, ' ');
363
+
364
+ if (settings.name === settings.name.toUpperCase()) {
365
+ settings.name = settings.name[0] + settings.name.substring(1).toLowerCase();
366
+ }
367
+ }
368
+
369
+ if (!settings.name && id) {
370
+ var pos = id.lastIndexOf('.');
371
+ settings.name = id.substring(pos + 1).replace(/[_.]/g, ' ');
372
+ settings.name = (settings.name || '').toString().replace(/_/g, ' ');
373
+ settings.name = Utils.CapitalWords(settings.name);
374
+ }
375
+
376
+ return settings;
377
+ }
378
+ /**
379
+ * @param {any} obj
380
+ * @param {any} settings
381
+ * @param {{ user: any; language: ioBroker.Languages; }} options
382
+ */
383
+
384
+ }, {
385
+ key: "setSettings",
386
+ value: function setSettings(obj, settings, options) {
387
+ if (obj) {
388
+ obj.common = obj.common || {};
389
+ obj.common.custom = obj.common.custom || {};
390
+ obj.common.custom[NAMESPACE] = obj.common.custom[NAMESPACE] || {};
391
+ obj.common.custom[NAMESPACE][options.user || 'admin'] = settings;
392
+ var s = obj.common.custom[NAMESPACE][options.user || 'admin'];
393
+
394
+ if (s.useCommon) {
395
+ if (s.color !== undefined) {
396
+ obj.common.color = s.color;
397
+ delete s.color;
398
+ }
399
+
400
+ if (s.icon !== undefined) {
401
+ obj.common.icon = s.icon;
402
+ delete s.icon;
403
+ }
404
+
405
+ if (s.name !== undefined) {
406
+ if (_typeof(obj.common.name) !== 'object') {
407
+ obj.common.name = {};
408
+ obj.common.name[options.language] = s.name;
409
+ } else {
410
+ obj.common.name[options.language] = s.name;
411
+ }
412
+
413
+ delete s.name;
414
+ }
415
+ }
416
+
417
+ return true;
418
+ } else {
419
+ return false;
420
+ }
421
+ }
422
+ /**
423
+ * Get the icon for the given settings.
424
+ * @param {{ icon: string | undefined; name: string | undefined; prefix: string | undefined}} settings
425
+ * @param {any} style
426
+ * @returns {JSX.Element | null}
427
+ */
428
+
429
+ }, {
430
+ key: "getIcon",
431
+ value: function getIcon(settings, style) {
432
+ if (settings && settings.icon) {
433
+ // If UTF-8 icon
434
+ if (settings.icon.length <= 2) {
435
+ return /*#__PURE__*/_react["default"].createElement("span", {
436
+ style: style || {}
437
+ }, settings.icon);
438
+ } else if (settings.icon.startsWith('data:image')) {
439
+ return /*#__PURE__*/_react["default"].createElement("img", {
440
+ alt: settings.name,
441
+ src: settings.icon,
442
+ style: style || {}
443
+ });
444
+ } else {
445
+ // may be later some changes for second type
446
+ return /*#__PURE__*/_react["default"].createElement("img", {
447
+ alt: settings.name,
448
+ src: (settings.prefix || '') + settings.icon,
449
+ style: style || {}
450
+ });
451
+ }
452
+ }
453
+
454
+ return null;
455
+ }
456
+ /**
457
+ * Get the icon for the given object.
458
+ * @param {string} id
459
+ * @param {{ common: { icon: any; }; }} obj
460
+ * @returns {string | null}
461
+ */
462
+
463
+ }, {
464
+ key: "getObjectIcon",
465
+ value: function getObjectIcon(id, obj) {
466
+ // If id is Object
467
+ if (_typeof(id) === 'object') {
468
+ obj = id;
469
+ id = obj._id;
470
+ }
471
+
472
+ if (obj && obj.common && obj.common.icon) {
473
+ var icon = obj.common.icon; // If UTF-8 icon
474
+
475
+ if (typeof icon === 'string' && icon.length <= 2) {
476
+ return icon;
477
+ } else if (icon.startsWith('data:image')) {
478
+ return icon;
479
+ } else {
480
+ var parts = id.split('.');
481
+
482
+ if (parts[0] === 'system') {
483
+ icon = 'adapter/' + parts[2] + (icon.startsWith('/') ? '' : '/') + icon;
484
+ } else {
485
+ icon = 'adapter/' + parts[0] + (icon.startsWith('/') ? '' : '/') + icon;
486
+ }
487
+
488
+ if (window.location.pathname.match(/adapter\/[^/]+\/[^/]+\.html/)) {
489
+ icon = '../../' + icon;
490
+ } else if (window.location.pathname.match(/material\/[.\d]+/)) {
491
+ icon = '../../' + icon;
492
+ } else if (window.location.pathname.match(/material\//)) {
493
+ icon = '../' + icon;
494
+ }
495
+
496
+ return icon;
497
+ }
498
+ } else {
499
+ return null;
500
+ }
501
+ }
502
+ /**
503
+ * Splits CamelCase into words.
504
+ * @param {string | undefined} text
505
+ * @returns {string}
506
+ */
507
+
508
+ }, {
509
+ key: "splitCamelCase",
510
+ value: function splitCamelCase(text) {
511
+ if (false && text !== text.toUpperCase()) {
512
+ var words = text.split(/\s+/);
513
+
514
+ for (var i = 0; i < words.length; i++) {
515
+ var word = words[i];
516
+
517
+ if (word.toLowerCase() !== word && word.toUpperCase() !== word) {
518
+ var z = 0;
519
+ var ww = [];
520
+ var start = 0;
521
+
522
+ while (z < word.length) {
523
+ if (word[z].match(/[A-ZÜÄÖА-Я]/)) {
524
+ ww.push(word.substring(start, z));
525
+ start = z;
526
+ }
527
+
528
+ z++;
529
+ }
530
+
531
+ if (start !== z) {
532
+ ww.push(word.substring(start, z));
533
+ }
534
+
535
+ for (var k = 0; k < ww.length; k++) {
536
+ words.splice(i + k, 0, ww[k]);
537
+ }
538
+
539
+ i += ww.length;
540
+ }
541
+ }
542
+
543
+ return words.map(function (w) {
544
+ w = w.trim();
545
+
546
+ if (w) {
547
+ return w[0].toUpperCase() + w.substring(1).toLowerCase();
548
+ }
549
+
550
+ return '';
551
+ }).join(' ');
552
+ } else {
553
+ return Utils.CapitalWords(text);
554
+ }
555
+ }
556
+ /**
557
+ * Check if the given color is bright.
558
+ * https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
559
+ * @param {string | null | undefined} color
560
+ * @param {boolean} [defaultValue]
561
+ * @returns {boolean}
562
+ */
563
+
564
+ }, {
565
+ key: "isUseBright",
566
+ value: function isUseBright(color, defaultValue) {
567
+ if (color === null || color === undefined || color === '') {
568
+ return defaultValue === undefined ? true : defaultValue;
569
+ }
570
+
571
+ color = color.toString();
572
+
573
+ if (color.indexOf('#') === 0) {
574
+ color = color.slice(1);
575
+ }
576
+
577
+ var r;
578
+ var g;
579
+ var b;
580
+ var rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
581
+
582
+ if (rgb && rgb.length === 4) {
583
+ r = parseInt(rgb[1], 10);
584
+ g = parseInt(rgb[2], 10);
585
+ b = parseInt(rgb[3], 10);
586
+ } else {
587
+ // convert 3-digit hex to 6-digits.
588
+ if (color.length === 3) {
589
+ color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];
590
+ }
591
+
592
+ if (color.length !== 6) {
593
+ return false;
594
+ }
595
+
596
+ r = parseInt(color.slice(0, 2), 16);
597
+ g = parseInt(color.slice(2, 4), 16);
598
+ b = parseInt(color.slice(4, 6), 16);
599
+ } // http://stackoverflow.com/a/3943023/112731
600
+
601
+
602
+ return r * 0.299 + g * 0.587 + b * 0.114 <= 186;
603
+ }
604
+ }, {
605
+ key: "getTimeString",
606
+ value:
607
+ /**
608
+ * Get the time string in the format 00:00.
609
+ * @param {string | number} seconds
610
+ */
611
+ function getTimeString(seconds) {
612
+ seconds = parseFloat(seconds);
613
+
614
+ if (isNaN(seconds)) {
615
+ return '--:--';
616
+ }
617
+
618
+ var hours = Math.floor(seconds / 3600);
619
+ var minutes = Math.floor(seconds % 3600 / 60);
620
+ var secs = seconds % 60;
621
+
622
+ if (hours) {
623
+ if (minutes < 10) minutes = '0' + minutes;
624
+ if (secs < 10) secs = '0' + secs;
625
+ return hours + ':' + minutes + ':' + secs;
626
+ } else {
627
+ if (secs < 10) secs = '0' + secs;
628
+ return minutes + ':' + secs;
629
+ }
630
+ }
631
+ /**
632
+ * Gets the wind direction with the given angle (degrees).
633
+ * @param {number} angle in degrees.
634
+ * @returns {string | undefined}
635
+ */
636
+
637
+ }, {
638
+ key: "getWindDirection",
639
+ value: function getWindDirection(angle) {
640
+ if (angle >= 0 && angle < 11.25) {
641
+ return 'N';
642
+ } else if (angle >= 11.25 && angle < 33.75) {
643
+ return 'NNE';
644
+ } else if (angle >= 33.75 && angle < 56.25) {
645
+ return 'NE';
646
+ } else if (angle >= 56.25 && angle < 78.75) {
647
+ return 'ENE';
648
+ } else if (angle >= 78.75 && angle < 101.25) {
649
+ return 'E';
650
+ } else if (angle >= 101.25 && angle < 123.75) {
651
+ return 'ESE';
652
+ } else if (angle >= 123.75 && angle < 146.25) {
653
+ return 'SE';
654
+ } else if (angle >= 146.25 && angle < 168.75) {
655
+ return 'SSE';
656
+ } else if (angle >= 168.75 && angle < 191.25) {
657
+ return 'S';
658
+ } else if (angle >= 191.25 && angle < 213.75) {
659
+ return 'SSW';
660
+ } else if (angle >= 213.75 && angle < 236.25) {
661
+ return 'SW';
662
+ } else if (angle >= 236.25 && angle < 258.75) {
663
+ return 'WSW';
664
+ } else if (angle >= 258.75 && angle < 281.25) {
665
+ return 'W';
666
+ } else if (angle >= 281.25 && angle < 303.75) {
667
+ return 'WNW';
668
+ } else if (angle >= 303.75 && angle < 326.25) {
669
+ return 'NW';
670
+ } else if (angle >= 326.25 && angle < 348.75) {
671
+ return 'NNW';
672
+ } else if (angle >= 348.75) {
673
+ return 'N';
674
+ }
675
+ }
676
+ /**
677
+ * Pad the given number with a zero if its not 2 digits long.
678
+ * @param {string | number} num
679
+ */
680
+
681
+ }, {
682
+ key: "padding",
683
+ value: function padding(num) {
684
+ if (typeof num === 'string') {
685
+ if (num.length < 2) {
686
+ return '0' + num;
687
+ } else {
688
+ return num;
689
+ }
690
+ } else if (num < 10) {
691
+ return '0' + num;
692
+ } else {
693
+ return num;
694
+ }
695
+ }
696
+ /**
697
+ * Sets the date format.
698
+ * @param {string} format
699
+ */
700
+
701
+ }, {
702
+ key: "setDataFormat",
703
+ value: function setDataFormat(format) {
704
+ if (format) {
705
+ Utils.dateFormat = format.toUpperCase().split(/[.-/]/);
706
+ Utils.dateFormat.splice(Utils.dateFormat.indexOf('YYYY'), 1);
707
+ }
708
+ }
709
+ /**
710
+ * Converts the date to a string.
711
+ * @param {string | number | Date} now
712
+ * @returns {string}
713
+ */
714
+
715
+ }, {
716
+ key: "date2string",
717
+ value: function date2string(now) {
718
+ if (typeof now === 'string') {
719
+ now = now.trim();
720
+ if (!now) return ''; // only letters
721
+
722
+ if (now.match(/^[\w\s]+$/)) {
723
+ // Day of week
724
+ return now;
725
+ }
726
+
727
+ var m = now.match(/(\d{1,4})[-./](\d{1,2})[-./](\d{1,4})/);
728
+
729
+ if (m) {
730
+ var a = [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
731
+ var year = a.find(function (y) {
732
+ return y > 31;
733
+ });
734
+ a.splice(a.indexOf(year), 1);
735
+ var day = a.find(function (m) {
736
+ return m > 12;
737
+ });
738
+
739
+ if (day) {
740
+ a.splice(a.indexOf(day), 1);
741
+ now = new Date(year, a[0] - 1, day);
742
+ } else {
743
+ // MM DD
744
+ if (Utils.dateFormat[0][0] === 'M' && Utils.dateFormat[1][0] === 'D') {
745
+ now = new Date(year, a[0] - 1, a[1]);
746
+
747
+ if (Math.abs(now.getTime - Date.now()) > 3600000 * 24 * 10) {
748
+ now = new Date(year, a[1] - 1, a[0]);
749
+ }
750
+ } else // DD MM
751
+ if (Utils.dateFormat[0][0] === 'D' && Utils.dateFormat[1][0] === 'M') {
752
+ now = new Date(year, a[1] - 1, a[0]);
753
+
754
+ if (Math.abs(now.getTime - Date.now()) > 3600000 * 24 * 10) {
755
+ now = new Date(year, a[0] - 1, a[1]);
756
+ }
757
+ } else {
758
+ now = new Date(now);
759
+ }
760
+ }
761
+ } else {
762
+ now = new Date(now);
763
+ }
764
+ } else {
765
+ now = new Date(now);
766
+ }
767
+
768
+ var date = _i18n["default"].t('ra_dow_' + days[now.getDay()]).replace('ra_dow_', '');
769
+
770
+ date += '. ' + now.getDate() + ' ' + _i18n["default"].t('ra_month_' + months[now.getMonth()]).replace('ra_month_', '');
771
+ return date;
772
+ }
773
+ /**
774
+ * Render a text as a link.
775
+ * @param {string} text
776
+ * @returns {string | JSX.Element[]}
777
+ */
778
+
779
+ }, {
780
+ key: "renderTextWithA",
781
+ value: function renderTextWithA(text) {
782
+ var m = text.match(/<a [^<]+<\/a>|<br\/?>/);
783
+
784
+ if (m) {
785
+ var result = [];
786
+ var key = 1;
787
+
788
+ do {
789
+ var p = text.split(m[0]);
790
+ p[0] && result.push( /*#__PURE__*/_react["default"].createElement("span", {
791
+ key: 'a' + key++
792
+ }, p[0]));
793
+
794
+ if (m[0].startsWith('<br')) {
795
+ result.push( /*#__PURE__*/_react["default"].createElement("br", {
796
+ key: 'a' + key++
797
+ }));
798
+ } else {
799
+ var href = m[0].match(/href="([^"]+)"/) || m[0].match(/href='([^']+)'/);
800
+ var target = m[0].match(/target="([^"]+)"/) || m[0].match(/target='([^']+)'/);
801
+ var rel = m[0].match(/rel="([^"]+)"/) || m[0].match(/rel='([^']+)'/);
802
+ var title = m[0].match(/>([^<]*)</); // eslint-disable-next-line
803
+
804
+ result.push( /*#__PURE__*/_react["default"].createElement("a", {
805
+ key: 'a' + key++,
806
+ href: href ? href[1] : '',
807
+ target: target ? target[1] : '_blank',
808
+ rel: rel ? rel[1] : ''
809
+ }, title ? title[1] : ''));
810
+ }
811
+
812
+ text = p[1];
813
+ m = text && text.match(/<a [^<]+<\/a>|<br\/?>/);
814
+
815
+ if (!m) {
816
+ p[1] && result.push( /*#__PURE__*/_react["default"].createElement("span", {
817
+ key: 'a' + key++
818
+ }, p[1]));
819
+ }
820
+ } while (m);
821
+
822
+ return result;
823
+ } else {
824
+ return text;
825
+ }
826
+ }
827
+ /**
828
+ * Get the smart name of the given state.
829
+ * @param {Record<string, ioBroker.StateObject> | ioBroker.StateObject} states
830
+ * @param {string} id
831
+ * @param {string} instanceId
832
+ * @param {boolean} [noCommon]
833
+ */
834
+
835
+ }, {
836
+ key: "getSmartName",
837
+ value: function getSmartName(states, id, instanceId, noCommon) {
838
+ if (!id) {
839
+ if (!noCommon) {
840
+ if (!states.common) {
841
+ return states.smartName;
842
+ } else {
843
+ if (states && !states.common) {
844
+ return states.smartName;
845
+ } else {
846
+ return states.common.smartName;
847
+ }
848
+ }
849
+ } else {
850
+ if (states && !states.common) {
851
+ return states.smartName;
852
+ } else {
853
+ return states && states.common && states.common.custom && states.common.custom[instanceId] ? states.common.custom[instanceId].smartName : undefined;
854
+ }
855
+ }
856
+ } else if (!noCommon) {
857
+ return states[id].common.smartName;
858
+ } else {
859
+ return states[id] && states[id].common && states[id].common.custom && states[id].common.custom[instanceId] ? states[id].common.custom[instanceId].smartName || null : null;
860
+ }
861
+ }
862
+ /**
863
+ * Get the smart name from a state.
864
+ * @param {ioBroker.StateObject} obj
865
+ * @param {string} instanceId
866
+ * @param {boolean} [noCommon]
867
+ */
868
+
869
+ }, {
870
+ key: "getSmartNameFromObj",
871
+ value: function getSmartNameFromObj(obj, instanceId, noCommon) {
872
+ if (!noCommon) {
873
+ if (!obj.common) {
874
+ return obj.smartName;
875
+ } else {
876
+ if (obj && !obj.common) {
877
+ return obj.smartName;
878
+ } else {
879
+ return obj.common.smartName;
880
+ }
881
+ }
882
+ } else {
883
+ if (obj && !obj.common) {
884
+ return obj.smartName;
885
+ } else {
886
+ return obj && obj.common && obj.common.custom && obj.common.custom[instanceId] ? obj.common.custom[instanceId].smartName : undefined;
887
+ }
888
+ }
889
+ }
890
+ /**
891
+ * Enable smart name for a state.
892
+ * @param {ioBroker.StateObject} obj
893
+ * @param {string} instanceId
894
+ * @param {boolean} [noCommon]
895
+ */
896
+
897
+ }, {
898
+ key: "enableSmartName",
899
+ value: function enableSmartName(obj, instanceId, noCommon) {
900
+ if (noCommon) {
901
+ obj.common.custom = obj.common.custom || {};
902
+ obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
903
+ obj.common.custom[instanceId].smartName = {};
904
+ } else {
905
+ obj.common.smartName = {};
906
+ }
907
+ }
908
+ /**
909
+ * Completely remove smart name from a state.
910
+ * @param {ioBroker.StateObject} obj
911
+ * @param {string | number} instanceId
912
+ * @param {boolean} [noCommon]
913
+ */
914
+
915
+ }, {
916
+ key: "removeSmartName",
917
+ value: function removeSmartName(obj, instanceId, noCommon) {
918
+ if (noCommon) {
919
+ if (obj.common && obj.common.custom && obj.common.custom[instanceId]) {
920
+ obj.common.custom[instanceId] = null;
921
+ }
922
+ } else {
923
+ obj.common.smartName = null;
924
+ }
925
+ }
926
+ /**
927
+ * Update the smartname of a state.
928
+ * @param {ioBroker.StateObject} obj
929
+ * @param {string} newSmartName
930
+ * @param {string | undefined} byON
931
+ * @param {string | undefined} smartType
932
+ * @param {string} instanceId
933
+ * @param {boolean} [noCommon]
934
+ */
935
+
936
+ }, {
937
+ key: "updateSmartName",
938
+ value: function updateSmartName(obj, newSmartName, byON, smartType, instanceId, noCommon) {
939
+ var language = _i18n["default"].getLanguage(); // convert Old format
940
+
941
+
942
+ if (typeof obj.common.smartName === 'string') {
943
+ var nnn = obj.common.smartName;
944
+ obj.common.smartName = {};
945
+ obj.common.smartName[language] = nnn;
946
+ } // convert old settings
947
+
948
+
949
+ if (obj["native"] && obj["native"].byON) {
950
+ delete obj["native"].byON;
951
+ var _smartName = obj.common.smartName;
952
+
953
+ if (!_smartName || _typeof(_smartName) !== 'object') {
954
+ _smartName = {
955
+ en: _smartName
956
+ };
957
+ _smartName[language] = _smartName.en;
958
+ }
959
+
960
+ obj.common.smartName = _smartName;
961
+ }
962
+
963
+ if (smartType !== undefined) {
964
+ if (noCommon) {
965
+ obj.common.custom = obj.common.custom || {};
966
+ obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
967
+ obj.common.custom[instanceId].smartName = obj.common.custom[instanceId].smartName || {};
968
+
969
+ if (!smartType) {
970
+ delete obj.common.custom[instanceId].smartName.smartType;
971
+ } else {
972
+ obj.common.custom[instanceId].smartName.smartType = smartType;
973
+ }
974
+ } else {
975
+ obj.common.smartName = obj.common.smartName || {};
976
+
977
+ if (!smartType) {
978
+ delete obj.common.smartName.smartType;
979
+ } else {
980
+ obj.common.smartName.smartType = smartType;
981
+ }
982
+ }
983
+ }
984
+
985
+ if (byON !== undefined) {
986
+ if (noCommon) {
987
+ obj.common.custom = obj.common.custom || {};
988
+ obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
989
+ obj.common.custom[instanceId].smartName = obj.common.custom[instanceId].smartName || {};
990
+ obj.common.custom[instanceId].smartName.byON = byON;
991
+ } else {
992
+ obj.common.smartName = obj.common.smartName || {};
993
+ obj.common.smartName.byON = byON;
994
+ }
995
+ }
996
+
997
+ if (newSmartName !== undefined) {
998
+ var smartName;
999
+
1000
+ if (noCommon) {
1001
+ obj.common.custom = obj.common.custom || {};
1002
+ obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
1003
+ obj.common.custom[instanceId].smartName = obj.common.custom[instanceId].smartName || {};
1004
+ smartName = obj.common.custom[instanceId].smartName;
1005
+ } else {
1006
+ obj.common.smartName = obj.common.smartName || {};
1007
+ smartName = obj.common.smartName;
1008
+ }
1009
+
1010
+ smartName[language] = newSmartName; // If smart name deleted
1011
+
1012
+ if (smartName && (!smartName[language] || smartName[language] === obj.common.name && (!obj.common.role || obj.common.role.indexOf('button') >= 0))) {
1013
+ delete smartName[language];
1014
+ var empty = true; // Check if structure has any definitions
1015
+
1016
+ for (var key in smartName) {
1017
+ if (smartName.hasOwnProperty(key)) {
1018
+ empty = false;
1019
+ break;
1020
+ }
1021
+ } // If empty => delete smartName completely
1022
+
1023
+
1024
+ if (empty) {
1025
+ if (noCommon) {
1026
+ if (obj.common.custom[instanceId].smartName.byON === undefined) {
1027
+ delete obj.common.custom[instanceId];
1028
+ } else {
1029
+ delete obj.common.custom[instanceId].en;
1030
+ delete obj.common.custom[instanceId].de;
1031
+ delete obj.common.custom[instanceId].ru;
1032
+ delete obj.common.custom[instanceId].nl;
1033
+ delete obj.common.custom[instanceId].pl;
1034
+ delete obj.common.custom[instanceId].it;
1035
+ delete obj.common.custom[instanceId].fr;
1036
+ delete obj.common.custom[instanceId].pt;
1037
+ delete obj.common.custom[instanceId].es;
1038
+ delete obj.common.custom[instanceId]['zh-cn'];
1039
+ }
1040
+ } else {
1041
+ if (obj.common.smartName.byON !== undefined) {
1042
+ delete obj.common.smartName.en;
1043
+ delete obj.common.smartName.de;
1044
+ delete obj.common.smartName.ru;
1045
+ delete obj.common.smartName.nl;
1046
+ delete obj.common.smartName.pl;
1047
+ delete obj.common.smartName.it;
1048
+ delete obj.common.smartName.fr;
1049
+ delete obj.common.smartName.pt;
1050
+ delete obj.common.smartName.es;
1051
+ delete obj.common.smartName['zh-cn'];
1052
+ } else {
1053
+ obj.common.smartName = null;
1054
+ }
1055
+ }
1056
+ }
1057
+ }
1058
+ }
1059
+ }
1060
+ /**
1061
+ * Disable the smart name of a state.
1062
+ * @param {ioBroker.StateObject} obj
1063
+ * @param {string} instanceId
1064
+ * @param {boolean} [noCommon]
1065
+ */
1066
+
1067
+ }, {
1068
+ key: "disableSmartName",
1069
+ value: function disableSmartName(obj, instanceId, noCommon) {
1070
+ if (noCommon) {
1071
+ obj.common.custom = obj.common.custom || {};
1072
+ obj.common.custom[instanceId] = obj.common.custom[instanceId] || {};
1073
+ obj.common.custom[instanceId].smartName = false;
1074
+ } else {
1075
+ obj.common.smartName = false;
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Copy text to the clipboard.
1080
+ * @param {string} text
1081
+ * @param {Event} [e]
1082
+ */
1083
+
1084
+ }, {
1085
+ key: "copyToClipboard",
1086
+ value: function copyToClipboard(text, e) {
1087
+ var el = window.document.createElement('textarea');
1088
+ el.value = text;
1089
+ window.document.body.appendChild(el);
1090
+ el.select();
1091
+ window.document.execCommand('copy');
1092
+ window.document.body.removeChild(el);
1093
+ console.log(text);
1094
+ e && e.stopPropagation();
1095
+ e && e.preventDefault();
1096
+ }
1097
+ /**
1098
+ * Gets the extension of a file name.
1099
+ * @param {string | null} [fileName] the file name.
1100
+ * @returns {string | null} The extension in lower case.
1101
+ */
1102
+
1103
+ }, {
1104
+ key: "getFileExtension",
1105
+ value: function getFileExtension(fileName) {
1106
+ var pos = (fileName || '').lastIndexOf('.');
1107
+
1108
+ if (pos !== -1) {
1109
+ return fileName.substring(pos + 1).toLowerCase();
1110
+ } else {
1111
+ return null;
1112
+ }
1113
+ }
1114
+ /**
1115
+ * Format number of bytes as a string with B, KB, MB or GB.
1116
+ * The base for all calculations is 1024.
1117
+ * @param {number} bytes The number of bytes.
1118
+ * @returns {string} The formatted string (e.g. '723.5 KB')
1119
+ */
1120
+
1121
+ }, {
1122
+ key: "formatBytes",
1123
+ value: function formatBytes(bytes) {
1124
+ if (Math.abs(bytes) < 1024) {
1125
+ return bytes + ' B';
1126
+ }
1127
+
1128
+ var units = ['KB', 'MB', 'GB']; //const units = ['KiB','MiB','GiB','TiB','PiB','EiB','ZiB','YiB'];
1129
+
1130
+ var u = -1;
1131
+
1132
+ do {
1133
+ bytes /= 1024;
1134
+ ++u;
1135
+ } while (Math.abs(bytes) >= 1024 && u < units.length - 1);
1136
+
1137
+ return bytes.toFixed(1) + ' ' + units[u];
1138
+ }
1139
+ /**
1140
+ * Invert the given color according to theme type to get the inverted text color for background
1141
+ * @param {string} color Color in the format '#rrggbb' or '#rgb' (or without hash)
1142
+ * @param {string} themeType theme type
1143
+ * @param {string} invert dark theme has light color in control or light theme has light color in control
1144
+ * @returns {string}
1145
+ */
1146
+
1147
+ }, {
1148
+ key: "getInvertedColor",
1149
+ value: function getInvertedColor(color, themeType, invert) {
1150
+ if (!color) {
1151
+ return undefined;
1152
+ } else {
1153
+ var invertedColor = Utils.invertColor(color, true);
1154
+
1155
+ if (invertedColor === '#FFFFFF' && (themeType === 'dark' || invert && themeType === 'light')) {
1156
+ return '#DDD';
1157
+ } else if (invertedColor === '#000000' && (themeType === 'light' || invert && themeType === 'dark')) {
1158
+ return '#222';
1159
+ } else {
1160
+ return undefined;
1161
+ }
1162
+ }
1163
+ } // Big thanks to: https://stackoverflow.com/questions/35969656/how-can-i-generate-the-opposite-color-according-to-current-color
1164
+
1165
+ /**
1166
+ * Invert the given color
1167
+ * @param {string} hex Color in the format '#rrggbb' or '#rgb' (or without hash)
1168
+ * @param {boolean} bw Set to black or white.
1169
+ * @returns {string}
1170
+ */
1171
+
1172
+ }, {
1173
+ key: "invertColor",
1174
+ value: function invertColor(hex, bw) {
1175
+ if (hex === undefined || hex === null || hex === '' || typeof hex !== 'string') {
1176
+ return '';
1177
+ }
1178
+
1179
+ if (hex.startsWith('rgba')) {
1180
+ var m = hex.match(/rgba?\((\d+),\s*(\d+),\s*(\d+),\s*([.\d]+)\)/);
1181
+
1182
+ if (m) {
1183
+ hex = parseInt(m[1], 10).toString(16).padStart(2, '0') + parseInt(m[2], 10).toString(16).padStart(2, '0') + parseInt(m[2], 10).toString(16).padStart(2, '0');
1184
+ }
1185
+ } else if (hex.startsWith('rgba')) {
1186
+ var _m = hex.match(/rgb?\((\d+),\s*(\d+),\s*(\d+)\)/);
1187
+
1188
+ if (_m) {
1189
+ hex = parseInt(_m[1], 10).toString(16).padStart(2, '0') + parseInt(_m[2], 10).toString(16).padStart(2, '0') + parseInt(_m[2], 10).toString(16).padStart(2, '0');
1190
+ }
1191
+ } else if (hex.startsWith('#')) {
1192
+ hex = hex.slice(1);
1193
+ } // convert 3-digit hex to 6-digits.
1194
+
1195
+
1196
+ if (hex.length === 3) {
1197
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
1198
+ }
1199
+
1200
+ if (hex.length !== 6) {
1201
+ console.warn('Cannot invert color: ' + hex);
1202
+ return hex;
1203
+ }
1204
+
1205
+ var r = parseInt(hex.slice(0, 2), 16);
1206
+ var g = parseInt(hex.slice(2, 4), 16);
1207
+ var b = parseInt(hex.slice(4, 6), 16);
1208
+
1209
+ if (bw) {
1210
+ // http://stackoverflow.com/a/3943023/112731
1211
+ return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF';
1212
+ } // invert color components
1213
+
1214
+
1215
+ r = (255 - r).toString(16);
1216
+ g = (255 - g).toString(16);
1217
+ b = (255 - b).toString(16); // pad each with zeros and return
1218
+
1219
+ return '#' + r.padStart(2, '0') + g.padStart(2, '0') + b.padStart(2, '0');
1220
+ } // https://github.com/lukeed/clsx/blob/master/src/index.js
1221
+ // License
1222
+ // MIT © Luke Edwards
1223
+
1224
+ /**
1225
+ * @private
1226
+ * @param {any} mix
1227
+ * @returns {string}
1228
+ */
1229
+
1230
+ }, {
1231
+ key: "_toVal",
1232
+ value: function _toVal(mix) {
1233
+ var k,
1234
+ y,
1235
+ str = '';
1236
+
1237
+ if (typeof mix === 'string' || typeof mix === 'number') {
1238
+ str += mix;
1239
+ } else if (_typeof(mix) === 'object') {
1240
+ if (Array.isArray(mix)) {
1241
+ for (k = 0; k < mix.length; k++) {
1242
+ if (mix[k]) {
1243
+ if (y = Utils._toVal(mix[k])) {
1244
+ str && (str += ' ');
1245
+ str += y;
1246
+ }
1247
+ }
1248
+ }
1249
+ } else {
1250
+ for (k in mix) {
1251
+ if (mix[k]) {
1252
+ str && (str += ' ');
1253
+ str += k;
1254
+ }
1255
+ }
1256
+ }
1257
+ }
1258
+
1259
+ return str;
1260
+ } // https://github.com/lukeed/clsx/blob/master/src/index.js
1261
+ // License
1262
+ // MIT © Luke Edwards
1263
+
1264
+ /**
1265
+ * Convert any object to a string with its values.
1266
+ * @returns {string}
1267
+ */
1268
+
1269
+ }, {
1270
+ key: "clsx",
1271
+ value: function clsx() {
1272
+ var i = 0;
1273
+ var tmp;
1274
+ var x;
1275
+ var str = '';
1276
+
1277
+ while (i < arguments.length) {
1278
+ if (tmp = arguments[i++]) {
1279
+ if (x = Utils._toVal(tmp)) {
1280
+ str && (str += ' ');
1281
+ str += x;
1282
+ }
1283
+ }
1284
+ }
1285
+
1286
+ return str;
1287
+ }
1288
+ /**
1289
+ * Get the current theme name (either from local storage or the browser settings).
1290
+ * @param {string} [themeName]
1291
+ * @returns {string}
1292
+ */
1293
+
1294
+ }, {
1295
+ key: "getThemeName",
1296
+ value: function getThemeName() {
1297
+ var themeName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1298
+
1299
+ if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
1300
+ return window.vendorPrefix;
1301
+ }
1302
+
1303
+ return themeName ? themeName : window.localStorage && window.localStorage.getItem('App.themeName') ? window.localStorage.getItem('App.themeName') : window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'colored';
1304
+ }
1305
+ /**
1306
+ * Get the type of theme.
1307
+ * @param {string} [themeName]
1308
+ * @returns {'dark' | 'light'}
1309
+ */
1310
+
1311
+ }, {
1312
+ key: "getThemeType",
1313
+ value: function getThemeType() {
1314
+ var themeName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1315
+
1316
+ if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
1317
+ return 'light';
1318
+ }
1319
+
1320
+ themeName = themeName || window.localStorage && window.localStorage.getItem('App.themeName');
1321
+ return themeName === 'dark' || themeName === 'blue' ? 'dark' : 'light';
1322
+ }
1323
+ /**
1324
+ * Set the theme name and theme type.
1325
+ * @param {string} themeName
1326
+ */
1327
+
1328
+ }, {
1329
+ key: "setThemeName",
1330
+ value: function setThemeName(themeName) {
1331
+ if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
1332
+ return; // ignore
1333
+ }
1334
+
1335
+ window.localStorage.setItem('App.themeName', themeName);
1336
+ window.localStorage.setItem('App.theme', themeName === 'dark' || themeName === 'blue' ? 'dark' : 'light');
1337
+ }
1338
+ /**
1339
+ * Toggle the theme name between 'dark' and 'colored'.
1340
+ * @param {string | null} themeName
1341
+ * @returns {string} the new theme name.
1342
+ */
1343
+
1344
+ }, {
1345
+ key: "toggleTheme",
1346
+ value: function toggleTheme(themeName) {
1347
+ if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
1348
+ return window.vendorPrefix;
1349
+ }
1350
+
1351
+ themeName = themeName || window.localStorage && window.localStorage.getItem('App.themeName'); // dark => blue => colored => light => dark
1352
+
1353
+ var themes = Utils.getThemeNames();
1354
+ var pos = themes.indexOf(themeName);
1355
+ var newTheme;
1356
+
1357
+ if (pos !== -1) {
1358
+ newTheme = themes[(pos + 1) % themes.length];
1359
+ } else {
1360
+ newTheme = themes[0];
1361
+ }
1362
+
1363
+ Utils.setThemeName(newTheme);
1364
+ return newTheme;
1365
+ }
1366
+ /**
1367
+ * Get the list of themes
1368
+ * @returns {array<string>} list of possible themes
1369
+ */
1370
+
1371
+ }, {
1372
+ key: "getThemeNames",
1373
+ value: function getThemeNames() {
1374
+ if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
1375
+ return [window.vendorPrefix];
1376
+ }
1377
+
1378
+ return ['light', 'dark', 'blue', 'colored'];
1379
+ }
1380
+ /**
1381
+ * Parse a query string into its parts.
1382
+ * @param {string} query
1383
+ * @returns {Record<string, string | boolean | number>}
1384
+ */
1385
+
1386
+ }, {
1387
+ key: "parseQuery",
1388
+ value: function parseQuery(query) {
1389
+ query = (query || '').toString().replace(/^\?/, '');
1390
+ /** @type {Record<string, string | boolean | number>} */
1391
+
1392
+ var result = {};
1393
+ query.split('&').forEach(function (part) {
1394
+ part = part.trim();
1395
+
1396
+ if (part) {
1397
+ var parts = part.split('=');
1398
+ var attr = decodeURIComponent(parts[0]).trim();
1399
+
1400
+ if (parts.length > 1) {
1401
+ result[attr] = decodeURIComponent(parts[1]);
1402
+
1403
+ if (result[attr] === 'true') {
1404
+ result[attr] = true;
1405
+ } else if (result[attr] === 'false') {
1406
+ result[attr] = false;
1407
+ } else {
1408
+ var f = parseFloat(result[attr]);
1409
+
1410
+ if (f.toString() === result[attr]) {
1411
+ result[attr] = f;
1412
+ }
1413
+ }
1414
+ } else {
1415
+ result[attr] = true;
1416
+ }
1417
+ }
1418
+ });
1419
+ return result;
1420
+ }
1421
+ /**
1422
+ * Returns parent ID.
1423
+ * @param {string} id
1424
+ * @returns {string | null} parent ID or null if no parent
1425
+ */
1426
+
1427
+ }, {
1428
+ key: "getParentId",
1429
+ value: function getParentId(id) {
1430
+ var p = (id || '').toString().split('.');
1431
+
1432
+ if (p.length > 1) {
1433
+ p.pop();
1434
+ return p.join('.');
1435
+ } else {
1436
+ return null;
1437
+ }
1438
+ }
1439
+ }, {
1440
+ key: "formatDate",
1441
+ value: function formatDate(dateObj, dateFormat) {
1442
+ // format could be DD.MM.YYYY, YYYY.MM.DD or MM/DD/YYYY
1443
+ if (!dateObj) {
1444
+ return '';
1445
+ }
1446
+
1447
+ var text;
1448
+ var mm = dateObj.getMonth() + 1;
1449
+
1450
+ if (mm < 10) {
1451
+ mm = '0' + mm;
1452
+ }
1453
+
1454
+ var dd = dateObj.getDate();
1455
+
1456
+ if (dd < 10) {
1457
+ dd = '0' + dd;
1458
+ }
1459
+
1460
+ if (dateFormat === 'MM/DD/YYYY') {
1461
+ text = mm + '/' + dd + '/' + dateObj.getFullYear();
1462
+ } else {
1463
+ text = dateObj.getFullYear() + '-' + mm + '-' + dd;
1464
+ } // time
1465
+
1466
+
1467
+ var v = dateObj.getHours();
1468
+
1469
+ if (v < 10) {
1470
+ text += ' 0' + v;
1471
+ } else {
1472
+ text += ' ' + v;
1473
+ }
1474
+
1475
+ v = dateObj.getMinutes();
1476
+
1477
+ if (v < 10) {
1478
+ text += ':0' + v;
1479
+ } else {
1480
+ text += ':' + v;
1481
+ }
1482
+
1483
+ v = dateObj.getSeconds();
1484
+
1485
+ if (v < 10) {
1486
+ text += ':0' + v;
1487
+ } else {
1488
+ text += ':' + v;
1489
+ }
1490
+
1491
+ v = dateObj.getMilliseconds();
1492
+
1493
+ if (v < 10) {
1494
+ text += '.00' + v;
1495
+ } else if (v < 100) {
1496
+ text += '.0' + v;
1497
+ } else {
1498
+ text += '.' + v;
1499
+ }
1500
+
1501
+ return text;
1502
+ }
1503
+ }, {
1504
+ key: "formatTime",
1505
+ value: function formatTime(seconds) {
1506
+ if (seconds) {
1507
+ seconds = Math.round(seconds);
1508
+ var d = Math.floor(seconds / (3600 * 24));
1509
+ var h = Math.floor(seconds % (3600 * 24) / 3600);
1510
+ var m = Math.floor(seconds % 3600 / 60);
1511
+ var s = seconds % 60;
1512
+
1513
+ if (d) {
1514
+ return "".concat(d, ".").concat(h.toString().padStart(2, '0'), ":").concat(m.toString().padStart(2, '0'), ":").concat(s.toString().padStart(2, '0'));
1515
+ } else if (h) {
1516
+ return "".concat(h, ":").concat(m.toString().padStart(2, '0'), ":").concat(s.toString().padStart(2, '0'));
1517
+ } else {
1518
+ return "0:".concat(m.toString().padStart(2, '0'), ":").concat(s.toString().padStart(2, '0'));
1519
+ }
1520
+ } else {
1521
+ return '0:00:00';
1522
+ }
1523
+ }
1524
+ }, {
1525
+ key: "MDtext2link",
1526
+ value: function MDtext2link(text) {
1527
+ var m = text.match(/\d+\.\)\s/);
1528
+
1529
+ if (m) {
1530
+ text = text.replace(m[0], m[0].replace(/\s/, '&nbsp;'));
1531
+ }
1532
+
1533
+ return text.replace(/[^a-zA-Zа-яА-Я0-9]/g, '').trim().replace(/\s/g, '').toLowerCase();
1534
+ }
1535
+ }, {
1536
+ key: "openLink",
1537
+ value: function openLink(url, target) {
1538
+ if (target === 'this') {
1539
+ window.location = url;
1540
+ } else {
1541
+ window.open(url, target || '_blank');
1542
+ }
1543
+ }
1544
+ }, {
1545
+ key: "MDgetTitle",
1546
+ value: function MDgetTitle(text) {
1547
+ var _Utils$extractHeader = Utils.extractHeader(text),
1548
+ body = _Utils$extractHeader.body,
1549
+ header = _Utils$extractHeader.header;
1550
+
1551
+ if (!header.title) {
1552
+ // remove {docsify-bla}
1553
+ body = body.replace(/{[^}]*}/g, '');
1554
+ body = body.trim();
1555
+ var lines = body.replace(/\r/g, '').split('\n');
1556
+
1557
+ for (var i = 0; i < lines.length; i++) {
1558
+ if (lines[i].startsWith('# ')) {
1559
+ return lines[i].substring(2).trim();
1560
+ }
1561
+ }
1562
+
1563
+ return '';
1564
+ } else {
1565
+ return header.title;
1566
+ }
1567
+ }
1568
+ }, {
1569
+ key: "MDextractHeader",
1570
+ value: function MDextractHeader(text) {
1571
+ var attrs = {};
1572
+
1573
+ if (text.substring(0, 3) === '---') {
1574
+ var pos = text.substring(3).indexOf('\n---');
1575
+
1576
+ if (pos !== -1) {
1577
+ var _header = text.substring(3, pos + 3);
1578
+
1579
+ var lines = _header.replace(/\r/g, '').split('\n');
1580
+
1581
+ lines.forEach(function (line) {
1582
+ if (!line.trim()) {
1583
+ return;
1584
+ }
1585
+
1586
+ var pos = line.indexOf(':');
1587
+
1588
+ if (pos !== -1) {
1589
+ var attr = line.substring(0, pos).trim();
1590
+ attrs[attr] = line.substring(pos + 1).trim();
1591
+ attrs[attr] = attrs[attr].replace(/^['"]|['"]$/g, '');
1592
+
1593
+ if (attrs[attr] === 'true') {
1594
+ attrs[attr] = true;
1595
+ } else if (attrs[attr] === 'false') {
1596
+ attrs[attr] = false;
1597
+ } else if (parseFloat(attrs[attr]).toString() === attrs[attr]) {
1598
+ attrs[attr] = parseFloat(attrs[attr]);
1599
+ }
1600
+ } else {
1601
+ attrs[line.trim()] = true;
1602
+ }
1603
+ });
1604
+ text = text.substring(pos + 7);
1605
+ }
1606
+ }
1607
+
1608
+ return {
1609
+ header: attrs,
1610
+ body: text
1611
+ };
1612
+ }
1613
+ }, {
1614
+ key: "MDremoveDocsify",
1615
+ value: function MDremoveDocsify(text) {
1616
+ var m = text.match(/{docsify-[^}]*}/g);
1617
+
1618
+ if (m) {
1619
+ m.forEach(function (doc) {
1620
+ return text = text.replace(doc, '');
1621
+ });
1622
+ }
1623
+
1624
+ return text;
1625
+ }
1626
+ /**
1627
+ * Generate the json file on the file for download.
1628
+ * @param {string} filename file name
1629
+ * @returns {object} json structure (not stringified)
1630
+ */
1631
+
1632
+ }, {
1633
+ key: "generateFile",
1634
+ value: function generateFile(filename, json) {
1635
+ var el = document.createElement('a');
1636
+ el.setAttribute('href', 'data:application/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(json, null, 2)));
1637
+ el.setAttribute('download', filename);
1638
+ el.style.display = 'none';
1639
+ document.body.appendChild(el);
1640
+ el.click();
1641
+ document.body.removeChild(el);
1642
+ }
1643
+ /**
1644
+ * Convert quality code into text
1645
+ * @param {number} quality code
1646
+ * @returns {array<string>} lines that decode qulity
1647
+ */
1648
+
1649
+ }, {
1650
+ key: "quality2text",
1651
+ value: function quality2text(quality) {
1652
+ var custom = quality & 0xFFFF0000;
1653
+ var text = QUALITY_BITS[quality];
1654
+ var result;
1655
+
1656
+ if (text) {
1657
+ result = [text];
1658
+ } else if (quality & 0x01) {
1659
+ result = [QUALITY_BITS[0x01], '0x' + (quality & (0xFFFF & ~1)).toString(16)];
1660
+ } else if (quality & 0x02) {
1661
+ result = [QUALITY_BITS[0x02], '0x' + (quality & (0xFFFF & ~2)).toString(16)];
1662
+ } else {
1663
+ result = ['0x' + quality.toString(16)];
1664
+ }
1665
+
1666
+ if (custom) {
1667
+ result.push('0x' + (custom >> 16).toString(16).toUpperCase());
1668
+ }
1669
+
1670
+ return result;
1671
+ }
1672
+ /**
1673
+ * Deep copy object
1674
+ * @param {object} object
1675
+ * @returns {object}
1676
+ */
1677
+
1678
+ }, {
1679
+ key: "clone",
1680
+ value: function clone(object) {
1681
+ return JSON.parse(JSON.stringify(object));
1682
+ }
1683
+ /**
1684
+ * Get states of object
1685
+ * @param {object} obj
1686
+ * @returns {object} states as an object in form {"value1": "label1", "value2": "label2"} or null
1687
+ */
1688
+
1689
+ }, {
1690
+ key: "getStates",
1691
+ value: function getStates(obj) {
1692
+ var _obj$common;
1693
+
1694
+ var states = obj === null || obj === void 0 ? void 0 : (_obj$common = obj.common) === null || _obj$common === void 0 ? void 0 : _obj$common.states;
1695
+
1696
+ if (states) {
1697
+ if (typeof states === 'string' && states[0] === '{') {
1698
+ try {
1699
+ states = JSON.parse(states);
1700
+ } catch (ex) {
1701
+ console.error("Cannot parse states: ".concat(states));
1702
+ states = null;
1703
+ }
1704
+ } else // if old format val1:text1;val2:text2
1705
+ if (typeof states === 'string') {
1706
+ var parts = states.split(';');
1707
+ states = {};
1708
+
1709
+ for (var p = 0; p < parts.length; p++) {
1710
+ var s = parts[p].split(':');
1711
+ states[s[0]] = s[1];
1712
+ }
1713
+ } else if (Array.isArray(states)) {
1714
+ var result = {};
1715
+ states.forEach(function (value, key) {
1716
+ return result[key] = value;
1717
+ });
1718
+ return result;
1719
+ }
1720
+ }
1721
+
1722
+ return states;
1723
+ }
1724
+ /**
1725
+ * Get svg file as text
1726
+ * @param {string} url URL of SVG file
1727
+ * @returns {object} Promise with "data:image..."
1728
+ */
1729
+
1730
+ }, {
1731
+ key: "getSvg",
1732
+ value: function getSvg(url) {
1733
+ return fetch(url).then(function (response) {
1734
+ return response.blob();
1735
+ }).then(function (blob) {
1736
+ return new Promise(function (resolve) {
1737
+ var reader = new FileReader();
1738
+
1739
+ reader.onload = function () {
1740
+ // do not optimize this function. "this" is important.
1741
+ resolve(this.result);
1742
+ };
1743
+
1744
+ reader.readAsDataURL(blob);
1745
+ });
1746
+ });
1747
+ }
1748
+ }]);
1749
+
1750
+ return Utils;
1751
+ }();
1752
+
1753
+ _defineProperty(Utils, "namespace", NAMESPACE);
1754
+
1755
+ _defineProperty(Utils, "INSTANCES", 'instances');
1756
+
1757
+ _defineProperty(Utils, "dateFormat", ['DD', 'MM']);
1758
+
1759
+ _defineProperty(Utils, "FORBIDDEN_CHARS", /(?:(?![ !#-&\(\)\+\x2D-:=@-Z\^_a-~\xB5\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BC-\u01BF\u01C4\u01C6\u01C7\u01C9\u01CA\u01CC-\u01F1\u01F3-\u0293\u0295-\u02AF\u0370-\u0373\u0376\u0377\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0560-\u0588\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FD-\u10FF\u13A0-\u13F5\u13F8-\u13FD\u17E0-\u17E9\u1810-\u1819\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6-\u1FBB\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCB\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFB\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C7B\u2C7E-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA620-\uA629\uA640-\uA66D\uA680-\uA69B\uA722-\uA76F\uA771-\uA787\uA78B-\uA78E\uA790-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F5\uA7F6\uA7FA\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uAB30-\uAB5A\uAB60-\uAB68\uAB70-\uABBF\uABF0-\uABF9\uFB00-\uFB06\uFB13-\uFB17\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]|\uD801[\uDC00-\uDC4F\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC]|\uD803[\uDC80-\uDCB2\uDCC0-\uDCF2\uDD30-\uDD39]|\uD804[\uDC66-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDD50-\uDD59]|\uD807[\uDC50-\uDC59\uDD50-\uDD59\uDDA0-\uDDA9]|\uD81A[\uDE60-\uDE69\uDEC0-\uDEC9\uDF50-\uDF59]|\uD81B[\uDE40-\uDE7F]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD837[\uDF00-\uDF09\uDF0B-\uDF1E]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDD00-\uDD43\uDD50-\uDD59]|\uD83E[\uDFF0-\uDFF9])[\s\S])+/g);
1760
+
1761
+ var _default = Utils;
1762
+ exports["default"] = _default;
1763
+ //# sourceMappingURL=Utils.js.map