$Config

Allows users to configure scripts

目前為 2024-07-02 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/446506/1404333/%24Config.js

  1. var $Config;
  2. /******/ (() => { // webpackBootstrap
  3. /******/ "use strict";
  4. /******/ var __webpack_modules__ = ({
  5.  
  6. /***/ "./ts/consts.ts":
  7. /*!**********************!*\
  8. !*** ./ts/consts.ts ***!
  9. \**********************/
  10. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  11.  
  12. __webpack_require__.r(__webpack_exports__);
  13. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  14. /* harmony export */ SOCKET_ID: () => (/* binding */ SOCKET_ID)
  15. /* harmony export */ });
  16. const SOCKET_ID = 'tree-frame';
  17.  
  18.  
  19. /***/ }),
  20.  
  21. /***/ "./ts/library/index.ts":
  22. /*!*****************************!*\
  23. !*** ./ts/library/index.ts ***!
  24. \*****************************/
  25. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  26.  
  27. __webpack_require__.r(__webpack_exports__);
  28. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  29. /* harmony export */ edit: () => (/* binding */ edit),
  30. /* harmony export */ init: () => (/* binding */ init),
  31. /* harmony export */ reset: () => (/* reexport safe */ _modal_body__WEBPACK_IMPORTED_MODULE_4__.reset)
  32. /* harmony export */ });
  33. /* harmony import */ var _validation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validation */ "./ts/library/validation/index.ts");
  34. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modal */ "./ts/modal/index.ts");
  35. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/consts.ts");
  36. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal/css */ "./ts/modal/css.ts");
  37. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  38. /* harmony import */ var _modal_header_actions_close__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/header/actions/close */ "./ts/modal/header/actions/close/index.ts");
  39. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  40. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  41. return new (P || (P = Promise))(function (resolve, reject) {
  42. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  43. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  44. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  45. step((generator = generator.apply(thisArg, _arguments || [])).next());
  46. });
  47. };
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. function init(config, socket, idPostfix) {
  55. var _a;
  56. return __awaiter(this, void 0, void 0, function* () {
  57. socket.id = `${_consts__WEBPACK_IMPORTED_MODULE_2__.SOCKET_ID}-${idPostfix}`;
  58. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.setRootId)(socket.id);
  59. try {
  60. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(config);
  61. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(config, socket);
  62. // Config is valid
  63. return {
  64. requireReset: false,
  65. tree: (_a = config.userTree) !== null && _a !== void 0 ? _a : config.defaultTree,
  66. };
  67. }
  68. catch (error) {
  69. if (typeof config !== 'object' || !(0,_validation__WEBPACK_IMPORTED_MODULE_0__.hasOwnProperty)(config, 'userTree')) {
  70. throw error;
  71. }
  72. delete config.userTree;
  73. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(config);
  74. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(config, socket);
  75. // Config is valid with userTree removed
  76. return {
  77. requireReset: true,
  78. tree: config.defaultTree,
  79. error,
  80. };
  81. }
  82. });
  83. }
  84. function edit() {
  85. (0,_modal__WEBPACK_IMPORTED_MODULE_1__.getSocket)().focus();
  86. return new Promise((resolve) => {
  87. (0,_modal_header_actions_close__WEBPACK_IMPORTED_MODULE_5__.setCallback)(resolve);
  88. });
  89. }
  90.  
  91.  
  92.  
  93. /***/ }),
  94.  
  95. /***/ "./ts/library/validation/errors.ts":
  96. /*!*****************************************!*\
  97. !*** ./ts/library/validation/errors.ts ***!
  98. \*****************************************/
  99. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  100.  
  101. __webpack_require__.r(__webpack_exports__);
  102. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  103. /* harmony export */ DeactivatedError: () => (/* binding */ DeactivatedError),
  104. /* harmony export */ EmptyArrayError: () => (/* binding */ EmptyArrayError),
  105. /* harmony export */ EmptyStringError: () => (/* binding */ EmptyStringError),
  106. /* harmony export */ HangingPredicateError: () => (/* binding */ HangingPredicateError),
  107. /* harmony export */ JoinedError: () => (/* binding */ JoinedError),
  108. /* harmony export */ MismatchedOptionsError: () => (/* binding */ MismatchedOptionsError),
  109. /* harmony export */ NoNodeColourError: () => (/* binding */ NoNodeColourError),
  110. /* harmony export */ NoOptionsError: () => (/* binding */ NoOptionsError),
  111. /* harmony export */ NonIntegerError: () => (/* binding */ NonIntegerError),
  112. /* harmony export */ PoolBranchError: () => (/* binding */ PoolBranchError),
  113. /* harmony export */ PoolSizeError: () => (/* binding */ PoolSizeError),
  114. /* harmony export */ PredicateError: () => (/* binding */ PredicateError),
  115. /* harmony export */ PropertyError: () => (/* binding */ PropertyError),
  116. /* harmony export */ SeedMatchError: () => (/* binding */ SeedMatchError),
  117. /* harmony export */ TypeError: () => (/* binding */ TypeError),
  118. /* harmony export */ UnexpectedStateError: () => (/* binding */ UnexpectedStateError),
  119. /* harmony export */ ValueError: () => (/* binding */ ValueError)
  120. /* harmony export */ });
  121. // Helpers
  122. function getOptionString(array) {
  123. if (array.length === 0) {
  124. throw new Error('No valid options.');
  125. }
  126. if (array.length === 1) {
  127. return `'${array[0]}'`;
  128. }
  129. return `'${array.slice(0, -1).join('\', \'')}' or '${array[array.length - 1]}'`;
  130. }
  131. function getPath(breadcrumbs) {
  132. return `/${breadcrumbs.join('/')}`;
  133. }
  134. // Errors
  135. class JoinedError extends Error {
  136. constructor(...errors) {
  137. super(errors.map(({ message }) => message).join(JoinedError.separator));
  138. }
  139. }
  140. JoinedError.separator = '\n\n';
  141. class UnexpectedStateError extends Error {
  142. constructor() {
  143. super('Unexpected state reached.');
  144. }
  145. }
  146. class TypeError extends Error {
  147. constructor(breadcrumbs, found, expected) {
  148. super(`Found a value of type '${found}' at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  149. }
  150. }
  151. class PropertyError extends Error {
  152. constructor(breadcrumbs, property, shouldExist) {
  153. super(`${shouldExist ? 'Missing' : 'Unexpected'} property '${property}' found at ${getPath(breadcrumbs)}.`);
  154. }
  155. }
  156. class ValueError extends Error {
  157. constructor(breadcrumbs, found, expected) {
  158. super(`Found a value of '${found}' at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  159. }
  160. }
  161. class NonIntegerError extends Error {
  162. constructor(breadcrumbs) {
  163. super(`Found illegal non-integer at ${getPath(breadcrumbs)}.`);
  164. }
  165. }
  166. class EmptyStringError extends Error {
  167. constructor(breadcrumbs) {
  168. super(`Found illegal empty string at ${getPath(breadcrumbs)}.`);
  169. }
  170. }
  171. class EmptyArrayError extends Error {
  172. constructor(breadcrumbs) {
  173. super(`Found illegal empty array at ${getPath(breadcrumbs)}.`);
  174. }
  175. }
  176. class PredicateError extends Error {
  177. constructor(breadcrumbs) {
  178. super(`Predicate failed at ${getPath(breadcrumbs)}. Predicates must succeed.`);
  179. }
  180. }
  181. class SeedMatchError extends Error {
  182. constructor() {
  183. super('All children must be structurally similar to their parent\'s seed.');
  184. }
  185. }
  186. class PoolBranchError extends Error {
  187. constructor(ancestorBreadcrumbs, descendantBreadcrumbs, poolId) {
  188. super('No node may share a poolId value with its ancestor.' + JoinedError.separator
  189. + `Found poolId value ${poolId} at ${getPath(ancestorBreadcrumbs)} and ${getPath(descendantBreadcrumbs)}.`);
  190. }
  191. }
  192. class PoolSizeError extends Error {
  193. constructor(poolId, found, expected) {
  194. super('Corresponding pools in the default & candidate trees must be the same size unless a pool parent or ancestor has a seed value.' + JoinedError.separator
  195. + `Found a size of ${found} at pool ${poolId}. Expected a size of ${expected}.`);
  196. }
  197. }
  198. class NoOptionsError extends Error {
  199. constructor() {
  200. super('Array type validators may not be empty.');
  201. }
  202. }
  203. class MismatchedOptionsError extends Error {
  204. constructor() {
  205. super('Values in array type validators must all be the same type.');
  206. }
  207. }
  208. class HangingPredicateError extends Error {
  209. constructor() {
  210. super('If a predicate is declared, a value must also be present.');
  211. }
  212. }
  213. class DeactivatedError extends Error {
  214. constructor() {
  215. super('Nodes can\'t be deactivated unless their parent has a seed.');
  216. }
  217. }
  218. class NoNodeColourError extends Error {
  219. constructor() {
  220. super('If the node color property is included, at least one value must be defined.');
  221. }
  222. }
  223.  
  224.  
  225. /***/ }),
  226.  
  227. /***/ "./ts/library/validation/index.ts":
  228. /*!****************************************!*\
  229. !*** ./ts/library/validation/index.ts ***!
  230. \****************************************/
  231. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  232.  
  233. __webpack_require__.r(__webpack_exports__);
  234. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  235. /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__),
  236. /* harmony export */ hasOwnProperty: () => (/* binding */ hasOwnProperty),
  237. /* harmony export */ validateUnexpectedKeys: () => (/* binding */ validateUnexpectedKeys)
  238. /* harmony export */ });
  239. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  240. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  241. /* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./styles */ "./ts/library/validation/styles.ts");
  242. /* harmony import */ var _trees_pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./trees/pools */ "./ts/library/validation/trees/pools.ts");
  243. /* harmony import */ var _trees_guards__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./trees/guards */ "./ts/library/validation/trees/guards.ts");
  244. /* harmony import */ var _trees_match__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trees/match */ "./ts/library/validation/trees/match.ts");
  245. /* harmony import */ var _trees_predicates__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trees/predicates */ "./ts/library/validation/trees/predicates.ts");
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. // Helpers
  254. // Credit to https://fettblog.eu/typescript-hasownproperty/
  255. function hasOwnProperty(object, property) {
  256. return Object.hasOwnProperty.call(object, property);
  257. }
  258. function validateUnexpectedKeys(breadcrumbs, object, expected) {
  259. for (const key of Object.keys(object)) {
  260. if (!expected.includes(key))
  261. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, key, false);
  262. }
  263. }
  264. // Guard
  265. function isConfig(candidate) {
  266. if (typeof candidate !== 'object')
  267. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([], typeof candidate, ['object']);
  268. validateUnexpectedKeys([], candidate, _types__WEBPACK_IMPORTED_MODULE_0__.CONFIG_KEYS);
  269. // title
  270. if (!hasOwnProperty(candidate, 'title'))
  271. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'title', true);
  272. if (typeof candidate.title !== 'string')
  273. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['title'], typeof candidate.title, ['string']);
  274. // defaultStyle
  275. if (hasOwnProperty(candidate, 'defaultStyle')) {
  276. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['defaultStyle'], candidate.defaultStyle))
  277. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  278. if (hasOwnProperty(candidate.defaultStyle, 'name'))
  279. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'name', false);
  280. if (hasOwnProperty(candidate.defaultStyle, 'isActive'))
  281. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'isActive', false);
  282. }
  283. // userStyles
  284. if (!hasOwnProperty(candidate, 'userStyles'))
  285. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'userStyles', true);
  286. if (!Array.isArray(candidate.userStyles))
  287. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles'], typeof candidate.userStyles, ['array']);
  288. for (const [i, style] of candidate.userStyles.entries()) {
  289. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['userStyles', i.toString()], style))
  290. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  291. if (!hasOwnProperty(style, 'name'))
  292. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'name', true);
  293. if (typeof style.name !== 'string')
  294. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'name'], typeof style.name, ['string']);
  295. if (!hasOwnProperty(style, 'isActive'))
  296. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'isActive', true);
  297. if (typeof style.isActive !== 'boolean')
  298. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'isActive'], typeof style.isActive, ['boolean']);
  299. }
  300. // defaultTree
  301. if (!hasOwnProperty(candidate, 'defaultTree') || !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['defaultTree'], candidate.defaultTree))
  302. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'defaultTree', true);
  303. // userTree
  304. if (hasOwnProperty(candidate, 'userTree') && !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['userTree'], candidate.userTree, true))
  305. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  306. return true;
  307. }
  308. // Validator
  309. function validateConfig({ title, defaultTree, userTree }) {
  310. // title
  311. if (title.length === 0)
  312. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.EmptyStringError(['title']);
  313. // trees
  314. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateSeeds)(['defaultTree'], defaultTree);
  315. (0,_trees_pools__WEBPACK_IMPORTED_MODULE_3__.validatePools)(['defaultTree'], defaultTree);
  316. if (userTree) {
  317. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateParentMatch)(['defaultTree'], defaultTree, ['userTree'], userTree);
  318. // Has to be done after mutations since new pools may be created
  319. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validatePoolSizeMatch)(defaultTree, userTree);
  320. }
  321. return Promise.all((0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree));
  322. }
  323. // API
  324. /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(candidate) {
  325. if (!isConfig(candidate))
  326. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  327. return validateConfig(candidate);
  328. }
  329.  
  330.  
  331. /***/ }),
  332.  
  333. /***/ "./ts/library/validation/styles.ts":
  334. /*!*****************************************!*\
  335. !*** ./ts/library/validation/styles.ts ***!
  336. \*****************************************/
  337. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  338.  
  339. __webpack_require__.r(__webpack_exports__);
  340. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  341. /* harmony export */ isStyles: () => (/* binding */ isStyles)
  342. /* harmony export */ });
  343. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  344. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  345.  
  346.  
  347. function isStyles(breadcrumbs, candidate) {
  348. if (typeof candidate !== 'object')
  349. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, typeof candidate, ['object']);
  350. if (Array.isArray(candidate))
  351. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, 'array', ['object']);
  352. for (const [key, value] of Object.entries(candidate)) {
  353. switch (key) {
  354. // Colours
  355. case 'modalOutline':
  356. case 'headBase':
  357. case 'headButtonExit':
  358. case 'headButtonLabel':
  359. case 'headButtonStyle':
  360. case 'nodeButtonRemove':
  361. case 'nodeButtonCreate':
  362. case 'nodeButtonMove':
  363. case 'nodeButtonDisable':
  364. case 'validBackground':
  365. case 'invalidBackground':
  366. case 'tooltipOutline':
  367. if (typeof value !== 'string')
  368. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  369. break;
  370. // Numbers
  371. case 'fontSize':
  372. if (typeof value !== 'number')
  373. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['number']);
  374. break;
  375. // Contrast methods
  376. case 'headContrast':
  377. case 'nodeContrast':
  378. if (typeof value !== 'string')
  379. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  380. if (!_types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS.includes(value))
  381. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, key], value, _types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS);
  382. break;
  383. // Booleans
  384. case 'isActive':
  385. case 'borderLeaf':
  386. case 'borderNode':
  387. if (typeof value !== 'boolean')
  388. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['boolean']);
  389. break;
  390. case 'nodeBase':
  391. if (!Array.isArray(value))
  392. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['array']);
  393. if (value.length === 0)
  394. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.NoNodeColourError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.EmptyArrayError([...breadcrumbs, key]));
  395. for (const [i, subValue] of value.entries()) {
  396. if (typeof subValue !== 'string')
  397. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key, i.toString()], typeof subValue, ['string']);
  398. }
  399. break;
  400. }
  401. }
  402. return true;
  403. }
  404.  
  405.  
  406. /***/ }),
  407.  
  408. /***/ "./ts/library/validation/trees/guards.ts":
  409. /*!***********************************************!*\
  410. !*** ./ts/library/validation/trees/guards.ts ***!
  411. \***********************************************/
  412. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  413.  
  414. __webpack_require__.r(__webpack_exports__);
  415. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  416. /* harmony export */ isParent: () => (/* binding */ isParent),
  417. /* harmony export */ isRoot: () => (/* binding */ isRoot)
  418. /* harmony export */ });
  419. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./ts/library/validation/types.ts");
  420. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  421. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./ts/library/validation/index.ts");
  422.  
  423.  
  424.  
  425. // Type predicates
  426. function isParent(breadcrumbs, candidate, isUserTree = false) {
  427. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children'))
  428. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'children', true);
  429. if (!Array.isArray(candidate.children))
  430. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'children'], typeof candidate.children, ['array']);
  431. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'seed')) {
  432. if (isUserTree)
  433. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'descendantPredicate', false);
  434. if (!isChild([...breadcrumbs, 'seed'], candidate.seed))
  435. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  436. }
  437. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'childPredicate')) {
  438. if (isUserTree)
  439. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'childPredicate', false);
  440. if (typeof candidate.childPredicate !== 'function')
  441. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'childPredicate'], typeof candidate.childPredicate, ['function']);
  442. }
  443. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'descendantPredicate')) {
  444. if (isUserTree)
  445. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'descendantPredicate', false);
  446. if (typeof candidate.descendantPredicate !== 'function')
  447. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'descendantPredicate'], typeof candidate.descendantPredicate, ['function']);
  448. }
  449. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'poolId') && typeof candidate.poolId !== 'number')
  450. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'poolId'], typeof candidate.poolId, ['number']);
  451. for (const [i, child] of candidate.children.entries()) {
  452. if (!isChild([...breadcrumbs, 'children', i.toString()], child, isUserTree))
  453. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  454. }
  455. return true;
  456. }
  457. function isChild(breadcrumbs, candidate, isUserTree = false) {
  458. if (typeof candidate !== 'object')
  459. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs], typeof candidate, ['object']);
  460. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'label') && typeof candidate.label !== 'string')
  461. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'label'], typeof candidate.label, ['string']);
  462. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'value') && !_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof candidate.value))
  463. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'value'], typeof candidate.value, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  464. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'predicate')) {
  465. if (isUserTree)
  466. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'predicate', false);
  467. if (typeof candidate.predicate !== 'function') {
  468. if (!Array.isArray(candidate.predicate))
  469. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate'], typeof candidate.predicate, _types__WEBPACK_IMPORTED_MODULE_0__.PREDICATE_TYPES);
  470. for (const [i, option] of candidate.predicate.entries()) {
  471. if (!_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof option))
  472. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate', i.toString()], typeof option, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  473. }
  474. }
  475. }
  476. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'input')) {
  477. if (typeof candidate.input !== 'string')
  478. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'input'], typeof candidate.input, ['string']);
  479. if (!_types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS.includes(candidate.input))
  480. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.ValueError([...breadcrumbs, 'input'], candidate.input, _types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS);
  481. }
  482. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'isActive') && typeof candidate.isActive !== 'boolean')
  483. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'isActive'], typeof candidate.isActive, ['boolean']);
  484. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children')) {
  485. if (!isParent(breadcrumbs, candidate, isUserTree))
  486. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  487. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_KEYS);
  488. }
  489. else {
  490. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.LEAF_KEYS);
  491. }
  492. return true;
  493. }
  494. function isRoot(breadcrumbs, candidate, isUserTree = false) {
  495. if (typeof candidate !== 'object')
  496. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(breadcrumbs, typeof candidate, ['object']);
  497. if (!isParent(breadcrumbs, candidate, isUserTree))
  498. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  499. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.ROOT_KEYS);
  500. return true;
  501. }
  502.  
  503.  
  504. /***/ }),
  505.  
  506. /***/ "./ts/library/validation/trees/match.ts":
  507. /*!**********************************************!*\
  508. !*** ./ts/library/validation/trees/match.ts ***!
  509. \**********************************************/
  510. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  511.  
  512. __webpack_require__.r(__webpack_exports__);
  513. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  514. /* harmony export */ validateParentMatch: () => (/* binding */ validateParentMatch),
  515. /* harmony export */ validatePoolSizeMatch: () => (/* binding */ validatePoolSizeMatch),
  516. /* harmony export */ validateSeeds: () => (/* binding */ validateSeeds)
  517. /* harmony export */ });
  518. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  519.  
  520. function mutateMatch(model, candidate, validate, property) {
  521. try {
  522. validate([], model, [], candidate);
  523. }
  524. catch (error) {
  525. if (property in model) {
  526. candidate[property] = model[property];
  527. }
  528. else {
  529. delete candidate[property];
  530. }
  531. }
  532. }
  533. function validatePredicateMatch(isFrozen, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  534. if ('predicate' in model !== 'predicate' in candidate)
  535. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'predicate', 'predicate' in model);
  536. if (typeof model.predicate !== typeof candidate.predicate)
  537. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'predicate'], typeof candidate.predicate, [typeof model.predicate]);
  538. if (typeof model.predicate === 'object') {
  539. const { length } = candidate.predicate;
  540. if (!isFrozen && !model.predicate.includes(candidate.value)) {
  541. candidate.value = model.predicate[candidate.predicate.indexOf(candidate.value)];
  542. }
  543. if (model.predicate.length !== length)
  544. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'predicate', 'length'], length, [model.predicate.length]);
  545. for (const [i, option] of model.predicate.entries()) {
  546. if (candidate.predicate[i] !== option)
  547. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'predicate', i.toString()], candidate.predicate[i], [option]);
  548. }
  549. }
  550. }
  551. function validateValueMatch(property, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  552. if (property in model !== property in candidate)
  553. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, property, property in model);
  554. if (model[property] !== candidate[property])
  555. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, property], candidate[property], [model[property]]);
  556. }
  557. // Tree validators
  558. function validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate, isFrozen = false) {
  559. if (isFrozen) {
  560. validateValueMatch('poolId', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  561. validateValueMatch('childPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  562. validateValueMatch('descendantPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  563. }
  564. else {
  565. mutateMatch(model, candidate, validateValueMatch.bind(null, 'poolId'), 'poolId');
  566. if ('childPredicate' in model)
  567. candidate.childPredicate = model.childPredicate;
  568. if ('descendantPredicate' in model)
  569. candidate.descendantPredicate = model.descendantPredicate;
  570. if ('seed' in model)
  571. candidate.seed = model.seed;
  572. }
  573. if ('seed' in model) {
  574. if (isFrozen) {
  575. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'seed'], candidate.seed, true);
  576. }
  577. for (const [i, child] of candidate.children.entries()) {
  578. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child, isFrozen);
  579. }
  580. }
  581. else if (!('poolId' in model)) {
  582. if (isFrozen && model.children.length !== candidate.children.length)
  583. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  584. if (model.children.length < candidate.children.length) {
  585. candidate.children = candidate.children.slice(0, model.children.length);
  586. }
  587. for (const [i, child] of candidate.children.entries()) {
  588. validateChildMatch([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child, isFrozen);
  589. }
  590. if (model.children.length > candidate.children.length) {
  591. candidate.children.push(...model.children.slice(candidate.children.length));
  592. }
  593. }
  594. }
  595. function validateChildMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate, isFrozen = true) {
  596. if ('value' in model !== 'value' in candidate) {
  597. if (isFrozen || 'value' in candidate)
  598. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', false);
  599. candidate.value = model.value;
  600. }
  601. else {
  602. if (typeof model.value !== typeof candidate.value)
  603. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  604. }
  605. if (isFrozen) {
  606. validateValueMatch('label', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  607. validatePredicateMatch(true, modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  608. }
  609. else {
  610. if (typeof model.value !== typeof candidate.value)
  611. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  612. mutateMatch(model, candidate, validateValueMatch.bind(null, 'label'), 'label');
  613. if ('predicate' in model)
  614. candidate.predicate = model.predicate;
  615. }
  616. if ('children' in model !== 'children' in candidate)
  617. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  618. if ('children' in model) {
  619. validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate, isFrozen);
  620. }
  621. }
  622. function validateSeeds(breadcrumbs, node) {
  623. if ('children' in node) {
  624. if ('seed' in node) {
  625. try {
  626. for (const [i, child] of node.children.entries()) {
  627. validateChildMatch([...breadcrumbs, 'seed'], node.seed, [...breadcrumbs, 'children', i.toString()], child);
  628. }
  629. }
  630. catch (error) {
  631. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.SeedMatchError(), error);
  632. }
  633. validateSeeds([...breadcrumbs, 'seed'], node.seed);
  634. }
  635. else {
  636. for (const [i, child] of node.children.entries()) {
  637. if ('isActive' in child && !child.isActive) {
  638. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.DeactivatedError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, 'children', i.toString(), 'isActive'], false, [true]));
  639. }
  640. }
  641. }
  642. for (const [i, child] of node.children.entries()) {
  643. validateSeeds([...breadcrumbs, 'children', i.toString()], child);
  644. }
  645. }
  646. }
  647. function getPoolSizes(node, uncapped = false) {
  648. const poolSizes = [];
  649. uncapped = uncapped || 'seed' in node;
  650. if ('poolId' in node) {
  651. poolSizes[node.poolId] = uncapped ? -1 : node.children.length;
  652. }
  653. if ('children' in node) {
  654. for (const child of node.children) {
  655. const subPoolSizes = getPoolSizes(child, uncapped);
  656. for (const id in subPoolSizes) {
  657. if (subPoolSizes[id] < 0) {
  658. poolSizes[id] = -1;
  659. }
  660. else if (id in poolSizes) {
  661. poolSizes[id] += subPoolSizes[id];
  662. }
  663. else {
  664. poolSizes[id] = subPoolSizes[id];
  665. }
  666. }
  667. }
  668. }
  669. return poolSizes;
  670. }
  671. function validatePoolSizeMatch(model, candidate) {
  672. const modelSizes = getPoolSizes(model);
  673. const candidateSizes = getPoolSizes(candidate);
  674. for (const id in modelSizes) {
  675. if (modelSizes[id] !== candidateSizes[id])
  676. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolSizeError(Number.parseInt(id), candidateSizes[id], modelSizes[id]);
  677. }
  678. }
  679.  
  680.  
  681. /***/ }),
  682.  
  683. /***/ "./ts/library/validation/trees/pools.ts":
  684. /*!**********************************************!*\
  685. !*** ./ts/library/validation/trees/pools.ts ***!
  686. \**********************************************/
  687. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  688.  
  689. __webpack_require__.r(__webpack_exports__);
  690. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  691. /* harmony export */ validatePools: () => (/* binding */ validatePools)
  692. /* harmony export */ });
  693. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  694.  
  695. function validatePools(breadcrumbs, node, ancestorPools = []) {
  696. if ('poolId' in node) {
  697. if (node.poolId in ancestorPools)
  698. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolBranchError(ancestorPools[node.poolId], breadcrumbs, node.poolId);
  699. // Slice maintains empty entries, so the 'in' operator still works
  700. ancestorPools = ancestorPools.slice();
  701. ancestorPools[node.poolId] = breadcrumbs;
  702. }
  703. if ('children' in node) {
  704. // Recurse
  705. for (const [i, child] of node.children.entries()) {
  706. validatePools([...breadcrumbs, 'children', i.toString()], child, ancestorPools);
  707. }
  708. }
  709. }
  710.  
  711.  
  712. /***/ }),
  713.  
  714. /***/ "./ts/library/validation/trees/predicates.ts":
  715. /*!***************************************************!*\
  716. !*** ./ts/library/validation/trees/predicates.ts ***!
  717. \***************************************************/
  718. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  719.  
  720. __webpack_require__.r(__webpack_exports__);
  721. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  722. /* harmony export */ validateParent: () => (/* binding */ validateParent)
  723. /* harmony export */ });
  724. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  725. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  726. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  727. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  728. return new (P || (P = Promise))(function (resolve, reject) {
  729. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  730. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  731. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  732. step((generator = generator.apply(thisArg, _arguments || [])).next());
  733. });
  734. };
  735.  
  736.  
  737. function getBoundPredicatePromise(response, { message }) {
  738. return __awaiter(this, void 0, void 0, function* () {
  739. try {
  740. yield (0,_predicate__WEBPACK_IMPORTED_MODULE_1__.getPredicatePromise)(response);
  741. }
  742. catch (cause) {
  743. throw new Error(message /* , {cause} */);
  744. }
  745. });
  746. }
  747. function validateValue(valueBreadcrumbs, value, predicateBreadcrumbs, predicate) {
  748. return __awaiter(this, void 0, void 0, function* () {
  749. if (typeof predicate === 'function') {
  750. yield getBoundPredicatePromise(predicate(value), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError(predicateBreadcrumbs));
  751. return;
  752. }
  753. if (!predicate.includes(value))
  754. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError(predicateBreadcrumbs), new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError(valueBreadcrumbs, value, predicate));
  755. });
  756. }
  757. function validateChild(breadcrumbs, child) {
  758. return __awaiter(this, void 0, void 0, function* () {
  759. if (!('predicate' in child)) {
  760. return;
  761. }
  762. if (!('value' in child)) {
  763. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.HangingPredicateError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(breadcrumbs, 'value', true));
  764. }
  765. if (Array.isArray(child.predicate)) {
  766. if (child.predicate.length === 0)
  767. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.NoOptionsError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.EmptyArrayError([...breadcrumbs, 'predicate']));
  768. const type = typeof child.predicate[0];
  769. for (let i = 1; i < child.predicate.length; ++i) {
  770. if (typeof child.predicate[i] !== type)
  771. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.MismatchedOptionsError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, 'predicate', i.toString()], typeof child.predicate[i], [type]));
  772. }
  773. }
  774. yield validateValue([...breadcrumbs, 'value'], child.value, [...breadcrumbs, 'predicate'], child.predicate);
  775. });
  776. }
  777. function validateParent(breadcrumbs, parent) {
  778. const promises = [];
  779. if ('seed' in parent) {
  780. const { seed } = parent;
  781. promises.push(validateChild([...breadcrumbs, 'seed'], seed));
  782. if ('children' in seed) {
  783. promises.push(...validateParent([...breadcrumbs, 'seed'], seed));
  784. }
  785. }
  786. const { children } = parent;
  787. if ('poolId' in parent && Math.floor(parent.poolId) !== parent.poolId)
  788. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.NonIntegerError([...breadcrumbs, 'poolId']);
  789. if ('childPredicate' in parent) {
  790. promises.push(getBoundPredicatePromise(parent.childPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'childPredicate'])));
  791. }
  792. if ('descendantPredicate' in parent) {
  793. promises.push(getBoundPredicatePromise(parent.descendantPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'descendantPredicate'])));
  794. }
  795. for (const [i, child] of children.entries()) {
  796. const childBreadcrumbs = [...breadcrumbs, 'children', i.toString()];
  797. promises.push(validateChild(childBreadcrumbs, child));
  798. if ('children' in child) {
  799. promises.push(...validateParent(childBreadcrumbs, child));
  800. }
  801. }
  802. return promises;
  803. }
  804.  
  805.  
  806. /***/ }),
  807.  
  808. /***/ "./ts/library/validation/types.ts":
  809. /*!****************************************!*\
  810. !*** ./ts/library/validation/types.ts ***!
  811. \****************************************/
  812. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  813.  
  814. __webpack_require__.r(__webpack_exports__);
  815. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  816. /* harmony export */ CONFIG_KEYS: () => (/* binding */ CONFIG_KEYS),
  817. /* harmony export */ CONTRAST_METHODS: () => (/* binding */ CONTRAST_METHODS),
  818. /* harmony export */ INPUT_FORMATS: () => (/* binding */ INPUT_FORMATS),
  819. /* harmony export */ LEAF_KEYS: () => (/* binding */ LEAF_KEYS),
  820. /* harmony export */ MIDDLE_KEYS: () => (/* binding */ MIDDLE_KEYS),
  821. /* harmony export */ PREDICATE_TYPES: () => (/* binding */ PREDICATE_TYPES),
  822. /* harmony export */ ROOT_KEYS: () => (/* binding */ ROOT_KEYS),
  823. /* harmony export */ VALUE_TYPES: () => (/* binding */ VALUE_TYPES)
  824. /* harmony export */ });
  825. // Value types
  826. const VALUE_TYPES = ['boolean', 'number', 'string'];
  827. const PREDICATE_TYPES = ['array', 'function'];
  828. const INPUT_FORMATS = ['color', 'date', 'datetime-local', 'email', 'month', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
  829. const CONTRAST_METHODS = ['Black / White', 'Invert'];
  830. // Node types
  831. const LEAF_KEYS = ['label', 'value', 'predicate', 'input', 'isActive'];
  832. const ROOT_KEYS = ['children', 'seed', 'childPredicate', 'descendantPredicate', 'poolId'];
  833. const MIDDLE_KEYS = [...LEAF_KEYS, ...ROOT_KEYS];
  834. // Config type
  835. const CONFIG_KEYS = ['title', 'defaultTree', 'userTree', 'defaultStyle', 'userStyles'];
  836.  
  837.  
  838. /***/ }),
  839.  
  840. /***/ "./ts/modal/body/consts.ts":
  841. /*!*********************************!*\
  842. !*** ./ts/modal/body/consts.ts ***!
  843. \*********************************/
  844. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  845.  
  846. __webpack_require__.r(__webpack_exports__);
  847. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  848. /* harmony export */ MODAL_BODY_ID: () => (/* binding */ MODAL_BODY_ID)
  849. /* harmony export */ });
  850. const MODAL_BODY_ID = 'modal-body';
  851.  
  852.  
  853. /***/ }),
  854.  
  855. /***/ "./ts/modal/body/css.ts":
  856. /*!******************************!*\
  857. !*** ./ts/modal/body/css.ts ***!
  858. \******************************/
  859. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  860.  
  861. __webpack_require__.r(__webpack_exports__);
  862. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  863. /* harmony export */ "default": () => (/* binding */ generate)
  864. /* harmony export */ });
  865. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  866. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  867.  
  868.  
  869. function generate() {
  870. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID}`, [
  871. ['overflow', 'hidden'],
  872. ['position', 'relative'],
  873. ]);
  874. }
  875.  
  876.  
  877. /***/ }),
  878.  
  879. /***/ "./ts/modal/body/index.ts":
  880. /*!********************************!*\
  881. !*** ./ts/modal/body/index.ts ***!
  882. \********************************/
  883. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  884.  
  885. __webpack_require__.r(__webpack_exports__);
  886. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  887. /* harmony export */ "default": () => (/* binding */ generate),
  888. /* harmony export */ reset: () => (/* binding */ reset)
  889. /* harmony export */ });
  890. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  891. /* harmony import */ var _trees__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./trees */ "./ts/modal/body/trees/index.ts");
  892. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/body/css.ts");
  893. /* harmony import */ var _trees_style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./trees/style */ "./ts/modal/body/trees/style/index.ts");
  894. /* harmony import */ var _trees_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./trees/data */ "./ts/modal/body/trees/data/index.ts");
  895. /* harmony import */ var _trees_style_update__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trees/style/update */ "./ts/modal/body/trees/style/update/index.ts");
  896. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  897. /* harmony import */ var _nodes_actions_active__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/active */ "./ts/modal/body/trees/nodes/actions/active.ts");
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906. let resetTree;
  907. function generate({ userTree, defaultTree, userStyles, defaultStyle }) {
  908. resetTree = defaultTree;
  909. (0,_trees_style_update__WEBPACK_IMPORTED_MODULE_5__["default"])((0,_trees_style__WEBPACK_IMPORTED_MODULE_3__.getActiveStyle)(userStyles, defaultStyle));
  910. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  911. const element = document.createElement('div');
  912. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID;
  913. element.append((0,_trees__WEBPACK_IMPORTED_MODULE_1__["default"])(userTree !== null && userTree !== void 0 ? userTree : defaultTree, userStyles, defaultStyle), (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_6__.generateEave)());
  914. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_6__.onMount)();
  915. (0,_nodes_actions_active__WEBPACK_IMPORTED_MODULE_7__.onMount)();
  916. return element;
  917. }
  918. function reset() {
  919. (0,_trees_data__WEBPACK_IMPORTED_MODULE_4__.setTree)(resetTree);
  920. }
  921.  
  922.  
  923. /***/ }),
  924.  
  925. /***/ "./ts/modal/body/trees/consts.ts":
  926. /*!***************************************!*\
  927. !*** ./ts/modal/body/trees/consts.ts ***!
  928. \***************************************/
  929. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  930.  
  931. __webpack_require__.r(__webpack_exports__);
  932. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  933. /* harmony export */ TREE_CONTAINER_ID: () => (/* binding */ TREE_CONTAINER_ID)
  934. /* harmony export */ });
  935. const TREE_CONTAINER_ID = 'tree-container';
  936.  
  937.  
  938. /***/ }),
  939.  
  940. /***/ "./ts/modal/body/trees/css.ts":
  941. /*!************************************!*\
  942. !*** ./ts/modal/body/trees/css.ts ***!
  943. \************************************/
  944. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  945.  
  946. __webpack_require__.r(__webpack_exports__);
  947. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  948. /* harmony export */ "default": () => (/* binding */ generate)
  949. /* harmony export */ });
  950. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/consts.ts");
  951. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  952. /* harmony import */ var _nodes_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/css */ "./ts/modal/body/trees/nodes/css.ts");
  953. /* harmony import */ var _nodes_actions_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nodes/actions/css */ "./ts/modal/body/trees/nodes/actions/css.ts");
  954.  
  955.  
  956.  
  957.  
  958. function generate() {
  959. (0,_nodes_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  960. (0,_nodes_actions_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  961. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TREE_CONTAINER_ID}`, [
  962. ['height', '60vh'],
  963. ['overflow-y', 'auto'],
  964. ['overscroll-behavior', 'contain'],
  965. ['display', 'flex'],
  966. ['background-color', `var(--nodeBase0)`],
  967. ]);
  968. }
  969.  
  970.  
  971. /***/ }),
  972.  
  973. /***/ "./ts/modal/body/trees/data/consts.ts":
  974. /*!********************************************!*\
  975. !*** ./ts/modal/body/trees/data/consts.ts ***!
  976. \********************************************/
  977. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  978.  
  979. __webpack_require__.r(__webpack_exports__);
  980. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  981. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  982. /* harmony export */ });
  983. const ROOT_ID = 'root-data';
  984.  
  985.  
  986. /***/ }),
  987.  
  988. /***/ "./ts/modal/body/trees/data/index.ts":
  989. /*!*******************************************!*\
  990. !*** ./ts/modal/body/trees/data/index.ts ***!
  991. \*******************************************/
  992. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  993.  
  994. __webpack_require__.r(__webpack_exports__);
  995. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  996. /* harmony export */ "default": () => (/* binding */ generate),
  997. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  998. /* harmony export */ setTree: () => (/* binding */ setTree)
  999. /* harmony export */ });
  1000. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/data/consts.ts");
  1001. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/trees/index.ts");
  1002.  
  1003.  
  1004. function getRoot() {
  1005. return _index__WEBPACK_IMPORTED_MODULE_1__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  1006. }
  1007. function setTree(data) {
  1008. const root = getRoot();
  1009. // Spread is necessary to avoid a shrinking iterable
  1010. for (const child of [...root.children]) {
  1011. child.disconnect();
  1012. }
  1013. root.addChildren(data.children);
  1014. }
  1015. function generate(data) {
  1016. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.generateTree)(data, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  1017. }
  1018.  
  1019.  
  1020. /***/ }),
  1021.  
  1022. /***/ "./ts/modal/body/trees/index.ts":
  1023. /*!**************************************!*\
  1024. !*** ./ts/modal/body/trees/index.ts ***!
  1025. \**************************************/
  1026. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1027.  
  1028. __webpack_require__.r(__webpack_exports__);
  1029. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1030. /* harmony export */ ROOTS: () => (/* binding */ ROOTS),
  1031. /* harmony export */ TREE_CONTAINER: () => (/* binding */ TREE_CONTAINER),
  1032. /* harmony export */ "default": () => (/* binding */ generate),
  1033. /* harmony export */ generateTree: () => (/* binding */ generateTree),
  1034. /* harmony export */ setActive: () => (/* binding */ setActive)
  1035. /* harmony export */ });
  1036. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/consts.ts");
  1037. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./style */ "./ts/modal/body/trees/style/index.ts");
  1038. /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./data */ "./ts/modal/body/trees/data/index.ts");
  1039. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/body/trees/css.ts");
  1040. /* harmony import */ var _nodes_root__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nodes/root */ "./ts/modal/body/trees/nodes/root.ts");
  1041. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048. const ROOTS = {};
  1049. const TREE_CONTAINER = document.createElement('div');
  1050. function setActive(button, actionId, doActivate = true) {
  1051. if (doActivate) {
  1052. button.classList.add(_consts__WEBPACK_IMPORTED_MODULE_5__.BUTTON_ACTIVE_CLASS);
  1053. TREE_CONTAINER.classList.add(actionId);
  1054. }
  1055. else {
  1056. button.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_5__.BUTTON_ACTIVE_CLASS);
  1057. TREE_CONTAINER.classList.remove(actionId);
  1058. }
  1059. }
  1060. function generateTree(data, id) {
  1061. if (ROOTS[id]) {
  1062. throw new Error(`Attempted to instantiate second tree with id '${id}'.`);
  1063. }
  1064. const root = new _nodes_root__WEBPACK_IMPORTED_MODULE_4__["default"](data);
  1065. root.element.elementContainer.id = id;
  1066. ROOTS[id] = root;
  1067. return root.element.elementContainer;
  1068. }
  1069. function generate(data, userStyles, defaultStyle) {
  1070. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1071. TREE_CONTAINER.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TREE_CONTAINER_ID;
  1072. TREE_CONTAINER.append((0,_style__WEBPACK_IMPORTED_MODULE_1__["default"])(userStyles, defaultStyle), (0,_data__WEBPACK_IMPORTED_MODULE_2__["default"])(data));
  1073. return TREE_CONTAINER;
  1074. }
  1075.  
  1076.  
  1077. /***/ }),
  1078.  
  1079. /***/ "./ts/modal/body/trees/nodes/actions/active.ts":
  1080. /*!*****************************************************!*\
  1081. !*** ./ts/modal/body/trees/nodes/actions/active.ts ***!
  1082. \*****************************************************/
  1083. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1084.  
  1085. __webpack_require__.r(__webpack_exports__);
  1086. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1087. /* harmony export */ onMount: () => (/* binding */ onMount),
  1088. /* harmony export */ register: () => (/* binding */ register),
  1089. /* harmony export */ reset: () => (/* binding */ reset)
  1090. /* harmony export */ });
  1091. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  1092. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  1093. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  1094. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./buttons/position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  1095. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101. function register() {
  1102. _edit__WEBPACK_IMPORTED_MODULE_0__.reset();
  1103. }
  1104. function reset() {
  1105. for (const action of [_edit__WEBPACK_IMPORTED_MODULE_0__, _buttons_position__WEBPACK_IMPORTED_MODULE_3__, _focus__WEBPACK_IMPORTED_MODULE_2__, _highlight__WEBPACK_IMPORTED_MODULE_1__]) {
  1106. if (action.isActive()) {
  1107. action.reset();
  1108. return true;
  1109. }
  1110. }
  1111. return false;
  1112. }
  1113. function onMount() {
  1114. (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)().addEventListener('keydown', (event) => {
  1115. if (event.key === 'Escape' && reset()) {
  1116. event.stopPropagation();
  1117. }
  1118. });
  1119. }
  1120.  
  1121.  
  1122. /***/ }),
  1123.  
  1124. /***/ "./ts/modal/body/trees/nodes/actions/buttons/button.ts":
  1125. /*!*************************************************************!*\
  1126. !*** ./ts/modal/body/trees/nodes/actions/buttons/button.ts ***!
  1127. \*************************************************************/
  1128. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1129.  
  1130. __webpack_require__.r(__webpack_exports__);
  1131. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1132. /* harmony export */ addActionButton: () => (/* binding */ addActionButton),
  1133. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  1134. /* harmony export */ });
  1135. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1136. /* harmony import */ var _active__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../active */ "./ts/modal/body/trees/nodes/actions/active.ts");
  1137. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1138. /* harmony import */ var _modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/alternate */ "./ts/modal/header/actions/alternate/index.ts");
  1139.  
  1140.  
  1141.  
  1142.  
  1143. // Creates an instantiation & adds it to the DOM
  1144. function addActionButton(template, onClick, node) {
  1145. const button = template.cloneNode(true);
  1146. button.addEventListener('click', (event) => {
  1147. event.stopPropagation();
  1148. _active__WEBPACK_IMPORTED_MODULE_1__.register();
  1149. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_3__.isActive)());
  1150. });
  1151. button.addEventListener('keydown', (event) => {
  1152. // Prevent button presses via the Enter key from triggering actions
  1153. if (event.key === 'Enter') {
  1154. event.stopPropagation();
  1155. }
  1156. });
  1157. button.addEventListener('mouseleave', () => {
  1158. button.blur();
  1159. });
  1160. node.element.addButton(button);
  1161. return button;
  1162. }
  1163. // Creates a template
  1164. const getNewButton = (function () {
  1165. const buttonTemplate = document.createElement('button');
  1166. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  1167. // Prevent tabbing to buttons until node is focused
  1168. buttonTemplate.setAttribute('tabIndex', '-1');
  1169. const svgTemplate = (() => {
  1170. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  1171. circle.setAttribute('r', '50');
  1172. circle.setAttribute('stroke-width', '10');
  1173. const svg = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'svg');
  1174. svg.setAttribute('viewBox', '-70 -70 140 140');
  1175. svg.append(circle);
  1176. return svg;
  1177. })();
  1178. return function (group, actionId, description) {
  1179. const button = buttonTemplate.cloneNode(true);
  1180. const svg = svgTemplate.cloneNode(true);
  1181. button.classList.add(actionId);
  1182. button.title = description;
  1183. svg.append(group);
  1184. button.append(svg);
  1185. return button;
  1186. };
  1187. })();
  1188.  
  1189.  
  1190. /***/ }),
  1191.  
  1192. /***/ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts":
  1193. /*!*************************************************************!*\
  1194. !*** ./ts/modal/body/trees/nodes/actions/buttons/consts.ts ***!
  1195. \*************************************************************/
  1196. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1197.  
  1198. __webpack_require__.r(__webpack_exports__);
  1199. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1200. /* harmony export */ ALT_CLASS: () => (/* binding */ ALT_CLASS),
  1201. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  1202. /* harmony export */ PROSPECTIVE_CLASS: () => (/* binding */ PROSPECTIVE_CLASS)
  1203. /* harmony export */ });
  1204. const BUTTON_CLASS = 'node-button';
  1205. const ALT_CLASS = 'node-icon-alt';
  1206. const PROSPECTIVE_CLASS = 'node-prospective';
  1207.  
  1208.  
  1209. /***/ }),
  1210.  
  1211. /***/ "./ts/modal/body/trees/nodes/actions/buttons/create/button.ts":
  1212. /*!********************************************************************!*\
  1213. !*** ./ts/modal/body/trees/nodes/actions/buttons/create/button.ts ***!
  1214. \********************************************************************/
  1215. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1216.  
  1217. __webpack_require__.r(__webpack_exports__);
  1218. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1219. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1220. /* harmony export */ });
  1221. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/create/consts.ts");
  1222. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/trees/nodes/actions/buttons/position/button/alt.ts");
  1223. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1224.  
  1225.  
  1226.  
  1227. const lineHorizontal = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1228. lineHorizontal.setAttribute('stroke-linecap', 'round');
  1229. lineHorizontal.setAttribute('stroke-width', '12');
  1230. lineHorizontal.setAttribute('x1', '-25');
  1231. lineHorizontal.setAttribute('x2', '25');
  1232. const lineVertical = lineHorizontal.cloneNode(true);
  1233. lineVertical.setAttribute('transform', 'rotate(90)');
  1234. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1235. g.append(lineHorizontal, lineVertical);
  1236. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Create', { scale: '1 1.15' });
  1237. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1238.  
  1239.  
  1240. /***/ }),
  1241.  
  1242. /***/ "./ts/modal/body/trees/nodes/actions/buttons/create/consts.ts":
  1243. /*!********************************************************************!*\
  1244. !*** ./ts/modal/body/trees/nodes/actions/buttons/create/consts.ts ***!
  1245. \********************************************************************/
  1246. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1247.  
  1248. __webpack_require__.r(__webpack_exports__);
  1249. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1250. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1251. /* harmony export */ });
  1252. const ACTION_ID = 'node-create';
  1253.  
  1254.  
  1255. /***/ }),
  1256.  
  1257. /***/ "./ts/modal/body/trees/nodes/actions/buttons/create/css.ts":
  1258. /*!*****************************************************************!*\
  1259. !*** ./ts/modal/body/trees/nodes/actions/buttons/create/css.ts ***!
  1260. \*****************************************************************/
  1261. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1262.  
  1263. __webpack_require__.r(__webpack_exports__);
  1264. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1265. /* harmony export */ "default": () => (/* binding */ generate)
  1266. /* harmony export */ });
  1267. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/create/consts.ts");
  1268. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/trees/nodes/actions/buttons/css.ts");
  1269.  
  1270.  
  1271. function generate() {
  1272. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonCreate');
  1273. }
  1274.  
  1275.  
  1276. /***/ }),
  1277.  
  1278. /***/ "./ts/modal/body/trees/nodes/actions/buttons/create/index.ts":
  1279. /*!*******************************************************************!*\
  1280. !*** ./ts/modal/body/trees/nodes/actions/buttons/create/index.ts ***!
  1281. \*******************************************************************/
  1282. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1283.  
  1284. __webpack_require__.r(__webpack_exports__);
  1285. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1286. /* harmony export */ mount: () => (/* binding */ mount),
  1287. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1288. /* harmony export */ });
  1289. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/create/consts.ts");
  1290. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/trees/nodes/actions/buttons/create/button.ts");
  1291. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1292. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1293. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  1294. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  1295. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts");
  1296. /* harmony import */ var _nodes_middle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/middle */ "./ts/modal/body/trees/nodes/middle.ts");
  1297. /* harmony import */ var _nodes_child__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/child */ "./ts/modal/body/trees/nodes/child.ts");
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307. let activeNode;
  1308. function reset() {
  1309. if (!activeNode) {
  1310. return;
  1311. }
  1312. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1313. activeNode = undefined;
  1314. }
  1315. function getChild(node) {
  1316. const { seed } = node;
  1317. const child = 'children' in seed ? new _nodes_middle__WEBPACK_IMPORTED_MODULE_7__["default"](seed, node, 0) : new _nodes_child__WEBPACK_IMPORTED_MODULE_8__["default"](seed, node, 0);
  1318. child.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1319. return child;
  1320. }
  1321. function doAction(source, parent, index, button) {
  1322. const child = getChild(source);
  1323. child.move(parent, index);
  1324. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(parent))
  1325. .then(() => {
  1326. child.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1327. child.isActive = true;
  1328. reset();
  1329. // Show the new node
  1330. child.element.scrollIntoView();
  1331. })
  1332. .catch((reason) => {
  1333. child.disconnect();
  1334. if (reason) {
  1335. (0,_tooltip__WEBPACK_IMPORTED_MODULE_6__.show)(reason, button);
  1336. }
  1337. });
  1338. }
  1339. function onClick(node, button, isAlt) {
  1340. const previousNode = activeNode;
  1341. reset();
  1342. if (!isAlt) {
  1343. doAction(node, node, 0, button);
  1344. }
  1345. else if (!previousNode || node !== previousNode) {
  1346. activeNode = node;
  1347. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node.seed, node, node.children, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1348. }
  1349. }
  1350. function mount(node) {
  1351. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1352. }
  1353. function shouldMount(node) {
  1354. return 'seed' in node;
  1355. }
  1356.  
  1357.  
  1358. /***/ }),
  1359.  
  1360. /***/ "./ts/modal/body/trees/nodes/actions/buttons/css.ts":
  1361. /*!**********************************************************!*\
  1362. !*** ./ts/modal/body/trees/nodes/actions/buttons/css.ts ***!
  1363. \**********************************************************/
  1364. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1365.  
  1366. __webpack_require__.r(__webpack_exports__);
  1367. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1368. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  1369. /* harmony export */ "default": () => (/* binding */ generate)
  1370. /* harmony export */ });
  1371. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1372. /* harmony import */ var _create_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create/css */ "./ts/modal/body/trees/nodes/actions/buttons/create/css.ts");
  1373. /* harmony import */ var _move_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./move/css */ "./ts/modal/body/trees/nodes/actions/buttons/move/css.ts");
  1374. /* harmony import */ var _disable_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./disable/css */ "./ts/modal/body/trees/nodes/actions/buttons/disable/css.ts");
  1375. /* harmony import */ var _duplicate_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./duplicate/css */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/css.ts");
  1376. /* harmony import */ var _position_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./position/css */ "./ts/modal/body/trees/nodes/actions/buttons/position/css.ts");
  1377. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../focus/consts */ "./ts/modal/body/trees/nodes/actions/focus/consts.ts");
  1378. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/trees/nodes/actions/highlight/consts.ts");
  1379. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  1380. /* harmony import */ var _modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/body/trees/style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  1381. /* harmony import */ var _modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/header/actions/alternate/consts */ "./ts/modal/header/actions/alternate/consts.ts");
  1382. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1383. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. function addColourRule(actionId, strokeVar) {
  1398. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)([
  1399. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_6__.FOCUS_SOURCE_CLASS}):not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS}) > `
  1400. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER} `
  1401. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId} > svg`,
  1402. ], ['fill', `var(${strokeVar})`]);
  1403. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)([
  1404. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_6__.FOCUS_SOURCE_CLASS}):not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS}) > `
  1405. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER} `
  1406. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_11__.BUTTON_ACTIVE_CLASS}) > svg > g`,
  1407. ], ['stroke', `none`]);
  1408. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1409. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_11__.BUTTON_ACTIVE_CLASS} > svg > g`, ['stroke', `var(${strokeVar})`]);
  1410. }
  1411. function generate() {
  1412. (0,_create_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1413. (0,_move_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  1414. (0,_disable_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1415. (0,_duplicate_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  1416. (0,_position_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  1417. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, ['height', '100%']);
  1418. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  1419. ['height', '100%'],
  1420. ['transform', 'scale(1.05)'],
  1421. ]);
  1422. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER}`, ['white-space', 'nowrap']);
  1423. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(${_focus_consts__WEBPACK_IMPORTED_MODULE_6__.FOCUS_SOURCE_CLASS}):not(${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS}) > `
  1424. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > ${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER} circle`, ['stroke', 'transparent']);
  1425. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(
  1426. // Not focused, not hovered
  1427. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_6__.FOCUS_SOURCE_CLASS}):not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS}) > `
  1428. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER} svg`, [['fill', 'none']]);
  1429. // Hide prospective nodes
  1430. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.PROSPECTIVE_CLASS}`, ['display', 'none']);
  1431. // Hide alt icon components
  1432. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS}:not(.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_10__.ACTION_ID} *)`, ['display', 'none']);
  1433. (0,_modal_css__WEBPACK_IMPORTED_MODULE_12__.addRule)(`.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_10__.ACTION_ID} button.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS} + *`, ['display', 'none']);
  1434. (0,_modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_9__.addDepthChangeListener)((depth, addRule) => {
  1435. const depthSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.DEPTH_CLASS_PREFIX}${depth} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_8__.ELEMENT_CLASSES.BUTTON_CONTAINER}`;
  1436. addRule(`${depthSelector} svg`, ['stroke', `var(--nodeBase${depth})`]);
  1437. addRule([
  1438. // Not active, focused
  1439. `${depthSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  1440. `${depthSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  1441. `.${_highlight_consts__WEBPACK_IMPORTED_MODULE_7__.HIGHLIGHT_CLASS}${depthSelector} .${_modal_consts__WEBPACK_IMPORTED_MODULE_11__.BUTTON_ACTIVE_CLASS} > svg`,
  1442. ], [
  1443. ['stroke', `var(--nodeContrast${depth})`],
  1444. ['fill', `var(--nodeBase${depth})`],
  1445. ]);
  1446. });
  1447. }
  1448.  
  1449.  
  1450. /***/ }),
  1451.  
  1452. /***/ "./ts/modal/body/trees/nodes/actions/buttons/disable/button.ts":
  1453. /*!*********************************************************************!*\
  1454. !*** ./ts/modal/body/trees/nodes/actions/buttons/disable/button.ts ***!
  1455. \*********************************************************************/
  1456. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1457.  
  1458. __webpack_require__.r(__webpack_exports__);
  1459. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1460. /* harmony export */ BUTTON_ALT: () => (/* binding */ BUTTON_ALT),
  1461. /* harmony export */ BUTTON_DEFAULT: () => (/* binding */ BUTTON_DEFAULT)
  1462. /* harmony export */ });
  1463. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts");
  1464. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1465. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1466. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1467.  
  1468.  
  1469.  
  1470.  
  1471. const gDefault = (() => {
  1472. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1473. circle.setAttribute('r', '30');
  1474. circle.setAttribute('stroke-width', '10');
  1475. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1476. line.setAttribute('stroke-linecap', 'round');
  1477. line.setAttribute('stroke-width', '10');
  1478. line.setAttribute('x1', '-30');
  1479. line.setAttribute('x2', '30');
  1480. line.setAttribute('transform', 'rotate(45)');
  1481. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1482. g.append(circle, line);
  1483. return g;
  1484. })();
  1485. const BUTTON_DEFAULT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gDefault, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, 'Toggle Enabled');
  1486. const gAlt = (() => {
  1487. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1488. line0.setAttribute('stroke-linecap', 'round');
  1489. line0.setAttribute('stroke-width', '12');
  1490. line0.setAttribute('x1', '-20');
  1491. line0.setAttribute('x2', '20');
  1492. line0.setAttribute('y1', '-20');
  1493. line0.setAttribute('y2', '20');
  1494. const line1 = line0.cloneNode(true);
  1495. line1.setAttribute('transform', 'rotate(90)');
  1496. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1497. g.append(line0, line1);
  1498. return g;
  1499. })();
  1500. const BUTTON_ALT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gAlt, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, 'Delete');
  1501. BUTTON_ALT.classList.add(_consts__WEBPACK_IMPORTED_MODULE_1__.ALT_CLASS);
  1502.  
  1503.  
  1504. /***/ }),
  1505.  
  1506. /***/ "./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts":
  1507. /*!*********************************************************************!*\
  1508. !*** ./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts ***!
  1509. \*********************************************************************/
  1510. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1511.  
  1512. __webpack_require__.r(__webpack_exports__);
  1513. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1514. /* harmony export */ ACTION_ID_ALT: () => (/* binding */ ACTION_ID_ALT),
  1515. /* harmony export */ ACTION_ID_DEFAULT: () => (/* binding */ ACTION_ID_DEFAULT),
  1516. /* harmony export */ DISABLED_CLASS: () => (/* binding */ DISABLED_CLASS)
  1517. /* harmony export */ });
  1518. const ACTION_ID_DEFAULT = 'node-active';
  1519. const ACTION_ID_ALT = 'node-delete';
  1520. const DISABLED_CLASS = 'node-disable';
  1521.  
  1522.  
  1523. /***/ }),
  1524.  
  1525. /***/ "./ts/modal/body/trees/nodes/actions/buttons/disable/css.ts":
  1526. /*!******************************************************************!*\
  1527. !*** ./ts/modal/body/trees/nodes/actions/buttons/disable/css.ts ***!
  1528. \******************************************************************/
  1529. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1530.  
  1531. __webpack_require__.r(__webpack_exports__);
  1532. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1533. /* harmony export */ "default": () => (/* binding */ generate)
  1534. /* harmony export */ });
  1535. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts");
  1536. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/trees/nodes/actions/buttons/css.ts");
  1537. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../highlight/consts */ "./ts/modal/body/trees/nodes/actions/highlight/consts.ts");
  1538. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  1539. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545. function generate() {
  1546. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, '--nodeButtonDisable');
  1547. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, '--nodeButtonDelete');
  1548. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([
  1549. // Self selectors
  1550. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > `
  1551. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER} > *`,
  1552. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > `
  1553. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER} > *`,
  1554. // Descendant selectors
  1555. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > `
  1556. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER} > *`,
  1557. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > `
  1558. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER} > *`,
  1559. ], ['opacity', '0.5']);
  1560. }
  1561.  
  1562.  
  1563. /***/ }),
  1564.  
  1565. /***/ "./ts/modal/body/trees/nodes/actions/buttons/disable/index.ts":
  1566. /*!********************************************************************!*\
  1567. !*** ./ts/modal/body/trees/nodes/actions/buttons/disable/index.ts ***!
  1568. \********************************************************************/
  1569. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1570.  
  1571. __webpack_require__.r(__webpack_exports__);
  1572. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1573. /* harmony export */ mount: () => (/* binding */ mount),
  1574. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1575. /* harmony export */ });
  1576. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts");
  1577. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/trees/nodes/actions/buttons/disable/button.ts");
  1578. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1579. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  1580. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts");
  1581. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. function updateButton(button, isActive) {
  1589. button.classList[isActive ? 'remove' : 'add'](_modal_consts__WEBPACK_IMPORTED_MODULE_5__.BUTTON_ACTIVE_CLASS);
  1590. }
  1591. function toggle(node) {
  1592. node.element[`${node.isActive ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1593. node.isActive = !node.isActive;
  1594. }
  1595. function onClick(node, button, isAlt) {
  1596. toggle(node);
  1597. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_3__.getSubPredicateResponses)(node.parent))
  1598. .then(() => {
  1599. if (isAlt) {
  1600. // TODO set up a way to confirm (tooltip + yes/no buttons? require extra button click?)
  1601. node.disconnect();
  1602. }
  1603. else {
  1604. updateButton(button, node.isActive);
  1605. }
  1606. })
  1607. .catch((reason) => {
  1608. toggle(node);
  1609. if (typeof reason === 'string') {
  1610. _tooltip__WEBPACK_IMPORTED_MODULE_4__.show(reason, button);
  1611. }
  1612. });
  1613. }
  1614. function mount(node) {
  1615. (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ALT, onClick, node);
  1616. const defaultButton = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_DEFAULT, onClick, node);
  1617. if (!node.isActive) {
  1618. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1619. updateButton(defaultButton, false);
  1620. }
  1621. }
  1622. function shouldMount(node) {
  1623. return 'seed' in node.parent;
  1624. }
  1625.  
  1626.  
  1627. /***/ }),
  1628.  
  1629. /***/ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/button.ts":
  1630. /*!***********************************************************************!*\
  1631. !*** ./ts/modal/body/trees/nodes/actions/buttons/duplicate/button.ts ***!
  1632. \***********************************************************************/
  1633. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1634.  
  1635. __webpack_require__.r(__webpack_exports__);
  1636. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1637. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1638. /* harmony export */ });
  1639. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/consts.ts");
  1640. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/trees/nodes/actions/buttons/position/button/alt.ts");
  1641. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1642.  
  1643.  
  1644.  
  1645. const RADIUS = 15;
  1646. const HEIGHT = 25;
  1647. const WIDTH = 10;
  1648. const outline0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1649. outline0.setAttribute('stroke-linecap', 'round');
  1650. outline0.setAttribute('stroke-width', '8');
  1651. outline0.setAttribute('fill', 'none');
  1652. outline0.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1653. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1654. + `h -${WIDTH}`
  1655. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1656. + `v ${HEIGHT}`
  1657. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`);
  1658. outline0.setAttribute('transform', `translate(-${RADIUS / 2}, -${RADIUS / 2})`);
  1659. const outline1 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1660. outline1.setAttribute('stroke-linecap', 'round');
  1661. outline1.setAttribute('stroke-width', '8');
  1662. outline1.setAttribute('fill', 'none');
  1663. outline1.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1664. + `q 0,-${RADIUS} -${RADIUS},-${RADIUS}`
  1665. + `h -${WIDTH}`
  1666. + `q -${RADIUS},0 -${RADIUS},${RADIUS}`
  1667. + `v ${HEIGHT}`
  1668. + `q 0,${RADIUS} ${RADIUS},${RADIUS}`
  1669. + `h ${WIDTH}`
  1670. + `q ${RADIUS},0 ${RADIUS},-${RADIUS}`
  1671. + `v -${HEIGHT}`);
  1672. outline1.setAttribute('transform', `translate(${RADIUS / 2}, ${RADIUS / 2})`);
  1673. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1674. g.setAttribute('transform', `rotate(10)`);
  1675. g.append(outline0, outline1);
  1676. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Duplicate', { scale: 0.6, translate: '10 16', rotate: 10 });
  1677. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1678.  
  1679.  
  1680. /***/ }),
  1681.  
  1682. /***/ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/consts.ts":
  1683. /*!***********************************************************************!*\
  1684. !*** ./ts/modal/body/trees/nodes/actions/buttons/duplicate/consts.ts ***!
  1685. \***********************************************************************/
  1686. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1687.  
  1688. __webpack_require__.r(__webpack_exports__);
  1689. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1690. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1691. /* harmony export */ });
  1692. const ACTION_ID = 'node-copy';
  1693.  
  1694.  
  1695. /***/ }),
  1696.  
  1697. /***/ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/css.ts":
  1698. /*!********************************************************************!*\
  1699. !*** ./ts/modal/body/trees/nodes/actions/buttons/duplicate/css.ts ***!
  1700. \********************************************************************/
  1701. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1702.  
  1703. __webpack_require__.r(__webpack_exports__);
  1704. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1705. /* harmony export */ "default": () => (/* binding */ generate)
  1706. /* harmony export */ });
  1707. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/consts.ts");
  1708. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/trees/nodes/actions/buttons/css.ts");
  1709.  
  1710.  
  1711. function generate() {
  1712. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonDuplicate');
  1713. }
  1714.  
  1715.  
  1716. /***/ }),
  1717.  
  1718. /***/ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/index.ts":
  1719. /*!**********************************************************************!*\
  1720. !*** ./ts/modal/body/trees/nodes/actions/buttons/duplicate/index.ts ***!
  1721. \**********************************************************************/
  1722. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1723.  
  1724. __webpack_require__.r(__webpack_exports__);
  1725. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1726. /* harmony export */ mount: () => (/* binding */ mount),
  1727. /* harmony export */ reset: () => (/* binding */ reset),
  1728. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1729. /* harmony export */ });
  1730. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/consts.ts");
  1731. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/button.ts");
  1732. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1733. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1734. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  1735. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  1736. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts");
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744. let activeNode;
  1745. function reset() {
  1746. if (!activeNode) {
  1747. return;
  1748. }
  1749. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1750. activeNode = undefined;
  1751. }
  1752. function validate(copy, button) {
  1753. Promise.all((0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(copy.parent))
  1754. .then(() => {
  1755. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1756. reset();
  1757. // Show the new node
  1758. copy.element.scrollIntoView();
  1759. })
  1760. .catch((reason) => {
  1761. copy.disconnect();
  1762. if (reason) {
  1763. (0,_tooltip__WEBPACK_IMPORTED_MODULE_6__.show)(reason, button);
  1764. }
  1765. });
  1766. }
  1767. function getCopy(node) {
  1768. const copy = node.duplicate();
  1769. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1770. return copy;
  1771. }
  1772. function doAction(node, parent, index, button) {
  1773. const copy = getCopy(node);
  1774. copy.move(parent, index);
  1775. validate(copy, button);
  1776. }
  1777. function onClick(node, button, isAlt) {
  1778. const previousNode = activeNode;
  1779. reset();
  1780. if (!isAlt) {
  1781. validate(getCopy(node), button);
  1782. }
  1783. else if (!previousNode || node !== previousNode) {
  1784. activeNode = node;
  1785. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1786. }
  1787. }
  1788. function mount(node) {
  1789. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1790. }
  1791. function shouldMount(node) {
  1792. return 'seed' in node.parent;
  1793. }
  1794.  
  1795.  
  1796. /***/ }),
  1797.  
  1798. /***/ "./ts/modal/body/trees/nodes/actions/buttons/move/button.ts":
  1799. /*!******************************************************************!*\
  1800. !*** ./ts/modal/body/trees/nodes/actions/buttons/move/button.ts ***!
  1801. \******************************************************************/
  1802. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1803.  
  1804. __webpack_require__.r(__webpack_exports__);
  1805. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1806. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1807. /* harmony export */ });
  1808. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/move/consts.ts");
  1809. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/trees/nodes/actions/buttons/position/button/alt.ts");
  1810. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1811.  
  1812.  
  1813.  
  1814. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1815. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1816. arrowTrunk.setAttribute('stroke-width', '10');
  1817. arrowTrunk.setAttribute('y1', '-30');
  1818. arrowTrunk.setAttribute('y2', '30');
  1819. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1820. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1821. arrowBottomLeft.setAttribute('stroke-width', '10');
  1822. arrowBottomLeft.setAttribute('x2', '-12');
  1823. arrowBottomLeft.setAttribute('y1', '27');
  1824. arrowBottomLeft.setAttribute('y2', '15');
  1825. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1826. arrowBottomRight.setAttribute('x2', '12');
  1827. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1828. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  1829. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Move');
  1830. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1831.  
  1832.  
  1833. /***/ }),
  1834.  
  1835. /***/ "./ts/modal/body/trees/nodes/actions/buttons/move/consts.ts":
  1836. /*!******************************************************************!*\
  1837. !*** ./ts/modal/body/trees/nodes/actions/buttons/move/consts.ts ***!
  1838. \******************************************************************/
  1839. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1840.  
  1841. __webpack_require__.r(__webpack_exports__);
  1842. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1843. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1844. /* harmony export */ });
  1845. const ACTION_ID = 'node-move';
  1846.  
  1847.  
  1848. /***/ }),
  1849.  
  1850. /***/ "./ts/modal/body/trees/nodes/actions/buttons/move/css.ts":
  1851. /*!***************************************************************!*\
  1852. !*** ./ts/modal/body/trees/nodes/actions/buttons/move/css.ts ***!
  1853. \***************************************************************/
  1854. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1855.  
  1856. __webpack_require__.r(__webpack_exports__);
  1857. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1858. /* harmony export */ "default": () => (/* binding */ generate)
  1859. /* harmony export */ });
  1860. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/move/consts.ts");
  1861. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/trees/nodes/actions/buttons/css.ts");
  1862.  
  1863.  
  1864. function generate() {
  1865. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonMove');
  1866. }
  1867.  
  1868.  
  1869. /***/ }),
  1870.  
  1871. /***/ "./ts/modal/body/trees/nodes/actions/buttons/move/index.ts":
  1872. /*!*****************************************************************!*\
  1873. !*** ./ts/modal/body/trees/nodes/actions/buttons/move/index.ts ***!
  1874. \*****************************************************************/
  1875. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1876.  
  1877. __webpack_require__.r(__webpack_exports__);
  1878. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1879. /* harmony export */ mount: () => (/* binding */ mount),
  1880. /* harmony export */ reset: () => (/* binding */ reset),
  1881. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  1882. /* harmony export */ unmount: () => (/* binding */ unmount)
  1883. /* harmony export */ });
  1884. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/move/consts.ts");
  1885. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/trees/nodes/actions/buttons/move/button.ts");
  1886. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1887. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1888. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  1889. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  1890. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../tooltip */ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts");
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898. let activeNode;
  1899. function reset() {
  1900. if (!activeNode) {
  1901. return;
  1902. }
  1903. _position__WEBPACK_IMPORTED_MODULE_4__.reset();
  1904. activeNode = undefined;
  1905. }
  1906. function doAction(node, newParent, index, button) {
  1907. const oldParent = node.parent;
  1908. const copy = node.duplicate();
  1909. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1910. copy.move(newParent, index);
  1911. node.isActive = false;
  1912. Promise.all([
  1913. ...(0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(oldParent),
  1914. ...(oldParent === newParent ? [] : (0,_edit__WEBPACK_IMPORTED_MODULE_5__.getSubPredicateResponses)(newParent)),
  1915. ])
  1916. .then(() => {
  1917. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.PROSPECTIVE_CLASS);
  1918. node.disconnect();
  1919. reset();
  1920. // Show where the node's been moved to
  1921. copy.element.scrollIntoView();
  1922. })
  1923. .catch((reason) => {
  1924. node.isActive = copy.isActive;
  1925. copy.disconnect();
  1926. if (reason) {
  1927. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show(reason, button);
  1928. }
  1929. });
  1930. }
  1931. function onClick(node, button, isAlt) {
  1932. const previousNode = activeNode;
  1933. reset();
  1934. if (!isAlt) {
  1935. const newIndex = node.getIndex() + 2;
  1936. if (newIndex < node.parent.children.length + 1) {
  1937. doAction(node, node.parent, newIndex, button);
  1938. }
  1939. else {
  1940. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show('Node can not be moved down.', button);
  1941. }
  1942. }
  1943. else if (!previousNode || node !== previousNode) {
  1944. // If the only valid target is the current parent
  1945. if (_position__WEBPACK_IMPORTED_MODULE_4__.hasDestinations(node)) {
  1946. activeNode = node;
  1947. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, node.getSiblings(), _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction, false);
  1948. }
  1949. else {
  1950. _tooltip__WEBPACK_IMPORTED_MODULE_6__.show('No other valid locations found.', button);
  1951. }
  1952. }
  1953. }
  1954. function unmount(node) {
  1955. if (activeNode && node === activeNode) {
  1956. reset();
  1957. }
  1958. }
  1959. function mount(node) {
  1960. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1961. }
  1962. function shouldMount(node) {
  1963. return Boolean(node.parent.seed) || ('poolId' in node.parent);
  1964. }
  1965.  
  1966.  
  1967. /***/ }),
  1968.  
  1969. /***/ "./ts/modal/body/trees/nodes/actions/buttons/position/button/alt.ts":
  1970. /*!**************************************************************************!*\
  1971. !*** ./ts/modal/body/trees/nodes/actions/buttons/position/button/alt.ts ***!
  1972. \**************************************************************************/
  1973. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1974.  
  1975. __webpack_require__.r(__webpack_exports__);
  1976. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1977. /* harmony export */ getPositionedButton: () => (/* binding */ getPositionedButton)
  1978. /* harmony export */ });
  1979. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  1980. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  1981. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1982.  
  1983.  
  1984.  
  1985. const G_ALT = (() => {
  1986. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1987. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1988. arrowTrunk.setAttribute('stroke-width', '10');
  1989. arrowTrunk.setAttribute('y1', '-30');
  1990. arrowTrunk.setAttribute('y2', '30');
  1991. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1992. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1993. arrowBottomLeft.setAttribute('stroke-width', '10');
  1994. arrowBottomLeft.setAttribute('x2', '-12');
  1995. arrowBottomLeft.setAttribute('y1', '27');
  1996. arrowBottomLeft.setAttribute('y2', '15');
  1997. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1998. arrowBottomRight.setAttribute('x2', '12');
  1999. const arrowTopRight = arrowBottomLeft.cloneNode(true);
  2000. arrowTopRight.setAttribute('transform', 'rotate(180)');
  2001. const arrowTopLeft = arrowBottomRight.cloneNode(true);
  2002. arrowTopLeft.setAttribute('transform', 'rotate(180)');
  2003. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2004. g.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS);
  2005. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight, arrowTopRight, arrowTopLeft);
  2006. return g;
  2007. })();
  2008. function getPositionedButton(gDefault, actionId, description, transform = {}) {
  2009. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2010. const gAlt = G_ALT.cloneNode(true);
  2011. gAlt.setAttribute('transform', Object.entries(transform).map(([key, value]) => `${key}(${value})`).join(' '));
  2012. g.append(gAlt, gDefault);
  2013. return (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, actionId, description);
  2014. }
  2015.  
  2016.  
  2017. /***/ }),
  2018.  
  2019. /***/ "./ts/modal/body/trees/nodes/actions/buttons/position/button/index.ts":
  2020. /*!****************************************************************************!*\
  2021. !*** ./ts/modal/body/trees/nodes/actions/buttons/position/button/index.ts ***!
  2022. \****************************************************************************/
  2023. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2024.  
  2025. __webpack_require__.r(__webpack_exports__);
  2026. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2027. /* harmony export */ BUTTON_PARENT: () => (/* binding */ BUTTON_PARENT),
  2028. /* harmony export */ BUTTON_SIBLING: () => (/* binding */ BUTTON_SIBLING)
  2029. /* harmony export */ });
  2030. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/buttons/position/consts.ts");
  2031. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  2032. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2033.  
  2034.  
  2035.  
  2036. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2037. arrowTrunk.setAttribute('stroke-linecap', 'round');
  2038. arrowTrunk.setAttribute('stroke-width', '10');
  2039. arrowTrunk.setAttribute('y1', '-30');
  2040. arrowTrunk.setAttribute('y2', '30');
  2041. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2042. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  2043. arrowBottomLeft.setAttribute('stroke-width', '10');
  2044. arrowBottomLeft.setAttribute('x2', '-12');
  2045. arrowBottomLeft.setAttribute('y1', '27');
  2046. arrowBottomLeft.setAttribute('y2', '15');
  2047. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2048. arrowBottomRight.setAttribute('x2', '12');
  2049. const gMain = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2050. gMain.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  2051. const gSibling = gMain.cloneNode(true);
  2052. const BUTTON_SIBLING = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gSibling, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select After');
  2053. const gParent = gMain.cloneNode(true);
  2054. gParent.setAttribute('transform', 'rotate(-45)');
  2055. const BUTTON_PARENT = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gParent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select Into');
  2056.  
  2057.  
  2058. /***/ }),
  2059.  
  2060. /***/ "./ts/modal/body/trees/nodes/actions/buttons/position/consts.ts":
  2061. /*!**********************************************************************!*\
  2062. !*** ./ts/modal/body/trees/nodes/actions/buttons/position/consts.ts ***!
  2063. \**********************************************************************/
  2064. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2065.  
  2066. __webpack_require__.r(__webpack_exports__);
  2067. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2068. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  2069. /* harmony export */ });
  2070. const ACTION_ID = 'node-position';
  2071.  
  2072.  
  2073. /***/ }),
  2074.  
  2075. /***/ "./ts/modal/body/trees/nodes/actions/buttons/position/css.ts":
  2076. /*!*******************************************************************!*\
  2077. !*** ./ts/modal/body/trees/nodes/actions/buttons/position/css.ts ***!
  2078. \*******************************************************************/
  2079. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2080.  
  2081. __webpack_require__.r(__webpack_exports__);
  2082. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2083. /* harmony export */ "default": () => (/* binding */ generate)
  2084. /* harmony export */ });
  2085. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/position/consts.ts");
  2086. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../focus/consts */ "./ts/modal/body/trees/nodes/actions/focus/consts.ts");
  2087. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  2088. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2089.  
  2090.  
  2091.  
  2092.  
  2093. function generate() {
  2094. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS} `
  2095. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS})`, ['display', 'none']);
  2096. }
  2097.  
  2098.  
  2099. /***/ }),
  2100.  
  2101. /***/ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts":
  2102. /*!*********************************************************************!*\
  2103. !*** ./ts/modal/body/trees/nodes/actions/buttons/position/index.ts ***!
  2104. \*********************************************************************/
  2105. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2106.  
  2107. __webpack_require__.r(__webpack_exports__);
  2108. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2109. /* harmony export */ getButton: () => (/* binding */ getButton),
  2110. /* harmony export */ hasDestinations: () => (/* binding */ hasDestinations),
  2111. /* harmony export */ isActive: () => (/* binding */ isActive),
  2112. /* harmony export */ mount: () => (/* binding */ mount),
  2113. /* harmony export */ reset: () => (/* binding */ reset)
  2114. /* harmony export */ });
  2115. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/buttons/position/consts.ts");
  2116. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/trees/nodes/actions/buttons/position/button/index.ts");
  2117. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/trees/nodes/actions/buttons/button.ts");
  2118. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  2119. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  2120. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  2121. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129. const destinations = [];
  2130. let origin;
  2131. function isActive() {
  2132. return Boolean(origin);
  2133. }
  2134. function setActive(doActivate = true) {
  2135. (0,_modal_body_trees__WEBPACK_IMPORTED_MODULE_5__.setActive)(origin.button, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, doActivate);
  2136. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.reset)();
  2137. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focus)(doActivate, origin.source, false);
  2138. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(doActivate, origin.source, doActivate);
  2139. if (doActivate) {
  2140. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.setTabIndexes)(false, origin.source);
  2141. origin.button.setAttribute('tabIndex', '1');
  2142. }
  2143. else {
  2144. origin.button.setAttribute('tabIndex', '-1');
  2145. }
  2146. origin.source.element.headContainer.focus();
  2147. }
  2148. function reset() {
  2149. if (!origin) {
  2150. return;
  2151. }
  2152. for (const { node, isParent, button } of destinations) {
  2153. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(false, node, isParent);
  2154. button.remove();
  2155. }
  2156. destinations.length = 0;
  2157. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(origin.source);
  2158. setActive(false);
  2159. origin = undefined;
  2160. }
  2161. function getButton(node, actionId, onClick, isParent) {
  2162. const button = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(isParent ? _button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_PARENT : _button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_SIBLING, onClick, node);
  2163. button.classList.add(actionId);
  2164. button.classList.add(_modal_consts__WEBPACK_IMPORTED_MODULE_6__.BUTTON_ACTIVE_CLASS);
  2165. button.setAttribute('tabIndex', '1');
  2166. return button;
  2167. }
  2168. function getBoundCallback(callback, parent, index) {
  2169. return (_, button) => callback(parent, index, button);
  2170. }
  2171. function addButtons(parent, actionId, callback, includeSelf) {
  2172. const isCurrentParent = parent === origin.parent;
  2173. if (isCurrentParent || (origin.isPooled && parent.poolId === origin.parent.poolId)) {
  2174. destinations.push({
  2175. node: parent,
  2176. isParent: true,
  2177. button: getButton(parent, actionId, getBoundCallback(callback, parent, 0), true),
  2178. });
  2179. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, parent);
  2180. for (const target of (!includeSelf && isCurrentParent) ? origin.siblings : parent.children) {
  2181. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, target, false);
  2182. destinations.push({
  2183. node: target,
  2184. isParent: false,
  2185. button: getButton(target, actionId, getBoundCallback(callback, target.parent, target.getIndex() + 1), false),
  2186. });
  2187. }
  2188. }
  2189. // Nodes can't be their own descendants
  2190. if (!isCurrentParent) {
  2191. for (const child of parent.children) {
  2192. if ('children' in child) {
  2193. addButtons(child, actionId, callback, includeSelf);
  2194. }
  2195. }
  2196. }
  2197. }
  2198. function hasDestinations(node) {
  2199. if (node.parent.children.length > 1) {
  2200. return true;
  2201. }
  2202. if (!('poolId' in node.parent)) {
  2203. return false;
  2204. }
  2205. const hasMatchingPool = (parent, poolId) => {
  2206. if (parent !== node.parent) {
  2207. if (parent.poolId === poolId) {
  2208. return true;
  2209. }
  2210. for (const child of parent.children) {
  2211. if ('children' in child && hasMatchingPool(child, poolId)) {
  2212. return true;
  2213. }
  2214. }
  2215. }
  2216. return false;
  2217. };
  2218. return hasMatchingPool(node.getRoot(), node.parent.poolId);
  2219. }
  2220. function mount(source, child, parent, siblings, actionId, button, callback, includeSelf = true) {
  2221. reset();
  2222. origin = {
  2223. source,
  2224. child,
  2225. siblings,
  2226. parent,
  2227. isPooled: 'poolId' in parent,
  2228. button,
  2229. actionId,
  2230. };
  2231. addButtons(parent.getRoot(), actionId, callback.bind(null, source), includeSelf);
  2232. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(source);
  2233. setActive();
  2234. return destinations.length;
  2235. }
  2236.  
  2237.  
  2238. /***/ }),
  2239.  
  2240. /***/ "./ts/modal/body/trees/nodes/actions/css.ts":
  2241. /*!**************************************************!*\
  2242. !*** ./ts/modal/body/trees/nodes/actions/css.ts ***!
  2243. \**************************************************/
  2244. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2245.  
  2246. __webpack_require__.r(__webpack_exports__);
  2247. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2248. /* harmony export */ "default": () => (/* binding */ generate)
  2249. /* harmony export */ });
  2250. /* harmony import */ var _edit_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit/css */ "./ts/modal/body/trees/nodes/actions/edit/css.ts");
  2251. /* harmony import */ var _edit_option_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./edit/option/css */ "./ts/modal/body/trees/nodes/actions/edit/option/css.ts");
  2252. /* harmony import */ var _highlight_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./highlight/css */ "./ts/modal/body/trees/nodes/actions/highlight/css.ts");
  2253. /* harmony import */ var _focus_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./focus/css */ "./ts/modal/body/trees/nodes/actions/focus/css.ts");
  2254. /* harmony import */ var _tooltip_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tooltip/css */ "./ts/modal/body/trees/nodes/actions/tooltip/css.ts");
  2255. /* harmony import */ var _buttons_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./buttons/css */ "./ts/modal/body/trees/nodes/actions/buttons/css.ts");
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262. function generate() {
  2263. (0,_edit_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  2264. (0,_edit_option_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  2265. (0,_highlight_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  2266. (0,_focus_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  2267. (0,_tooltip_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  2268. (0,_buttons_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  2269. }
  2270.  
  2271.  
  2272. /***/ }),
  2273.  
  2274. /***/ "./ts/modal/body/trees/nodes/actions/edit/consts.ts":
  2275. /*!**********************************************************!*\
  2276. !*** ./ts/modal/body/trees/nodes/actions/edit/consts.ts ***!
  2277. \**********************************************************/
  2278. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2279.  
  2280. __webpack_require__.r(__webpack_exports__);
  2281. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2282. /* harmony export */ ACTIVE_CLASS: () => (/* binding */ ACTIVE_CLASS),
  2283. /* harmony export */ EDITABLE_CLASS: () => (/* binding */ EDITABLE_CLASS),
  2284. /* harmony export */ INVALID_BACKGROUND_CLASS: () => (/* binding */ INVALID_BACKGROUND_CLASS),
  2285. /* harmony export */ INVALID_CLASS: () => (/* binding */ INVALID_CLASS),
  2286. /* harmony export */ VALID_BACKGROUND_CLASS: () => (/* binding */ VALID_BACKGROUND_CLASS),
  2287. /* harmony export */ VALID_CLASS: () => (/* binding */ VALID_CLASS)
  2288. /* harmony export */ });
  2289. const EDITABLE_CLASS = 'editable';
  2290. const VALID_CLASS = 'valid';
  2291. const INVALID_CLASS = 'invalid';
  2292. const INVALID_BACKGROUND_CLASS = 'background-invalid';
  2293. const VALID_BACKGROUND_CLASS = 'background-valid';
  2294. const ACTIVE_CLASS = 'edit-active';
  2295.  
  2296.  
  2297. /***/ }),
  2298.  
  2299. /***/ "./ts/modal/body/trees/nodes/actions/edit/css.ts":
  2300. /*!*******************************************************!*\
  2301. !*** ./ts/modal/body/trees/nodes/actions/edit/css.ts ***!
  2302. \*******************************************************/
  2303. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2304.  
  2305. __webpack_require__.r(__webpack_exports__);
  2306. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2307. /* harmony export */ "default": () => (/* binding */ generate)
  2308. /* harmony export */ });
  2309. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/edit/consts.ts");
  2310. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  2311. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2312.  
  2313.  
  2314.  
  2315. function generate() {
  2316. // Use pointer when the node has a value and isn't being edited
  2317. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2318. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.EDITABLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  2319. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}:not(:focus)`,
  2320. ], ['cursor', 'pointer']);
  2321. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}`, [
  2322. ['flex-grow', '1'],
  2323. ['padding', '0 0.6em'],
  2324. ['outline', 'none'],
  2325. ]);
  2326. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="checkbox"]`, [
  2327. ['height', '1em'],
  2328. ['width', '2.2em'],
  2329. ['cursor', 'pointer'],
  2330. ]);
  2331. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="color"]`, ['height', '1.3em']);
  2332. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`], ['right', '0']);
  2333. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, ['background-color', 'var(--validBackground)']);
  2334. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`, ['background-color', 'var(--invalidBackground)']);
  2335. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2336. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2337. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2338. ], ['width', '100%']);
  2339. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, ['color', 'var(--validFont) !important']);
  2340. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, ['color', 'var(--invalidFont) !important']);
  2341. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS} *)`, ['pointer-events', 'none']);
  2342. }
  2343.  
  2344.  
  2345. /***/ }),
  2346.  
  2347. /***/ "./ts/modal/body/trees/nodes/actions/edit/index.ts":
  2348. /*!*********************************************************!*\
  2349. !*** ./ts/modal/body/trees/nodes/actions/edit/index.ts ***!
  2350. \*********************************************************/
  2351. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2352.  
  2353. __webpack_require__.r(__webpack_exports__);
  2354. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2355. /* harmony export */ doAction: () => (/* binding */ doAction),
  2356. /* harmony export */ getSubPredicateResponses: () => (/* binding */ getSubPredicateResponses),
  2357. /* harmony export */ isActive: () => (/* binding */ isActive),
  2358. /* harmony export */ mount: () => (/* binding */ mount),
  2359. /* harmony export */ reset: () => (/* binding */ reset),
  2360. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2361. /* harmony export */ unmount: () => (/* binding */ unmount),
  2362. /* harmony export */ update: () => (/* binding */ update)
  2363. /* harmony export */ });
  2364. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/edit/consts.ts");
  2365. /* harmony import */ var _option__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./option */ "./ts/modal/body/trees/nodes/actions/edit/option/index.ts");
  2366. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../tooltip */ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts");
  2367. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  2368. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374. let activeNode;
  2375. function isActive() {
  2376. return Boolean(activeNode);
  2377. }
  2378. function reset() {
  2379. if (!activeNode) {
  2380. return;
  2381. }
  2382. activeNode.element.render(activeNode.value);
  2383. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2384. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2385. activeNode.element.valueElement.blur();
  2386. activeNode.element.valueContainer.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2387. _tooltip__WEBPACK_IMPORTED_MODULE_2__.reset();
  2388. _option__WEBPACK_IMPORTED_MODULE_1__.reset();
  2389. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2390. activeNode = undefined;
  2391. }
  2392. function getValue(node) {
  2393. switch (typeof node.value) {
  2394. case 'boolean':
  2395. return Boolean(node.element.valueElement.checked);
  2396. case 'number':
  2397. return Number(node.element.valueElement.value);
  2398. default:
  2399. return node.element.valueElement.value;
  2400. }
  2401. }
  2402. function getSubPredicateResponse(predicate, children) {
  2403. return (0,_predicate__WEBPACK_IMPORTED_MODULE_4__.getPredicatePromise)(predicate(children.map((child) => child.getJSON())));
  2404. }
  2405. function getDescendantPredicateResponses(node) {
  2406. const responses = [];
  2407. if ('descendantPredicate' in node) {
  2408. responses.push(getSubPredicateResponse(node.descendantPredicate, node.children));
  2409. }
  2410. if ('parent' in node) {
  2411. responses.push(...getDescendantPredicateResponses(node.parent));
  2412. }
  2413. return responses;
  2414. }
  2415. function getChildPredicateResponse(node) {
  2416. if ('childPredicate' in node) {
  2417. return getSubPredicateResponse(node.childPredicate, node.children);
  2418. }
  2419. return Promise.resolve(null);
  2420. }
  2421. function getSubPredicateResponses(parent) {
  2422. return [getChildPredicateResponse(parent), ...getDescendantPredicateResponses(parent)];
  2423. }
  2424. function getOwnPredicateResponse(node) {
  2425. if (!('predicate' in node)) {
  2426. return Promise.resolve();
  2427. }
  2428. const { predicate } = node;
  2429. const value = getValue(node);
  2430. if (typeof predicate === 'function') {
  2431. return (0,_predicate__WEBPACK_IMPORTED_MODULE_4__.getPredicatePromise)(predicate(value));
  2432. }
  2433. return Promise[predicate.indexOf(value) > -1 ? 'resolve' : 'reject']();
  2434. }
  2435. function getAllPredicateResponses(node = activeNode) {
  2436. return [getOwnPredicateResponse(node), ...getSubPredicateResponses(node.parent)];
  2437. }
  2438. function update(node) {
  2439. const previousValue = node.value;
  2440. node.value = getValue(node);
  2441. if (node.hasOptions) {
  2442. _option__WEBPACK_IMPORTED_MODULE_1__.update(node.value);
  2443. }
  2444. Promise.all(getAllPredicateResponses())
  2445. .then(() => {
  2446. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2447. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2448. _tooltip__WEBPACK_IMPORTED_MODULE_2__.hide();
  2449. })
  2450. .catch((reason) => {
  2451. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2452. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2453. activeNode.value = previousValue;
  2454. if (reason) {
  2455. _tooltip__WEBPACK_IMPORTED_MODULE_2__.show(reason);
  2456. }
  2457. });
  2458. }
  2459. function unmount(node) {
  2460. if (node === activeNode) {
  2461. reset();
  2462. }
  2463. }
  2464. function doAction(node) {
  2465. const previousNode = activeNode;
  2466. reset();
  2467. if (previousNode !== node) {
  2468. activeNode = node;
  2469. activeNode.element.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2470. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2471. _tooltip__WEBPACK_IMPORTED_MODULE_2__.setNode(node);
  2472. if (node.hasOptions) {
  2473. _option__WEBPACK_IMPORTED_MODULE_1__.setNode(node);
  2474. }
  2475. if (node.input === 'color') {
  2476. node.element.valueElement.click();
  2477. }
  2478. else {
  2479. node.element.valueElement.select();
  2480. }
  2481. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2482. }
  2483. }
  2484. function mount(node) {
  2485. const { backgroundContainer, valueElement, headContainer } = node.element;
  2486. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.EDITABLE_CLASS);
  2487. backgroundContainer.append(...(() => {
  2488. const valid = document.createElement('div');
  2489. const invalid = document.createElement('div');
  2490. valid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS);
  2491. invalid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS);
  2492. return [valid, invalid];
  2493. })());
  2494. // Start
  2495. valueElement.addEventListener('focus', (event) => {
  2496. event.stopPropagation();
  2497. if (event.relatedTarget && activeNode !== node) {
  2498. doAction(node);
  2499. }
  2500. });
  2501. headContainer.addEventListener('click', (event) => {
  2502. event.stopPropagation();
  2503. if (activeNode !== node) {
  2504. doAction(node);
  2505. }
  2506. });
  2507. // Process new value
  2508. if (typeof node.value === 'boolean') {
  2509. valueElement.addEventListener('click', (event) => {
  2510. event.stopPropagation();
  2511. update(node);
  2512. });
  2513. }
  2514. else {
  2515. valueElement.addEventListener('input', (event) => {
  2516. event.stopPropagation();
  2517. update(node);
  2518. });
  2519. // Stop
  2520. if (node.input === 'color') {
  2521. valueElement.addEventListener('change', (event) => {
  2522. event.stopPropagation();
  2523. reset();
  2524. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.focusHovered)();
  2525. });
  2526. }
  2527. }
  2528. if (node.hasOptions) {
  2529. _option__WEBPACK_IMPORTED_MODULE_1__.generate(node);
  2530. }
  2531. valueElement.addEventListener('keydown', (event) => {
  2532. switch (event.key) {
  2533. case 'Enter':
  2534. case 'Escape':
  2535. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.focusHovered)();
  2536. // eslint-disable-next-line no-fallthrough
  2537. case 'Tab':
  2538. event.stopPropagation();
  2539. reset();
  2540. }
  2541. });
  2542. }
  2543. function shouldMount(node) {
  2544. return 'value' in node;
  2545. }
  2546.  
  2547.  
  2548. /***/ }),
  2549.  
  2550. /***/ "./ts/modal/body/trees/nodes/actions/edit/option/consts.ts":
  2551. /*!*****************************************************************!*\
  2552. !*** ./ts/modal/body/trees/nodes/actions/edit/option/consts.ts ***!
  2553. \*****************************************************************/
  2554. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2555.  
  2556. __webpack_require__.r(__webpack_exports__);
  2557. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2558. /* harmony export */ OPTION_ACTIVE_CLASS: () => (/* binding */ OPTION_ACTIVE_CLASS),
  2559. /* harmony export */ OPTION_BACKGROUND_CLASS: () => (/* binding */ OPTION_BACKGROUND_CLASS),
  2560. /* harmony export */ OPTION_CLASS: () => (/* binding */ OPTION_CLASS),
  2561. /* harmony export */ OPTION_CONTAINER_CLASS: () => (/* binding */ OPTION_CONTAINER_CLASS),
  2562. /* harmony export */ OPTION_PARENT_CLASS: () => (/* binding */ OPTION_PARENT_CLASS),
  2563. /* harmony export */ OPTION_SHOW_CLASS: () => (/* binding */ OPTION_SHOW_CLASS),
  2564. /* harmony export */ OPTION_WRAPPER_CLASS: () => (/* binding */ OPTION_WRAPPER_CLASS)
  2565. /* harmony export */ });
  2566. const OPTION_CLASS = 'option';
  2567. const OPTION_CONTAINER_CLASS = 'option-container';
  2568. const OPTION_PARENT_CLASS = 'option-parent';
  2569. const OPTION_WRAPPER_CLASS = 'option-wrapper';
  2570. const OPTION_BACKGROUND_CLASS = 'option-background';
  2571. const OPTION_SHOW_CLASS = 'option-show';
  2572. const OPTION_ACTIVE_CLASS = 'option-active';
  2573.  
  2574.  
  2575. /***/ }),
  2576.  
  2577. /***/ "./ts/modal/body/trees/nodes/actions/edit/option/css.ts":
  2578. /*!**************************************************************!*\
  2579. !*** ./ts/modal/body/trees/nodes/actions/edit/option/css.ts ***!
  2580. \**************************************************************/
  2581. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2582.  
  2583. __webpack_require__.r(__webpack_exports__);
  2584. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2585. /* harmony export */ "default": () => (/* binding */ generate)
  2586. /* harmony export */ });
  2587. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/edit/option/consts.ts");
  2588. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/nodes/actions/edit/consts.ts");
  2589. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  2590. /* harmony import */ var _modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/trees/style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  2591. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597. function generate() {
  2598. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_WRAPPER_CLASS}`, [
  2599. ['z-index', '1'],
  2600. ['position', 'absolute'],
  2601. ['bottom', '0'],
  2602. ['display', 'flex'],
  2603. ['width', '100%'],
  2604. ['pointer-events', 'initial'],
  2605. ]);
  2606. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}`, [
  2607. ['position', 'absolute'],
  2608. ['display', 'flex'],
  2609. ['flex-direction', 'column'],
  2610. ['width', '100%'],
  2611. ['margin-left', '-1px'],
  2612. ['max-height', 'calc(4.2em + 5px)'],
  2613. ['overflow-y', 'auto'],
  2614. ['border-bottom-left-radius', '12px'],
  2615. ]);
  2616. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_1__.ACTIVE_CLASS} *) `, [['display', 'none']]);
  2617. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}`, [['position', 'relative']]);
  2618. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS} > *`, [['height', '1.4em']]);
  2619. (0,_modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_3__.addDepthChangeListener)((depth, addRule) => {
  2620. const headSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.DEPTH_CLASS_PREFIX}${depth} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  2621. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS}`, [['border', `1px solid var(--nodeBase${depth})`]]);
  2622. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}`, [
  2623. ['background-color', `var(--nodeContrast${depth})`],
  2624. ['color', `var(--nodeBase${depth})`],
  2625. ['border', `1px solid var(--nodeBase${depth})`],
  2626. ]);
  2627. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [['background-color', `var(--nodeBase${depth})`]]);
  2628. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`, [['color', `var(--nodeContrast${depth})`]]);
  2629. addRule(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [['width', '100%']]);
  2630. });
  2631. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`, [
  2632. ['position', 'relative'],
  2633. ['transition-property', 'all'],
  2634. ['transition-duration', '500ms'],
  2635. ['padding', '0 0.6rem'],
  2636. ]);
  2637. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS}`, [
  2638. ['position', 'absolute'],
  2639. ['width', '0'],
  2640. ['transition', 'width 500ms ease 0s'],
  2641. ]);
  2642. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS})`, [['display', 'none']]);
  2643. }
  2644.  
  2645.  
  2646. /***/ }),
  2647.  
  2648. /***/ "./ts/modal/body/trees/nodes/actions/edit/option/index.ts":
  2649. /*!****************************************************************!*\
  2650. !*** ./ts/modal/body/trees/nodes/actions/edit/option/index.ts ***!
  2651. \****************************************************************/
  2652. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2653.  
  2654. __webpack_require__.r(__webpack_exports__);
  2655. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2656. /* harmony export */ generate: () => (/* binding */ generate),
  2657. /* harmony export */ reset: () => (/* binding */ reset),
  2658. /* harmony export */ setNode: () => (/* binding */ setNode),
  2659. /* harmony export */ update: () => (/* binding */ update)
  2660. /* harmony export */ });
  2661. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/edit/option/consts.ts");
  2662. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  2663. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  2664.  
  2665.  
  2666.  
  2667. const activeOptions = [];
  2668. let activeIndex = -1;
  2669. function getTotalOffsetTop(from) {
  2670. let offsetTop = 2;
  2671. let node;
  2672. for (node = from; !node.classList.contains(_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ROOT_CLASS); node = node.offsetParent) {
  2673. offsetTop += node.offsetTop;
  2674. }
  2675. return offsetTop;
  2676. }
  2677. // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
  2678. function escapeRegExp(string) {
  2679. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  2680. }
  2681. function update(value) {
  2682. const regExp = new RegExp(escapeRegExp(value), 'i');
  2683. for (const { parentElement, innerText } of activeOptions) {
  2684. parentElement.classList[regExp.test(innerText) ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS);
  2685. }
  2686. const wrapper = activeOptions[0].parentElement.parentElement;
  2687. const totalOffsetTop = getTotalOffsetTop(wrapper);
  2688. if (_modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop + _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.clientHeight < totalOffsetTop + wrapper.clientHeight) {
  2689. _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop = totalOffsetTop + wrapper.clientHeight - _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.clientHeight;
  2690. }
  2691. }
  2692. function setValue(node, value, doKill = false) {
  2693. node.element.valueElement.value = value;
  2694. node.value = value;
  2695. if (doKill) {
  2696. // Simulate an 'enter' button press
  2697. node.element.valueElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'Tab' }));
  2698. }
  2699. }
  2700. function setActive(option, isActive = true) {
  2701. option.classList[isActive ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_ACTIVE_CLASS);
  2702. }
  2703. function reset() {
  2704. for (const { parentElement } of activeOptions) {
  2705. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS);
  2706. }
  2707. if (activeIndex >= 0) {
  2708. setActive(activeOptions[activeIndex].parentElement, false);
  2709. activeIndex = -1;
  2710. }
  2711. activeOptions.length = 0;
  2712. }
  2713. function setNode(node) {
  2714. activeOptions.push(...node.element.valueContainer.querySelectorAll(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS}`));
  2715. update(node.value);
  2716. }
  2717. function generate(node) {
  2718. const wrapper = document.createElement('div');
  2719. const parent = document.createElement('div');
  2720. for (const value of node.predicate) {
  2721. const container = document.createElement('div');
  2722. const background = document.createElement('div');
  2723. const option = document.createElement('div');
  2724. option.innerText = value;
  2725. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CONTAINER_CLASS);
  2726. option.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_CLASS);
  2727. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_BACKGROUND_CLASS);
  2728. container.append(background, option);
  2729. parent.appendChild(container);
  2730. container.addEventListener('click', (event) => {
  2731. event.stopPropagation();
  2732. // Necessary to prevent re-focusing the input element
  2733. event.preventDefault();
  2734. setValue(node, value, true);
  2735. });
  2736. container.addEventListener('mouseenter', (event) => {
  2737. event.stopPropagation();
  2738. setActive(container);
  2739. });
  2740. container.addEventListener('mouseleave', (event) => {
  2741. event.stopPropagation();
  2742. setActive(container, false);
  2743. });
  2744. }
  2745. node.element.valueElement.addEventListener('keydown', ({ key }) => {
  2746. const priorIndex = activeIndex;
  2747. let hasChanged = false;
  2748. switch (key) {
  2749. case 'Tab':
  2750. case 'Enter':
  2751. if (activeIndex >= 0) {
  2752. setValue(node, activeOptions[activeIndex].innerText);
  2753. }
  2754. return;
  2755. case 'ArrowDown':
  2756. for (let i = activeIndex + 1; i < activeOptions.length; ++i) {
  2757. const { parentElement } = activeOptions[i];
  2758. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS)) {
  2759. activeIndex = i;
  2760. hasChanged = true;
  2761. const optionBottom = parentElement.offsetTop + parentElement.clientHeight;
  2762. if (parentElement.parentElement.scrollTop < optionBottom) {
  2763. parentElement.parentElement.scrollTop = optionBottom - parentElement.parentElement.clientHeight;
  2764. }
  2765. const totalOffsetTop = getTotalOffsetTop(parentElement);
  2766. if (_modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop + _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.clientHeight < totalOffsetTop + parentElement.clientHeight - parentElement.parentElement.scrollTop) {
  2767. _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop = totalOffsetTop + parentElement.clientHeight - _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.clientHeight - parentElement.parentElement.scrollTop;
  2768. }
  2769. break;
  2770. }
  2771. }
  2772. break;
  2773. case 'ArrowUp':
  2774. for (let i = activeIndex - 1; i >= 0; --i) {
  2775. const { parentElement } = activeOptions[i];
  2776. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_SHOW_CLASS)) {
  2777. activeIndex = i;
  2778. hasChanged = true;
  2779. // Scroll option list if necessary
  2780. if (parentElement.parentElement.scrollTop > parentElement.offsetTop) {
  2781. parentElement.parentElement.scrollTop = parentElement.offsetTop;
  2782. }
  2783. const totalOffsetTop = getTotalOffsetTop(parentElement);
  2784. // Scroll modal body if necessary
  2785. if (_modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop > totalOffsetTop - parentElement.parentElement.scrollTop) {
  2786. _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop = totalOffsetTop - parentElement.parentElement.scrollTop;
  2787. }
  2788. break;
  2789. }
  2790. }
  2791. if (hasChanged) {
  2792. break;
  2793. }
  2794. // eslint-disable-next-line no-fallthrough
  2795. default:
  2796. if (activeIndex >= 0) {
  2797. setActive(activeOptions[activeIndex].parentElement, false);
  2798. }
  2799. activeIndex = -1;
  2800. return;
  2801. }
  2802. if (!hasChanged) {
  2803. return;
  2804. }
  2805. if (priorIndex >= 0) {
  2806. setActive(activeOptions[priorIndex].parentElement, false);
  2807. }
  2808. const { parentElement } = activeOptions[activeIndex];
  2809. setActive(parentElement);
  2810. });
  2811. wrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_WRAPPER_CLASS);
  2812. parent.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.OPTION_PARENT_CLASS);
  2813. wrapper.appendChild(parent);
  2814. node.element.valueContainer.appendChild(wrapper);
  2815. }
  2816.  
  2817.  
  2818. /***/ }),
  2819.  
  2820. /***/ "./ts/modal/body/trees/nodes/actions/focus/consts.ts":
  2821. /*!***********************************************************!*\
  2822. !*** ./ts/modal/body/trees/nodes/actions/focus/consts.ts ***!
  2823. \***********************************************************/
  2824. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2825.  
  2826. __webpack_require__.r(__webpack_exports__);
  2827. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2828. /* harmony export */ FOCUS_CLASS: () => (/* binding */ FOCUS_CLASS),
  2829. /* harmony export */ FOCUS_SOURCE_CLASS: () => (/* binding */ FOCUS_SOURCE_CLASS)
  2830. /* harmony export */ });
  2831. const FOCUS_CLASS = 'node-focus';
  2832. const FOCUS_SOURCE_CLASS = 'node-focus-source';
  2833.  
  2834.  
  2835. /***/ }),
  2836.  
  2837. /***/ "./ts/modal/body/trees/nodes/actions/focus/css.ts":
  2838. /*!********************************************************!*\
  2839. !*** ./ts/modal/body/trees/nodes/actions/focus/css.ts ***!
  2840. \********************************************************/
  2841. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2842.  
  2843. __webpack_require__.r(__webpack_exports__);
  2844. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2845. /* harmony export */ "default": () => (/* binding */ generate)
  2846. /* harmony export */ });
  2847. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/focus/consts.ts");
  2848. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  2849. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2850.  
  2851.  
  2852.  
  2853. function generate() {
  2854. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['cursor', 'zoom-in']);
  2855. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}`, ['cursor', 'zoom-out']);
  2856. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS} `
  2857. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS})`
  2858. + `:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER} > *)`, ['display', 'none']);
  2859. // Makes it easy to focus down the tree
  2860. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.MIDDLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [['margin-left', '1.8em']]);
  2861. }
  2862.  
  2863.  
  2864. /***/ }),
  2865.  
  2866. /***/ "./ts/modal/body/trees/nodes/actions/focus/index.ts":
  2867. /*!**********************************************************!*\
  2868. !*** ./ts/modal/body/trees/nodes/actions/focus/index.ts ***!
  2869. \**********************************************************/
  2870. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2871.  
  2872. __webpack_require__.r(__webpack_exports__);
  2873. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2874. /* harmony export */ doAction: () => (/* binding */ doAction),
  2875. /* harmony export */ focus: () => (/* binding */ focus),
  2876. /* harmony export */ focusBranch: () => (/* binding */ focusBranch),
  2877. /* harmony export */ isActive: () => (/* binding */ isActive),
  2878. /* harmony export */ mount: () => (/* binding */ mount),
  2879. /* harmony export */ reset: () => (/* binding */ reset),
  2880. /* harmony export */ setTabIndexes: () => (/* binding */ setTabIndexes),
  2881. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2882. /* harmony export */ unmount: () => (/* binding */ unmount)
  2883. /* harmony export */ });
  2884. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/focus/consts.ts");
  2885. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  2886. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  2887. /* harmony import */ var _active__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../active */ "./ts/modal/body/trees/nodes/actions/active.ts");
  2888.  
  2889.  
  2890.  
  2891.  
  2892. let candidateNode;
  2893. let activeNode;
  2894. function isActive() {
  2895. return Boolean(activeNode);
  2896. }
  2897. function setTabIndexes(doAdd = true, node = activeNode) {
  2898. const { 'buttonContainer': { 'children': buttons }, valueElement } = node.element;
  2899. for (let i = buttons.length - 1; i >= 0; --i) {
  2900. // Must be set to -1 to prevent tabbing (removeAttribute sets it to 0)
  2901. buttons[i].setAttribute('tabIndex', doAdd ? '1' : '-1');
  2902. }
  2903. if (valueElement) {
  2904. valueElement.setAttribute('tabIndex', doAdd ? '1' : '-1');
  2905. }
  2906. }
  2907. function focus(doFocus = true, node = activeNode, doForce = true) {
  2908. // Avoid unfocusing the active node if not forced
  2909. if (doForce || node !== activeNode) {
  2910. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS);
  2911. }
  2912. }
  2913. function focusBranch(doFocus = true, node = activeNode, focusAncestors = true) {
  2914. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS);
  2915. if (focusAncestors && 'parent' in node) {
  2916. focusBranch(doFocus, node.parent);
  2917. }
  2918. }
  2919. function reset() {
  2920. if (!activeNode) {
  2921. return;
  2922. }
  2923. focus(false);
  2924. focusBranch(false);
  2925. (0,_highlight__WEBPACK_IMPORTED_MODULE_2__.removeSustained)(activeNode);
  2926. setTabIndexes(false);
  2927. activeNode.element.scrollIntoView();
  2928. activeNode = undefined;
  2929. }
  2930. function doAction(node, doForce = false) {
  2931. const toggleOn = node !== activeNode;
  2932. // Avoid changing the view when it's already been focused
  2933. if ((0,_buttons_position__WEBPACK_IMPORTED_MODULE_1__.isActive)() || (doForce && !toggleOn)) {
  2934. return;
  2935. }
  2936. reset();
  2937. _active__WEBPACK_IMPORTED_MODULE_3__.register();
  2938. if (toggleOn) {
  2939. activeNode = node;
  2940. node.element.headContainer.focus();
  2941. focus();
  2942. focusBranch();
  2943. (0,_highlight__WEBPACK_IMPORTED_MODULE_2__.addSustained)(node);
  2944. setTabIndexes();
  2945. }
  2946. }
  2947. function unmount(node) {
  2948. if (node === activeNode) {
  2949. reset();
  2950. }
  2951. }
  2952. function mount(node) {
  2953. const { elementContainer, headContainer } = node.element;
  2954. // Handle mouse input
  2955. elementContainer.addEventListener('mousedown', (event) => {
  2956. event.stopPropagation();
  2957. candidateNode = node;
  2958. });
  2959. headContainer.addEventListener('mouseup', (event) => {
  2960. event.stopPropagation();
  2961. candidateNode = undefined;
  2962. });
  2963. headContainer.addEventListener('dragstart', (event) => {
  2964. event.preventDefault();
  2965. });
  2966. elementContainer.addEventListener('dragstart', (event) => {
  2967. event.preventDefault();
  2968. });
  2969. elementContainer.addEventListener('mouseup', (event) => {
  2970. event.stopPropagation();
  2971. if (node === candidateNode) {
  2972. doAction(node);
  2973. }
  2974. candidateNode = undefined;
  2975. });
  2976. // Handle keyboard input
  2977. elementContainer.addEventListener('keydown', (event) => {
  2978. if (event.key === 'Enter') {
  2979. event.stopPropagation();
  2980. doAction(node);
  2981. }
  2982. });
  2983. }
  2984. function shouldMount() {
  2985. return true;
  2986. }
  2987.  
  2988.  
  2989. /***/ }),
  2990.  
  2991. /***/ "./ts/modal/body/trees/nodes/actions/highlight/consts.ts":
  2992. /*!***************************************************************!*\
  2993. !*** ./ts/modal/body/trees/nodes/actions/highlight/consts.ts ***!
  2994. \***************************************************************/
  2995. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2996.  
  2997. __webpack_require__.r(__webpack_exports__);
  2998. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2999. /* harmony export */ EAVE_ID: () => (/* binding */ EAVE_ID),
  3000. /* harmony export */ HIGHLIGHT_BACKGROUND_CLASS: () => (/* binding */ HIGHLIGHT_BACKGROUND_CLASS),
  3001. /* harmony export */ HIGHLIGHT_CLASS: () => (/* binding */ HIGHLIGHT_CLASS)
  3002. /* harmony export */ });
  3003. const HIGHLIGHT_CLASS = 'highlight';
  3004. const HIGHLIGHT_BACKGROUND_CLASS = 'background-highlight';
  3005. const EAVE_ID = 'tree-eave';
  3006.  
  3007.  
  3008. /***/ }),
  3009.  
  3010. /***/ "./ts/modal/body/trees/nodes/actions/highlight/css.ts":
  3011. /*!************************************************************!*\
  3012. !*** ./ts/modal/body/trees/nodes/actions/highlight/css.ts ***!
  3013. \************************************************************/
  3014. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3015.  
  3016. __webpack_require__.r(__webpack_exports__);
  3017. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3018. /* harmony export */ "default": () => (/* binding */ generate)
  3019. /* harmony export */ });
  3020. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/highlight/consts.ts");
  3021. /* harmony import */ var _buttons_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/consts */ "./ts/modal/body/trees/nodes/actions/buttons/consts.ts");
  3022. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3023. /* harmony import */ var _modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/trees/style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  3024. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030. function generate() {
  3031. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['width', '100%']);
  3032. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3033. ['padding-right', '0.4em'],
  3034. // Extend the background further into the value
  3035. ['padding-left', '15%'],
  3036. ]);
  3037. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}:last-child`, [
  3038. ['border-top-right-radius', '50%'],
  3039. ['border-bottom-right-radius', '50%'],
  3040. ]);
  3041. (0,_modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_3__.addDepthChangeListener)((depth, addRule) => {
  3042. const rootSelector = `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.DEPTH_CLASS_PREFIX}${depth}`;
  3043. const headSelector = `${rootSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  3044. addRule(`${rootSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['background-color', `var(--nodeContrast${depth})`]);
  3045. addRule(`${headSelector} .${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}`, ['background-color', `var(--nodeContrast${depth})`]);
  3046. addRule([
  3047. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}${headSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  3048. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}${headSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  3049. ], ['color', `var(--nodeBase${depth})`]);
  3050. addRule(`${headSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3051. ['background-image', `linear-gradient(to left, var(--nodeBase${depth}) 60%, transparent)`],
  3052. ['background-size', 'auto'],
  3053. ]);
  3054. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}${headSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['background-image', `linear-gradient(to left, var(--nodeContrast${depth}) 60%, transparent)`]);
  3055. });
  3056. // Bug fixer
  3057. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID}`, [
  3058. ['position', 'absolute'],
  3059. ['bottom', '0'],
  3060. ['width', '100%'],
  3061. ['height', '1px'],
  3062. ]);
  3063. }
  3064.  
  3065.  
  3066. /***/ }),
  3067.  
  3068. /***/ "./ts/modal/body/trees/nodes/actions/highlight/index.ts":
  3069. /*!**************************************************************!*\
  3070. !*** ./ts/modal/body/trees/nodes/actions/highlight/index.ts ***!
  3071. \**************************************************************/
  3072. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3073.  
  3074. __webpack_require__.r(__webpack_exports__);
  3075. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3076. /* harmony export */ addSustained: () => (/* binding */ addSustained),
  3077. /* harmony export */ focusHovered: () => (/* binding */ focusHovered),
  3078. /* harmony export */ generateEave: () => (/* binding */ generateEave),
  3079. /* harmony export */ isActive: () => (/* binding */ isActive),
  3080. /* harmony export */ mount: () => (/* binding */ mount),
  3081. /* harmony export */ onMount: () => (/* binding */ onMount),
  3082. /* harmony export */ removeSustained: () => (/* binding */ removeSustained),
  3083. /* harmony export */ reset: () => (/* binding */ reset),
  3084. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  3085. /* harmony export */ });
  3086. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/highlight/consts.ts");
  3087. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  3088. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  3089. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/trees/nodes/actions/buttons/position/index.ts");
  3090. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096. let sustainedNodes = [];
  3097. let activeNode;
  3098. function focusHovered() {
  3099. if (activeNode) {
  3100. activeNode.element.headContainer.focus();
  3101. }
  3102. }
  3103. function isActive() {
  3104. return Boolean(activeNode);
  3105. }
  3106. function removeSustained(node) {
  3107. sustainedNodes.splice(sustainedNodes.indexOf(node), 1);
  3108. // Avoid unhighlighting if it's still sustained by another action
  3109. if (node !== activeNode && !sustainedNodes.includes(node)) {
  3110. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3111. }
  3112. }
  3113. function addSustained(node) {
  3114. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3115. sustainedNodes.push(node);
  3116. }
  3117. function setActive(node, doFocus = false) {
  3118. if (activeNode && !sustainedNodes.includes(activeNode)) {
  3119. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3120. }
  3121. activeNode = node;
  3122. if (node) {
  3123. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3124. if (doFocus) {
  3125. node.element.headContainer.focus();
  3126. }
  3127. }
  3128. }
  3129. function mount(node) {
  3130. const { backgroundContainer, headContainer, elementContainer } = node.element;
  3131. backgroundContainer.appendChild((() => {
  3132. const background = document.createElement('div');
  3133. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS);
  3134. return background;
  3135. })());
  3136. headContainer.setAttribute('tabIndex', '1');
  3137. headContainer.addEventListener('focusin', (event) => {
  3138. event.stopPropagation();
  3139. setActive(node);
  3140. });
  3141. headContainer.addEventListener('mouseenter', (event) => {
  3142. event.stopPropagation();
  3143. setActive(node, !((0,_edit__WEBPACK_IMPORTED_MODULE_1__.isActive)() || (0,_focus__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (0,_buttons_position__WEBPACK_IMPORTED_MODULE_3__.isActive)()));
  3144. });
  3145. elementContainer.addEventListener('mouseenter', (event) => {
  3146. event.stopPropagation();
  3147. setActive(node);
  3148. });
  3149. elementContainer.addEventListener('mouseleave', (event) => {
  3150. event.stopPropagation();
  3151. if ('parent' in node) {
  3152. setActive(node.parent);
  3153. }
  3154. else {
  3155. setActive();
  3156. }
  3157. });
  3158. }
  3159. function shouldMount() {
  3160. return true;
  3161. }
  3162. // Prevents zipping to the end of the tree when mousing over the bottom pixel
  3163. function generateEave() {
  3164. const element = document.createElement('div');
  3165. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID;
  3166. element.setAttribute('tabIndex', '3');
  3167. // Prevent tabbing away from the modal
  3168. element.addEventListener('keydown', (event) => {
  3169. if (event.key === 'Tab' && !event.shiftKey && element.isSameNode(event.target)) {
  3170. event.preventDefault();
  3171. }
  3172. });
  3173. return element;
  3174. }
  3175. // Blur focused node & reset focus index
  3176. function reset() {
  3177. setActive();
  3178. (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)().focus();
  3179. }
  3180. function onMount() {
  3181. const socket = (0,_modal__WEBPACK_IMPORTED_MODULE_4__.getSocket)();
  3182. socket.setAttribute('tabIndex', '1');
  3183. // Prevent tabbing away from the modal
  3184. socket.addEventListener('keydown', (event) => {
  3185. if (event.key === 'Tab' && event.shiftKey && socket.isSameNode(event.target)) {
  3186. event.preventDefault();
  3187. }
  3188. });
  3189. socket.addEventListener('focusin', () => {
  3190. setActive();
  3191. });
  3192. }
  3193.  
  3194.  
  3195. /***/ }),
  3196.  
  3197. /***/ "./ts/modal/body/trees/nodes/actions/tooltip/consts.ts":
  3198. /*!*************************************************************!*\
  3199. !*** ./ts/modal/body/trees/nodes/actions/tooltip/consts.ts ***!
  3200. \*************************************************************/
  3201. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3202.  
  3203. __webpack_require__.r(__webpack_exports__);
  3204. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3205. /* harmony export */ TOOLTIP_ANIMATION: () => (/* binding */ TOOLTIP_ANIMATION),
  3206. /* harmony export */ TOOLTIP_BOTTOM_CLASS: () => (/* binding */ TOOLTIP_BOTTOM_CLASS),
  3207. /* harmony export */ TOOLTIP_CLASS: () => (/* binding */ TOOLTIP_CLASS),
  3208. /* harmony export */ TOOLTIP_CONTAINER_CLASS: () => (/* binding */ TOOLTIP_CONTAINER_CLASS),
  3209. /* harmony export */ TOOLTIP_TOP_CLASS: () => (/* binding */ TOOLTIP_TOP_CLASS)
  3210. /* harmony export */ });
  3211. const TOOLTIP_CLASS = 'tooltip';
  3212. const TOOLTIP_CONTAINER_CLASS = 'tooltip-container';
  3213. const TOOLTIP_TOP_CLASS = 'tooltip-above';
  3214. const TOOLTIP_BOTTOM_CLASS = 'tooltip-below';
  3215. const TOOLTIP_ANIMATION = [
  3216. [
  3217. // keyframes
  3218. { opacity: 1 },
  3219. { opacity: 1 },
  3220. { opacity: 0 },
  3221. ], { duration: 2000 },
  3222. ];
  3223.  
  3224.  
  3225. /***/ }),
  3226.  
  3227. /***/ "./ts/modal/body/trees/nodes/actions/tooltip/css.ts":
  3228. /*!**********************************************************!*\
  3229. !*** ./ts/modal/body/trees/nodes/actions/tooltip/css.ts ***!
  3230. \**********************************************************/
  3231. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3232.  
  3233. __webpack_require__.r(__webpack_exports__);
  3234. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3235. /* harmony export */ "default": () => (/* binding */ generate)
  3236. /* harmony export */ });
  3237. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/tooltip/consts.ts");
  3238. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3239. /* harmony import */ var _modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body/trees/style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  3240. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3241.  
  3242.  
  3243.  
  3244.  
  3245. // todo you need tooltips for deletion/creation/movement.
  3246. // you'll need a different system to position tooltips underneath/above buttons
  3247. function generate() {
  3248. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [['position', 'relative']]);
  3249. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`, [
  3250. ['position', 'absolute'],
  3251. ['text-align', 'center'],
  3252. ['z-index', '1'],
  3253. ['width', '100%'],
  3254. ['pointer-events', 'none'],
  3255. ['white-space', 'normal'],
  3256. ]);
  3257. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}`, ['bottom', '102%']);
  3258. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}`, ['top', '102%']);
  3259. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`, [
  3260. ['margin', '0 auto'],
  3261. ['font-size', '0.9em'],
  3262. ['padding', '3px 8px'],
  3263. ['border-radius', '1em'],
  3264. ['width', '10em'],
  3265. ['outline', 'solid 3px var(--borderTooltip)'],
  3266. ]);
  3267. (0,_modal_body_trees_style_update_depth__WEBPACK_IMPORTED_MODULE_2__.addDepthChangeListener)((depth, addRule) => {
  3268. addRule(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.DEPTH_CLASS_PREFIX}${depth} > :not(.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.CHILD_CONTAINER}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`, [
  3269. ['background-color', `var(--nodeBase${depth})`],
  3270. ['color', `var(--nodeContrast${depth})`],
  3271. ]);
  3272. });
  3273. // Don't show when there's no hint to give
  3274. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}:empty`], ['display', 'none']);
  3275. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`, [
  3276. ['content', '""'],
  3277. ['position', 'absolute'],
  3278. ['left', '50%'],
  3279. ['margin-left', '-0.5em'],
  3280. ['border-width', '0.5em'],
  3281. ['border-style', 'solid'],
  3282. ]);
  3283. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`, [
  3284. ['top', '100%'],
  3285. ['border-color', 'var(--borderTooltip) transparent transparent transparent'],
  3286. ]);
  3287. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}::after`, [
  3288. ['bottom', '100%'],
  3289. ['border-color', 'transparent transparent var(--borderTooltip) transparent'],
  3290. ]);
  3291. }
  3292.  
  3293.  
  3294. /***/ }),
  3295.  
  3296. /***/ "./ts/modal/body/trees/nodes/actions/tooltip/index.ts":
  3297. /*!************************************************************!*\
  3298. !*** ./ts/modal/body/trees/nodes/actions/tooltip/index.ts ***!
  3299. \************************************************************/
  3300. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3301.  
  3302. __webpack_require__.r(__webpack_exports__);
  3303. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3304. /* harmony export */ hide: () => (/* binding */ hide),
  3305. /* harmony export */ reset: () => (/* binding */ reset),
  3306. /* harmony export */ setNode: () => (/* binding */ setNode),
  3307. /* harmony export */ show: () => (/* binding */ show)
  3308. /* harmony export */ });
  3309. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/actions/tooltip/consts.ts");
  3310. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3311. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  3312.  
  3313.  
  3314.  
  3315. let activeParent;
  3316. function isAboveCenter(element, yPosition = 0) {
  3317. if (!element.isSameNode(_modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER)) {
  3318. if (element.classList.contains(_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.ELEMENT_CONTAINER)) {
  3319. yPosition += element.offsetTop;
  3320. }
  3321. return isAboveCenter(element.parentElement, yPosition);
  3322. }
  3323. const scrollPosition = _modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.scrollTop + (_modal_body_trees__WEBPACK_IMPORTED_MODULE_2__.TREE_CONTAINER.clientHeight / 2);
  3324. return scrollPosition > yPosition;
  3325. }
  3326. function generate(parent) {
  3327. const container = document.createElement('div');
  3328. const element = document.createElement('div');
  3329. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS);
  3330. element.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS);
  3331. container.appendChild(element);
  3332. parent.insertBefore(container, parent.firstChild);
  3333. return [container, element];
  3334. }
  3335. function getAnimated(parent) {
  3336. if (!parent) {
  3337. const element = activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`);
  3338. return [element.parentElement, element];
  3339. }
  3340. const oldElement = parent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`);
  3341. if (oldElement) {
  3342. const [animation] = oldElement.getAnimations();
  3343. animation.currentTime = 0;
  3344. return [oldElement.parentElement, oldElement];
  3345. }
  3346. const [container, element] = generate(parent);
  3347. element.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION).onfinish = () => {
  3348. container.remove();
  3349. };
  3350. return [container, element];
  3351. }
  3352. function show(message, parent) {
  3353. const [container, element] = getAnimated(parent);
  3354. if (isAboveCenter(container)) {
  3355. container.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS);
  3356. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS);
  3357. }
  3358. else {
  3359. container.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS);
  3360. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS);
  3361. }
  3362. element.innerText = message;
  3363. }
  3364. function hide() {
  3365. const element = activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CLASS}`);
  3366. if (element) {
  3367. element.innerText = '';
  3368. }
  3369. }
  3370. function reset() {
  3371. activeParent.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`).remove();
  3372. activeParent = undefined;
  3373. }
  3374. function setNode(node) {
  3375. const { parentElement } = node.element.valueElement;
  3376. generate(parentElement);
  3377. activeParent = parentElement;
  3378. }
  3379.  
  3380.  
  3381. /***/ }),
  3382.  
  3383. /***/ "./ts/modal/body/trees/nodes/child.ts":
  3384. /*!********************************************!*\
  3385. !*** ./ts/modal/body/trees/nodes/child.ts ***!
  3386. \********************************************/
  3387. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3388.  
  3389. __webpack_require__.r(__webpack_exports__);
  3390. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3391. /* harmony export */ "default": () => (/* binding */ Child)
  3392. /* harmony export */ });
  3393. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./ts/modal/body/trees/nodes/element.ts");
  3394. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  3395. /* harmony import */ var _actions_edit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  3396. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  3397. /* harmony import */ var _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/buttons/disable */ "./ts/modal/body/trees/nodes/actions/buttons/disable/index.ts");
  3398. /* harmony import */ var _actions_buttons_move__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/buttons/move */ "./ts/modal/body/trees/nodes/actions/buttons/move/index.ts");
  3399. /* harmony import */ var _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/buttons/duplicate */ "./ts/modal/body/trees/nodes/actions/buttons/duplicate/index.ts");
  3400. /* harmony import */ var _style_update_depth__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409. const actions = [
  3410. // No button
  3411. _actions_highlight__WEBPACK_IMPORTED_MODULE_1__,
  3412. _actions_focus__WEBPACK_IMPORTED_MODULE_3__,
  3413. _actions_edit__WEBPACK_IMPORTED_MODULE_2__,
  3414. // Button
  3415. _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_4__,
  3416. _actions_buttons_move__WEBPACK_IMPORTED_MODULE_5__,
  3417. _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_6__,
  3418. ];
  3419. class Child {
  3420. constructor(data, parent, index) {
  3421. this.depth = parent.depth + 1;
  3422. this.element = new _element__WEBPACK_IMPORTED_MODULE_0__["default"](data);
  3423. this.element.addDepthClass(this.depth % (0,_style_update_depth__WEBPACK_IMPORTED_MODULE_7__.getDepthClassCount)());
  3424. for (const [key, value] of Object.entries(Object.assign({ isActive: true }, data))) {
  3425. this[key] = value;
  3426. }
  3427. this.hasOptions = Array.isArray(data.predicate);
  3428. this.attach(parent, index);
  3429. for (const { shouldMount, mount } of actions) {
  3430. if (shouldMount(this)) {
  3431. mount(this);
  3432. }
  3433. }
  3434. }
  3435. getRoot() {
  3436. return this.parent.getRoot();
  3437. }
  3438. getIndex() {
  3439. return this.parent.children.indexOf(this);
  3440. }
  3441. getSiblings() {
  3442. const index = this.getIndex();
  3443. const siblings = this.parent.children;
  3444. return [...siblings.slice(0, index), ...siblings.slice(index + 1)];
  3445. }
  3446. updateDepthClass(classCount) {
  3447. this.element.addDepthClass(this.depth % classCount);
  3448. }
  3449. detach() {
  3450. this.parent.children.splice(this.getIndex(), 1);
  3451. this.element.remove();
  3452. this.parent = undefined;
  3453. }
  3454. attach(parent, index = parent.children.length) {
  3455. parent.children.splice(index, 0, this);
  3456. parent.element.addChild(this.element, index);
  3457. this.parent = parent;
  3458. }
  3459. move(parent, to) {
  3460. this.detach();
  3461. this.attach(parent, typeof to === 'number' ? to : to.getIndex() + 1);
  3462. }
  3463. duplicate() {
  3464. return new Child(this.getJSON(), this.parent, this.getIndex() + 1);
  3465. }
  3466. unmount() {
  3467. for (const action of actions) {
  3468. if ('unmount' in action) {
  3469. action.unmount(this);
  3470. }
  3471. }
  3472. }
  3473. disconnect() {
  3474. this.unmount();
  3475. this.detach();
  3476. }
  3477. getJSON() {
  3478. const data = { isActive: this.isActive };
  3479. for (const property of ['label', 'value', 'input']) {
  3480. if (property in this) {
  3481. data[property] = this[property];
  3482. }
  3483. }
  3484. return data;
  3485. }
  3486. }
  3487.  
  3488.  
  3489. /***/ }),
  3490.  
  3491. /***/ "./ts/modal/body/trees/nodes/consts.ts":
  3492. /*!*********************************************!*\
  3493. !*** ./ts/modal/body/trees/nodes/consts.ts ***!
  3494. \*********************************************/
  3495. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3496.  
  3497. __webpack_require__.r(__webpack_exports__);
  3498. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3499. /* harmony export */ DEPTH_CLASS_PREFIX: () => (/* binding */ DEPTH_CLASS_PREFIX),
  3500. /* harmony export */ ELEMENT_CLASSES: () => (/* binding */ ELEMENT_CLASSES),
  3501. /* harmony export */ MIDDLE_CLASS: () => (/* binding */ MIDDLE_CLASS),
  3502. /* harmony export */ ROOT_CLASS: () => (/* binding */ ROOT_CLASS)
  3503. /* harmony export */ });
  3504. const ROOT_CLASS = 'root';
  3505. const MIDDLE_CLASS = 'middle';
  3506. const ELEMENT_CLASSES = {
  3507. ELEMENT_CONTAINER: 'node',
  3508. BACKGROUND_CONTAINER: 'node-background-container',
  3509. CHILD_CONTAINER: 'node-child-container',
  3510. BUTTON_CONTAINER: 'node-button-container',
  3511. HEAD_CONTAINER: 'node-head-container',
  3512. VALUE_CONTAINER: 'node-value-container',
  3513. VALUE: 'node-value',
  3514. LABEL_CONTAINER: 'node-label-container',
  3515. LABEL: 'node-label',
  3516. };
  3517. const DEPTH_CLASS_PREFIX = 'node-depth-';
  3518.  
  3519.  
  3520. /***/ }),
  3521.  
  3522. /***/ "./ts/modal/body/trees/nodes/css.ts":
  3523. /*!******************************************!*\
  3524. !*** ./ts/modal/body/trees/nodes/css.ts ***!
  3525. \******************************************/
  3526. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3527.  
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3530. /* harmony export */ "default": () => (/* binding */ generate)
  3531. /* harmony export */ });
  3532. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3533. /* harmony import */ var _style_update_depth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/update/depth */ "./ts/modal/body/trees/style/update/depth.ts");
  3534. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3535.  
  3536.  
  3537.  
  3538. function generate() {
  3539. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, [
  3540. ['flex-grow', '1'],
  3541. // Apparently it maxes out at the viewport's height without a content-related height value
  3542. ['height', 'fit-content'],
  3543. ]);
  3544. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}):first-child`, ['margin-top', '0.7px']);
  3545. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}) > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER}`, ['margin-left', '1.8em']);
  3546. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['position', 'relative']);
  3547. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER} > :not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER})`, ['height', '1.6em']);
  3548. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, [['user-select', 'none']]);
  3549. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  3550. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  3551. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  3552. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  3553. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  3554. ], [
  3555. ['flex-grow', '1'],
  3556. ['display', 'flex'],
  3557. ['align-items', 'center'],
  3558. ]);
  3559. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  3560. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  3561. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  3562. ], [['position', 'absolute']]);
  3563. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3564. ['right', '0'],
  3565. ['top', '0'],
  3566. ['pointer-events', 'none'],
  3567. ]);
  3568. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [['user-select', 'none']]);
  3569. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`, [
  3570. ['width', '100%'],
  3571. ['height', '100%'],
  3572. ]);
  3573. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [
  3574. ['height', '100%'],
  3575. ['width', '0'],
  3576. ['transition', 'width 500ms'],
  3577. ['position', 'absolute'],
  3578. ]);
  3579. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  3580. // Puts it above the backgrounds
  3581. ['position', 'relative'],
  3582. ['user-select', 'none'],
  3583. ]);
  3584. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER} > *`, [['height', '100%']]);
  3585. (0,_style_update_depth__WEBPACK_IMPORTED_MODULE_1__.addDepthChangeListener)((depth, addRule) => {
  3586. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`, [
  3587. ['color', `var(--nodeContrast${depth})`],
  3588. ['background', `var(--nodeBase${depth})`],
  3589. ]);
  3590. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`, ['outline', `1px solid var(--nodeContrast${depth})`]);
  3591. addRule(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`, ['outline', `1px solid var(--nodeContrast${depth})`]);
  3592. });
  3593. }
  3594.  
  3595.  
  3596. /***/ }),
  3597.  
  3598. /***/ "./ts/modal/body/trees/nodes/element.ts":
  3599. /*!**********************************************!*\
  3600. !*** ./ts/modal/body/trees/nodes/element.ts ***!
  3601. \**********************************************/
  3602. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3603.  
  3604. __webpack_require__.r(__webpack_exports__);
  3605. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3606. /* harmony export */ "default": () => (/* binding */ Element)
  3607. /* harmony export */ });
  3608. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3609.  
  3610. class Element {
  3611. constructor(data) {
  3612. this.elementContainer = document.createElement('div');
  3613. this.backgroundContainer = document.createElement('div');
  3614. this.headContainer = document.createElement('span');
  3615. this.buttonContainer = document.createElement('span');
  3616. this.childContainer = document.createElement('div');
  3617. this.elementContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER);
  3618. this.backgroundContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER);
  3619. this.childContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER);
  3620. this.headContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER);
  3621. this.buttonContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BUTTON_CONTAINER);
  3622. this.elementContainer.appendChild(this.backgroundContainer);
  3623. this.headContainer.appendChild(this.buttonContainer);
  3624. if ('value' in data) {
  3625. this.valueContainer = document.createElement('label');
  3626. this.valueElement = document.createElement('input');
  3627. this.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER);
  3628. this.valueElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE);
  3629. this.valueElement.setAttribute('tabIndex', '-1');
  3630. if (typeof data.value === 'boolean') {
  3631. this.valueElement.type = 'checkbox';
  3632. // Positions tooltips below checkboxes
  3633. const valueWrapper = document.createElement('span');
  3634. valueWrapper.appendChild(this.valueElement);
  3635. this.valueContainer.appendChild(valueWrapper);
  3636. }
  3637. else {
  3638. if (typeof data.value === 'number') {
  3639. this.valueElement.type = 'number';
  3640. // Disables a tooltip implying that decimal values are invalid
  3641. this.valueElement.step = 'any';
  3642. }
  3643. else if ('input' in data) {
  3644. this.valueElement.type = data.input;
  3645. }
  3646. this.valueContainer.appendChild(this.valueElement);
  3647. }
  3648. this.render(data.value);
  3649. this.headContainer.appendChild(this.valueContainer);
  3650. }
  3651. this.elementContainer.appendChild(this.headContainer);
  3652. if ('label' in data) {
  3653. this.labelContainer = document.createElement('div');
  3654. this.labelElement = document.createElement('span');
  3655. this.labelContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER);
  3656. this.labelElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL);
  3657. this.labelElement.innerText = data.label;
  3658. this.labelContainer.appendChild(this.labelElement);
  3659. this.headContainer.appendChild(this.labelContainer);
  3660. }
  3661. this.elementContainer.appendChild(this.childContainer);
  3662. }
  3663. render(value) {
  3664. if (typeof value === 'boolean') {
  3665. this.valueElement.checked = value;
  3666. }
  3667. else {
  3668. this.valueElement.value = value.toString();
  3669. }
  3670. }
  3671. addClass(...names) {
  3672. for (const name of names) {
  3673. this.elementContainer.classList.add(name);
  3674. }
  3675. }
  3676. removeClass(...names) {
  3677. for (const name of names) {
  3678. this.elementContainer.classList.remove(name);
  3679. }
  3680. }
  3681. addDepthClass(depth) {
  3682. if (this.depthClass) {
  3683. this.removeClass(this.depthClass);
  3684. }
  3685. const depthClass = `${_consts__WEBPACK_IMPORTED_MODULE_0__.DEPTH_CLASS_PREFIX}${depth}`;
  3686. this.addClass(depthClass);
  3687. this.depthClass = depthClass;
  3688. }
  3689. addChild(child, index) {
  3690. var _a;
  3691. this.childContainer.insertBefore(child.elementContainer, (_a = this.childContainer.children[index]) !== null && _a !== void 0 ? _a : null);
  3692. }
  3693. addButton(button) {
  3694. this.buttonContainer.appendChild(button);
  3695. }
  3696. remove() {
  3697. this.elementContainer.remove();
  3698. }
  3699. scrollIntoView() {
  3700. this.backgroundContainer.scrollIntoView({ block: 'center' });
  3701. }
  3702. }
  3703.  
  3704.  
  3705. /***/ }),
  3706.  
  3707. /***/ "./ts/modal/body/trees/nodes/middle.ts":
  3708. /*!*********************************************!*\
  3709. !*** ./ts/modal/body/trees/nodes/middle.ts ***!
  3710. \*********************************************/
  3711. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3712.  
  3713. __webpack_require__.r(__webpack_exports__);
  3714. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3715. /* harmony export */ "default": () => (/* binding */ Middle)
  3716. /* harmony export */ });
  3717. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3718. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/trees/nodes/child.ts");
  3719. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/trees/nodes/actions/buttons/create/index.ts");
  3720. var __rest = (undefined && undefined.__rest) || function (s, e) {
  3721. var t = {};
  3722. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  3723. t[p] = s[p];
  3724. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  3725. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  3726. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  3727. t[p[i]] = s[p[i]];
  3728. }
  3729. return t;
  3730. };
  3731.  
  3732.  
  3733.  
  3734. const actions = [_actions_buttons_create__WEBPACK_IMPORTED_MODULE_2__];
  3735. class Middle extends _child__WEBPACK_IMPORTED_MODULE_1__["default"] {
  3736. constructor(_a, parent, index) {
  3737. var { children } = _a, data = __rest(_a, ["children"]);
  3738. super(data, parent, index);
  3739. this.children = [];
  3740. for (const [key, value] of Object.entries(data)) {
  3741. this[key] = value;
  3742. }
  3743. for (const child of children) {
  3744. if ('children' in child) {
  3745. new Middle(child, this);
  3746. }
  3747. else {
  3748. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  3749. }
  3750. }
  3751. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS);
  3752. for (const { shouldMount, mount } of actions) {
  3753. if (shouldMount(this)) {
  3754. mount(this);
  3755. }
  3756. }
  3757. }
  3758. duplicate() {
  3759. return new Middle(this.getJSON(), this.parent, this.getIndex() + 1);
  3760. }
  3761. unmount() {
  3762. super.unmount();
  3763. for (const action of actions) {
  3764. if ('unmount' in action) {
  3765. action.unmount(this);
  3766. }
  3767. }
  3768. }
  3769. disconnect() {
  3770. this.unmount();
  3771. for (const child of this.children) {
  3772. child.disconnect();
  3773. }
  3774. this.detach();
  3775. }
  3776. updateDepthClass(classCount) {
  3777. super.updateDepthClass(classCount);
  3778. for (const child of this.children) {
  3779. child.updateDepthClass(classCount);
  3780. }
  3781. }
  3782. getJSON() {
  3783. return Object.assign({ children: this.children.map((child) => child.getJSON()) }, super.getJSON());
  3784. }
  3785. }
  3786.  
  3787.  
  3788. /***/ }),
  3789.  
  3790. /***/ "./ts/modal/body/trees/nodes/root.ts":
  3791. /*!*******************************************!*\
  3792. !*** ./ts/modal/body/trees/nodes/root.ts ***!
  3793. \*******************************************/
  3794. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3795.  
  3796. __webpack_require__.r(__webpack_exports__);
  3797. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3798. /* harmony export */ "default": () => (/* binding */ Root)
  3799. /* harmony export */ });
  3800. /* harmony import */ var _middle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./middle */ "./ts/modal/body/trees/nodes/middle.ts");
  3801. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/trees/nodes/child.ts");
  3802. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./element */ "./ts/modal/body/trees/nodes/element.ts");
  3803. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/nodes/consts.ts");
  3804. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  3805. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  3806. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/trees/nodes/actions/buttons/create/index.ts");
  3807. var __rest = (undefined && undefined.__rest) || function (s, e) {
  3808. var t = {};
  3809. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  3810. t[p] = s[p];
  3811. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  3812. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  3813. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  3814. t[p[i]] = s[p[i]];
  3815. }
  3816. return t;
  3817. };
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825. const actions = [_actions_highlight__WEBPACK_IMPORTED_MODULE_4__, _actions_focus__WEBPACK_IMPORTED_MODULE_5__, _actions_buttons_create__WEBPACK_IMPORTED_MODULE_6__];
  3826. class Root {
  3827. constructor(_a) {
  3828. var { children } = _a, data = __rest(_a, ["children"]);
  3829. this.children = [];
  3830. this.depth = 0;
  3831. this.element = new _element__WEBPACK_IMPORTED_MODULE_2__["default"]({});
  3832. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.ROOT_CLASS);
  3833. this.element.addDepthClass(0);
  3834. for (const [key, value] of Object.entries(data)) {
  3835. this[key] = value;
  3836. }
  3837. this.addChildren(children);
  3838. for (const { shouldMount, mount } of actions) {
  3839. if (shouldMount(this)) {
  3840. mount(this);
  3841. }
  3842. }
  3843. }
  3844. addChildren(children) {
  3845. for (const child of children) {
  3846. if ('children' in child) {
  3847. new _middle__WEBPACK_IMPORTED_MODULE_0__["default"](child, this);
  3848. }
  3849. else {
  3850. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  3851. }
  3852. }
  3853. }
  3854. getRoot() {
  3855. return this;
  3856. }
  3857. updateDepthClass(classCount) {
  3858. for (const child of this.children) {
  3859. child.updateDepthClass(classCount);
  3860. }
  3861. }
  3862. getJSON() {
  3863. return { children: this.children.map((child) => child.getJSON()) };
  3864. }
  3865. }
  3866.  
  3867.  
  3868. /***/ }),
  3869.  
  3870. /***/ "./ts/modal/body/trees/style/consts.ts":
  3871. /*!*********************************************!*\
  3872. !*** ./ts/modal/body/trees/style/consts.ts ***!
  3873. \*********************************************/
  3874. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3875.  
  3876. __webpack_require__.r(__webpack_exports__);
  3877. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3878. /* harmony export */ DEFAULT_STYLE: () => (/* binding */ DEFAULT_STYLE),
  3879. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  3880. /* harmony export */ });
  3881. const ROOT_ID = 'root-style';
  3882. const DEFAULT_STYLE = {
  3883. fontSize: 18,
  3884. borderTooltip: '#570000',
  3885. borderModal: '#ffffff',
  3886. headBase: '#000000',
  3887. headContrast: 'Black / White',
  3888. headButtonExit: '#f10000',
  3889. headButtonLabel: '#ffd189',
  3890. headButtonStyle: '#ff75da',
  3891. headButtonHide: '#00bfff',
  3892. headButtonAlt: '#ffea00',
  3893. nodeBase: ['#000000'],
  3894. nodeContrast: 'Black / White',
  3895. nodeButtonCreate: '#40ff40',
  3896. nodeButtonDuplicate: '#40ffff',
  3897. nodeButtonMove: '#ac60ff',
  3898. nodeButtonDisable: '#ffd000',
  3899. nodeButtonDelete: '#ff1111',
  3900. validBackground: '#d9ffc0',
  3901. invalidBackground: '#ffb4be',
  3902. };
  3903.  
  3904.  
  3905. /***/ }),
  3906.  
  3907. /***/ "./ts/modal/body/trees/style/css.ts":
  3908. /*!******************************************!*\
  3909. !*** ./ts/modal/body/trees/style/css.ts ***!
  3910. \******************************************/
  3911. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3912.  
  3913. __webpack_require__.r(__webpack_exports__);
  3914. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3915. /* harmony export */ "default": () => (/* binding */ generate)
  3916. /* harmony export */ });
  3917. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/style/consts.ts");
  3918. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/trees/consts.ts");
  3919. /* harmony import */ var _data_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/consts */ "./ts/modal/body/trees/data/consts.ts");
  3920. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3921. /* harmony import */ var _modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/style/consts */ "./ts/modal/header/actions/style/consts.ts");
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927. function generate() {
  3928. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.TREE_CONTAINER_ID}.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID} > #${_data_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_ID}`, ['display', 'none']);
  3929. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.TREE_CONTAINER_ID}:not(.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID}) > #${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID}`, ['display', 'none']);
  3930. }
  3931.  
  3932.  
  3933. /***/ }),
  3934.  
  3935. /***/ "./ts/modal/body/trees/style/index.ts":
  3936. /*!********************************************!*\
  3937. !*** ./ts/modal/body/trees/style/index.ts ***!
  3938. \********************************************/
  3939. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3940.  
  3941. __webpack_require__.r(__webpack_exports__);
  3942. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3943. /* harmony export */ "default": () => (/* binding */ generate),
  3944. /* harmony export */ getActiveStyle: () => (/* binding */ getActiveStyle),
  3945. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  3946. /* harmony export */ getUserStyles: () => (/* binding */ getUserStyles),
  3947. /* harmony export */ toJSON: () => (/* binding */ toJSON),
  3948. /* harmony export */ toRawStyle: () => (/* binding */ toRawStyle)
  3949. /* harmony export */ });
  3950. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/trees/style/consts.ts");
  3951. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/trees/style/css.ts");
  3952. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./update */ "./ts/modal/body/trees/style/update/index.ts");
  3953. /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! .. */ "./ts/modal/body/trees/index.ts");
  3954. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960. function getRoot() {
  3961. return ___WEBPACK_IMPORTED_MODULE_3__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  3962. }
  3963. // Fill any missing entries
  3964. function getFilledStyle(style = {}) {
  3965. return Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  3966. }
  3967. function getActiveStyle(userStyles, devStyle) {
  3968. const activeUserStyle = userStyles.find(({ isActive }) => isActive);
  3969. return activeUserStyle !== null && activeUserStyle !== void 0 ? activeUserStyle : getFilledStyle(devStyle);
  3970. }
  3971. function toJSON(style) {
  3972. const filledStyle = Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  3973. const toDepthColour = (value) => ({ value, input: 'color' });
  3974. return {
  3975. label: 'Name',
  3976. value: filledStyle.name,
  3977. children: [
  3978. {
  3979. label: 'Style Is Active?',
  3980. value: filledStyle.isActive,
  3981. },
  3982. {
  3983. label: 'Modal',
  3984. children: [
  3985. {
  3986. label: 'Font Size (px)',
  3987. value: filledStyle.fontSize,
  3988. predicate: (value) => value > 0 ? true : 'Font size must be greater than zero',
  3989. },
  3990. {
  3991. label: 'Border Color',
  3992. value: filledStyle.borderModal,
  3993. input: 'color',
  3994. },
  3995. ],
  3996. },
  3997. {
  3998. label: 'Header',
  3999. children: [
  4000. {
  4001. label: 'General',
  4002. children: [
  4003. {
  4004. label: 'Base Color',
  4005. value: filledStyle.headBase,
  4006. input: 'color',
  4007. },
  4008. {
  4009. label: 'Contrast Method',
  4010. value: filledStyle.headContrast,
  4011. predicate: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  4012. },
  4013. ],
  4014. },
  4015. {
  4016. label: 'Buttons',
  4017. children: [
  4018. {
  4019. label: 'Exit Color',
  4020. value: filledStyle.headButtonExit,
  4021. input: 'color',
  4022. },
  4023. {
  4024. label: 'Label Color',
  4025. value: filledStyle.headButtonLabel,
  4026. input: 'color',
  4027. },
  4028. {
  4029. label: 'Style Color',
  4030. value: filledStyle.headButtonStyle,
  4031. input: 'color',
  4032. },
  4033. {
  4034. label: 'Hide Color',
  4035. value: filledStyle.headButtonHide,
  4036. input: 'color',
  4037. },
  4038. {
  4039. label: 'Alt Buttons Color',
  4040. value: filledStyle.headButtonAlt,
  4041. input: 'color',
  4042. },
  4043. ],
  4044. },
  4045. ],
  4046. },
  4047. {
  4048. label: 'Body',
  4049. children: [
  4050. {
  4051. label: 'General',
  4052. children: [
  4053. {
  4054. label: 'Depth Base Colors',
  4055. seed: toDepthColour(_consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeBase[0]),
  4056. children: filledStyle.nodeBase.map(toDepthColour),
  4057. childPredicate: (children) => children.length > 0 ? true : 'At least one color must be provided.',
  4058. },
  4059. {
  4060. label: 'Contrast Method',
  4061. value: filledStyle.nodeContrast,
  4062. predicate: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  4063. },
  4064. ],
  4065. },
  4066. {
  4067. label: 'Buttons',
  4068. children: [
  4069. {
  4070. label: 'Create Color',
  4071. value: filledStyle.nodeButtonCreate,
  4072. input: 'color',
  4073. },
  4074. {
  4075. label: 'Duplicate Color',
  4076. value: filledStyle.nodeButtonDuplicate,
  4077. input: 'color',
  4078. },
  4079. {
  4080. label: 'Move Color',
  4081. value: filledStyle.nodeButtonMove,
  4082. input: 'color',
  4083. },
  4084. {
  4085. label: 'Disable Color',
  4086. value: filledStyle.nodeButtonDisable,
  4087. input: 'color',
  4088. },
  4089. {
  4090. label: 'Delete Color',
  4091. value: filledStyle.nodeButtonDelete,
  4092. input: 'color',
  4093. },
  4094. ],
  4095. },
  4096. {
  4097. label: 'Miscellaneous',
  4098. children: [
  4099. {
  4100. label: 'Valid Color',
  4101. value: filledStyle.validBackground,
  4102. input: 'color',
  4103. },
  4104. {
  4105. label: 'Invalid Color',
  4106. value: filledStyle.invalidBackground,
  4107. input: 'color',
  4108. },
  4109. {
  4110. label: 'Tooltip Color',
  4111. value: filledStyle.borderTooltip,
  4112. input: 'color',
  4113. },
  4114. ],
  4115. },
  4116. ],
  4117. },
  4118. ],
  4119. };
  4120. }
  4121. function toRawStyle(json) {
  4122. const [, modal, header, body] = json.children.map(({ children }) => children);
  4123. const [headerGeneral, headerButtons] = header.map(({ children }) => children);
  4124. const [bodyGeneral, bodyButtons, bodyMisc] = body.map(({ children }) => children);
  4125. return {
  4126. fontSize: modal[0].value,
  4127. borderModal: modal[1].value,
  4128. headBase: headerGeneral[0].value,
  4129. headContrast: headerGeneral[1].value,
  4130. headButtonExit: headerButtons[0].value,
  4131. headButtonLabel: headerButtons[1].value,
  4132. headButtonStyle: headerButtons[2].value,
  4133. headButtonHide: headerButtons[3].value,
  4134. headButtonAlt: headerButtons[4].value,
  4135. nodeBase: bodyGeneral[0].children
  4136. .filter(({ isActive }) => isActive)
  4137. .map((child) => child.value),
  4138. nodeContrast: bodyGeneral[1].value,
  4139. nodeButtonCreate: bodyButtons[0].value,
  4140. nodeButtonDuplicate: bodyButtons[1].value,
  4141. nodeButtonMove: bodyButtons[2].value,
  4142. nodeButtonDisable: bodyButtons[3].value,
  4143. nodeButtonDelete: bodyButtons[4].value,
  4144. validBackground: bodyMisc[0].value,
  4145. invalidBackground: bodyMisc[1].value,
  4146. borderTooltip: bodyMisc[2].value,
  4147. };
  4148. }
  4149. // For returning updated styles to the userscript
  4150. function getUserStyles() {
  4151. const { 'children': styleNodes } = getRoot().getJSON();
  4152. const styles = [];
  4153. for (const json of styleNodes) {
  4154. styles.push(Object.assign({ name: json.value, isActive: json.children[0].value }, toRawStyle(json)));
  4155. }
  4156. return styles;
  4157. }
  4158. function generate(userStyles, devStyle) {
  4159. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  4160. const defaultStyle = getFilledStyle(devStyle);
  4161. return (0,___WEBPACK_IMPORTED_MODULE_3__.generateTree)({
  4162. children: userStyles.map(toJSON),
  4163. seed: toJSON(Object.assign({ name: 'New Style', isActive: false }, defaultStyle)),
  4164. descendantPredicate: (styleNodes) => {
  4165. const activeStyles = styleNodes.filter(({ isActive, 'children': [{ value }], }) => isActive && value);
  4166. switch (activeStyles.length) {
  4167. case 0:
  4168. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(defaultStyle);
  4169. return true;
  4170. case 1:
  4171. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(toRawStyle(activeStyles[0]));
  4172. return true;
  4173. default:
  4174. return 'Only one color scheme may be active at a time.';
  4175. }
  4176. },
  4177. }, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  4178. }
  4179.  
  4180.  
  4181. /***/ }),
  4182.  
  4183. /***/ "./ts/modal/body/trees/style/update/depth.ts":
  4184. /*!***************************************************!*\
  4185. !*** ./ts/modal/body/trees/style/update/depth.ts ***!
  4186. \***************************************************/
  4187. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4188.  
  4189. __webpack_require__.r(__webpack_exports__);
  4190. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4191. /* harmony export */ addDepthChangeListener: () => (/* binding */ addDepthChangeListener),
  4192. /* harmony export */ getDepthClassCount: () => (/* binding */ getDepthClassCount),
  4193. /* harmony export */ updateDepth: () => (/* binding */ updateDepth)
  4194. /* harmony export */ });
  4195. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../index */ "./ts/modal/body/trees/index.ts");
  4196. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4197.  
  4198.  
  4199. const STYLESHEET = (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.generateStylesheet)();
  4200. const callbacks = [];
  4201. let currentClassCount;
  4202. function getDepthClassCount() {
  4203. return currentClassCount;
  4204. }
  4205. function addDepthRule(selectors, styles) {
  4206. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(selectors, styles, STYLESHEET);
  4207. }
  4208. function addDepthChangeListener(callback) {
  4209. callbacks.push((depth) => callback(depth, addDepthRule));
  4210. for (let i = 0; i < currentClassCount; ++i) {
  4211. callback(i, addDepthRule);
  4212. }
  4213. }
  4214. function updateDepth(depth) {
  4215. for (let i = STYLESHEET.cssRules.length - 1; i >= 0; --i) {
  4216. STYLESHEET.deleteRule(i);
  4217. }
  4218. for (const root of Object.values(_index__WEBPACK_IMPORTED_MODULE_0__.ROOTS)) {
  4219. root.updateDepthClass(depth);
  4220. }
  4221. for (let i = 0; i < depth; ++i) {
  4222. for (const callback of callbacks) {
  4223. callback(i, addDepthRule);
  4224. }
  4225. }
  4226. currentClassCount = depth;
  4227. }
  4228.  
  4229.  
  4230. /***/ }),
  4231.  
  4232. /***/ "./ts/modal/body/trees/style/update/index.ts":
  4233. /*!***************************************************!*\
  4234. !*** ./ts/modal/body/trees/style/update/index.ts ***!
  4235. \***************************************************/
  4236. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4237.  
  4238. __webpack_require__.r(__webpack_exports__);
  4239. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4240. /* harmony export */ "default": () => (/* binding */ updateStylesheet)
  4241. /* harmony export */ });
  4242. /* harmony import */ var _depth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./depth */ "./ts/modal/body/trees/style/update/depth.ts");
  4243. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4244. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4245. var t = {};
  4246. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4247. t[p] = s[p];
  4248. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4249. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4250. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4251. t[p[i]] = s[p[i]];
  4252. }
  4253. return t;
  4254. };
  4255.  
  4256.  
  4257. const STYLESHEET = (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.generateStylesheet)();
  4258. function getContrast(hex, method) {
  4259. const r = parseInt(hex.slice(1, 3), 16);
  4260. const g = parseInt(hex.slice(3, 5), 16);
  4261. const b = parseInt(hex.slice(5, 7), 16);
  4262. switch (method) {
  4263. case 'Black / White': {
  4264. // https://stackoverflow.com/a/3943023/112731
  4265. const luminosity = r * 0.299 + g * 0.587 + b * 0.114;
  4266. return luminosity > 145 ? 'black' : 'white';
  4267. }
  4268. }
  4269. const toHexPart = (rgb) => {
  4270. const x = (255 - rgb).toString(16);
  4271. return x.length === 2 ? x : `0${x}`;
  4272. };
  4273. return `#${toHexPart(r)}${toHexPart((g))}${toHexPart(b)}`;
  4274. }
  4275. function updateStylesheet(_a) {
  4276. var { fontSize, headContrast, nodeBase, nodeContrast } = _a, colours = __rest(_a, ["fontSize", "headContrast", "nodeBase", "nodeContrast"]);
  4277. for (let i = STYLESHEET.cssRules.length - 1; i >= 0; --i) {
  4278. STYLESHEET.deleteRule(i);
  4279. }
  4280. (0,_depth__WEBPACK_IMPORTED_MODULE_0__.updateDepth)(nodeBase.length);
  4281. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)('', ['font-size', `${fontSize}px`], STYLESHEET);
  4282. const colourStyles = Object.entries(colours).map(([property, value]) => [`--${property}`, value]);
  4283. for (const [depth, baseColour] of nodeBase.entries()) {
  4284. const contrastColour = getContrast(baseColour, nodeContrast);
  4285. colourStyles.push([`--nodeBase${depth}`, baseColour]);
  4286. colourStyles.push([`--nodeContrast${depth}`, contrastColour]);
  4287. }
  4288. colourStyles.push(['--headContrast', getContrast(colours.headBase, headContrast)]);
  4289. colourStyles.push(['--validFont', getContrast(colours.validBackground, nodeContrast)]);
  4290. colourStyles.push(['--invalidFont', getContrast(colours.invalidBackground, nodeContrast)]);
  4291. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addVariables)(colourStyles, STYLESHEET);
  4292. }
  4293.  
  4294.  
  4295. /***/ }),
  4296.  
  4297. /***/ "./ts/modal/consts.ts":
  4298. /*!****************************!*\
  4299. !*** ./ts/modal/consts.ts ***!
  4300. \****************************/
  4301. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4302.  
  4303. __webpack_require__.r(__webpack_exports__);
  4304. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4305. /* harmony export */ BUTTON_ACTIVE_CLASS: () => (/* binding */ BUTTON_ACTIVE_CLASS),
  4306. /* harmony export */ MODAL_BACKGROUND_ID: () => (/* binding */ MODAL_BACKGROUND_ID),
  4307. /* harmony export */ MODAL_ID: () => (/* binding */ MODAL_ID),
  4308. /* harmony export */ SVG_NAMESPACE: () => (/* binding */ SVG_NAMESPACE)
  4309. /* harmony export */ });
  4310. const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  4311. // Indicates 'on' state for actions that can be turned on and off
  4312. const BUTTON_ACTIVE_CLASS = 'active';
  4313. const MODAL_BACKGROUND_ID = 'modal-background';
  4314. const MODAL_ID = 'modal-content';
  4315.  
  4316.  
  4317. /***/ }),
  4318.  
  4319. /***/ "./ts/modal/css.ts":
  4320. /*!*************************!*\
  4321. !*** ./ts/modal/css.ts ***!
  4322. \*************************/
  4323. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4324.  
  4325. __webpack_require__.r(__webpack_exports__);
  4326. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4327. /* harmony export */ addRule: () => (/* binding */ addRule),
  4328. /* harmony export */ addVariables: () => (/* binding */ addVariables),
  4329. /* harmony export */ "default": () => (/* binding */ generate),
  4330. /* harmony export */ generateStylesheet: () => (/* binding */ generateStylesheet),
  4331. /* harmony export */ getRuleString: () => (/* binding */ getRuleString),
  4332. /* harmony export */ getTargetWindow: () => (/* binding */ getTargetWindow),
  4333. /* harmony export */ setRootId: () => (/* binding */ setRootId)
  4334. /* harmony export */ });
  4335. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  4336.  
  4337. let targetWindow = window;
  4338. while (targetWindow.frameElement) {
  4339. targetWindow = window.parent;
  4340. }
  4341. function getTargetWindow() {
  4342. return targetWindow;
  4343. }
  4344. let rootSelector = 'body';
  4345. function setRootId(id) {
  4346. rootSelector = `#${id}`;
  4347. }
  4348. function generateStylesheet() {
  4349. const wrapper = document.createElement('style');
  4350. getTargetWindow().document.head.appendChild(wrapper);
  4351. return wrapper.sheet;
  4352. }
  4353. const STYLESHEET = generateStylesheet();
  4354. function isStyle(candidate) {
  4355. return candidate.length > 0 && typeof candidate[0] === 'string';
  4356. }
  4357. function getStyleString([property, value]) {
  4358. return `${property}:${value};`;
  4359. }
  4360. function getRuleString(selectors, rules) {
  4361. const styleString = isStyle(rules) ? getStyleString(rules) : rules.map(getStyleString).join('');
  4362. const selectorString = typeof selectors === 'string' ? selectors : selectors.join(`,${rootSelector} `);
  4363. return `${rootSelector} ${selectorString}{${styleString}}`;
  4364. }
  4365. function addRule(selectors, styles, stylesheet = STYLESHEET) {
  4366. stylesheet.insertRule(getRuleString(selectors, styles));
  4367. }
  4368. function addVariables(rules, stylesheet = STYLESHEET) {
  4369. const styleString = rules.map(getStyleString).join('');
  4370. stylesheet.insertRule(`:root{${styleString}}`);
  4371. }
  4372. function generate() {
  4373. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID}`, [
  4374. ['position', 'fixed'],
  4375. ['left', '0'],
  4376. ['top', '0'],
  4377. ['width', '100%'],
  4378. ['height', '100%'],
  4379. ['background-color', '#0003'],
  4380. ]);
  4381. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID}`, [
  4382. ['position', 'relative'],
  4383. ['margin', '12vh auto'],
  4384. ['padding', '0'],
  4385. ['width', '80%'],
  4386. ['font-family', 'Tahoma, Geneva, sans-serif'],
  4387. ['outline', 'var(--borderModal) solid 2px'],
  4388. ['box-shadow', '1px 1px 10px 4px #00000015, 0 0 30px 10px #00000065'],
  4389. ]);
  4390. addRule('button', [
  4391. ['display', 'inline-flex'],
  4392. ['cursor', 'pointer'],
  4393. ['background', 'none'],
  4394. ['font-size', 'inherit'],
  4395. ['padding', '0'],
  4396. ['margin', '0'],
  4397. ['border', 'none'],
  4398. ['outline-offset', '-2px'],
  4399. ]);
  4400. addRule('button *', [['pointer-events', 'none']]);
  4401. addRule('svg', [['fill', 'none']]);
  4402. addRule('input', [
  4403. ['font', 'inherit'],
  4404. ['background', 'inherit'],
  4405. ['color', 'inherit'],
  4406. ['border', 'none'],
  4407. ]);
  4408. addRule(':focus-visible:not(button):not(input)', [['outline', 'none']]);
  4409. addRule('label', [['cursor', 'inherit']]);
  4410. }
  4411.  
  4412.  
  4413. /***/ }),
  4414.  
  4415. /***/ "./ts/modal/header/actions/alternate/button.ts":
  4416. /*!*****************************************************!*\
  4417. !*** ./ts/modal/header/actions/alternate/button.ts ***!
  4418. \*****************************************************/
  4419. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4420.  
  4421. __webpack_require__.r(__webpack_exports__);
  4422. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4423. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4424. /* harmony export */ });
  4425. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4426. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4427. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4428.  
  4429.  
  4430.  
  4431. const ALPHA = Math.PI / 5;
  4432. const RADIUS = 46;
  4433. const points = [];
  4434. // https://stackoverflow.com/questions/14580033/algorithm-for-drawing-a-5-point-star
  4435. for (let i = 0; i < 12; ++i) {
  4436. const r = RADIUS * (i % 2 + 1) / 2;
  4437. const omega = ALPHA * i;
  4438. points.push([r * Math.sin(omega), r * Math.cos(omega)]);
  4439. }
  4440. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  4441. outline.setAttribute('stroke-linecap', 'round');
  4442. outline.setAttribute('stroke-width', '7');
  4443. outline.setAttribute('d', points.map(([x, y], i) => `${i === 0 ? 'M' : 'L'} ${x},${y}`).join());
  4444. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  4445. g.append(outline);
  4446. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Special Buttons');
  4447. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  4448.  
  4449.  
  4450. /***/ }),
  4451.  
  4452. /***/ "./ts/modal/header/actions/alternate/consts.ts":
  4453. /*!*****************************************************!*\
  4454. !*** ./ts/modal/header/actions/alternate/consts.ts ***!
  4455. \*****************************************************/
  4456. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4457.  
  4458. __webpack_require__.r(__webpack_exports__);
  4459. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4460. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  4461. /* harmony export */ });
  4462. const ACTION_ID = 'modal-alt';
  4463.  
  4464.  
  4465. /***/ }),
  4466.  
  4467. /***/ "./ts/modal/header/actions/alternate/css.ts":
  4468. /*!**************************************************!*\
  4469. !*** ./ts/modal/header/actions/alternate/css.ts ***!
  4470. \**************************************************/
  4471. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4472.  
  4473. __webpack_require__.r(__webpack_exports__);
  4474. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4475. /* harmony export */ "default": () => (/* binding */ generate)
  4476. /* harmony export */ });
  4477. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4478. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  4479.  
  4480.  
  4481. function generate() {
  4482. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonAlt');
  4483. }
  4484.  
  4485.  
  4486. /***/ }),
  4487.  
  4488. /***/ "./ts/modal/header/actions/alternate/index.ts":
  4489. /*!****************************************************!*\
  4490. !*** ./ts/modal/header/actions/alternate/index.ts ***!
  4491. \****************************************************/
  4492. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4493.  
  4494. __webpack_require__.r(__webpack_exports__);
  4495. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4496. /* harmony export */ "default": () => (/* binding */ generate),
  4497. /* harmony export */ isActive: () => (/* binding */ isActive)
  4498. /* harmony export */ });
  4499. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/alternate/button.ts");
  4500. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  4501. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/alternate/css.ts");
  4502. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4503. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  4504. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4505.  
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511. let _isActive = false;
  4512. let keyHeld = false;
  4513. function isActive() {
  4514. return _isActive;
  4515. }
  4516. function doAction(doActivate = !_isActive) {
  4517. (0,_modal_body_trees__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, doActivate);
  4518. _isActive = doActivate;
  4519. }
  4520. function generate() {
  4521. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  4522. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction);
  4523. _button__WEBPACK_IMPORTED_MODULE_0__["default"].title += ' (Ctrl)';
  4524. const targetWindow = (0,_modal_css__WEBPACK_IMPORTED_MODULE_5__.getTargetWindow)();
  4525. targetWindow.addEventListener('keydown', (event) => {
  4526. if (event.key === 'Control') {
  4527. keyHeld = true;
  4528. doAction(true);
  4529. }
  4530. });
  4531. targetWindow.addEventListener('keyup', (event) => {
  4532. if (event.key === 'Control') {
  4533. keyHeld = false;
  4534. doAction(false);
  4535. }
  4536. });
  4537. targetWindow.addEventListener('blur', () => {
  4538. if (keyHeld) {
  4539. keyHeld = false;
  4540. doAction(false);
  4541. }
  4542. });
  4543. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  4544. }
  4545.  
  4546.  
  4547. /***/ }),
  4548.  
  4549. /***/ "./ts/modal/header/actions/button.ts":
  4550. /*!*******************************************!*\
  4551. !*** ./ts/modal/header/actions/button.ts ***!
  4552. \*******************************************/
  4553. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4554.  
  4555. __webpack_require__.r(__webpack_exports__);
  4556. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4557. /* harmony export */ bindAction: () => (/* binding */ bindAction),
  4558. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  4559. /* harmony export */ });
  4560. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  4561. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  4562. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4563.  
  4564.  
  4565.  
  4566. // Adds the template to the DOM
  4567. function bindAction(button, doAction, hotkey) {
  4568. const bound = (event) => {
  4569. event.stopPropagation();
  4570. button.blur();
  4571. doAction();
  4572. };
  4573. button.addEventListener('click', bound);
  4574. if (hotkey) {
  4575. button.title += ` (Alt+${hotkey})`;
  4576. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.getTargetWindow)().addEventListener('keydown', (event) => {
  4577. if (event.altKey && event.key.toUpperCase() === hotkey) {
  4578. bound(event);
  4579. }
  4580. });
  4581. }
  4582. return bound;
  4583. }
  4584. // Creates a template
  4585. const getNewButton = (function () {
  4586. const buttonTemplate = document.createElement('button');
  4587. const svgTemplate = document.createElementNS(_consts__WEBPACK_IMPORTED_MODULE_1__.SVG_NAMESPACE, 'svg');
  4588. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  4589. // Prevent tabbing to buttons until node is focused
  4590. buttonTemplate.setAttribute('tabIndex', '2');
  4591. svgTemplate.setAttribute('viewBox', `-70 -70 140 140`);
  4592. return function (group, actionId, description) {
  4593. const button = buttonTemplate.cloneNode(true);
  4594. const svg = svgTemplate.cloneNode(true);
  4595. button.id = actionId;
  4596. button.title = description;
  4597. svg.append(group);
  4598. button.append(svg);
  4599. return button;
  4600. };
  4601. })();
  4602.  
  4603.  
  4604. /***/ }),
  4605.  
  4606. /***/ "./ts/modal/header/actions/close/button.ts":
  4607. /*!*************************************************!*\
  4608. !*** ./ts/modal/header/actions/close/button.ts ***!
  4609. \*************************************************/
  4610. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4611.  
  4612. __webpack_require__.r(__webpack_exports__);
  4613. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4614. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4615. /* harmony export */ });
  4616. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4617. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4618. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4619.  
  4620.  
  4621.  
  4622. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  4623. line0.setAttribute('stroke-linecap', 'round');
  4624. line0.setAttribute('stroke-width', '12');
  4625. line0.setAttribute('x1', '-30');
  4626. line0.setAttribute('x2', '30');
  4627. line0.setAttribute('y1', '-30');
  4628. line0.setAttribute('y2', '30');
  4629. const line1 = line0.cloneNode(true);
  4630. line1.setAttribute('transform', 'rotate(90 0 0)');
  4631. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  4632. g.append(line0, line1);
  4633. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Save & Exit');
  4634. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  4635.  
  4636.  
  4637. /***/ }),
  4638.  
  4639. /***/ "./ts/modal/header/actions/close/consts.ts":
  4640. /*!*************************************************!*\
  4641. !*** ./ts/modal/header/actions/close/consts.ts ***!
  4642. \*************************************************/
  4643. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4644.  
  4645. __webpack_require__.r(__webpack_exports__);
  4646. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4647. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  4648. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  4649. /* harmony export */ });
  4650. const ACTION_ID = 'modal-close';
  4651. const HOTKEY = 'X';
  4652.  
  4653.  
  4654. /***/ }),
  4655.  
  4656. /***/ "./ts/modal/header/actions/close/css.ts":
  4657. /*!**********************************************!*\
  4658. !*** ./ts/modal/header/actions/close/css.ts ***!
  4659. \**********************************************/
  4660. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4661.  
  4662. __webpack_require__.r(__webpack_exports__);
  4663. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4664. /* harmony export */ "default": () => (/* binding */ generate)
  4665. /* harmony export */ });
  4666. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4667. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4668.  
  4669.  
  4670. function generate() {
  4671. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)([
  4672. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:focus > svg`,
  4673. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:hover > svg`,
  4674. ], ['background-color', 'var(--headButtonExit)']);
  4675. }
  4676.  
  4677.  
  4678. /***/ }),
  4679.  
  4680. /***/ "./ts/modal/header/actions/close/index.ts":
  4681. /*!************************************************!*\
  4682. !*** ./ts/modal/header/actions/close/index.ts ***!
  4683. \************************************************/
  4684. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4685.  
  4686. __webpack_require__.r(__webpack_exports__);
  4687. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4688. /* harmony export */ "default": () => (/* binding */ generate),
  4689. /* harmony export */ setCallback: () => (/* binding */ setCallback)
  4690. /* harmony export */ });
  4691. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/close/button.ts");
  4692. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  4693. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/close/css.ts");
  4694. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4695. /* harmony import */ var _modal_body_trees_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/trees/data */ "./ts/modal/body/trees/data/index.ts");
  4696. /* harmony import */ var _modal_body_trees_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/trees/style */ "./ts/modal/body/trees/style/index.ts");
  4697. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  4698. /* harmony import */ var _nodes_actions_edit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  4699. /* harmony import */ var _nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/actions/buttons/move */ "./ts/modal/body/trees/nodes/actions/buttons/move/index.ts");
  4700. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/trees/nodes/actions/highlight/index.ts");
  4701. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  4702.  
  4703.  
  4704.  
  4705.  
  4706.  
  4707.  
  4708.  
  4709.  
  4710.  
  4711.  
  4712.  
  4713. let callback;
  4714. function setCallback(_callback) {
  4715. callback = _callback;
  4716. }
  4717. // TODO Maybe add a white, 0.5 opacity foreground over everything with a loading symbol.
  4718. // Do the same when waiting for a config.
  4719. // Prevent interaction during loading by adding a stopPropagation click listener to the foreground.
  4720. function doAction() {
  4721. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_6__.reset)();
  4722. (0,_nodes_actions_edit__WEBPACK_IMPORTED_MODULE_7__.reset)();
  4723. (0,_nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__.reset)();
  4724. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_9__.reset)();
  4725. _modal_body_trees__WEBPACK_IMPORTED_MODULE_10__.TREE_CONTAINER.scroll(0, 0);
  4726. callback === null || callback === void 0 ? void 0 : callback({
  4727. tree: (0,_modal_body_trees_data__WEBPACK_IMPORTED_MODULE_4__.getRoot)().getJSON(),
  4728. styles: (0,_modal_body_trees_style__WEBPACK_IMPORTED_MODULE_5__.getUserStyles)(),
  4729. });
  4730. callback = undefined;
  4731. }
  4732. function generate(background) {
  4733. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  4734. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  4735. background.addEventListener('click', (event) => {
  4736. if (background.isSameNode(event.target)) {
  4737. doAction();
  4738. }
  4739. });
  4740. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  4741. }
  4742.  
  4743.  
  4744. /***/ }),
  4745.  
  4746. /***/ "./ts/modal/header/actions/consts.ts":
  4747. /*!*******************************************!*\
  4748. !*** ./ts/modal/header/actions/consts.ts ***!
  4749. \*******************************************/
  4750. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4751.  
  4752. __webpack_require__.r(__webpack_exports__);
  4753. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4754. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  4755. /* harmony export */ BUTTON_CONTAINER_ID: () => (/* binding */ BUTTON_CONTAINER_ID)
  4756. /* harmony export */ });
  4757. const BUTTON_CLASS = 'modal-button';
  4758. const BUTTON_CONTAINER_ID = 'modal-button-container';
  4759.  
  4760.  
  4761. /***/ }),
  4762.  
  4763. /***/ "./ts/modal/header/actions/css.ts":
  4764. /*!****************************************!*\
  4765. !*** ./ts/modal/header/actions/css.ts ***!
  4766. \****************************************/
  4767. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4768.  
  4769. __webpack_require__.r(__webpack_exports__);
  4770. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4771. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  4772. /* harmony export */ "default": () => (/* binding */ generate)
  4773. /* harmony export */ });
  4774. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  4775. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  4776. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  4777.  
  4778.  
  4779.  
  4780. function addColourRule(actionId, colour) {
  4781. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${actionId}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS} > svg`, [
  4782. ['stroke', `var(--headBase)`],
  4783. ['fill', `var(${colour})`],
  4784. ]);
  4785. }
  4786. function generate() {
  4787. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CONTAINER_ID}`, [
  4788. ['display', 'inline-flex'],
  4789. ['flex-direction', 'row'],
  4790. ]);
  4791. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4792. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  4793. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  4794. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS} > svg`,
  4795. ], ['background-color', `var(--headContrast)`]);
  4796. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, ['border-left', '2px solid var(--headContrast)']);
  4797. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4798. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):focus`,
  4799. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):hover`,
  4800. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child).${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}`,
  4801. ], ['border-color', 'var(--headBase)']);
  4802. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4803. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus:not(.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}) > svg`,
  4804. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover:not(.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}) > svg`,
  4805. ], ['stroke', `var(--headBase)`]);
  4806. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  4807. ['width', '1.81em'],
  4808. ['stroke', 'var(--headContrast)'],
  4809. ['fill', `var(--headContrast)`],
  4810. // Fixes pixel gap between button border & svg
  4811. ['margin-left', '-0.5px'],
  4812. ]);
  4813. }
  4814.  
  4815.  
  4816. /***/ }),
  4817.  
  4818. /***/ "./ts/modal/header/actions/hide/button.ts":
  4819. /*!************************************************!*\
  4820. !*** ./ts/modal/header/actions/hide/button.ts ***!
  4821. \************************************************/
  4822. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4823.  
  4824. __webpack_require__.r(__webpack_exports__);
  4825. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4826. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4827. /* harmony export */ });
  4828. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  4829. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4830. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4831.  
  4832.  
  4833.  
  4834. const edgeTop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  4835. edgeTop.setAttribute('stroke-linecap', 'round');
  4836. edgeTop.setAttribute('stroke-width', '6');
  4837. edgeTop.setAttribute('d', 'M -55, 0'
  4838. + 'Q 0,80 55,0');
  4839. edgeTop.setAttribute('fill', 'none');
  4840. const edgeBottom = edgeTop.cloneNode(true);
  4841. edgeBottom.setAttribute('transform', 'scale(1,-1)');
  4842. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  4843. circle.setAttribute('cx', '0');
  4844. circle.setAttribute('cy', '0');
  4845. circle.setAttribute('r', '26');
  4846. circle.setAttribute('stroke-width', '7');
  4847. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  4848. line.setAttribute('stroke-linecap', 'round');
  4849. line.setAttribute('stroke-width', '7');
  4850. line.setAttribute('x1', '-26');
  4851. line.setAttribute('x2', '26');
  4852. line.setAttribute('y1', '0');
  4853. line.setAttribute('y2', '0');
  4854. line.setAttribute('transform', 'rotate(45 0 0)');
  4855. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  4856. g.append(edgeTop, edgeBottom, circle, line);
  4857. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Disabled Node Visibility');
  4858. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  4859.  
  4860.  
  4861. /***/ }),
  4862.  
  4863. /***/ "./ts/modal/header/actions/hide/consts.ts":
  4864. /*!************************************************!*\
  4865. !*** ./ts/modal/header/actions/hide/consts.ts ***!
  4866. \************************************************/
  4867. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4868.  
  4869. __webpack_require__.r(__webpack_exports__);
  4870. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4871. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  4872. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  4873. /* harmony export */ });
  4874. const ACTION_ID = 'modal-hide';
  4875. const HOTKEY = 'H';
  4876.  
  4877.  
  4878. /***/ }),
  4879.  
  4880. /***/ "./ts/modal/header/actions/hide/css.ts":
  4881. /*!*********************************************!*\
  4882. !*** ./ts/modal/header/actions/hide/css.ts ***!
  4883. \*********************************************/
  4884. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4885.  
  4886. __webpack_require__.r(__webpack_exports__);
  4887. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4888. /* harmony export */ "default": () => (/* binding */ generate)
  4889. /* harmony export */ });
  4890. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  4891. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  4892. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4893. /* harmony import */ var _modal_body_trees_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/trees/consts */ "./ts/modal/body/trees/consts.ts");
  4894. /* harmony import */ var _nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/buttons/disable/consts */ "./ts/modal/body/trees/nodes/actions/buttons/disable/consts.ts");
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900. function generate() {
  4901. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_trees_consts__WEBPACK_IMPORTED_MODULE_3__.TREE_CONTAINER_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__.DISABLED_CLASS}`, ['display', 'none']);
  4902. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonHide');
  4903. }
  4904.  
  4905.  
  4906. /***/ }),
  4907.  
  4908. /***/ "./ts/modal/header/actions/hide/index.ts":
  4909. /*!***********************************************!*\
  4910. !*** ./ts/modal/header/actions/hide/index.ts ***!
  4911. \***********************************************/
  4912. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4913.  
  4914. __webpack_require__.r(__webpack_exports__);
  4915. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4916. /* harmony export */ "default": () => (/* binding */ generate)
  4917. /* harmony export */ });
  4918. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/hide/button.ts");
  4919. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  4920. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/hide/css.ts");
  4921. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4922. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928. let isActive = false;
  4929. function doAction() {
  4930. isActive = !isActive;
  4931. (0,_modal_body_trees__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  4932. }
  4933. function generate() {
  4934. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  4935. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  4936. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  4937. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  4938. }
  4939.  
  4940.  
  4941. /***/ }),
  4942.  
  4943. /***/ "./ts/modal/header/actions/index.ts":
  4944. /*!******************************************!*\
  4945. !*** ./ts/modal/header/actions/index.ts ***!
  4946. \******************************************/
  4947. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4948.  
  4949. __webpack_require__.r(__webpack_exports__);
  4950. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4951. /* harmony export */ "default": () => (/* binding */ generate)
  4952. /* harmony export */ });
  4953. /* harmony import */ var _close__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./close */ "./ts/modal/header/actions/close/index.ts");
  4954. /* harmony import */ var _labels__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./labels */ "./ts/modal/header/actions/labels/index.ts");
  4955. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/header/actions/style/index.ts");
  4956. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hide */ "./ts/modal/header/actions/hide/index.ts");
  4957. /* harmony import */ var _alternate__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./alternate */ "./ts/modal/header/actions/alternate/index.ts");
  4958. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/css.ts");
  4959. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967. function generate(background) {
  4968. (0,_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  4969. const element = document.createElement('span');
  4970. element.id = _consts__WEBPACK_IMPORTED_MODULE_6__.BUTTON_CONTAINER_ID;
  4971. element.append((0,_alternate__WEBPACK_IMPORTED_MODULE_4__["default"])(), (0,_hide__WEBPACK_IMPORTED_MODULE_3__["default"])(), (0,_labels__WEBPACK_IMPORTED_MODULE_1__["default"])(), (0,_style__WEBPACK_IMPORTED_MODULE_2__["default"])(), (0,_close__WEBPACK_IMPORTED_MODULE_0__["default"])(background));
  4972. return element;
  4973. }
  4974.  
  4975.  
  4976. /***/ }),
  4977.  
  4978. /***/ "./ts/modal/header/actions/labels/button.ts":
  4979. /*!**************************************************!*\
  4980. !*** ./ts/modal/header/actions/labels/button.ts ***!
  4981. \**************************************************/
  4982. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4983.  
  4984. __webpack_require__.r(__webpack_exports__);
  4985. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4986. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  4987. /* harmony export */ });
  4988. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  4989. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  4990. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4991.  
  4992.  
  4993.  
  4994. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  4995. outline.setAttribute('stroke-linecap', 'round');
  4996. outline.setAttribute('stroke-width', '7');
  4997. outline.setAttribute('d', 'M 20,-30'
  4998. + 'L -40,-30'
  4999. + 'L -40,30'
  5000. + 'L 20,30'
  5001. + 'L 50,0'
  5002. + 'L 20,-30');
  5003. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5004. circle.setAttribute('stroke-width', '5');
  5005. circle.setAttribute('r', '5');
  5006. circle.setAttribute('cx', '20');
  5007. circle.setAttribute('cy', '0');
  5008. const loop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5009. loop.setAttribute('fill', 'none');
  5010. loop.setAttribute('stroke-linecap', 'round');
  5011. loop.setAttribute('stroke-width', '6');
  5012. loop.setAttribute('d', 'M 20,0'
  5013. + 'C -70,50 -30,50 15,30');
  5014. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5015. g.setAttribute('transform', 'rotate(-60 0 0)');
  5016. g.append(outline, circle, loop);
  5017. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Labels');
  5018. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5019.  
  5020.  
  5021. /***/ }),
  5022.  
  5023. /***/ "./ts/modal/header/actions/labels/consts.ts":
  5024. /*!**************************************************!*\
  5025. !*** ./ts/modal/header/actions/labels/consts.ts ***!
  5026. \**************************************************/
  5027. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5028.  
  5029. __webpack_require__.r(__webpack_exports__);
  5030. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5031. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5032. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5033. /* harmony export */ });
  5034. const ACTION_ID = 'modal-labels';
  5035. const HOTKEY = 'N';
  5036.  
  5037.  
  5038. /***/ }),
  5039.  
  5040. /***/ "./ts/modal/header/actions/labels/css.ts":
  5041. /*!***********************************************!*\
  5042. !*** ./ts/modal/header/actions/labels/css.ts ***!
  5043. \***********************************************/
  5044. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5045.  
  5046. __webpack_require__.r(__webpack_exports__);
  5047. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5048. /* harmony export */ "default": () => (/* binding */ generate)
  5049. /* harmony export */ });
  5050. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  5051. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5052. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5053. /* harmony import */ var _modal_body_trees_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/trees/consts */ "./ts/modal/body/trees/consts.ts");
  5054. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/trees/nodes/consts.ts");
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060. function generate() {
  5061. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_trees_consts__WEBPACK_IMPORTED_MODULE_3__.TREE_CONTAINER_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_consts__WEBPACK_IMPORTED_MODULE_4__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['display', 'none']);
  5062. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonLabel');
  5063. }
  5064.  
  5065.  
  5066. /***/ }),
  5067.  
  5068. /***/ "./ts/modal/header/actions/labels/index.ts":
  5069. /*!*************************************************!*\
  5070. !*** ./ts/modal/header/actions/labels/index.ts ***!
  5071. \*************************************************/
  5072. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5073.  
  5074. __webpack_require__.r(__webpack_exports__);
  5075. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5076. /* harmony export */ "default": () => (/* binding */ generate)
  5077. /* harmony export */ });
  5078. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/labels/button.ts");
  5079. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  5080. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/labels/css.ts");
  5081. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5082. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088. let isActive = false;
  5089. function doAction() {
  5090. isActive = !isActive;
  5091. (0,_modal_body_trees__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5092. }
  5093. function generate() {
  5094. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5095. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5096. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  5097. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5098. }
  5099.  
  5100.  
  5101. /***/ }),
  5102.  
  5103. /***/ "./ts/modal/header/actions/style/button.ts":
  5104. /*!*************************************************!*\
  5105. !*** ./ts/modal/header/actions/style/button.ts ***!
  5106. \*************************************************/
  5107. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5108.  
  5109. __webpack_require__.r(__webpack_exports__);
  5110. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5111. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5112. /* harmony export */ });
  5113. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5114. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5115. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5116.  
  5117.  
  5118.  
  5119. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  5120. handle.setAttribute('stroke-linecap', 'round');
  5121. handle.setAttribute('stroke-width', '6');
  5122. handle.setAttribute('x', '-5');
  5123. handle.setAttribute('y', '15');
  5124. handle.setAttribute('width', '15');
  5125. handle.setAttribute('height', '40');
  5126. handle.setAttribute('rx', '5');
  5127. const frame = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5128. frame.setAttribute('fill', 'none');
  5129. frame.setAttribute('stroke-linecap', 'round');
  5130. frame.setAttribute('stroke-width', '3');
  5131. frame.setAttribute('d', 'M 2.5,15'
  5132. + 'L 2.5,0'
  5133. + 'L -36,-15'
  5134. + 'L -36,-35'
  5135. + 'L -30,-35');
  5136. const curveLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5137. curveLeft.setAttribute('fill', 'none');
  5138. curveLeft.setAttribute('stroke-linecap', 'round');
  5139. curveLeft.setAttribute('stroke-width', '6');
  5140. curveLeft.setAttribute('d', 'M -25 -30'
  5141. + 'Q -30,-35 -25,-40');
  5142. const curveRight = curveLeft.cloneNode(true);
  5143. curveRight.setAttribute('transform', 'scale(-1,1) translate(-10,0)');
  5144. const roller = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  5145. roller.setAttribute('stroke-linecap', 'round');
  5146. roller.setAttribute('stroke-width', '6');
  5147. roller.setAttribute('x', '-22.5');
  5148. roller.setAttribute('y', '-47.5');
  5149. roller.setAttribute('width', '55');
  5150. roller.setAttribute('height', '25');
  5151. roller.setAttribute('rx', '1');
  5152. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5153. g.append(handle, frame, curveLeft, curveRight, roller);
  5154. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Style Editor');
  5155. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5156.  
  5157.  
  5158. /***/ }),
  5159.  
  5160. /***/ "./ts/modal/header/actions/style/consts.ts":
  5161. /*!*************************************************!*\
  5162. !*** ./ts/modal/header/actions/style/consts.ts ***!
  5163. \*************************************************/
  5164. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5165.  
  5166. __webpack_require__.r(__webpack_exports__);
  5167. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5168. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5169. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5170. /* harmony export */ });
  5171. const ACTION_ID = 'modal-style';
  5172. const HOTKEY = 'C';
  5173.  
  5174.  
  5175. /***/ }),
  5176.  
  5177. /***/ "./ts/modal/header/actions/style/css.ts":
  5178. /*!**********************************************!*\
  5179. !*** ./ts/modal/header/actions/style/css.ts ***!
  5180. \**********************************************/
  5181. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5182.  
  5183. __webpack_require__.r(__webpack_exports__);
  5184. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5185. /* harmony export */ "default": () => (/* binding */ generate)
  5186. /* harmony export */ });
  5187. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5188. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5189.  
  5190.  
  5191. function generate() {
  5192. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonStyle');
  5193. }
  5194.  
  5195.  
  5196. /***/ }),
  5197.  
  5198. /***/ "./ts/modal/header/actions/style/index.ts":
  5199. /*!************************************************!*\
  5200. !*** ./ts/modal/header/actions/style/index.ts ***!
  5201. \************************************************/
  5202. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5203.  
  5204. __webpack_require__.r(__webpack_exports__);
  5205. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5206. /* harmony export */ "default": () => (/* binding */ generate)
  5207. /* harmony export */ });
  5208. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/style/button.ts");
  5209. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  5210. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/style/css.ts");
  5211. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5212. /* harmony import */ var _modal_body_trees__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/trees */ "./ts/modal/body/trees/index.ts");
  5213. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/trees/nodes/actions/focus/index.ts");
  5214. /* harmony import */ var _nodes_actions_edit__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/edit */ "./ts/modal/body/trees/nodes/actions/edit/index.ts");
  5215. /* harmony import */ var _nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/buttons/move */ "./ts/modal/body/trees/nodes/actions/buttons/move/index.ts");
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224. let isActive = false;
  5225. function doAction() {
  5226. isActive = !isActive;
  5227. (0,_modal_body_trees__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  5228. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__.reset)();
  5229. (0,_nodes_actions_edit__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5230. (0,_nodes_actions_buttons_move__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5231. // Reset tab index
  5232. document.body.focus();
  5233. }
  5234. function generate() {
  5235. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5236. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5237. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5238. }
  5239.  
  5240.  
  5241. /***/ }),
  5242.  
  5243. /***/ "./ts/modal/header/consts.ts":
  5244. /*!***********************************!*\
  5245. !*** ./ts/modal/header/consts.ts ***!
  5246. \***********************************/
  5247. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5248.  
  5249. __webpack_require__.r(__webpack_exports__);
  5250. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5251. /* harmony export */ HEADER_ID: () => (/* binding */ HEADER_ID)
  5252. /* harmony export */ });
  5253. const HEADER_ID = 'modal-header';
  5254.  
  5255.  
  5256. /***/ }),
  5257.  
  5258. /***/ "./ts/modal/header/css.ts":
  5259. /*!********************************!*\
  5260. !*** ./ts/modal/header/css.ts ***!
  5261. \********************************/
  5262. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5263.  
  5264. __webpack_require__.r(__webpack_exports__);
  5265. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5266. /* harmony export */ "default": () => (/* binding */ generate)
  5267. /* harmony export */ });
  5268. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  5269. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  5270.  
  5271.  
  5272. function generate() {
  5273. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID}`, [
  5274. ['display', 'flex'],
  5275. ['align-items', 'center'],
  5276. ['background', 'var(--headBase)'],
  5277. ['color', 'var(--headContrast)'],
  5278. ['border-bottom', '2px solid var(--borderModal)'],
  5279. ['font-size', '1.6em'],
  5280. ['text-align', 'center'],
  5281. ]);
  5282. }
  5283.  
  5284.  
  5285. /***/ }),
  5286.  
  5287. /***/ "./ts/modal/header/index.ts":
  5288. /*!**********************************!*\
  5289. !*** ./ts/modal/header/index.ts ***!
  5290. \**********************************/
  5291. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5292.  
  5293. __webpack_require__.r(__webpack_exports__);
  5294. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5295. /* harmony export */ "default": () => (/* binding */ generate)
  5296. /* harmony export */ });
  5297. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  5298. /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./title */ "./ts/modal/header/title/index.ts");
  5299. /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./ts/modal/header/actions/index.ts");
  5300. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/header/css.ts");
  5301.  
  5302.  
  5303.  
  5304.  
  5305. function generate({ title }, background) {
  5306. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  5307. const element = document.createElement('div');
  5308. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID;
  5309. element.append((0,_title__WEBPACK_IMPORTED_MODULE_1__["default"])(title), (0,_actions__WEBPACK_IMPORTED_MODULE_2__["default"])(background));
  5310. return element;
  5311. }
  5312.  
  5313.  
  5314. /***/ }),
  5315.  
  5316. /***/ "./ts/modal/header/title/consts.ts":
  5317. /*!*****************************************!*\
  5318. !*** ./ts/modal/header/title/consts.ts ***!
  5319. \*****************************************/
  5320. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5321.  
  5322. __webpack_require__.r(__webpack_exports__);
  5323. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5324. /* harmony export */ TITLE_CONTAINER_ID: () => (/* binding */ TITLE_CONTAINER_ID),
  5325. /* harmony export */ TITLE_ID: () => (/* binding */ TITLE_ID)
  5326. /* harmony export */ });
  5327. const TITLE_CONTAINER_ID = 'title-container';
  5328. const TITLE_ID = 'title';
  5329.  
  5330.  
  5331. /***/ }),
  5332.  
  5333. /***/ "./ts/modal/header/title/css.ts":
  5334. /*!**************************************!*\
  5335. !*** ./ts/modal/header/title/css.ts ***!
  5336. \**************************************/
  5337. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5338.  
  5339. __webpack_require__.r(__webpack_exports__);
  5340. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5341. /* harmony export */ "default": () => (/* binding */ generate)
  5342. /* harmony export */ });
  5343. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  5344. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5345.  
  5346.  
  5347. function generate() {
  5348. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID}`, [
  5349. ['flex-grow', '1'],
  5350. ['white-space', 'nowrap'],
  5351. ['overflow', 'hidden'],
  5352. ['text-overflow', 'ellipsis'],
  5353. ['padding', '0 20px'],
  5354. ]);
  5355. }
  5356.  
  5357.  
  5358. /***/ }),
  5359.  
  5360. /***/ "./ts/modal/header/title/index.ts":
  5361. /*!****************************************!*\
  5362. !*** ./ts/modal/header/title/index.ts ***!
  5363. \****************************************/
  5364. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5365.  
  5366. __webpack_require__.r(__webpack_exports__);
  5367. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5368. /* harmony export */ "default": () => (/* binding */ generate)
  5369. /* harmony export */ });
  5370. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  5371. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/header/title/css.ts");
  5372.  
  5373.  
  5374. function generate(title) {
  5375. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5376. const titleContainer = document.createElement('span');
  5377. const titleElement = document.createElement('span');
  5378. titleContainer.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID;
  5379. titleElement.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_ID;
  5380. titleElement.innerText = title;
  5381. // In case the text is too long to fit
  5382. titleElement.title = title;
  5383. titleContainer.append(titleElement);
  5384. return titleContainer;
  5385. }
  5386.  
  5387.  
  5388. /***/ }),
  5389.  
  5390. /***/ "./ts/modal/index.ts":
  5391. /*!***************************!*\
  5392. !*** ./ts/modal/index.ts ***!
  5393. \***************************/
  5394. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5395.  
  5396. __webpack_require__.r(__webpack_exports__);
  5397. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5398. /* harmony export */ "default": () => (/* binding */ generate),
  5399. /* harmony export */ getSocket: () => (/* binding */ getSocket)
  5400. /* harmony export */ });
  5401. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  5402. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/css.ts");
  5403. /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./ts/modal/header/index.ts");
  5404. /* harmony import */ var _body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./body */ "./ts/modal/body/index.ts");
  5405.  
  5406.  
  5407.  
  5408.  
  5409. let socket;
  5410. function getSocket() {
  5411. return socket;
  5412. }
  5413. function generate(config, _socket) {
  5414. socket = _socket;
  5415. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5416. const background = document.createElement('div');
  5417. const foreground = document.createElement('div');
  5418. background.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID;
  5419. foreground.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID;
  5420. background.append(foreground);
  5421. socket.append(background);
  5422. foreground.append((0,_header__WEBPACK_IMPORTED_MODULE_2__["default"])(config, background));
  5423. foreground.append((0,_body__WEBPACK_IMPORTED_MODULE_3__["default"])(config));
  5424. }
  5425.  
  5426.  
  5427. /***/ }),
  5428.  
  5429. /***/ "./ts/predicate.ts":
  5430. /*!*************************!*\
  5431. !*** ./ts/predicate.ts ***!
  5432. \*************************/
  5433. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5434.  
  5435. __webpack_require__.r(__webpack_exports__);
  5436. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5437. /* harmony export */ getPredicatePromise: () => (/* binding */ getPredicatePromise)
  5438. /* harmony export */ });
  5439. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  5440. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  5441. return new (P || (P = Promise))(function (resolve, reject) {
  5442. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5443. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  5444. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  5445. step((generator = generator.apply(thisArg, _arguments || [])).next());
  5446. });
  5447. };
  5448. function getPredicateResponse(response) {
  5449. return __awaiter(this, void 0, void 0, function* () {
  5450. try {
  5451. return yield response;
  5452. }
  5453. catch ({ message }) {
  5454. throw message;
  5455. }
  5456. });
  5457. }
  5458. function getPredicatePromise(_response) {
  5459. return __awaiter(this, void 0, void 0, function* () {
  5460. const response = yield getPredicateResponse(_response);
  5461. if (typeof response === 'string') {
  5462. throw response;
  5463. }
  5464. else if (response) {
  5465. return;
  5466. }
  5467. throw null;
  5468. });
  5469. }
  5470.  
  5471.  
  5472. /***/ })
  5473.  
  5474. /******/ });
  5475. /************************************************************************/
  5476. /******/ // The module cache
  5477. /******/ var __webpack_module_cache__ = {};
  5478. /******/
  5479. /******/ // The require function
  5480. /******/ function __webpack_require__(moduleId) {
  5481. /******/ // Check if module is in cache
  5482. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  5483. /******/ if (cachedModule !== undefined) {
  5484. /******/ return cachedModule.exports;
  5485. /******/ }
  5486. /******/ // Create a new module (and put it into the cache)
  5487. /******/ var module = __webpack_module_cache__[moduleId] = {
  5488. /******/ // no module.id needed
  5489. /******/ // no module.loaded needed
  5490. /******/ exports: {}
  5491. /******/ };
  5492. /******/
  5493. /******/ // Execute the module function
  5494. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  5495. /******/
  5496. /******/ // Return the exports of the module
  5497. /******/ return module.exports;
  5498. /******/ }
  5499. /******/
  5500. /************************************************************************/
  5501. /******/ /* webpack/runtime/define property getters */
  5502. /******/ (() => {
  5503. /******/ // define getter functions for harmony exports
  5504. /******/ __webpack_require__.d = (exports, definition) => {
  5505. /******/ for(var key in definition) {
  5506. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  5507. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  5508. /******/ }
  5509. /******/ }
  5510. /******/ };
  5511. /******/ })();
  5512. /******/
  5513. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  5514. /******/ (() => {
  5515. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  5516. /******/ })();
  5517. /******/
  5518. /******/ /* webpack/runtime/make namespace object */
  5519. /******/ (() => {
  5520. /******/ // define __esModule on exports
  5521. /******/ __webpack_require__.r = (exports) => {
  5522. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  5523. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  5524. /******/ }
  5525. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  5526. /******/ };
  5527. /******/ })();
  5528. /******/
  5529. /************************************************************************/
  5530. var __webpack_exports__ = {};
  5531. // This entry need to be wrapped in an IIFE because it declares '$Config' on top-level, which conflicts with the current library output.
  5532. (() => {
  5533. /*!*******************************!*\
  5534. !*** ./ts/library/$Config.js ***!
  5535. \*******************************/
  5536. __webpack_require__.r(__webpack_exports__);
  5537. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5538. /* harmony export */ "default": () => (/* binding */ $Config)
  5539. /* harmony export */ });
  5540. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./index */ "./ts/library/index.ts");
  5541. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modal/css */ "./ts/modal/css.ts");
  5542. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  5543.  
  5544.  
  5545.  
  5546.  
  5547. const VERSION = 0;
  5548.  
  5549. const KEY_VERSION = 'TREE_FRAME_VERSION';
  5550.  
  5551. const KEY_STYLES = 'TREE_FRAME_USER_STYLES';
  5552.  
  5553. const STYLE_OUTER = {
  5554. position: 'fixed',
  5555. height: '100vh',
  5556. width: '100vw',
  5557. };
  5558.  
  5559. const getStrippedForest = (children) => {
  5560. const stripped = [];
  5561. for (const child of children) {
  5562. if (child.isActive === false) {
  5563. continue;
  5564. }
  5565. const data = {};
  5566. if ('value' in child) {
  5567. data.value = child.value;
  5568. }
  5569. if ('label' in child) {
  5570. data.label = child.label;
  5571. }
  5572. if ('children' in child) {
  5573. data.children = getStrippedForest(child.children);
  5574. }
  5575. stripped.push(data);
  5576. }
  5577. return stripped;
  5578. };
  5579.  
  5580. const getError = (reason, error) => {
  5581. const message = `[${TITLE}]${reason.includes('\n') ? '\n\n' : ' '}${reason}`;
  5582. if (error) {
  5583. error.message = message;
  5584. return error;
  5585. }
  5586. return new Error(message);
  5587. };
  5588.  
  5589. /**
  5590. * A node's value.
  5591. * @typedef {boolean | number | string} NodeValue
  5592. */
  5593.  
  5594. /**
  5595. * A child node.
  5596. * @typedef {object} ChildNode
  5597. * @property {string} [label] The node's purpose.
  5598. * @property {boolean | number | string} [value] The node's data.
  5599. * @property {Array<NodeValue> | function(NodeValue): boolean | string} [predicate] A data validator.
  5600. * @property {"color" | "date" | "datetime-local" | "email" | "month" | "password" | "search" | "tel" | "text" | "time" | "url" | "week"} [input] The desired input type.
  5601. */
  5602.  
  5603. /**
  5604. * A parent node.
  5605. * @typedef {object} ParentNode
  5606. * @property {Array<ChildNode | (ChildNode & ParentNode)>} children The node's children.
  5607. * @property {ChildNode | (ChildNode & ParentNode)} [seed] - A node that may be added to children.
  5608. * @property {function(Array<ChildNode>): boolean | string} [childPredicate] A child validator.
  5609. * @property {function(Array<ChildNode>): boolean | string} [descendantPredicate] A descendant validator.
  5610. * @property {number} [poolId] Children may be moved between nodes with poolId values that match their parent's.
  5611. */
  5612.  
  5613. /**
  5614. * A style to pass to the config-editor.
  5615. * @typedef {object} InnerStyle
  5616. * @property {number} [fontSize] The base font size.
  5617. * @property {string} [borderTooltip] The colour of tooltip borders.
  5618. * @property {string} [borderModal] The colour of the modal's border.
  5619. * @property {string} [headBase] The base colour of the modal's header.
  5620. * @property {'Black / White' | 'Invert'} [headContrast] The method of generating a contrast colour for the modal's header.
  5621. * @property {string} [headButtonExit] The colour of the modal header's exit button.
  5622. * @property {string} [headButtonLabel] The colour of the modal header's exit button.
  5623. * @property {string} [headButtonStyle] The colour of the modal header's style button.
  5624. * @property {string} [headButtonHide] The colour of the modal header's node-hider button.
  5625. * @property {string} [headButtonAlt] The colour of the modal header's alt button.
  5626. * @property {Array<string>} [nodeBase] Base colours for nodes, depending on their depth.
  5627. * @property {'Black / White' | 'Invert'} [nodeContrast] The method of generating a contrast colour for nodes.
  5628. * @property {string} [nodeButtonCreate] The colour of nodes' add-child buttons.
  5629. * @property {string} [nodeButtonDuplicate] The colour of nodes' duplicate buttons.
  5630. * @property {string} [nodeButtonMove] The colour of nodes' move buttons.
  5631. * @property {string} [nodeButtonDisable] The colour of nodes' toggle-active buttons.
  5632. * @property {string} [nodeButtonDelete] The colour of nodes' delete buttons.
  5633. * @property {string} [validBackground] The colour used to show that a node's value is valid.
  5634. * @property {string} [invalidBackground] The colour used to show that a node's value is invalid.
  5635. */
  5636.  
  5637. class $Config {
  5638. /**
  5639. * @param {string} KEY_TREE The identifier used to store and retrieve the user's config.
  5640. * @param {ParentNode} TREE_DEFAULT The tree to use as a starting point for the user's config.
  5641. * @param {function(Array<ChildNode | (ChildNode & ParentNode)>): *} _getConfig Takes a root node's children and returns the data structure expected by your script.
  5642. * @param {string} TITLE The heading to use in the config-editor.
  5643. * @param {InnerStyle} [STYLE_INNER] A custom style to use as the default
  5644. * @param {object} [_STYLE_OUTER] CSS to assign to the element. e.g. {zIndex: 9999}.
  5645. */
  5646. constructor(KEY_TREE, TREE_DEFAULT, _getConfig, TITLE, STYLE_INNER = {}, _STYLE_OUTER = {}) {
  5647. // PRIVATE FUNCTIONS
  5648. const getConfig = ({children}) => _getConfig(getStrippedForest(children));
  5649. // CORE PERMISSION CHECKS
  5650. if (typeof GM.getValue !== 'function') {
  5651. throw getError('Missing GM.getValue permission.');
  5652. }
  5653. if (typeof GM.setValue !== 'function') {
  5654. throw getError('Missing GM.setValue permission.');
  5655. }
  5656. if (typeof KEY_TREE !== 'string' || !(/^[a-z_][a-z0-9_]*$/i.test(KEY_TREE))) {
  5657. throw getError(`'${KEY_TREE}' is not a valid storage key.`);
  5658. }
  5659. // PRIVATE STATE
  5660. let isOpen = false;
  5661. const styleOuter = {
  5662. ...STYLE_OUTER,
  5663. ..._STYLE_OUTER,
  5664. };
  5665. // PUBLIC FUNCTIONS
  5666. const setConfig = (tree) => {
  5667. const config = getConfig(tree);
  5668. this.get = () => config;
  5669. };
  5670. this.ready = async () => {
  5671. // Setup root element
  5672. const target = (() => {
  5673. const target = document.createElement('div');
  5674. for (const [property, value] of Object.entries(styleOuter)) {
  5675. target.style[property] = value;
  5676. }
  5677. target.style.display = 'none';
  5678. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.getTargetWindow)().document.body.appendChild(target);
  5679. return target;
  5680. })();
  5681. // Retrieve data
  5682. const [userTree, userStyles, version] = await Promise.all([
  5683. GM.getValue(KEY_TREE),
  5684. GM.getValue(KEY_STYLES, []),
  5685. GM.getValue(KEY_VERSION, -1),
  5686. ]);
  5687. // Patch to current version
  5688. (() => {
  5689. if (version !== -1 || !userTree) {
  5690. return;
  5691. }
  5692. const patch = (node) => {
  5693. delete node.predicate;
  5694. delete node.childPredicate;
  5695. delete node.descendantPredicate;
  5696. delete node.seed;
  5697. if ('children' in node) {
  5698. for (const child of node.children) {
  5699. patch(child);
  5700. }
  5701. }
  5702. };
  5703. patch(userTree);
  5704. })();
  5705. // Listen for post-init communication
  5706. const open = (doOpen = true) => new Promise((resolve) => {
  5707. isOpen = doOpen;
  5708. target.style.display = doOpen ? (styleOuter.display ?? 'initial') : 'none';
  5709. // Delay script execution until visual update
  5710. setTimeout(resolve, 0);
  5711. });
  5712. const disconnect = () => new Promise((resolve) => {
  5713. isOpen = false;
  5714. target.remove();
  5715. // Delay script execution until visual update
  5716. setTimeout(resolve, 0);
  5717. });
  5718. /**
  5719. * @name $Config#reset
  5720. * @description Deletes the user's data.
  5721. * @returns {Promise<void>} Resolves upon completing the deletion.
  5722. */
  5723. this.reset = async () => {
  5724. if (isOpen) {
  5725. throw getError('Cannot reset while the UI is open.');
  5726. }
  5727. if (typeof GM.deleteValue !== 'function') {
  5728. throw getError('Missing GM.deleteValue permission.');
  5729. }
  5730. try {
  5731. setConfig(TREE_DEFAULT);
  5732. } catch (error) {
  5733. throw getError('Unable to parse default config.', error);
  5734. }
  5735. await GM.deleteValue(KEY_TREE);
  5736. // It may have previously been a rejected promise
  5737. this.ready = Promise.resolve();
  5738. (0,_modal_body__WEBPACK_IMPORTED_MODULE_2__.reset)();
  5739. };
  5740. /**
  5741. * @name $Config#edit
  5742. * @description Allows the user to edit the active config.
  5743. * @returns {Promise<void>} Resolves when the user closes the config editor.
  5744. */
  5745. this.edit = async () => {
  5746. if (isOpen) {
  5747. throw getError('A config editor is already open.');
  5748. }
  5749. open();
  5750. const {tree, styles} = await (0,_index__WEBPACK_IMPORTED_MODULE_0__.edit)();
  5751. GM.setValue(KEY_TREE, tree);
  5752. GM.setValue(KEY_STYLES, styles);
  5753. GM.setValue(KEY_VERSION, VERSION);
  5754. setConfig(tree);
  5755. await open(false);
  5756. };
  5757. // Pass data
  5758. try {
  5759. const response = await (0,_index__WEBPACK_IMPORTED_MODULE_0__.init)({
  5760. userStyles,
  5761. defaultTree: TREE_DEFAULT,
  5762. title: TITLE,
  5763. defaultStyle: STYLE_INNER,
  5764. ...(userTree ? {userTree} : {}),
  5765. }, target, KEY_TREE);
  5766. if (response.requireReset) {
  5767. throw getError(
  5768. 'Your config is invalid.'
  5769. + '\nThis could be due to a script update or your data being corrupted.'
  5770. + `\n\nReason:\n${response.error.message.replaceAll(/\n+/g, '\n')}`,
  5771. response.error,
  5772. );
  5773. }
  5774. setConfig(response.tree);
  5775. } catch (error) {
  5776. delete this.reset;
  5777. await disconnect();
  5778. throw getError(
  5779. 'Your config is invalid.'
  5780. + '\nThis could be due to a script update or your data being corrupted.'
  5781. + `\n\nReason:\n${error.message.replaceAll(/\n+/g, '\n')}`,
  5782. error,
  5783. );
  5784. }
  5785. };
  5786. }
  5787. }
  5788.  
  5789. })();
  5790.  
  5791. $Config = __webpack_exports__["default"];
  5792. /******/ })()
  5793. ;

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址