$Config

Allows users to configure scripts

目前为 2025-02-16 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/446506/1538382/%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 _modal_body_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body/data */ "./ts/modal/body/data/index.ts");
  36. /* harmony import */ var _modal_header_actions_close__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal/header/actions/close */ "./ts/modal/header/actions/close/index.ts");
  37. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  38. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  39. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  40. return new (P || (P = Promise))(function (resolve, reject) {
  41. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  42. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  43. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  44. step((generator = generator.apply(thisArg, _arguments || [])).next());
  45. });
  46. };
  47.  
  48.  
  49.  
  50.  
  51.  
  52. function init(page, socket, targetWindow = window) {
  53. return __awaiter(this, void 0, void 0, function* () {
  54. const response = {};
  55. try {
  56. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(page);
  57. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(page, socket, targetWindow);
  58. // Config is valid
  59. response.requireReset = false;
  60. }
  61. catch (error) {
  62. if (typeof page !== 'object' || !(0,_validation__WEBPACK_IMPORTED_MODULE_0__.hasOwnProperty)(page, 'userTree')) {
  63. throw error;
  64. }
  65. delete page.userTree;
  66. // Test validity after reset
  67. yield (0,_validation__WEBPACK_IMPORTED_MODULE_0__["default"])(page);
  68. (0,_modal__WEBPACK_IMPORTED_MODULE_1__["default"])(page, socket, targetWindow);
  69. response.requireReset = true;
  70. response.error = error;
  71. }
  72. return Object.assign(Object.assign({}, response), (0,_modal_body_data__WEBPACK_IMPORTED_MODULE_2__.getSaveData)());
  73. });
  74. }
  75. function edit() {
  76. (0,_modal__WEBPACK_IMPORTED_MODULE_1__.getSocket)().focus();
  77. return new Promise((resolve) => {
  78. (0,_modal_header_actions_close__WEBPACK_IMPORTED_MODULE_3__.setCallback)(resolve);
  79. });
  80. }
  81.  
  82.  
  83. /***/ }),
  84.  
  85. /***/ "./ts/library/validation/errors.ts":
  86. /*!*****************************************!*\
  87. !*** ./ts/library/validation/errors.ts ***!
  88. \*****************************************/
  89. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  90.  
  91. __webpack_require__.r(__webpack_exports__);
  92. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  93. /* harmony export */ DeactivatedError: () => (/* binding */ DeactivatedError),
  94. /* harmony export */ DependenceError: () => (/* binding */ DependenceError),
  95. /* harmony export */ EmptyArrayError: () => (/* binding */ EmptyArrayError),
  96. /* harmony export */ EmptyStringError: () => (/* binding */ EmptyStringError),
  97. /* harmony export */ FunctionMatchError: () => (/* binding */ FunctionMatchError),
  98. /* harmony export */ JoinedError: () => (/* binding */ JoinedError),
  99. /* harmony export */ NonPosIntError: () => (/* binding */ NonPosIntError),
  100. /* harmony export */ OptionError: () => (/* binding */ OptionError),
  101. /* harmony export */ OptionMatchError: () => (/* binding */ OptionMatchError),
  102. /* harmony export */ PoolBranchError: () => (/* binding */ PoolBranchError),
  103. /* harmony export */ PoolSizeError: () => (/* binding */ PoolSizeError),
  104. /* harmony export */ PredicateError: () => (/* binding */ PredicateError),
  105. /* harmony export */ PropertyError: () => (/* binding */ PropertyError),
  106. /* harmony export */ SeedMatchError: () => (/* binding */ SeedMatchError),
  107. /* harmony export */ TypeError: () => (/* binding */ TypeError),
  108. /* harmony export */ UnexpectedStateError: () => (/* binding */ UnexpectedStateError),
  109. /* harmony export */ ValueError: () => (/* binding */ ValueError)
  110. /* harmony export */ });
  111. // Helpers
  112. function getOptionString(array) {
  113. if (array.length === 0) {
  114. throw new Error('No valid options.');
  115. }
  116. if (array.length === 1) {
  117. return `"${array[0]}"`;
  118. }
  119. return `"${array.slice(0, -1).join('", "')}" or "${array[array.length - 1]}"`;
  120. }
  121. function getPath(breadcrumbs) {
  122. return `/${breadcrumbs.join('/')}`;
  123. }
  124. // Errors
  125. class JoinedError extends Error {
  126. constructor(...errors) {
  127. super(errors.map(({ message }) => message).join(JoinedError.separator));
  128. }
  129. }
  130. JoinedError.separator = '\n\n';
  131. class UnexpectedStateError extends Error {
  132. constructor() {
  133. super('Unexpected state reached.');
  134. }
  135. }
  136. class TypeError extends Error {
  137. constructor(breadcrumbs, found, expected) {
  138. super(`Found a value of type "${found}" at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  139. }
  140. }
  141. class PropertyError extends Error {
  142. constructor(breadcrumbs, property, shouldExist) {
  143. super(`${shouldExist ? 'Missing' : 'Unexpected'} property "${property}" found at ${getPath(breadcrumbs)}.`);
  144. }
  145. }
  146. class ValueError extends Error {
  147. constructor(breadcrumbs, found, expected) {
  148. super(`Found a value of "${found}" at ${getPath(breadcrumbs)}. Expected ${getOptionString(expected)}.`);
  149. }
  150. }
  151. class NonPosIntError extends Error {
  152. constructor(breadcrumbs, value) {
  153. super(`Found a value of "${value}" at ${getPath(breadcrumbs)}. Expected a positive integer.`);
  154. }
  155. }
  156. class EmptyStringError extends Error {
  157. constructor(breadcrumbs) {
  158. super(`Found illegal empty string at ${getPath(breadcrumbs)}.`);
  159. }
  160. }
  161. class EmptyArrayError extends Error {
  162. constructor(breadcrumbs) {
  163. super(`Found illegal empty array at ${getPath(breadcrumbs)}.`);
  164. }
  165. }
  166. class PredicateError extends Error {
  167. constructor(breadcrumbs) {
  168. super(`Predicate failed at ${getPath(breadcrumbs)}. Predicates must succeed.`);
  169. }
  170. }
  171. class OptionError extends Error {
  172. constructor() {
  173. super('Node value not found in its options.');
  174. }
  175. }
  176. class SeedMatchError extends Error {
  177. constructor() {
  178. super('All children must be structurally similar to their parent\'s seed.');
  179. }
  180. }
  181. class PoolBranchError extends Error {
  182. constructor(ancestorBreadcrumbs, descendantBreadcrumbs, poolId) {
  183. super('No node may share a poolId value with its ancestor.' + JoinedError.separator
  184. + `Found poolId value ${poolId} at ${getPath(ancestorBreadcrumbs)} and ${getPath(descendantBreadcrumbs)}.`);
  185. }
  186. }
  187. class PoolSizeError extends Error {
  188. constructor(poolId, found, expected) {
  189. 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
  190. + `Found a size of ${found} at pool ${poolId}. Expected a size of ${expected}.`);
  191. }
  192. }
  193. class FunctionMatchError extends Error {
  194. constructor() {
  195. super('Corresponding function values in seed & non-seed branches must be the same pointer.');
  196. }
  197. }
  198. class OptionMatchError extends Error {
  199. constructor() {
  200. super('Options must have the same type as their node\'s value.');
  201. }
  202. }
  203. class DependenceError extends Error {
  204. constructor(found, missing) {
  205. super(`Nodes with a "${found}" entry must have a "${missing}" property.`);
  206. }
  207. }
  208. class DeactivatedError extends Error {
  209. constructor() {
  210. super('Nodes can\'t be deactivated unless their parent has a seed.');
  211. }
  212. }
  213.  
  214.  
  215. /***/ }),
  216.  
  217. /***/ "./ts/library/validation/index.ts":
  218. /*!****************************************!*\
  219. !*** ./ts/library/validation/index.ts ***!
  220. \****************************************/
  221. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  222.  
  223. __webpack_require__.r(__webpack_exports__);
  224. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  225. /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__),
  226. /* harmony export */ hasOwnProperty: () => (/* binding */ hasOwnProperty),
  227. /* harmony export */ validateUnexpectedKeys: () => (/* binding */ validateUnexpectedKeys)
  228. /* harmony export */ });
  229. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  230. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  231. /* harmony import */ var _styles__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./styles */ "./ts/library/validation/styles.ts");
  232. /* harmony import */ var _trees_pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./trees/pools */ "./ts/library/validation/trees/pools.ts");
  233. /* harmony import */ var _trees_guards__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./trees/guards */ "./ts/library/validation/trees/guards.ts");
  234. /* harmony import */ var _trees_match__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./trees/match */ "./ts/library/validation/trees/match.ts");
  235. /* harmony import */ var _trees_predicates__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trees/predicates */ "./ts/library/validation/trees/predicates.ts");
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. // Helpers
  244. // Credit to https://fettblog.eu/typescript-hasownproperty/
  245. function hasOwnProperty(object, property) {
  246. return Object.hasOwnProperty.call(object, property);
  247. }
  248. function validateUnexpectedKeys(breadcrumbs, object, expected) {
  249. for (const key of Object.keys(object)) {
  250. if (!expected.includes(key))
  251. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, key, false);
  252. }
  253. }
  254. // Guard
  255. function isPage(candidate) {
  256. if (typeof candidate !== 'object')
  257. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([], typeof candidate, ['object']);
  258. validateUnexpectedKeys([], candidate, _types__WEBPACK_IMPORTED_MODULE_0__.PAGE_KEYS);
  259. // title
  260. if (!hasOwnProperty(candidate, 'title'))
  261. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'title', true);
  262. if (typeof candidate.title !== 'string')
  263. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['title'], typeof candidate.title, ['string']);
  264. // defaultStyle
  265. if (hasOwnProperty(candidate, 'defaultStyle')) {
  266. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['defaultStyle'], candidate.defaultStyle))
  267. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  268. if (hasOwnProperty(candidate.defaultStyle, 'name'))
  269. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'name', false);
  270. if (hasOwnProperty(candidate.defaultStyle, 'isActive'))
  271. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['defaultStyle'], 'isActive', false);
  272. }
  273. // userStyles
  274. if (!hasOwnProperty(candidate, 'userStyles'))
  275. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'userStyles', true);
  276. if (!Array.isArray(candidate.userStyles))
  277. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles'], typeof candidate.userStyles, ['array']);
  278. for (const [i, style] of candidate.userStyles.entries()) {
  279. if (!(0,_styles__WEBPACK_IMPORTED_MODULE_2__.isStyles)(['userStyles', i.toString()], style))
  280. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  281. if (!hasOwnProperty(style, 'name'))
  282. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'name', true);
  283. if (typeof style.name !== 'string')
  284. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'name'], typeof style.name, ['string']);
  285. if (!hasOwnProperty(style, 'isActive'))
  286. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(['userStyles', i.toString()], 'isActive', true);
  287. if (typeof style.isActive !== 'boolean')
  288. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(['userStyles', i.toString(), 'isActive'], typeof style.isActive, ['boolean']);
  289. }
  290. // defaultTree
  291. if (!hasOwnProperty(candidate, 'defaultTree') || !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['defaultTree'], candidate.defaultTree))
  292. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError([], 'defaultTree', true);
  293. // userTree
  294. if (hasOwnProperty(candidate, 'userTree') && !(0,_trees_guards__WEBPACK_IMPORTED_MODULE_4__.isRoot)(['userTree'], candidate.userTree, true))
  295. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  296. return true;
  297. }
  298. // Validator
  299. function validatePage({ title, defaultTree, userTree }) {
  300. // title
  301. if (title.length === 0)
  302. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.EmptyStringError(['title']);
  303. // trees
  304. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validateSeeds)(['defaultTree'], defaultTree);
  305. (0,_trees_pools__WEBPACK_IMPORTED_MODULE_3__.validatePools)(['defaultTree'], defaultTree);
  306. if (!userTree) {
  307. return Promise.all((0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree));
  308. }
  309. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.matchUserTreeParent)(['defaultTree'], defaultTree, ['userTree'], userTree);
  310. // Has to be done after mutations since new pools may be created
  311. (0,_trees_match__WEBPACK_IMPORTED_MODULE_5__.validatePoolSizeMatch)(defaultTree, userTree);
  312. return Promise.all([
  313. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['defaultTree'], defaultTree),
  314. ...(0,_trees_predicates__WEBPACK_IMPORTED_MODULE_6__.validateParent)(['userTree'], userTree),
  315. ]);
  316. }
  317. // API
  318. /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(candidate) {
  319. if (!isPage(candidate))
  320. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  321. return validatePage(candidate);
  322. }
  323.  
  324.  
  325. /***/ }),
  326.  
  327. /***/ "./ts/library/validation/styles.ts":
  328. /*!*****************************************!*\
  329. !*** ./ts/library/validation/styles.ts ***!
  330. \*****************************************/
  331. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  332.  
  333. __webpack_require__.r(__webpack_exports__);
  334. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  335. /* harmony export */ isStyles: () => (/* binding */ isStyles)
  336. /* harmony export */ });
  337. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "./ts/library/validation/errors.ts");
  338. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ "./ts/library/validation/types.ts");
  339.  
  340.  
  341. function isStyles(breadcrumbs, candidate) {
  342. if (typeof candidate !== 'object')
  343. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, typeof candidate, ['object']);
  344. if (Array.isArray(candidate))
  345. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError(breadcrumbs, 'array', ['object']);
  346. for (const [key, value] of Object.entries(candidate)) {
  347. switch (key) {
  348. // Colours
  349. case 'modalOutline':
  350. case 'headBase':
  351. case 'headButtonExit':
  352. case 'headButtonLabel':
  353. case 'headButtonStyle':
  354. case 'headButtonSticky':
  355. case 'nodeHeaderBase':
  356. case 'nodeBlendBase':
  357. case 'nodeValueBase':
  358. case 'nodeButtonRemove':
  359. case 'nodeButtonCreate':
  360. case 'nodeButtonMove':
  361. case 'nodeButtonDisable':
  362. case 'validBackground':
  363. case 'invalidBackground':
  364. case 'focusBackground':
  365. case 'tooltipOutline':
  366. if (typeof value !== 'string')
  367. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  368. break;
  369. // Numbers
  370. case 'fontSize':
  371. case 'width':
  372. case 'height':
  373. if (typeof value !== 'number')
  374. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['number']);
  375. break;
  376. // Contrast methods
  377. case 'headContrast':
  378. case 'nodeContrast':
  379. if (typeof value !== 'string')
  380. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['string']);
  381. if (!_types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS.includes(value))
  382. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, key], value, _types__WEBPACK_IMPORTED_MODULE_1__.CONTRAST_METHODS);
  383. break;
  384. // Booleans
  385. case 'isActive':
  386. case 'borderLeaf':
  387. case 'borderNode':
  388. if (typeof value !== 'boolean')
  389. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, key], typeof value, ['boolean']);
  390. break;
  391. }
  392. }
  393. return true;
  394. }
  395.  
  396.  
  397. /***/ }),
  398.  
  399. /***/ "./ts/library/validation/trees/guards.ts":
  400. /*!***********************************************!*\
  401. !*** ./ts/library/validation/trees/guards.ts ***!
  402. \***********************************************/
  403. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  404.  
  405. __webpack_require__.r(__webpack_exports__);
  406. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  407. /* harmony export */ isParent: () => (/* binding */ isParent),
  408. /* harmony export */ isRoot: () => (/* binding */ isRoot)
  409. /* harmony export */ });
  410. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../types */ "./ts/library/validation/types.ts");
  411. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  412. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../index */ "./ts/library/validation/index.ts");
  413.  
  414.  
  415.  
  416. function hasDependee(breadcrumbs, candidate, property, dependence) {
  417. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, property)) {
  418. return false;
  419. }
  420. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, dependence))
  421. return true;
  422. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_1__.DependenceError(property, dependence), new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, dependence, true));
  423. }
  424. function hasId(breadcrumbs, candidate, property) {
  425. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, property)) {
  426. return false;
  427. }
  428. if (typeof candidate[property] !== 'number')
  429. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, property], typeof candidate[property], ['number']);
  430. if (Object.is(candidate[property] % 1, 0))
  431. return true;
  432. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.NonPosIntError([...breadcrumbs, property], candidate[property]);
  433. }
  434. // Type predicates
  435. function isChild(breadcrumbs, candidate, isUserTree = false) {
  436. if (typeof candidate !== 'object')
  437. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs], typeof candidate, ['object']);
  438. if (isUserTree) {
  439. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.SAVED_KEYS);
  440. }
  441. else {
  442. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, 'children' in candidate ? _types__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_KEYS : _types__WEBPACK_IMPORTED_MODULE_0__.LEAF_KEYS);
  443. }
  444. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'label') && typeof candidate.label !== 'string')
  445. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'label'], typeof candidate.label, ['string']);
  446. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'value') && !_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof candidate.value))
  447. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'value'], typeof candidate.value, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  448. if (hasDependee(breadcrumbs, candidate, 'options', 'value')) {
  449. if (!Array.isArray(candidate.options))
  450. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options'], typeof candidate.options, ['array']);
  451. for (const [i, option] of candidate.options.entries()) {
  452. if (!_types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES.includes(typeof option))
  453. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, _types__WEBPACK_IMPORTED_MODULE_0__.VALUE_TYPES);
  454. }
  455. }
  456. if (hasDependee(breadcrumbs, candidate, 'predicate', 'value') && typeof candidate.predicate !== 'function')
  457. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'predicate'], typeof candidate.predicate, ['function']);
  458. if (hasDependee(breadcrumbs, candidate, 'onUpdate', 'value') && typeof candidate.onUpdate !== 'function')
  459. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onUpdate'], typeof candidate.onUpdate, ['function']);
  460. if (hasDependee(breadcrumbs, candidate, 'listeners', 'value')) {
  461. if (typeof candidate.listeners !== 'object')
  462. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners'], typeof candidate.listeners, ['object']);
  463. for (const [event, callback] of Object.entries(candidate.listeners)) {
  464. if (typeof callback !== 'function')
  465. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'listeners', event], typeof callback, ['function']);
  466. }
  467. }
  468. if (hasDependee(breadcrumbs, candidate, 'input', 'value')) {
  469. if (typeof candidate.input !== 'string')
  470. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'input'], typeof candidate.input, ['string']);
  471. if (!_types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS.includes(candidate.input))
  472. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.ValueError([...breadcrumbs, 'input'], candidate.input, _types__WEBPACK_IMPORTED_MODULE_0__.INPUT_FORMATS);
  473. }
  474. if (hasDependee(breadcrumbs, candidate, 'inputAttributes', 'value') && typeof candidate.inputAttributes !== 'object')
  475. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'inputAttributes'], typeof candidate.inputAttributes, ['object']);
  476. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'get') && typeof candidate.get !== 'function')
  477. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'get'], typeof candidate.get, ['function']);
  478. hasId(breadcrumbs, candidate, 'hideId');
  479. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'isActive') && typeof candidate.isActive !== 'boolean')
  480. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'isActive'], typeof candidate.isActive, ['boolean']);
  481. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children') && !isParent(breadcrumbs, candidate, isUserTree))
  482. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  483. return true;
  484. }
  485. function isParent(breadcrumbs, candidate, isUserTree = false) {
  486. if (!(0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'children'))
  487. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.PropertyError(breadcrumbs, 'children', true);
  488. if (!Array.isArray(candidate.children))
  489. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'children'], typeof candidate.children, ['array']);
  490. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'seed') && !isChild([...breadcrumbs, 'seed'], candidate.seed))
  491. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  492. hasId(breadcrumbs, candidate, 'poolId');
  493. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'childPredicate') && typeof candidate.childPredicate !== 'function')
  494. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'childPredicate'], typeof candidate.childPredicate, ['function']);
  495. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'descendantPredicate') && typeof candidate.descendantPredicate !== 'function')
  496. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'descendantPredicate'], typeof candidate.descendantPredicate, ['function']);
  497. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onChildUpdate') && typeof candidate.onChildUpdate !== 'function')
  498. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onChildUpdate'], typeof candidate.onChildUpdate, ['function']);
  499. if ((0,_index__WEBPACK_IMPORTED_MODULE_2__.hasOwnProperty)(candidate, 'onDescendantUpdate') && typeof candidate.onDescendantUpdate !== 'function')
  500. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError([...breadcrumbs, 'onDescendantUpdate'], typeof candidate.onDescendantUpdate, ['function']);
  501. for (const [i, child] of candidate.children.entries()) {
  502. if (!isChild([...breadcrumbs, 'children', i.toString()], child, isUserTree))
  503. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  504. }
  505. return true;
  506. }
  507. function isRoot(breadcrumbs, candidate, isUserTree = false) {
  508. if (typeof candidate !== 'object')
  509. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.TypeError(breadcrumbs, typeof candidate, ['object']);
  510. if (!isParent(breadcrumbs, candidate, isUserTree))
  511. throw new _errors__WEBPACK_IMPORTED_MODULE_1__.UnexpectedStateError();
  512. (0,_index__WEBPACK_IMPORTED_MODULE_2__.validateUnexpectedKeys)(breadcrumbs, candidate, _types__WEBPACK_IMPORTED_MODULE_0__.ROOT_KEYS);
  513. return true;
  514. }
  515.  
  516.  
  517. /***/ }),
  518.  
  519. /***/ "./ts/library/validation/trees/match.ts":
  520. /*!**********************************************!*\
  521. !*** ./ts/library/validation/trees/match.ts ***!
  522. \**********************************************/
  523. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  524.  
  525. __webpack_require__.r(__webpack_exports__);
  526. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  527. /* harmony export */ matchUserTreeParent: () => (/* binding */ matchUserTreeParent),
  528. /* harmony export */ validatePoolSizeMatch: () => (/* binding */ validatePoolSizeMatch),
  529. /* harmony export */ validateSeeds: () => (/* binding */ validateSeeds)
  530. /* harmony export */ });
  531. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  532.  
  533. // Helpers
  534. function validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  535. if ('options' in model !== 'options' in candidate)
  536. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'options', 'options' in model);
  537. if ('options' in model) {
  538. if (model.options.length !== candidate.options.length)
  539. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', 'length'], candidate.options.length, [model.options.length]);
  540. for (const [i, option] of model.options.entries()) {
  541. if (candidate.options[i] !== option)
  542. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'options', i.toString()], candidate.options[i], [option]);
  543. }
  544. }
  545. }
  546. function validateValueMatch(property, modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  547. if (property in model !== property in candidate)
  548. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, property, property in model);
  549. if (model[property] !== candidate[property])
  550. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, property], candidate[property], [model[property]]);
  551. }
  552. function assignKeys(from, to) {
  553. for (const key of Object.keys(from)) {
  554. if (!(key in to)) {
  555. to[key] = from[key];
  556. }
  557. }
  558. }
  559. // Consistent userTree validators/enforcers
  560. function matchUserTreeChild(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  561. if ('value' in model !== 'value' in candidate) {
  562. if ('value' in candidate)
  563. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', false);
  564. candidate.value = model.value;
  565. }
  566. else if (typeof model.value !== typeof candidate.value) {
  567. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  568. }
  569. if ('label' in model) {
  570. candidate.label = model.label;
  571. }
  572. else {
  573. delete candidate.label;
  574. }
  575. if ('children' in model !== 'children' in candidate)
  576. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  577. if ('children' in model) {
  578. matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  579. }
  580. else {
  581. assignKeys(model, candidate);
  582. }
  583. }
  584. function matchUserTreeParent(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  585. assignKeys(model, candidate);
  586. if ('seed' in model) {
  587. for (const [i, child] of candidate.children.entries()) {
  588. matchUserTreeChild([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  589. }
  590. return;
  591. }
  592. if ('poolId' in model) {
  593. return;
  594. }
  595. if (model.children.length !== candidate.children.length)
  596. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  597. for (const [i, child] of candidate.children.entries()) {
  598. matchUserTreeChild([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  599. }
  600. // Done after validation to avoid validating certain matches
  601. if (model.children.length > candidate.children.length) {
  602. candidate.children.push(...model.children.slice(candidate.children.length));
  603. }
  604. }
  605. // defaultTree internal consistency validators
  606. function validateChildMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  607. if ('value' in model !== 'value' in candidate)
  608. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'value', 'value' in model);
  609. if (typeof model.value !== typeof candidate.value)
  610. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...candidateBreadcrumbs, 'value'], typeof candidate.value, [typeof model.value]);
  611. validateValueMatch('label', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  612. validateValueMatch('input', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  613. validateOptionMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  614. try {
  615. validateValueMatch('predicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  616. validateValueMatch('onUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  617. }
  618. catch (error) {
  619. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  620. }
  621. if ('children' in model !== 'children' in candidate)
  622. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PropertyError(candidateBreadcrumbs, 'children', 'children' in model);
  623. if ('children' in model) {
  624. validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  625. }
  626. }
  627. function validateParentMatch(modelBreadcrumbs, model, candidateBreadcrumbs, candidate) {
  628. validateValueMatch('poolId', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  629. try {
  630. validateValueMatch('childPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  631. validateValueMatch('onChildUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  632. validateValueMatch('descendantPredicate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  633. validateValueMatch('onDescendantUpdate', modelBreadcrumbs, model, candidateBreadcrumbs, candidate);
  634. }
  635. catch (error) {
  636. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.FunctionMatchError(), error);
  637. }
  638. if ('seed' in model) {
  639. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'seed'], candidate.seed);
  640. for (const [i, child] of candidate.children.entries()) {
  641. validateChildMatch([...modelBreadcrumbs, 'seed'], model.seed, [...candidateBreadcrumbs, 'children', i.toString()], child);
  642. }
  643. }
  644. else if (!('poolId' in model)) {
  645. if (model.children.length !== candidate.children.length)
  646. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...candidateBreadcrumbs, 'children', 'length'], candidate.children.length, [model.children.length]);
  647. for (const [i, child] of candidate.children.entries()) {
  648. validateChildMatch([...modelBreadcrumbs, 'children', i.toString()], model.children[i], [...candidateBreadcrumbs, 'children', i.toString()], child);
  649. }
  650. if (model.children.length > candidate.children.length) {
  651. candidate.children.push(...model.children.slice(candidate.children.length));
  652. }
  653. }
  654. }
  655. // Other validators
  656. function validateSeeds(breadcrumbs, node) {
  657. if ('children' in node) {
  658. if ('seed' in node) {
  659. try {
  660. for (const [i, child] of node.children.entries()) {
  661. validateChildMatch([...breadcrumbs, 'seed'], node.seed, [...breadcrumbs, 'children', i.toString()], child);
  662. }
  663. }
  664. catch (error) {
  665. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.SeedMatchError(), error);
  666. }
  667. validateSeeds([...breadcrumbs, 'seed'], node.seed);
  668. }
  669. else {
  670. for (const [i, child] of node.children.entries()) {
  671. if ('isActive' in child && !child.isActive) {
  672. 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]));
  673. }
  674. }
  675. }
  676. for (const [i, child] of node.children.entries()) {
  677. validateSeeds([...breadcrumbs, 'children', i.toString()], child);
  678. }
  679. }
  680. }
  681. function getPoolSizes(node, uncapped = false) {
  682. const poolSizes = [];
  683. uncapped = uncapped || 'seed' in node;
  684. if ('poolId' in node) {
  685. poolSizes[node.poolId] = uncapped ? -1 : node.children.length;
  686. }
  687. if ('children' in node) {
  688. for (const child of node.children) {
  689. const subPoolSizes = getPoolSizes(child, uncapped);
  690. for (const id in subPoolSizes) {
  691. if (subPoolSizes[id] < 0) {
  692. poolSizes[id] = -1;
  693. }
  694. else if (id in poolSizes) {
  695. poolSizes[id] += subPoolSizes[id];
  696. }
  697. else {
  698. poolSizes[id] = subPoolSizes[id];
  699. }
  700. }
  701. }
  702. }
  703. return poolSizes;
  704. }
  705. function validatePoolSizeMatch(model, candidate) {
  706. const modelSizes = getPoolSizes(model);
  707. const candidateSizes = getPoolSizes(candidate);
  708. for (const id in modelSizes) {
  709. if (modelSizes[id] !== candidateSizes[id])
  710. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolSizeError(Number.parseInt(id), candidateSizes[id], modelSizes[id]);
  711. }
  712. }
  713.  
  714.  
  715. /***/ }),
  716.  
  717. /***/ "./ts/library/validation/trees/pools.ts":
  718. /*!**********************************************!*\
  719. !*** ./ts/library/validation/trees/pools.ts ***!
  720. \**********************************************/
  721. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  722.  
  723. __webpack_require__.r(__webpack_exports__);
  724. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  725. /* harmony export */ validatePools: () => (/* binding */ validatePools)
  726. /* harmony export */ });
  727. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  728.  
  729. function validatePools(breadcrumbs, node, ancestorPools = []) {
  730. if ('poolId' in node) {
  731. if (node.poolId in ancestorPools)
  732. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.PoolBranchError(ancestorPools[node.poolId], breadcrumbs, node.poolId);
  733. // Slice maintains empty entries, so the 'in' operator still works
  734. ancestorPools = ancestorPools.slice();
  735. ancestorPools[node.poolId] = breadcrumbs;
  736. }
  737. if ('children' in node) {
  738. // Recurse
  739. for (const [i, child] of node.children.entries()) {
  740. validatePools([...breadcrumbs, 'children', i.toString()], child, ancestorPools);
  741. }
  742. }
  743. }
  744.  
  745.  
  746. /***/ }),
  747.  
  748. /***/ "./ts/library/validation/trees/predicates.ts":
  749. /*!***************************************************!*\
  750. !*** ./ts/library/validation/trees/predicates.ts ***!
  751. \***************************************************/
  752. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  753.  
  754. __webpack_require__.r(__webpack_exports__);
  755. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  756. /* harmony export */ validateParent: () => (/* binding */ validateParent)
  757. /* harmony export */ });
  758. /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/library/validation/errors.ts");
  759. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../predicate */ "./ts/predicate.ts");
  760.  
  761.  
  762. function getBoundPredicatePromise(response, error) {
  763. return (0,_predicate__WEBPACK_IMPORTED_MODULE_1__.getPredicatePromise)(response)
  764. .catch(() => Promise.reject(error));
  765. }
  766. function validateChild(breadcrumbs, child) {
  767. if (!('options' in child) && !('predicate' in child))
  768. return Promise.resolve();
  769. if ('options' in child) {
  770. const type = typeof child.value;
  771. let valueFound = false;
  772. for (const [i, option] of child.options.entries()) {
  773. if (typeof option !== type) {
  774. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionMatchError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.TypeError([...breadcrumbs, 'options', i.toString()], typeof option, [type]));
  775. }
  776. valueFound || (valueFound = child.value === option);
  777. }
  778. if (valueFound)
  779. return Promise.resolve();
  780. }
  781. if ('predicate' in child)
  782. return getBoundPredicatePromise(child.predicate(child.value), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'predicate']));
  783. throw new _errors__WEBPACK_IMPORTED_MODULE_0__.JoinedError(new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionError(), new _errors__WEBPACK_IMPORTED_MODULE_0__.ValueError([...breadcrumbs, 'value'], child.value, child.options));
  784. }
  785. function validateParent(breadcrumbs, parent) {
  786. const promises = [];
  787. if ('seed' in parent) {
  788. const { seed } = parent;
  789. promises.push(validateChild([...breadcrumbs, 'seed'], seed));
  790. if ('children' in seed) {
  791. promises.push(...validateParent([...breadcrumbs, 'seed'], seed));
  792. }
  793. }
  794. const { children } = parent;
  795. if ('childPredicate' in parent) {
  796. promises.push(getBoundPredicatePromise(parent.childPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'childPredicate'])));
  797. }
  798. if ('descendantPredicate' in parent) {
  799. promises.push(getBoundPredicatePromise(parent.descendantPredicate(children), new _errors__WEBPACK_IMPORTED_MODULE_0__.PredicateError([...breadcrumbs, 'descendantPredicate'])));
  800. }
  801. for (const [i, child] of children.entries()) {
  802. const childBreadcrumbs = [...breadcrumbs, 'children', i.toString()];
  803. promises.push(validateChild(childBreadcrumbs, child));
  804. if ('children' in child) {
  805. promises.push(...validateParent(childBreadcrumbs, child));
  806. }
  807. }
  808. return promises;
  809. }
  810.  
  811.  
  812. /***/ }),
  813.  
  814. /***/ "./ts/library/validation/types.ts":
  815. /*!****************************************!*\
  816. !*** ./ts/library/validation/types.ts ***!
  817. \****************************************/
  818. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  819.  
  820. __webpack_require__.r(__webpack_exports__);
  821. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  822. /* harmony export */ CONTRAST_METHODS: () => (/* binding */ CONTRAST_METHODS),
  823. /* harmony export */ INPUT_FORMATS: () => (/* binding */ INPUT_FORMATS),
  824. /* harmony export */ LEAF_KEYS: () => (/* binding */ LEAF_KEYS),
  825. /* harmony export */ MIDDLE_KEYS: () => (/* binding */ MIDDLE_KEYS),
  826. /* harmony export */ PAGE_KEYS: () => (/* binding */ PAGE_KEYS),
  827. /* harmony export */ ROOT_KEYS: () => (/* binding */ ROOT_KEYS),
  828. /* harmony export */ ROOT_OTHER_KEYS: () => (/* binding */ ROOT_OTHER_KEYS),
  829. /* harmony export */ ROOT_PREDICATE_KEYS: () => (/* binding */ ROOT_PREDICATE_KEYS),
  830. /* harmony export */ ROOT_UPDATE_KEYS: () => (/* binding */ ROOT_UPDATE_KEYS),
  831. /* harmony export */ SAVED_KEYS: () => (/* binding */ SAVED_KEYS),
  832. /* harmony export */ VALUE_TYPES: () => (/* binding */ VALUE_TYPES)
  833. /* harmony export */ });
  834. // Basic types
  835. const VALUE_TYPES = ['boolean', 'number', 'string'];
  836. const INPUT_FORMATS = ['color', 'date', 'datetime-local', 'email', 'month', 'password', 'search', 'tel', 'text', 'time', 'url', 'week'];
  837. const CONTRAST_METHODS = ['Black / White', 'Invert'];
  838. // Key categories
  839. const SAVED_KEYS = ['label', 'value', 'isActive', 'children'];
  840. const ROOT_PREDICATE_KEYS = ['childPredicate', 'descendantPredicate'];
  841. const ROOT_UPDATE_KEYS = ['onChildUpdate', 'onDescendantUpdate'];
  842. const ROOT_OTHER_KEYS = ['children', 'seed', 'poolId', 'get'];
  843. // Node types
  844. // hacky code to avoid a duplicate "get" in MIDDLE_KEYS
  845. const _LEAF_KEYS = ['label', 'value', 'predicate', 'options', 'input', 'isActive', 'onUpdate', 'listeners', 'hideId', 'inputAttributes'];
  846. const LEAF_KEYS = [..._LEAF_KEYS, 'get'];
  847. const ROOT_KEYS = [...ROOT_PREDICATE_KEYS, ...ROOT_UPDATE_KEYS, ...ROOT_OTHER_KEYS];
  848. const MIDDLE_KEYS = [..._LEAF_KEYS, ...ROOT_KEYS];
  849. // Config type
  850. const PAGE_KEYS = ['title', 'defaultTree', 'userTree', 'defaultStyle', 'userStyles'];
  851.  
  852.  
  853. /***/ }),
  854.  
  855. /***/ "./ts/modal/body/consts.ts":
  856. /*!*********************************!*\
  857. !*** ./ts/modal/body/consts.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 */ MODAL_BODY_ID: () => (/* binding */ MODAL_BODY_ID)
  864. /* harmony export */ });
  865. const MODAL_BODY_ID = 'modal-body';
  866.  
  867.  
  868. /***/ }),
  869.  
  870. /***/ "./ts/modal/body/css.ts":
  871. /*!******************************!*\
  872. !*** ./ts/modal/body/css.ts ***!
  873. \******************************/
  874. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  875.  
  876. __webpack_require__.r(__webpack_exports__);
  877. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  878. /* harmony export */ "default": () => (/* binding */ generate)
  879. /* harmony export */ });
  880. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  881. /* harmony import */ var _nodes_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nodes/css */ "./ts/modal/body/nodes/css.ts");
  882. /* harmony import */ var _nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./nodes/actions/css */ "./ts/modal/body/nodes/actions/css.ts");
  883. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  884.  
  885.  
  886.  
  887.  
  888. function generate() {
  889. (0,_nodes_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  890. (0,_nodes_actions_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  891. (0,_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID}`, [
  892. ['overflow-y', 'auto'],
  893. ['overflow-x', 'hidden'],
  894. ['overscroll-behavior', 'contain'],
  895. ['background-color', 'var(--nodeValueBase)'],
  896. ['flex-grow', '1'],
  897. ]);
  898. }
  899.  
  900.  
  901. /***/ }),
  902.  
  903. /***/ "./ts/modal/body/data/consts.ts":
  904. /*!**************************************!*\
  905. !*** ./ts/modal/body/data/consts.ts ***!
  906. \**************************************/
  907. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  908.  
  909. __webpack_require__.r(__webpack_exports__);
  910. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  911. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  912. /* harmony export */ });
  913. const ROOT_ID = 'root-data';
  914.  
  915.  
  916. /***/ }),
  917.  
  918. /***/ "./ts/modal/body/data/index.ts":
  919. /*!*************************************!*\
  920. !*** ./ts/modal/body/data/index.ts ***!
  921. \*************************************/
  922. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  923.  
  924. __webpack_require__.r(__webpack_exports__);
  925. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  926. /* harmony export */ "default": () => (/* binding */ generate),
  927. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  928. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  929. /* harmony export */ setTree: () => (/* binding */ setTree)
  930. /* harmony export */ });
  931. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/data/consts.ts");
  932. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "./ts/modal/body/index.ts");
  933.  
  934.  
  935. function getRoot() {
  936. return _index__WEBPACK_IMPORTED_MODULE_1__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  937. }
  938. function getSaveData() {
  939. const { tree, config } = getRoot().getSaveData();
  940. return { tree, config };
  941. }
  942. function setTree(data) {
  943. const root = getRoot();
  944. // Spread avoids looping on a shrinking array
  945. for (const child of [...root.children]) {
  946. child.disconnect();
  947. }
  948. root.addChildren(data.children);
  949. }
  950. function generate(data) {
  951. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.generateTree)(data, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  952. }
  953.  
  954.  
  955. /***/ }),
  956.  
  957. /***/ "./ts/modal/body/index.ts":
  958. /*!********************************!*\
  959. !*** ./ts/modal/body/index.ts ***!
  960. \********************************/
  961. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  962.  
  963. __webpack_require__.r(__webpack_exports__);
  964. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  965. /* harmony export */ ROOTS: () => (/* binding */ ROOTS),
  966. /* harmony export */ "default": () => (/* binding */ generate),
  967. /* harmony export */ element: () => (/* binding */ element),
  968. /* harmony export */ generateTree: () => (/* binding */ generateTree),
  969. /* harmony export */ reset: () => (/* binding */ reset),
  970. /* harmony export */ setActive: () => (/* binding */ setActive)
  971. /* harmony export */ });
  972. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/consts.ts");
  973. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/css.ts");
  974. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style */ "./ts/modal/body/style/index.ts");
  975. /* harmony import */ var _data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./data */ "./ts/modal/body/data/index.ts");
  976. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  977. /* harmony import */ var _nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./nodes/actions/active */ "./ts/modal/body/nodes/actions/active.ts");
  978. /* harmony import */ var _nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./nodes/actions/history */ "./ts/modal/body/nodes/actions/history.ts");
  979. /* harmony import */ var _nodes_root__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./nodes/root */ "./ts/modal/body/nodes/root.ts");
  980. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../consts */ "./ts/modal/consts.ts");
  981. /* harmony import */ var _modal_header_actions_sticky_css__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/header/actions/sticky/css */ "./ts/modal/header/actions/sticky/css.ts");
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992. const ROOTS = {};
  993. const element = document.createElement('div');
  994. let resetTree;
  995. function setActive(button, actionId, doActivate = true) {
  996. if (doActivate) {
  997. button.classList.add(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  998. element.classList.add(actionId);
  999. }
  1000. else {
  1001. button.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  1002. element.classList.remove(actionId);
  1003. }
  1004. }
  1005. function generateTree(data, id) {
  1006. if (ROOTS[id]) {
  1007. throw new Error(`Attempted to instantiate second tree with id '${id}'.`);
  1008. }
  1009. const root = new _nodes_root__WEBPACK_IMPORTED_MODULE_7__["default"](data);
  1010. root.element.elementContainer.id = id;
  1011. ROOTS[id] = root;
  1012. return root.element.elementContainer;
  1013. }
  1014. function generate({ userTree, defaultTree, userStyles, defaultStyle }) {
  1015. resetTree = defaultTree;
  1016. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1017. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BODY_ID;
  1018. // avoid blurring an input when dragging the scrollbar
  1019. element.addEventListener('mousedown', (event) => {
  1020. event.stopPropagation();
  1021. event.preventDefault();
  1022. });
  1023. element.append((0,_style__WEBPACK_IMPORTED_MODULE_2__["default"])(userStyles, defaultStyle), (0,_data__WEBPACK_IMPORTED_MODULE_3__["default"])(userTree !== null && userTree !== void 0 ? userTree : defaultTree));
  1024. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.onMount)();
  1025. (0,_nodes_actions_active__WEBPACK_IMPORTED_MODULE_5__.onMount)();
  1026. (0,_nodes_actions_history__WEBPACK_IMPORTED_MODULE_6__.onMount)();
  1027. (0,_modal_header_actions_sticky_css__WEBPACK_IMPORTED_MODULE_9__["default"])(ROOTS);
  1028. return element;
  1029. }
  1030. function reset() {
  1031. (0,_data__WEBPACK_IMPORTED_MODULE_3__.setTree)(resetTree);
  1032. }
  1033.  
  1034.  
  1035. /***/ }),
  1036.  
  1037. /***/ "./ts/modal/body/nodes/actions/active.ts":
  1038. /*!***********************************************!*\
  1039. !*** ./ts/modal/body/nodes/actions/active.ts ***!
  1040. \***********************************************/
  1041. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1042.  
  1043. __webpack_require__.r(__webpack_exports__);
  1044. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1045. /* harmony export */ onMount: () => (/* binding */ onMount),
  1046. /* harmony export */ reset: () => (/* binding */ reset)
  1047. /* harmony export */ });
  1048. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  1049. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  1050. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1051. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  1052.  
  1053.  
  1054.  
  1055.  
  1056. function reset() {
  1057. for (const action of [_buttons_position__WEBPACK_IMPORTED_MODULE_2__, _focus__WEBPACK_IMPORTED_MODULE_1__, _highlight__WEBPACK_IMPORTED_MODULE_0__]) {
  1058. if (action.isActive()) {
  1059. action.reset();
  1060. return true;
  1061. }
  1062. }
  1063. return false;
  1064. }
  1065. function onMount() {
  1066. (0,_modal__WEBPACK_IMPORTED_MODULE_3__.getSocket)().addEventListener('keydown', (event) => {
  1067. if ((event.key === 'Escape' || event.key === 'Backspace') && reset()) {
  1068. event.stopImmediatePropagation();
  1069. }
  1070. });
  1071. }
  1072.  
  1073.  
  1074. /***/ }),
  1075.  
  1076. /***/ "./ts/modal/body/nodes/actions/buttons/button.ts":
  1077. /*!*******************************************************!*\
  1078. !*** ./ts/modal/body/nodes/actions/buttons/button.ts ***!
  1079. \*******************************************************/
  1080. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1081.  
  1082. __webpack_require__.r(__webpack_exports__);
  1083. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1084. /* harmony export */ addActionButton: () => (/* binding */ addActionButton),
  1085. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  1086. /* harmony export */ });
  1087. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1088. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  1089. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1090. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  1091. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1092. /* harmony import */ var _modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/header/actions/alternate */ "./ts/modal/header/actions/alternate/index.ts");
  1093. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101. // Creates an instantiation & adds it to the DOM
  1102. function addActionButton(template, onClick, node) {
  1103. const button = template.cloneNode(true);
  1104. button.addEventListener('click', (event) => {
  1105. event.stopPropagation();
  1106. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_6__.isUnresolved)()) {
  1107. (0,_overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip)(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_3__.MESSAGE_UNRESOLVED, node, button.querySelector('circle'));
  1108. return;
  1109. }
  1110. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  1111. if (event.ctrlKey) {
  1112. (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.doAction)(true);
  1113. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1114. }
  1115. else {
  1116. onClick(node, button, (0,_modal_header_actions_alternate__WEBPACK_IMPORTED_MODULE_5__.isActive)());
  1117. }
  1118. });
  1119. button.addEventListener('keydown', (event) => {
  1120. // Prevent button presses via the Enter key from triggering actions
  1121. if (event.key === 'Enter') {
  1122. event.stopPropagation();
  1123. }
  1124. });
  1125. button.addEventListener('mouseleave', () => {
  1126. button.blur();
  1127. });
  1128. node.element.addButton(button);
  1129. return button;
  1130. }
  1131. // Creates a template
  1132. const getNewButton = (function () {
  1133. const buttonTemplate = document.createElement('button');
  1134. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  1135. // Prevent tabbing to buttons until node is focused
  1136. buttonTemplate.setAttribute('tabindex', '-1');
  1137. const svgTemplate = (() => {
  1138. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'circle');
  1139. circle.setAttribute('r', '50');
  1140. circle.setAttribute('stroke-width', '10');
  1141. const svg = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_4__.SVG_NAMESPACE, 'svg');
  1142. svg.setAttribute('viewBox', '-70 -70 140 140');
  1143. svg.append(circle);
  1144. return svg;
  1145. })();
  1146. return function (group, actionId, description) {
  1147. const button = buttonTemplate.cloneNode(true);
  1148. const svg = svgTemplate.cloneNode(true);
  1149. button.classList.add(actionId);
  1150. button.title = description;
  1151. svg.append(group);
  1152. button.append(svg);
  1153. return button;
  1154. };
  1155. })();
  1156.  
  1157.  
  1158. /***/ }),
  1159.  
  1160. /***/ "./ts/modal/body/nodes/actions/buttons/consts.ts":
  1161. /*!*******************************************************!*\
  1162. !*** ./ts/modal/body/nodes/actions/buttons/consts.ts ***!
  1163. \*******************************************************/
  1164. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1165.  
  1166. __webpack_require__.r(__webpack_exports__);
  1167. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1168. /* harmony export */ ALT_CLASS: () => (/* binding */ ALT_CLASS),
  1169. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  1170. /* harmony export */ TEST_ADD_CLASS: () => (/* binding */ TEST_ADD_CLASS),
  1171. /* harmony export */ TEST_REMOVE_CLASS: () => (/* binding */ TEST_REMOVE_CLASS)
  1172. /* harmony export */ });
  1173. const BUTTON_CLASS = 'node-button';
  1174. const ALT_CLASS = 'node-icon-alt';
  1175. const TEST_ADD_CLASS = 'node-test-add';
  1176. const TEST_REMOVE_CLASS = 'node-test-remove';
  1177.  
  1178.  
  1179. /***/ }),
  1180.  
  1181. /***/ "./ts/modal/body/nodes/actions/buttons/create/button.ts":
  1182. /*!**************************************************************!*\
  1183. !*** ./ts/modal/body/nodes/actions/buttons/create/button.ts ***!
  1184. \**************************************************************/
  1185. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1186.  
  1187. __webpack_require__.r(__webpack_exports__);
  1188. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1189. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1190. /* harmony export */ });
  1191. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1192. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1193. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1194.  
  1195.  
  1196.  
  1197. const lineHorizontal = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1198. lineHorizontal.setAttribute('stroke-linecap', 'round');
  1199. lineHorizontal.setAttribute('stroke-width', '12');
  1200. lineHorizontal.setAttribute('x1', '-25');
  1201. lineHorizontal.setAttribute('x2', '25');
  1202. const lineVertical = lineHorizontal.cloneNode(true);
  1203. lineVertical.setAttribute('transform', 'rotate(90)');
  1204. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1205. g.append(lineHorizontal, lineVertical);
  1206. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Create', { scale: '1 1.15' });
  1207. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1208.  
  1209.  
  1210. /***/ }),
  1211.  
  1212. /***/ "./ts/modal/body/nodes/actions/buttons/create/consts.ts":
  1213. /*!**************************************************************!*\
  1214. !*** ./ts/modal/body/nodes/actions/buttons/create/consts.ts ***!
  1215. \**************************************************************/
  1216. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1217.  
  1218. __webpack_require__.r(__webpack_exports__);
  1219. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1220. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1221. /* harmony export */ });
  1222. const ACTION_ID = 'node-create';
  1223.  
  1224.  
  1225. /***/ }),
  1226.  
  1227. /***/ "./ts/modal/body/nodes/actions/buttons/create/css.ts":
  1228. /*!***********************************************************!*\
  1229. !*** ./ts/modal/body/nodes/actions/buttons/create/css.ts ***!
  1230. \***********************************************************/
  1231. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1232.  
  1233. __webpack_require__.r(__webpack_exports__);
  1234. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1235. /* harmony export */ "default": () => (/* binding */ generate)
  1236. /* harmony export */ });
  1237. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1238. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1239.  
  1240.  
  1241. function generate() {
  1242. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonCreate');
  1243. }
  1244.  
  1245.  
  1246. /***/ }),
  1247.  
  1248. /***/ "./ts/modal/body/nodes/actions/buttons/create/index.ts":
  1249. /*!*************************************************************!*\
  1250. !*** ./ts/modal/body/nodes/actions/buttons/create/index.ts ***!
  1251. \*************************************************************/
  1252. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1253.  
  1254. __webpack_require__.r(__webpack_exports__);
  1255. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1256. /* harmony export */ mount: () => (/* binding */ mount),
  1257. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1258. /* harmony export */ });
  1259. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/create/consts.ts");
  1260. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/create/button.ts");
  1261. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1262. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1263. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1264. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1265. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1266. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1267. /* harmony import */ var _nodes_child__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/child */ "./ts/modal/body/nodes/child.ts");
  1268. /* harmony import */ var _nodes_middle__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @nodes/middle */ "./ts/modal/body/nodes/middle.ts");
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279. function getChild(node) {
  1280. const { seed } = node;
  1281. const child = 'children' in seed ? new _nodes_middle__WEBPACK_IMPORTED_MODULE_9__["default"](seed, node, 0) : new _nodes_child__WEBPACK_IMPORTED_MODULE_8__["default"](seed, node, 0);
  1282. child.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1283. return child;
  1284. }
  1285. function redo(child, ancestors) {
  1286. child.disconnect();
  1287. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1288. }
  1289. function undo(child, parent, index, ancestors) {
  1290. child.attach(child, parent, index);
  1291. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1292. }
  1293. function validate(child, target, button, index) {
  1294. const ancestors = child.getAncestors();
  1295. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1296. .then(() => {
  1297. _history__WEBPACK_IMPORTED_MODULE_5__.register(child, redo.bind(null, child, ancestors), undo.bind(null, child, child.parent, index, ancestors), false, true);
  1298. child.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1299. child.isActive = true;
  1300. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1301. return child;
  1302. })
  1303. .catch((reason) => {
  1304. child.disconnect();
  1305. if (reason) {
  1306. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, target, button.querySelector('circle'));
  1307. }
  1308. });
  1309. }
  1310. function doAction(source, target, button, index) {
  1311. const child = getChild(source);
  1312. child.move(index === 0 ? target : target.parent, index);
  1313. return validate(child, target, button, index);
  1314. }
  1315. function onClick(node, button, isAlt) {
  1316. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1317. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1318. return;
  1319. }
  1320. if (isAlt) {
  1321. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node.seed, node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1322. return;
  1323. }
  1324. validate(getChild(node), node, button, 0);
  1325. }
  1326. function mount(node) {
  1327. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1328. }
  1329. function shouldMount(node) {
  1330. return 'seed' in node;
  1331. }
  1332.  
  1333.  
  1334. /***/ }),
  1335.  
  1336. /***/ "./ts/modal/body/nodes/actions/buttons/css.ts":
  1337. /*!****************************************************!*\
  1338. !*** ./ts/modal/body/nodes/actions/buttons/css.ts ***!
  1339. \****************************************************/
  1340. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1341.  
  1342. __webpack_require__.r(__webpack_exports__);
  1343. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1344. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  1345. /* harmony export */ "default": () => (/* binding */ generate)
  1346. /* harmony export */ });
  1347. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1348. /* harmony import */ var _create_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create/css */ "./ts/modal/body/nodes/actions/buttons/create/css.ts");
  1349. /* harmony import */ var _move_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./move/css */ "./ts/modal/body/nodes/actions/buttons/move/css.ts");
  1350. /* harmony import */ var _disable_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./disable/css */ "./ts/modal/body/nodes/actions/buttons/disable/css.ts");
  1351. /* harmony import */ var _duplicate_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./duplicate/css */ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts");
  1352. /* harmony import */ var _position_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./position/css */ "./ts/modal/body/nodes/actions/buttons/position/css.ts");
  1353. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1354. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1355. /* harmony import */ var _modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/header/actions/alternate/consts */ "./ts/modal/header/actions/alternate/consts.ts");
  1356. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1357. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369. function addColourRule(actionId, strokeVar) {
  1370. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1371. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}) > `
  1372. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1373. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId} > svg`,
  1374. ], ['fill', `var(${strokeVar})`]);
  1375. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER} > `
  1376. + `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg > g`, ['stroke', `var(${strokeVar})`]);
  1377. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1378. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:hover > svg > circle`,
  1379. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${actionId}.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:focus > svg > circle`,
  1380. ], ['stroke', `var(${strokeVar})`]);
  1381. }
  1382. function generate() {
  1383. (0,_create_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  1384. (0,_move_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  1385. (0,_disable_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  1386. (0,_duplicate_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  1387. (0,_position_css__WEBPACK_IMPORTED_MODULE_5__["default"])();
  1388. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}`, [
  1389. ['height', '100%'],
  1390. ['position', 'relative'],
  1391. ]);
  1392. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  1393. ['height', '100%'],
  1394. ['transform', 'scale(1.05)'],
  1395. ]);
  1396. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`, [
  1397. ['white-space', 'nowrap'],
  1398. ['z-index', '1'],
  1399. ]);
  1400. // Hide prospective nodes
  1401. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1402. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_ADD_CLASS}`,
  1403. `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TEST_REMOVE_CLASS}`,
  1404. ], [['pointer-events', 'none']]);
  1405. // Hide alt icon components
  1406. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS}:not(.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__.ACTION_ID} *)`, ['display', 'none']);
  1407. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_modal_header_actions_alternate_consts__WEBPACK_IMPORTED_MODULE_8__.ACTION_ID} button.${_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS} + *`, ['display', 'none']);
  1408. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_7__.NODE_COLOURS) {
  1409. const buttonSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.BUTTON_CONTAINER}`;
  1410. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}):not(:focus):not(:hover) > svg > g`, ['stroke', base]);
  1411. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)(`${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:hover):not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS}:focus) > svg > circle`, ['stroke', base]);
  1412. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1413. // Not active, focused
  1414. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg > g`,
  1415. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg > g`,
  1416. ], [['stroke', contrast]]);
  1417. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([`${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`], [['stroke', base]]);
  1418. (0,_modal_css__WEBPACK_IMPORTED_MODULE_10__.addRule)([
  1419. // Not active, focused
  1420. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  1421. `${buttonSelector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  1422. `.${_highlight_consts__WEBPACK_IMPORTED_MODULE_6__.HIGHLIGHT_CLASS}${buttonSelector} > .${_modal_consts__WEBPACK_IMPORTED_MODULE_9__.BUTTON_ACTIVE_CLASS} > svg`,
  1423. ], [['fill', base]]);
  1424. }
  1425. }
  1426.  
  1427.  
  1428. /***/ }),
  1429.  
  1430. /***/ "./ts/modal/body/nodes/actions/buttons/disable/button.ts":
  1431. /*!***************************************************************!*\
  1432. !*** ./ts/modal/body/nodes/actions/buttons/disable/button.ts ***!
  1433. \***************************************************************/
  1434. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1435.  
  1436. __webpack_require__.r(__webpack_exports__);
  1437. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1438. /* harmony export */ BUTTON_ALT: () => (/* binding */ BUTTON_ALT),
  1439. /* harmony export */ BUTTON_DEFAULT: () => (/* binding */ BUTTON_DEFAULT)
  1440. /* harmony export */ });
  1441. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1442. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1443. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1444. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1445.  
  1446.  
  1447.  
  1448.  
  1449. const gDefault = (() => {
  1450. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'circle');
  1451. circle.setAttribute('r', '30');
  1452. circle.setAttribute('stroke-width', '10');
  1453. const line = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1454. line.setAttribute('stroke-linecap', 'round');
  1455. line.setAttribute('stroke-width', '10');
  1456. line.setAttribute('x1', '-30');
  1457. line.setAttribute('x2', '30');
  1458. line.setAttribute('transform', 'rotate(45)');
  1459. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1460. g.append(circle, line);
  1461. return g;
  1462. })();
  1463. const BUTTON_DEFAULT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gDefault, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, 'Toggle Enabled');
  1464. const gAlt = (() => {
  1465. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'line');
  1466. line0.setAttribute('stroke-linecap', 'round');
  1467. line0.setAttribute('stroke-width', '12');
  1468. line0.setAttribute('x1', '-20');
  1469. line0.setAttribute('x2', '20');
  1470. line0.setAttribute('y1', '-20');
  1471. line0.setAttribute('y2', '20');
  1472. const line1 = line0.cloneNode(true);
  1473. line1.setAttribute('transform', 'rotate(90)');
  1474. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_3__.SVG_NAMESPACE, 'g');
  1475. g.append(line0, line1);
  1476. return g;
  1477. })();
  1478. const BUTTON_ALT = (0,_button__WEBPACK_IMPORTED_MODULE_2__.getNewButton)(gAlt, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, 'Delete');
  1479. BUTTON_ALT.classList.add(_consts__WEBPACK_IMPORTED_MODULE_1__.ALT_CLASS);
  1480.  
  1481.  
  1482. /***/ }),
  1483.  
  1484. /***/ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts":
  1485. /*!***************************************************************!*\
  1486. !*** ./ts/modal/body/nodes/actions/buttons/disable/consts.ts ***!
  1487. \***************************************************************/
  1488. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1489.  
  1490. __webpack_require__.r(__webpack_exports__);
  1491. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1492. /* harmony export */ ACTION_ID_ALT: () => (/* binding */ ACTION_ID_ALT),
  1493. /* harmony export */ ACTION_ID_DEFAULT: () => (/* binding */ ACTION_ID_DEFAULT),
  1494. /* harmony export */ DISABLED_CLASS: () => (/* binding */ DISABLED_CLASS)
  1495. /* harmony export */ });
  1496. const ACTION_ID_DEFAULT = 'node-active';
  1497. const ACTION_ID_ALT = 'node-delete';
  1498. const DISABLED_CLASS = 'node-disable';
  1499.  
  1500.  
  1501. /***/ }),
  1502.  
  1503. /***/ "./ts/modal/body/nodes/actions/buttons/disable/css.ts":
  1504. /*!************************************************************!*\
  1505. !*** ./ts/modal/body/nodes/actions/buttons/disable/css.ts ***!
  1506. \************************************************************/
  1507. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1508.  
  1509. __webpack_require__.r(__webpack_exports__);
  1510. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1511. /* harmony export */ "default": () => (/* binding */ generate)
  1512. /* harmony export */ });
  1513. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1514. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1515. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  1516. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  1517. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523. function generate() {
  1524. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_DEFAULT, '--nodeButtonDisable');
  1525. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID_ALT, '--nodeButtonDelete');
  1526. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)([
  1527. // Self selectors
  1528. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1529. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1530. // Descendant selectors
  1531. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  1532. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS} :not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_2__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_3__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  1533. ], ['opacity', '0.5']);
  1534. }
  1535.  
  1536.  
  1537. /***/ }),
  1538.  
  1539. /***/ "./ts/modal/body/nodes/actions/buttons/disable/index.ts":
  1540. /*!**************************************************************!*\
  1541. !*** ./ts/modal/body/nodes/actions/buttons/disable/index.ts ***!
  1542. \**************************************************************/
  1543. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1544.  
  1545. __webpack_require__.r(__webpack_exports__);
  1546. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1547. /* harmony export */ mount: () => (/* binding */ mount),
  1548. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1549. /* harmony export */ });
  1550. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  1551. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/disable/button.ts");
  1552. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1553. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1554. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1555. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1556. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1557. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1558. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568. function updateButton(button, isActive) {
  1569. button.classList[isActive ? 'remove' : 'add'](_modal_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  1570. }
  1571. function toggle(node) {
  1572. node.element[`${node.isActive ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1573. node.isActive = !node.isActive;
  1574. }
  1575. function undo(node, parent, index, ancestors) {
  1576. node.attach(parent, index);
  1577. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1578. }
  1579. function redo(node, ancestors) {
  1580. node.disconnect();
  1581. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1582. }
  1583. function onClick(node, button, isAlt) {
  1584. if (isAlt) {
  1585. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1586. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1587. }
  1588. else {
  1589. toggle(node);
  1590. }
  1591. const ancestors = node.getAncestors();
  1592. Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1593. .then(() => {
  1594. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1595. if (isAlt) {
  1596. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, undo.bind(null, node, node.parent, node.getIndex(), ancestors), redo.bind(null, node, ancestors), true, false, true);
  1597. }
  1598. else {
  1599. const act = () => {
  1600. toggle(node);
  1601. updateButton(button, node.isActive);
  1602. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1603. };
  1604. _history__WEBPACK_IMPORTED_MODULE_5__.register(node, act, act, false);
  1605. updateButton(button, node.isActive);
  1606. }
  1607. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1608. })
  1609. .catch((reason) => {
  1610. if (isAlt) {
  1611. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_3__.TEST_REMOVE_CLASS);
  1612. }
  1613. else {
  1614. toggle(node);
  1615. }
  1616. if (typeof reason === 'string') {
  1617. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, node, button.querySelector('circle'));
  1618. }
  1619. });
  1620. }
  1621. function mount(node) {
  1622. (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ALT, onClick, node);
  1623. const defaultButton = (0,_button__WEBPACK_IMPORTED_MODULE_2__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__.BUTTON_DEFAULT, onClick, node);
  1624. if (!node.isActive) {
  1625. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.DISABLED_CLASS);
  1626. updateButton(defaultButton, false);
  1627. }
  1628. }
  1629. function shouldMount(node) {
  1630. return 'seed' in node.parent;
  1631. }
  1632.  
  1633.  
  1634. /***/ }),
  1635.  
  1636. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts":
  1637. /*!*****************************************************************!*\
  1638. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/button.ts ***!
  1639. \*****************************************************************/
  1640. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1641.  
  1642. __webpack_require__.r(__webpack_exports__);
  1643. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1644. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1645. /* harmony export */ });
  1646. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1647. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1648. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1649.  
  1650.  
  1651.  
  1652. const RADIUS = 15;
  1653. const HEIGHT = 25;
  1654. const WIDTH = 10;
  1655. const outline0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1656. outline0.setAttribute('stroke-linecap', 'round');
  1657. outline0.setAttribute('stroke-width', '8');
  1658. outline0.setAttribute('fill', 'none');
  1659. outline0.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1660. + `q 0 -${RADIUS} -${RADIUS} -${RADIUS}`
  1661. + `h -${WIDTH}`
  1662. + `q -${RADIUS} 0 -${RADIUS} ${RADIUS}`
  1663. + `v ${HEIGHT}`
  1664. + `q 0 ${RADIUS} ${RADIUS} ${RADIUS}`);
  1665. outline0.setAttribute('transform', `translate(-${RADIUS / 2}, -${RADIUS / 2})`);
  1666. const outline1 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  1667. outline1.setAttribute('stroke-linecap', 'round');
  1668. outline1.setAttribute('stroke-width', '8');
  1669. outline1.setAttribute('fill', 'none');
  1670. outline1.setAttribute('d', `M ${WIDTH / 2 + RADIUS} ${-HEIGHT / 2}`
  1671. + `q 0 -${RADIUS} -${RADIUS} -${RADIUS}`
  1672. + `h -${WIDTH}`
  1673. + `q -${RADIUS} 0 -${RADIUS} ${RADIUS}`
  1674. + `v ${HEIGHT}`
  1675. + `q 0 ${RADIUS} ${RADIUS} ${RADIUS}`
  1676. + `h ${WIDTH}`
  1677. + `q ${RADIUS} 0 ${RADIUS} -${RADIUS}`
  1678. + `v -${HEIGHT}`);
  1679. outline1.setAttribute('transform', `translate(${RADIUS / 2}, ${RADIUS / 2})`);
  1680. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1681. g.setAttribute('transform', `rotate(10)`);
  1682. g.append(outline0, outline1);
  1683. 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 });
  1684. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1685.  
  1686.  
  1687. /***/ }),
  1688.  
  1689. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts":
  1690. /*!*****************************************************************!*\
  1691. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts ***!
  1692. \*****************************************************************/
  1693. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1694.  
  1695. __webpack_require__.r(__webpack_exports__);
  1696. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1697. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1698. /* harmony export */ });
  1699. const ACTION_ID = 'node-copy';
  1700.  
  1701.  
  1702. /***/ }),
  1703.  
  1704. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/css.ts":
  1705. /*!**************************************************************!*\
  1706. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/css.ts ***!
  1707. \**************************************************************/
  1708. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1709.  
  1710. __webpack_require__.r(__webpack_exports__);
  1711. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1712. /* harmony export */ "default": () => (/* binding */ generate)
  1713. /* harmony export */ });
  1714. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1715. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1716.  
  1717.  
  1718. function generate() {
  1719. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonDuplicate');
  1720. }
  1721.  
  1722.  
  1723. /***/ }),
  1724.  
  1725. /***/ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts":
  1726. /*!****************************************************************!*\
  1727. !*** ./ts/modal/body/nodes/actions/buttons/duplicate/index.ts ***!
  1728. \****************************************************************/
  1729. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1730.  
  1731. __webpack_require__.r(__webpack_exports__);
  1732. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1733. /* harmony export */ mount: () => (/* binding */ mount),
  1734. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1735. /* harmony export */ });
  1736. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/duplicate/consts.ts");
  1737. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/duplicate/button.ts");
  1738. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1739. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1740. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1741. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1742. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1743. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752. function undo(node, ancestors) {
  1753. node.disconnect();
  1754. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1755. }
  1756. function redo(node, parent, index, ancestors) {
  1757. node.attach(parent, index);
  1758. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1759. }
  1760. function validate(copy, target, button, index) {
  1761. const ancestors = copy.getAncestors();
  1762. return Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(ancestors))
  1763. .then(() => {
  1764. _history__WEBPACK_IMPORTED_MODULE_5__.register(copy, undo.bind(null, copy, ancestors), redo.bind(null, copy, copy.parent, index, ancestors), false, true);
  1765. copy.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1766. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(ancestors);
  1767. return copy;
  1768. })
  1769. .catch((reason) => {
  1770. copy.disconnect();
  1771. if (reason) {
  1772. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, target, button.querySelector('circle'));
  1773. }
  1774. });
  1775. }
  1776. function getCopy(node) {
  1777. const copy = node.duplicate();
  1778. copy.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1779. return copy;
  1780. }
  1781. function doAction(source, target, button, index) {
  1782. const copy = getCopy(source);
  1783. copy.move(index === 0 ? target : target.parent, index);
  1784. return validate(copy, target, button, index);
  1785. }
  1786. function onClick(node, button, isAlt) {
  1787. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1788. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1789. return;
  1790. }
  1791. if (isAlt) {
  1792. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1793. return;
  1794. }
  1795. const copy = getCopy(node);
  1796. validate(copy, node, button, copy.getIndex());
  1797. }
  1798. function mount(node) {
  1799. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1800. }
  1801. function shouldMount(node) {
  1802. return 'seed' in node.parent;
  1803. }
  1804.  
  1805.  
  1806. /***/ }),
  1807.  
  1808. /***/ "./ts/modal/body/nodes/actions/buttons/move/button.ts":
  1809. /*!************************************************************!*\
  1810. !*** ./ts/modal/body/nodes/actions/buttons/move/button.ts ***!
  1811. \************************************************************/
  1812. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1813.  
  1814. __webpack_require__.r(__webpack_exports__);
  1815. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1816. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  1817. /* harmony export */ });
  1818. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1819. /* harmony import */ var _position_button_alt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../position/button/alt */ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts");
  1820. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  1821.  
  1822.  
  1823.  
  1824. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1825. arrowTrunk.setAttribute('stroke-linecap', 'round');
  1826. arrowTrunk.setAttribute('stroke-width', '10');
  1827. arrowTrunk.setAttribute('y1', '-30');
  1828. arrowTrunk.setAttribute('y2', '30');
  1829. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  1830. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  1831. arrowBottomLeft.setAttribute('stroke-width', '10');
  1832. arrowBottomLeft.setAttribute('x2', '-12');
  1833. arrowBottomLeft.setAttribute('y1', '27');
  1834. arrowBottomLeft.setAttribute('y2', '15');
  1835. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  1836. arrowBottomRight.setAttribute('x2', '12');
  1837. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  1838. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  1839. const BUTTON = (0,_position_button_alt__WEBPACK_IMPORTED_MODULE_1__.getPositionedButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Move');
  1840. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  1841.  
  1842.  
  1843. /***/ }),
  1844.  
  1845. /***/ "./ts/modal/body/nodes/actions/buttons/move/consts.ts":
  1846. /*!************************************************************!*\
  1847. !*** ./ts/modal/body/nodes/actions/buttons/move/consts.ts ***!
  1848. \************************************************************/
  1849. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1850.  
  1851. __webpack_require__.r(__webpack_exports__);
  1852. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1853. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  1854. /* harmony export */ });
  1855. const ACTION_ID = 'node-move';
  1856.  
  1857.  
  1858. /***/ }),
  1859.  
  1860. /***/ "./ts/modal/body/nodes/actions/buttons/move/css.ts":
  1861. /*!*********************************************************!*\
  1862. !*** ./ts/modal/body/nodes/actions/buttons/move/css.ts ***!
  1863. \*********************************************************/
  1864. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1865.  
  1866. __webpack_require__.r(__webpack_exports__);
  1867. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1868. /* harmony export */ "default": () => (/* binding */ generate)
  1869. /* harmony export */ });
  1870. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1871. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  1872.  
  1873.  
  1874. function generate() {
  1875. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--nodeButtonMove');
  1876. }
  1877.  
  1878.  
  1879. /***/ }),
  1880.  
  1881. /***/ "./ts/modal/body/nodes/actions/buttons/move/index.ts":
  1882. /*!***********************************************************!*\
  1883. !*** ./ts/modal/body/nodes/actions/buttons/move/index.ts ***!
  1884. \***********************************************************/
  1885. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1886.  
  1887. __webpack_require__.r(__webpack_exports__);
  1888. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1889. /* harmony export */ mount: () => (/* binding */ mount),
  1890. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  1891. /* harmony export */ });
  1892. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/move/consts.ts");
  1893. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/move/button.ts");
  1894. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  1895. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  1896. /* harmony import */ var _position__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  1897. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../history */ "./ts/modal/body/nodes/actions/history.ts");
  1898. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  1899. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  1900. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910. function getAncestorBranches(node, temp) {
  1911. if (node.parent === temp.parent) {
  1912. return [node.getAncestors()];
  1913. }
  1914. const oldAncestors = node.getAncestors();
  1915. const newAncestors = temp.getAncestors();
  1916. for (let i = Math.min(oldAncestors.length, newAncestors.length) - 1; i > 1; --i) {
  1917. if (oldAncestors[oldAncestors.length - i] === newAncestors[newAncestors.length - i]) {
  1918. return [oldAncestors.slice(0, -i), newAncestors];
  1919. }
  1920. }
  1921. // Branch is from the root
  1922. return [oldAncestors.slice(0, -1), newAncestors];
  1923. }
  1924. function move(node, to, index, ancestorBranches) {
  1925. node.move(to, index);
  1926. for (const branch of ancestorBranches) {
  1927. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(branch);
  1928. }
  1929. }
  1930. function doAction(source, target, button, index) {
  1931. const priorIndex = source.getIndex();
  1932. if (index === priorIndex) {
  1933. return source;
  1934. }
  1935. const temp = source.duplicate();
  1936. source.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1937. temp.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_ADD_CLASS);
  1938. temp.move(index === 0 ? target : target.parent, index);
  1939. const ancestorBranches = getAncestorBranches(source, temp);
  1940. return Promise.all(ancestorBranches.map((branch) => Promise.all(_callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].predicate.getSub(branch))))
  1941. .then(() => {
  1942. const priorParent = source.parent;
  1943. source.move(index === 0 ? target : target.parent, index);
  1944. _history__WEBPACK_IMPORTED_MODULE_5__.register(source, move.bind(null, source, priorParent, priorIndex, ancestorBranches), move.bind(null, source, source.parent, index, ancestorBranches));
  1945. for (const branch of ancestorBranches) {
  1946. _callbacks__WEBPACK_IMPORTED_MODULE_6__["default"].update.triggerSub(branch);
  1947. }
  1948. return source;
  1949. })
  1950. .catch((reason) => {
  1951. if (reason) {
  1952. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)(reason, source, button.querySelector('circle'));
  1953. }
  1954. })
  1955. .finally(() => {
  1956. temp.disconnect();
  1957. source.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_2__.TEST_REMOVE_CLASS);
  1958. });
  1959. }
  1960. function hasDestinations(node) {
  1961. return node.parent.children.length > 1 || (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_8__.get)(node.parent).length > 1;
  1962. }
  1963. function onClick(node, button, isAlt) {
  1964. if (_position__WEBPACK_IMPORTED_MODULE_4__.isToggle(node, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID)) {
  1965. _position__WEBPACK_IMPORTED_MODULE_4__.reset(node);
  1966. return;
  1967. }
  1968. if (isAlt) {
  1969. if (hasDestinations(node)) {
  1970. _position__WEBPACK_IMPORTED_MODULE_4__.mount(node, node, node.parent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, button, doAction);
  1971. }
  1972. else {
  1973. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('No other valid locations found.', node, button.querySelector('circle'));
  1974. }
  1975. return;
  1976. }
  1977. const newIndex = node.getIndex() + 2;
  1978. if (newIndex < node.parent.children.length + 1) {
  1979. doAction(node, node, button, newIndex);
  1980. }
  1981. else {
  1982. (0,_overlays__WEBPACK_IMPORTED_MODULE_7__.showTooltip)('Node can not be moved down.', node, button.querySelector('circle'));
  1983. }
  1984. }
  1985. function mount(node) {
  1986. (0,_button__WEBPACK_IMPORTED_MODULE_3__.addActionButton)(_button__WEBPACK_IMPORTED_MODULE_1__["default"], onClick, node);
  1987. }
  1988. function shouldMount(node) {
  1989. return Boolean(node.parent.seed) || ('poolId' in node.parent);
  1990. }
  1991.  
  1992.  
  1993. /***/ }),
  1994.  
  1995. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/alt.ts":
  1996. /*!********************************************************************!*\
  1997. !*** ./ts/modal/body/nodes/actions/buttons/position/button/alt.ts ***!
  1998. \********************************************************************/
  1999. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2000.  
  2001. __webpack_require__.r(__webpack_exports__);
  2002. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2003. /* harmony export */ getPositionedButton: () => (/* binding */ getPositionedButton)
  2004. /* harmony export */ });
  2005. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  2006. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2007. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2008.  
  2009.  
  2010.  
  2011. const G_ALT = (() => {
  2012. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2013. arrowTrunk.setAttribute('stroke-linecap', 'round');
  2014. arrowTrunk.setAttribute('stroke-width', '10');
  2015. arrowTrunk.setAttribute('y1', '-30');
  2016. arrowTrunk.setAttribute('y2', '30');
  2017. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2018. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  2019. arrowBottomLeft.setAttribute('stroke-width', '10');
  2020. arrowBottomLeft.setAttribute('x2', '-12');
  2021. arrowBottomLeft.setAttribute('y1', '27');
  2022. arrowBottomLeft.setAttribute('y2', '15');
  2023. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2024. arrowBottomRight.setAttribute('x2', '12');
  2025. const arrowTopRight = arrowBottomLeft.cloneNode(true);
  2026. arrowTopRight.setAttribute('transform', 'rotate(180)');
  2027. const arrowTopLeft = arrowBottomRight.cloneNode(true);
  2028. arrowTopLeft.setAttribute('transform', 'rotate(180)');
  2029. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2030. g.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ALT_CLASS);
  2031. g.append(arrowTrunk, arrowBottomLeft, arrowBottomRight, arrowTopRight, arrowTopLeft);
  2032. return g;
  2033. })();
  2034. function getPositionedButton(gDefault, actionId, description, transform = {}) {
  2035. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2036. const gAlt = G_ALT.cloneNode(true);
  2037. gAlt.setAttribute('transform', Object.entries(transform).map(([key, value]) => `${key}(${value})`).join(' '));
  2038. g.append(gAlt, gDefault);
  2039. return (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, actionId, description);
  2040. }
  2041.  
  2042.  
  2043. /***/ }),
  2044.  
  2045. /***/ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts":
  2046. /*!**********************************************************************!*\
  2047. !*** ./ts/modal/body/nodes/actions/buttons/position/button/index.ts ***!
  2048. \**********************************************************************/
  2049. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2050.  
  2051. __webpack_require__.r(__webpack_exports__);
  2052. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2053. /* harmony export */ BUTTON_PARENT: () => (/* binding */ BUTTON_PARENT),
  2054. /* harmony export */ BUTTON_SIBLING: () => (/* binding */ BUTTON_SIBLING)
  2055. /* harmony export */ });
  2056. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2057. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2058. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2059.  
  2060.  
  2061.  
  2062. const arrowTrunk = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2063. arrowTrunk.setAttribute('stroke-linecap', 'round');
  2064. arrowTrunk.setAttribute('stroke-width', '10');
  2065. arrowTrunk.setAttribute('y1', '-30');
  2066. arrowTrunk.setAttribute('y2', '30');
  2067. const arrowBottomLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  2068. arrowBottomLeft.setAttribute('stroke-linecap', 'round');
  2069. arrowBottomLeft.setAttribute('stroke-width', '10');
  2070. arrowBottomLeft.setAttribute('x2', '-12');
  2071. arrowBottomLeft.setAttribute('y1', '27');
  2072. arrowBottomLeft.setAttribute('y2', '15');
  2073. const arrowBottomRight = arrowBottomLeft.cloneNode(true);
  2074. arrowBottomRight.setAttribute('x2', '12');
  2075. const gMain = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  2076. gMain.append(arrowTrunk, arrowBottomLeft, arrowBottomRight);
  2077. const gSibling = gMain.cloneNode(true);
  2078. const BUTTON_SIBLING = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gSibling, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select After');
  2079. const gParent = gMain.cloneNode(true);
  2080. gParent.setAttribute('transform', 'rotate(-45)');
  2081. const BUTTON_PARENT = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(gParent, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Select Into');
  2082.  
  2083.  
  2084. /***/ }),
  2085.  
  2086. /***/ "./ts/modal/body/nodes/actions/buttons/position/consts.ts":
  2087. /*!****************************************************************!*\
  2088. !*** ./ts/modal/body/nodes/actions/buttons/position/consts.ts ***!
  2089. \****************************************************************/
  2090. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2091.  
  2092. __webpack_require__.r(__webpack_exports__);
  2093. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2094. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  2095. /* harmony export */ });
  2096. const ACTION_ID = 'node-position';
  2097.  
  2098.  
  2099. /***/ }),
  2100.  
  2101. /***/ "./ts/modal/body/nodes/actions/buttons/position/css.ts":
  2102. /*!*************************************************************!*\
  2103. !*** ./ts/modal/body/nodes/actions/buttons/position/css.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 */ "default": () => (/* binding */ generate)
  2110. /* harmony export */ });
  2111. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2112. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2113. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2114. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2115. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121. function generate() {
  2122. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS} `
  2123. + `.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_focus_consts__WEBPACK_IMPORTED_MODULE_1__.FOCUS_CLASS})`, ['display', 'none']);
  2124. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} button:not(.${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS})`, ['display', 'none']);
  2125. (0,_modal_css__WEBPACK_IMPORTED_MODULE_4__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} .${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS}:not(:has(~ .${_modal_consts__WEBPACK_IMPORTED_MODULE_3__.BUTTON_ACTIVE_CLASS}))`, [
  2126. ['border-top-right-radius', '0.8em'],
  2127. ['border-bottom-right-radius', '0.8em'],
  2128. ]);
  2129. }
  2130.  
  2131.  
  2132. /***/ }),
  2133.  
  2134. /***/ "./ts/modal/body/nodes/actions/buttons/position/index.ts":
  2135. /*!***************************************************************!*\
  2136. !*** ./ts/modal/body/nodes/actions/buttons/position/index.ts ***!
  2137. \***************************************************************/
  2138. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2139.  
  2140. __webpack_require__.r(__webpack_exports__);
  2141. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2142. /* harmony export */ getButton: () => (/* binding */ getButton),
  2143. /* harmony export */ isActive: () => (/* binding */ isActive),
  2144. /* harmony export */ isToggle: () => (/* binding */ isToggle),
  2145. /* harmony export */ mount: () => (/* binding */ mount),
  2146. /* harmony export */ reset: () => (/* binding */ reset)
  2147. /* harmony export */ });
  2148. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/buttons/position/consts.ts");
  2149. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./ts/modal/body/nodes/actions/buttons/position/button/index.ts");
  2150. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/body/nodes/actions/buttons/button.ts");
  2151. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  2152. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2153. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2154. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  2155. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  2156. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  2157. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2158. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2159. return new (P || (P = Promise))(function (resolve, reject) {
  2160. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2161. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2162. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2163. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2164. });
  2165. };
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175. const destinations = [];
  2176. let origin;
  2177. function isActive() {
  2178. return Boolean(origin);
  2179. }
  2180. function isToggle(source, id) {
  2181. return isActive() && origin.source === source && origin.actionId === id;
  2182. }
  2183. function setActive(doActivate = true) {
  2184. (0,_modal_body__WEBPACK_IMPORTED_MODULE_7__.setActive)(origin.button, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, doActivate);
  2185. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.reset)();
  2186. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focus)(doActivate, origin.source, false);
  2187. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(doActivate, origin.source, doActivate);
  2188. origin.button.setAttribute('tabindex', doActivate ? '0' : '-1');
  2189. }
  2190. function reset(scrollTarget) {
  2191. if (!origin) {
  2192. return;
  2193. }
  2194. for (const { node, isParent, button } of destinations) {
  2195. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(false, node, isParent);
  2196. button.remove();
  2197. }
  2198. destinations.length = 0;
  2199. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.removeSustained)(origin.source);
  2200. setActive(false);
  2201. (0,_scroll__WEBPACK_IMPORTED_MODULE_5__.scroll)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source);
  2202. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.setActive)(scrollTarget !== null && scrollTarget !== void 0 ? scrollTarget : origin.source, true);
  2203. origin = undefined;
  2204. }
  2205. function getButton(node, actionId, onClick, isParent) {
  2206. 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);
  2207. button.classList.add(actionId, _modal_consts__WEBPACK_IMPORTED_MODULE_8__.BUTTON_ACTIVE_CLASS);
  2208. button.setAttribute('tabindex', '0');
  2209. return button;
  2210. }
  2211. function getBoundCallback(callback, target, index) {
  2212. return (_, button) => __awaiter(this, void 0, void 0, function* () {
  2213. const node = yield callback(origin.source, target, button, index);
  2214. if (node) {
  2215. reset(node);
  2216. }
  2217. });
  2218. }
  2219. function addButtons(parent, actionId, callback) {
  2220. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, parent);
  2221. destinations.push({
  2222. node: parent,
  2223. isParent: true,
  2224. button: getButton(parent, actionId, getBoundCallback(callback, parent, 0), true),
  2225. });
  2226. for (const [i, target] of parent.children.entries()) {
  2227. if (target === origin.source) {
  2228. continue;
  2229. }
  2230. (0,_focus__WEBPACK_IMPORTED_MODULE_3__.focusBranch)(true, target, false);
  2231. destinations.push({
  2232. node: target,
  2233. isParent: false,
  2234. button: getButton(target, actionId, getBoundCallback(callback, target, i + 1), false),
  2235. });
  2236. }
  2237. }
  2238. function mount(source, child, parent, actionId, button, callback) {
  2239. reset();
  2240. origin = {
  2241. source,
  2242. child,
  2243. parent,
  2244. button,
  2245. actionId,
  2246. };
  2247. setActive();
  2248. for (const pool of (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_6__.get)(parent)) {
  2249. addButtons(pool, actionId, callback);
  2250. }
  2251. (0,_highlight__WEBPACK_IMPORTED_MODULE_4__.addSustained)(source);
  2252. return destinations.length;
  2253. }
  2254.  
  2255.  
  2256. /***/ }),
  2257.  
  2258. /***/ "./ts/modal/body/nodes/actions/callbacks/index.ts":
  2259. /*!********************************************************!*\
  2260. !*** ./ts/modal/body/nodes/actions/callbacks/index.ts ***!
  2261. \********************************************************/
  2262. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2263.  
  2264. __webpack_require__.r(__webpack_exports__);
  2265. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2266. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  2267. /* harmony export */ });
  2268. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  2269. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./predicate */ "./ts/modal/body/nodes/actions/callbacks/predicate.ts");
  2270.  
  2271.  
  2272. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ update: _update__WEBPACK_IMPORTED_MODULE_0__, predicate: _predicate__WEBPACK_IMPORTED_MODULE_1__ });
  2273.  
  2274.  
  2275. /***/ }),
  2276.  
  2277. /***/ "./ts/modal/body/nodes/actions/callbacks/predicate.ts":
  2278. /*!************************************************************!*\
  2279. !*** ./ts/modal/body/nodes/actions/callbacks/predicate.ts ***!
  2280. \************************************************************/
  2281. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2282.  
  2283. __webpack_require__.r(__webpack_exports__);
  2284. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2285. /* harmony export */ getAll: () => (/* binding */ getAll),
  2286. /* harmony export */ getSub: () => (/* binding */ getSub)
  2287. /* harmony export */ });
  2288. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2289. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2290. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2291. return new (P || (P = Promise))(function (resolve, reject) {
  2292. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2293. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2294. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2295. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2296. });
  2297. };
  2298.  
  2299. let ongoing;
  2300. function handle(promises) {
  2301. return __awaiter(this, void 0, void 0, function* () {
  2302. ongoing === null || ongoing === void 0 ? void 0 : ongoing(true);
  2303. const callback = new Promise((resolve) => {
  2304. ongoing = resolve;
  2305. });
  2306. const response = Promise.all(promises);
  2307. if (yield Promise.any([
  2308. callback,
  2309. // result of Promise.prototype.finally() gets ignored unless it's a rejection sigh
  2310. response
  2311. .then(() => false)
  2312. .catch(() => false),
  2313. ])) {
  2314. return false;
  2315. }
  2316. return yield response;
  2317. });
  2318. }
  2319. function getSub(ancestors) {
  2320. const responses = [];
  2321. if ('childPredicate' in ancestors[0]) {
  2322. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestors[0].childPredicate()));
  2323. }
  2324. for (const ancestor of ancestors) {
  2325. if ('descendantPredicate' in ancestor) {
  2326. responses.push((0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(ancestor.descendantPredicate()));
  2327. }
  2328. }
  2329. return responses;
  2330. }
  2331. function getAll(node) {
  2332. if (node.forceValid || ('options' in node && node.options.includes(node.value))) {
  2333. return handle(getSub(node.getAncestors()));
  2334. }
  2335. if ('predicate' in node) {
  2336. return handle([(0,_predicate__WEBPACK_IMPORTED_MODULE_0__.getPredicatePromise)(node.predicate()), ...getSub(node.getAncestors())]);
  2337. }
  2338. throw undefined;
  2339. }
  2340.  
  2341.  
  2342. /***/ }),
  2343.  
  2344. /***/ "./ts/modal/body/nodes/actions/callbacks/update.ts":
  2345. /*!*********************************************************!*\
  2346. !*** ./ts/modal/body/nodes/actions/callbacks/update.ts ***!
  2347. \*********************************************************/
  2348. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2349.  
  2350. __webpack_require__.r(__webpack_exports__);
  2351. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2352. /* harmony export */ handle: () => (/* binding */ handle),
  2353. /* harmony export */ triggerAll: () => (/* binding */ triggerAll),
  2354. /* harmony export */ triggerSub: () => (/* binding */ triggerSub)
  2355. /* harmony export */ });
  2356. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  2357. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2358. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2359. return new (P || (P = Promise))(function (resolve, reject) {
  2360. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2361. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2362. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2363. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2364. });
  2365. };
  2366.  
  2367. const maps = {
  2368. onUpdate: new Map(),
  2369. onChildUpdate: new Map(),
  2370. onDescendantUpdate: new Map(),
  2371. };
  2372. function isOutdated(response, map, node) {
  2373. return __awaiter(this, void 0, void 0, function* () {
  2374. if (map.has(node)) {
  2375. map.get(node)(false);
  2376. }
  2377. const callback = new Promise((resolve) => {
  2378. map.set(node, resolve);
  2379. });
  2380. if (yield Promise.any([
  2381. callback,
  2382. Promise.resolve(response)
  2383. .then(() => true)
  2384. .catch(() => true),
  2385. ])) {
  2386. map.delete(node);
  2387. return false;
  2388. }
  2389. return true;
  2390. });
  2391. }
  2392. function handle(_response, property, node) {
  2393. return __awaiter(this, void 0, void 0, function* () {
  2394. if (yield isOutdated(_response, maps[property], node)) {
  2395. return;
  2396. }
  2397. const response = yield _response;
  2398. if (typeof response !== 'object') {
  2399. return;
  2400. }
  2401. if ('hide' in response && typeof response.hide === 'object') {
  2402. for (const [id, doHide] of Object.entries(response.hide)) {
  2403. if (typeof doHide === 'boolean') {
  2404. (0,_hide__WEBPACK_IMPORTED_MODULE_0__["default"])(node, id, doHide);
  2405. }
  2406. }
  2407. }
  2408. });
  2409. }
  2410. function trigger(node, property) {
  2411. if (property in node) {
  2412. handle(node[property](), property, node);
  2413. }
  2414. }
  2415. function triggerSub(ancestors) {
  2416. trigger(ancestors[0], 'onChildUpdate');
  2417. for (const ancestor of ancestors) {
  2418. trigger(ancestor, 'onDescendantUpdate');
  2419. }
  2420. }
  2421. function triggerAll(node) {
  2422. trigger(node, 'onUpdate');
  2423. triggerSub(node.getAncestors());
  2424. }
  2425.  
  2426.  
  2427. /***/ }),
  2428.  
  2429. /***/ "./ts/modal/body/nodes/actions/css.ts":
  2430. /*!********************************************!*\
  2431. !*** ./ts/modal/body/nodes/actions/css.ts ***!
  2432. \********************************************/
  2433. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2434.  
  2435. __webpack_require__.r(__webpack_exports__);
  2436. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2437. /* harmony export */ "default": () => (/* binding */ generate)
  2438. /* harmony export */ });
  2439. /* harmony import */ var _edit_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit/css */ "./ts/modal/body/nodes/actions/edit/css.ts");
  2440. /* harmony import */ var _highlight_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./highlight/css */ "./ts/modal/body/nodes/actions/highlight/css.ts");
  2441. /* harmony import */ var _focus_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./focus/css */ "./ts/modal/body/nodes/actions/focus/css.ts");
  2442. /* harmony import */ var _overlays_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./overlays/css */ "./ts/modal/body/nodes/actions/overlays/css.ts");
  2443. /* harmony import */ var _buttons_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./buttons/css */ "./ts/modal/body/nodes/actions/buttons/css.ts");
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449. function generate() {
  2450. (0,_edit_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  2451. (0,_highlight_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  2452. (0,_focus_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  2453. (0,_overlays_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  2454. (0,_buttons_css__WEBPACK_IMPORTED_MODULE_4__["default"])();
  2455. }
  2456.  
  2457.  
  2458. /***/ }),
  2459.  
  2460. /***/ "./ts/modal/body/nodes/actions/edit/consts.ts":
  2461. /*!****************************************************!*\
  2462. !*** ./ts/modal/body/nodes/actions/edit/consts.ts ***!
  2463. \****************************************************/
  2464. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2465.  
  2466. __webpack_require__.r(__webpack_exports__);
  2467. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2468. /* harmony export */ ACTIVE_CLASS: () => (/* binding */ ACTIVE_CLASS),
  2469. /* harmony export */ INVALID_BACKGROUND_CLASS: () => (/* binding */ INVALID_BACKGROUND_CLASS),
  2470. /* harmony export */ INVALID_CLASS: () => (/* binding */ INVALID_CLASS),
  2471. /* harmony export */ VALID_BACKGROUND_CLASS: () => (/* binding */ VALID_BACKGROUND_CLASS),
  2472. /* harmony export */ VALID_CLASS: () => (/* binding */ VALID_CLASS)
  2473. /* harmony export */ });
  2474. const ACTIVE_CLASS = 'edit-active';
  2475. const VALID_CLASS = 'edit-valid';
  2476. const INVALID_CLASS = 'edit-invalid';
  2477. const VALID_BACKGROUND_CLASS = 'background-valid';
  2478. const INVALID_BACKGROUND_CLASS = 'background-invalid';
  2479.  
  2480.  
  2481. /***/ }),
  2482.  
  2483. /***/ "./ts/modal/body/nodes/actions/edit/css.ts":
  2484. /*!*************************************************!*\
  2485. !*** ./ts/modal/body/nodes/actions/edit/css.ts ***!
  2486. \*************************************************/
  2487. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2488.  
  2489. __webpack_require__.r(__webpack_exports__);
  2490. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2491. /* harmony export */ "default": () => (/* binding */ generate)
  2492. /* harmony export */ });
  2493. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2494. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2495. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2496.  
  2497.  
  2498.  
  2499. function generate() {
  2500. // Use pointer when the node has a value and isn't being edited
  2501. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.EDITABLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['cursor', 'pointer']);
  2502. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['pointer-events', 'none']);
  2503. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}`, [
  2504. ['flex-grow', '1'],
  2505. ['outline', 'none'],
  2506. ['min-width', '0'],
  2507. ]);
  2508. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="checkbox"]`, [
  2509. ['min-height', '1em'],
  2510. ['min-width', '1em'],
  2511. ]);
  2512. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.VALUE}[type="color"]`, [
  2513. ['height', '1.3em'],
  2514. ['cursor', 'pointer'],
  2515. ]);
  2516. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, ['background-color', 'var(--validBackground)']);
  2517. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`, ['background-color', 'var(--invalidBackground)']);
  2518. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`], [
  2519. ['transition-property', 'width, padding-left'],
  2520. ['transition-duration', '500ms'],
  2521. ['right', '0'],
  2522. ['width', '0'],
  2523. ['padding-left', '0'],
  2524. ]);
  2525. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2526. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2527. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_1__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2528. ], ['width', '100%']);
  2529. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  2530. `.${_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.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS}`,
  2531. `.${_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.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS}`,
  2532. ], ['padding-left', '0.8em']);
  2533. }
  2534.  
  2535.  
  2536. /***/ }),
  2537.  
  2538. /***/ "./ts/modal/body/nodes/actions/edit/index.ts":
  2539. /*!***************************************************!*\
  2540. !*** ./ts/modal/body/nodes/actions/edit/index.ts ***!
  2541. \***************************************************/
  2542. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2543.  
  2544. __webpack_require__.r(__webpack_exports__);
  2545. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2546. /* harmony export */ doAction: () => (/* binding */ doAction),
  2547. /* harmony export */ isActive: () => (/* binding */ isActive),
  2548. /* harmony export */ mount: () => (/* binding */ mount),
  2549. /* harmony export */ reset: () => (/* binding */ reset),
  2550. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2551. /* harmony export */ unmount: () => (/* binding */ unmount),
  2552. /* harmony export */ update: () => (/* binding */ update)
  2553. /* harmony export */ });
  2554. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/edit/consts.ts");
  2555. /* harmony import */ var _history__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../history */ "./ts/modal/body/nodes/actions/history.ts");
  2556. /* harmony import */ var _overlays__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../overlays */ "./ts/modal/body/nodes/actions/overlays/index.ts");
  2557. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2558. /* harmony import */ var _callbacks__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../callbacks */ "./ts/modal/body/nodes/actions/callbacks/index.ts");
  2559. /* harmony import */ var _overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../overlays/tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  2560. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../consts */ "./ts/modal/body/nodes/consts.ts");
  2561. /* harmony import */ var _predicate__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/predicate */ "./ts/predicate.ts");
  2562. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  2563. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2564. return new (P || (P = Promise))(function (resolve, reject) {
  2565. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2566. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2567. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2568. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2569. });
  2570. };
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579. let activeNode;
  2580. let priorValue;
  2581. function isActive() {
  2582. return Boolean(activeNode);
  2583. }
  2584. function addInputListeners(node = activeNode) {
  2585. const { headContainer, contrast: { valueElement } } = node.element;
  2586. if ('listeners' in node) {
  2587. for (const [event, callback] of Object.entries(node.listeners)) {
  2588. valueElement.addEventListener(event, callback);
  2589. }
  2590. }
  2591. if (typeof node.value === 'boolean') {
  2592. valueElement.addEventListener('click', (event) => {
  2593. event.stopPropagation();
  2594. update();
  2595. });
  2596. }
  2597. else {
  2598. valueElement.addEventListener('input', (event) => {
  2599. event.stopPropagation();
  2600. update();
  2601. });
  2602. }
  2603. valueElement.addEventListener('focusin', (event) => {
  2604. event.stopPropagation();
  2605. if (event.relatedTarget) {
  2606. doAction(node);
  2607. }
  2608. });
  2609. valueElement.addEventListener('blur', (event) => {
  2610. event.stopPropagation();
  2611. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2612. valueElement.focus();
  2613. return;
  2614. }
  2615. reset();
  2616. });
  2617. valueElement.addEventListener('keydown', (event) => {
  2618. switch (event.key) {
  2619. // see socket keydown listener in history
  2620. case 'z':
  2621. case 'Z':
  2622. case 'y':
  2623. case 'Y':
  2624. if (event.ctrlKey && !event.shiftKey) {
  2625. event.stopPropagation();
  2626. }
  2627. return;
  2628. case 'Enter':
  2629. case 'Escape':
  2630. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2631. event.preventDefault();
  2632. }
  2633. else {
  2634. headContainer.focus();
  2635. }
  2636. // eslint-disable-next-line no-fallthrough
  2637. case 'Undo':
  2638. case 'Redo':
  2639. // see socket keydown listener in highlight
  2640. // eslint-disable-next-line no-fallthrough
  2641. case 'Home':
  2642. case 'End':
  2643. case 'Backspace':
  2644. event.stopPropagation();
  2645. }
  2646. });
  2647. }
  2648. function clearUndoStack() {
  2649. const elements = activeNode.element.contrast;
  2650. const copy = elements.valueElement.cloneNode(true);
  2651. elements.valueElement.replaceWith(copy);
  2652. elements.valueElement = copy;
  2653. addInputListeners();
  2654. }
  2655. function setValue(node, value) {
  2656. node.value = value;
  2657. node.element.render(value);
  2658. _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].update.triggerAll(node);
  2659. }
  2660. function reset() {
  2661. if (!activeNode) {
  2662. return;
  2663. }
  2664. const { element } = activeNode;
  2665. clearUndoStack();
  2666. if (priorValue === activeNode.lastAcceptedValue) {
  2667. activeNode.value = activeNode.lastAcceptedValue;
  2668. activeNode.element.render(activeNode.lastAcceptedValue);
  2669. }
  2670. else {
  2671. _history__WEBPACK_IMPORTED_MODULE_1__.register(activeNode, setValue.bind(null, activeNode, priorValue), setValue.bind(null, activeNode, activeNode.lastAcceptedValue));
  2672. }
  2673. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2674. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2675. element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2676. _overlays__WEBPACK_IMPORTED_MODULE_2__.reset();
  2677. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2678. activeNode = undefined;
  2679. priorValue = undefined;
  2680. }
  2681. function getValue(node) {
  2682. switch (typeof node.value) {
  2683. case 'boolean':
  2684. return Boolean(node.element.contrast.valueElement.checked);
  2685. case 'number':
  2686. return Number(node.element.contrast.valueElement.value);
  2687. default:
  2688. return node.element.contrast.valueElement.value;
  2689. }
  2690. }
  2691. function update() {
  2692. return __awaiter(this, void 0, void 0, function* () {
  2693. const value = getValue(activeNode);
  2694. activeNode.value = value;
  2695. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2696. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2697. _overlays__WEBPACK_IMPORTED_MODULE_2__.update();
  2698. try {
  2699. if (!(yield _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].predicate.getAll(activeNode))) {
  2700. return;
  2701. }
  2702. }
  2703. catch (reason) {
  2704. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_CLASS);
  2705. if (reason) {
  2706. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2707. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(reason, activeNode);
  2708. }
  2709. return;
  2710. }
  2711. activeNode.lastAcceptedValue = value;
  2712. activeNode.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2713. _overlays__WEBPACK_IMPORTED_MODULE_2__.hideTooltip();
  2714. _callbacks__WEBPACK_IMPORTED_MODULE_4__["default"].update.triggerAll(activeNode);
  2715. });
  2716. }
  2717. function unmount(node) {
  2718. if (node === activeNode) {
  2719. reset();
  2720. }
  2721. }
  2722. function doAction(node) {
  2723. if ((0,_predicate__WEBPACK_IMPORTED_MODULE_7__.isUnresolved)()) {
  2724. _overlays__WEBPACK_IMPORTED_MODULE_2__.showTooltip(_overlays_tooltip_consts__WEBPACK_IMPORTED_MODULE_5__.MESSAGE_UNRESOLVED, node, node.element.contrast.valueContainer);
  2725. node.element.headContainer.focus();
  2726. return;
  2727. }
  2728. reset();
  2729. _overlays__WEBPACK_IMPORTED_MODULE_2__.tooltip.kill();
  2730. activeNode = node;
  2731. priorValue = node.value;
  2732. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTIVE_CLASS);
  2733. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_CLASS);
  2734. _overlays__WEBPACK_IMPORTED_MODULE_2__.setNode(node);
  2735. if (node.input === 'color') {
  2736. node.element.contrast.valueElement.click();
  2737. }
  2738. else if (typeof node.value !== 'boolean') {
  2739. const input = node.element.contrast.valueElement;
  2740. input.select();
  2741. input.scrollLeft = input.scrollWidth;
  2742. }
  2743. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2744. }
  2745. function mount(node) {
  2746. const { backgroundContainer, contrast, headContainer } = node.element;
  2747. node.lastAcceptedValue = node.value;
  2748. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_6__.EDITABLE_CLASS);
  2749. backgroundContainer.append(...(() => {
  2750. const valid = document.createElement('div');
  2751. const invalid = document.createElement('div');
  2752. valid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.VALID_BACKGROUND_CLASS);
  2753. invalid.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.INVALID_BACKGROUND_CLASS);
  2754. return [valid, invalid];
  2755. })());
  2756. // Start
  2757. headContainer.addEventListener('click', (event) => {
  2758. event.stopPropagation();
  2759. contrast.valueElement.focus();
  2760. });
  2761. // Process new value
  2762. if (typeof node.value === 'boolean') {
  2763. headContainer.addEventListener('mousedown', (event) => {
  2764. event.stopPropagation();
  2765. event.preventDefault();
  2766. });
  2767. headContainer.addEventListener('click', () => {
  2768. contrast.valueElement.checked = !contrast.valueElement.checked;
  2769. update();
  2770. });
  2771. contrast.valueContainer.addEventListener('click', (event) => {
  2772. event.stopPropagation();
  2773. });
  2774. }
  2775. addInputListeners(node);
  2776. }
  2777. function shouldMount(node) {
  2778. return 'value' in node;
  2779. }
  2780.  
  2781.  
  2782. /***/ }),
  2783.  
  2784. /***/ "./ts/modal/body/nodes/actions/focus/consts.ts":
  2785. /*!*****************************************************!*\
  2786. !*** ./ts/modal/body/nodes/actions/focus/consts.ts ***!
  2787. \*****************************************************/
  2788. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2789.  
  2790. __webpack_require__.r(__webpack_exports__);
  2791. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2792. /* harmony export */ BACKGROUND_CLASS: () => (/* binding */ BACKGROUND_CLASS),
  2793. /* harmony export */ FOCUS_CLASS: () => (/* binding */ FOCUS_CLASS),
  2794. /* harmony export */ FOCUS_SOURCE_CLASS: () => (/* binding */ FOCUS_SOURCE_CLASS)
  2795. /* harmony export */ });
  2796. const FOCUS_CLASS = 'node-focus';
  2797. const FOCUS_SOURCE_CLASS = 'node-focus-source';
  2798. const BACKGROUND_CLASS = 'background-focus';
  2799.  
  2800.  
  2801. /***/ }),
  2802.  
  2803. /***/ "./ts/modal/body/nodes/actions/focus/css.ts":
  2804. /*!**************************************************!*\
  2805. !*** ./ts/modal/body/nodes/actions/focus/css.ts ***!
  2806. \**************************************************/
  2807. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2808.  
  2809. __webpack_require__.r(__webpack_exports__);
  2810. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2811. /* harmony export */ "default": () => (/* binding */ generate)
  2812. /* harmony export */ });
  2813. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2814. /* harmony import */ var _highlight_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../highlight/consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  2815. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  2816. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  2817.  
  2818.  
  2819.  
  2820.  
  2821. function generate() {
  2822. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['cursor', 'zoom-in']);
  2823. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}`, ['cursor', 'zoom-out']);
  2824. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS}):not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.CHILD_CONTAINER} > *)`, ['display', 'none']);
  2825. // Makes it easy to focus down the tree
  2826. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.MIDDLE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [['margin-left', '1.8em']]);
  2827. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['background-color', 'var(--focusBackground)']);
  2828. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, [
  2829. ['transition-property', 'width, padding-left'],
  2830. ['transition-duration', '500ms'],
  2831. ['right', '0'],
  2832. ['width', '0'],
  2833. ['padding-left', '0'],
  2834. ]);
  2835. const headSelector = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS}:not(:hover:not(:has(> .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.CHILD_CONTAINER}:hover))) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}:not(.${_highlight_consts__WEBPACK_IMPORTED_MODULE_1__.TAB_CLASS} :focus):not(:hover)`;
  2836. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['width', '100%']);
  2837. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS}`, ['padding-left', '0.8em']);
  2838. }
  2839.  
  2840.  
  2841. /***/ }),
  2842.  
  2843. /***/ "./ts/modal/body/nodes/actions/focus/index.ts":
  2844. /*!****************************************************!*\
  2845. !*** ./ts/modal/body/nodes/actions/focus/index.ts ***!
  2846. \****************************************************/
  2847. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2848.  
  2849. __webpack_require__.r(__webpack_exports__);
  2850. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  2851. /* harmony export */ doAction: () => (/* binding */ doAction),
  2852. /* harmony export */ focus: () => (/* binding */ focus),
  2853. /* harmony export */ focusBranch: () => (/* binding */ focusBranch),
  2854. /* harmony export */ isActive: () => (/* binding */ isActive),
  2855. /* harmony export */ mount: () => (/* binding */ mount),
  2856. /* harmony export */ reset: () => (/* binding */ reset),
  2857. /* harmony export */ setTabIndexes: () => (/* binding */ setTabIndexes),
  2858. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  2859. /* harmony export */ unmount: () => (/* binding */ unmount)
  2860. /* harmony export */ });
  2861. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  2862. /* harmony import */ var _overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../overlays/tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  2863. /* harmony import */ var _buttons_position__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  2864. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  2865. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871. let candidateNode;
  2872. let activeNode;
  2873. function isActive() {
  2874. return Boolean(activeNode);
  2875. }
  2876. function setTabIndexes(doAdd = true, node = activeNode) {
  2877. const { 'buttonContainer': { 'children': buttons }, contrast: { valueElement } } = node.element;
  2878. for (let i = buttons.length - 1; i >= 0; --i) {
  2879. buttons[i].setAttribute('tabindex', doAdd ? '0' : '-1');
  2880. }
  2881. if (valueElement) {
  2882. valueElement.setAttribute('tabindex', doAdd ? '0' : '-1');
  2883. }
  2884. }
  2885. function focus(doFocus = true, node = activeNode, doForce = true) {
  2886. // Avoid unfocusing the active node if not forced
  2887. if (doForce || node !== activeNode) {
  2888. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_SOURCE_CLASS);
  2889. }
  2890. if (!('children' in node)) {
  2891. return;
  2892. }
  2893. }
  2894. function focusBranch(doFocus = true, node = activeNode, focusAncestors = true) {
  2895. node.element[`${doFocus ? 'add' : 'remove'}Class`](_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS);
  2896. if (focusAncestors && 'parent' in node) {
  2897. focusBranch(doFocus, node.parent);
  2898. }
  2899. }
  2900. function reset(doScroll = true) {
  2901. if (!activeNode) {
  2902. return;
  2903. }
  2904. focus(false);
  2905. focusBranch(false);
  2906. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.removeSustained)(activeNode);
  2907. setTabIndexes(false);
  2908. if (doScroll) {
  2909. (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.stickyScroll)(activeNode);
  2910. }
  2911. activeNode = undefined;
  2912. }
  2913. function doAction(node, doForce = false) {
  2914. const toggleOn = node !== activeNode;
  2915. (0,_overlays_tooltip__WEBPACK_IMPORTED_MODULE_1__.kill)();
  2916. if ((0,_buttons_position__WEBPACK_IMPORTED_MODULE_2__.isActive)() || (doForce && !toggleOn)) {
  2917. return;
  2918. }
  2919. reset(!toggleOn);
  2920. if (toggleOn) {
  2921. activeNode = node;
  2922. node.element.headContainer.focus();
  2923. focus();
  2924. focusBranch();
  2925. node.element.scrollIntoView(false);
  2926. (0,_highlight__WEBPACK_IMPORTED_MODULE_3__.addSustained)(node);
  2927. setTabIndexes();
  2928. }
  2929. }
  2930. function unmount(node) {
  2931. if (node === activeNode) {
  2932. reset();
  2933. }
  2934. }
  2935. function mount(node) {
  2936. const { elementContainer, headContainer, backgroundContainer } = node.element;
  2937. backgroundContainer.append((() => {
  2938. const background = document.createElement('div');
  2939. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BACKGROUND_CLASS);
  2940. return background;
  2941. })());
  2942. // Handle keyboard input
  2943. elementContainer.addEventListener('keydown', (event) => {
  2944. if (event.key === 'Enter') {
  2945. event.stopPropagation();
  2946. doAction(node);
  2947. }
  2948. });
  2949. // Handle side click
  2950. elementContainer.addEventListener('mousedown', (event) => {
  2951. event.stopPropagation();
  2952. candidateNode = node;
  2953. });
  2954. elementContainer.addEventListener('mouseup', (event) => {
  2955. event.stopPropagation();
  2956. if (node === candidateNode) {
  2957. doAction(node);
  2958. }
  2959. candidateNode = undefined;
  2960. });
  2961. if ('value' in node) {
  2962. headContainer.addEventListener('mousedown', (event) => {
  2963. event.stopPropagation();
  2964. candidateNode = undefined;
  2965. });
  2966. headContainer.addEventListener('mouseup', (event) => {
  2967. event.stopPropagation();
  2968. candidateNode = undefined;
  2969. });
  2970. return;
  2971. }
  2972. // Handle head click
  2973. headContainer.addEventListener('mousedown', (event) => {
  2974. event.stopPropagation();
  2975. candidateNode = node;
  2976. });
  2977. headContainer.addEventListener('mouseup', (event) => {
  2978. event.stopPropagation();
  2979. if (node === candidateNode && headContainer.isSameNode(event.target)) {
  2980. doAction(node);
  2981. }
  2982. candidateNode = undefined;
  2983. });
  2984. }
  2985. function shouldMount() {
  2986. return true;
  2987. }
  2988.  
  2989.  
  2990. /***/ }),
  2991.  
  2992. /***/ "./ts/modal/body/nodes/actions/hide/consts.ts":
  2993. /*!****************************************************!*\
  2994. !*** ./ts/modal/body/nodes/actions/hide/consts.ts ***!
  2995. \****************************************************/
  2996. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  2997.  
  2998. __webpack_require__.r(__webpack_exports__);
  2999. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3000. /* harmony export */ CLASS_PREFIX_READ: () => (/* binding */ CLASS_PREFIX_READ),
  3001. /* harmony export */ CLASS_PREFIX_WRITE: () => (/* binding */ CLASS_PREFIX_WRITE)
  3002. /* harmony export */ });
  3003. const CLASS_PREFIX_WRITE = 'node-hide-write-';
  3004. const CLASS_PREFIX_READ = 'node-hide-read-';
  3005.  
  3006.  
  3007. /***/ }),
  3008.  
  3009. /***/ "./ts/modal/body/nodes/actions/hide/index.ts":
  3010. /*!***************************************************!*\
  3011. !*** ./ts/modal/body/nodes/actions/hide/index.ts ***!
  3012. \***************************************************/
  3013. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3014.  
  3015. __webpack_require__.r(__webpack_exports__);
  3016. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3017. /* harmony export */ "default": () => (/* binding */ hide),
  3018. /* harmony export */ mount: () => (/* binding */ mount),
  3019. /* harmony export */ shouldMount: () => (/* binding */ shouldMount)
  3020. /* harmony export */ });
  3021. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/hide/consts.ts");
  3022. /* harmony import */ var _nodes_pools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/pools */ "./ts/modal/body/nodes/pools.ts");
  3023. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3024.  
  3025.  
  3026.  
  3027. const ids = [];
  3028. function setWriteClass(node, id, doHide) {
  3029. node.element[`${doHide ? 'add' : 'remove'}Class`](`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${id}`);
  3030. }
  3031. function hide(node, id, doHide = true) {
  3032. if (!('parent' in node) || 'seed' in node.parent) {
  3033. setWriteClass(node, id, doHide);
  3034. return;
  3035. }
  3036. for (const parent of (0,_nodes_pools__WEBPACK_IMPORTED_MODULE_1__.get)(node.parent)) {
  3037. hide(parent, id, doHide);
  3038. }
  3039. }
  3040. function mount(node) {
  3041. node.element.addClass(`${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`);
  3042. if (!ids[node.hideId]) {
  3043. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_WRITE}${node.hideId} .${_consts__WEBPACK_IMPORTED_MODULE_0__.CLASS_PREFIX_READ}${node.hideId}`, ['display', 'none']);
  3044. ids[node.hideId] = true;
  3045. }
  3046. }
  3047. function shouldMount(node) {
  3048. return 'hideId' in node;
  3049. }
  3050.  
  3051.  
  3052. /***/ }),
  3053.  
  3054. /***/ "./ts/modal/body/nodes/actions/highlight/consts.ts":
  3055. /*!*********************************************************!*\
  3056. !*** ./ts/modal/body/nodes/actions/highlight/consts.ts ***!
  3057. \*********************************************************/
  3058. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3059.  
  3060. __webpack_require__.r(__webpack_exports__);
  3061. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3062. /* harmony export */ EAVE_ID: () => (/* binding */ EAVE_ID),
  3063. /* harmony export */ HIGHLIGHT_BACKGROUND_CLASS: () => (/* binding */ HIGHLIGHT_BACKGROUND_CLASS),
  3064. /* harmony export */ HIGHLIGHT_CLASS: () => (/* binding */ HIGHLIGHT_CLASS),
  3065. /* harmony export */ TAB_CLASS: () => (/* binding */ TAB_CLASS)
  3066. /* harmony export */ });
  3067. const HIGHLIGHT_CLASS = 'highlight';
  3068. const HIGHLIGHT_BACKGROUND_CLASS = 'background-highlight';
  3069. const TAB_CLASS = 'tab-naving';
  3070. const EAVE_ID = 'tree-eave';
  3071.  
  3072.  
  3073. /***/ }),
  3074.  
  3075. /***/ "./ts/modal/body/nodes/actions/highlight/css.ts":
  3076. /*!******************************************************!*\
  3077. !*** ./ts/modal/body/nodes/actions/highlight/css.ts ***!
  3078. \******************************************************/
  3079. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3080.  
  3081. __webpack_require__.r(__webpack_exports__);
  3082. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3083. /* harmony export */ "default": () => (/* binding */ generate)
  3084. /* harmony export */ });
  3085. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3086. /* harmony import */ var _buttons_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  3087. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3088. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3089.  
  3090.  
  3091.  
  3092.  
  3093. function generate() {
  3094. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  3095. ['padding-right', '0.4em'],
  3096. // Extend the background further into the value
  3097. ['padding-left', '4em'],
  3098. ]);
  3099. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}:last-child`, [
  3100. ['border-top-right-radius', '0.8em'],
  3101. ['border-bottom-right-radius', '0.8em'],
  3102. ]);
  3103. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3104. ['transition-property', 'width'],
  3105. ['transition-duration', '500ms'],
  3106. ['overflow', 'hidden'],
  3107. ['right', '0'],
  3108. ]);
  3109. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3110. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3111. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3112. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`,
  3113. ], [['width', '0']]);
  3114. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [['margin-left', '-0.8em']]);
  3115. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3116. ['transition-property', 'width, padding-left'],
  3117. ['transition-duration', '500ms'],
  3118. ['width', '100%'],
  3119. ]);
  3120. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty):not(.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} *):not(.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} *) + * .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [['width', '0']]);
  3121. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([
  3122. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3123. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_ADD_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3124. `.${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.TEST_REMOVE_CLASS} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.BUTTON_CONTAINER}:not(:empty) + * .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`,
  3125. ], [['padding-left', '0.8em']]);
  3126. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, [
  3127. ['height', '100%'],
  3128. ['width', '100%'],
  3129. ['padding-left', '0'],
  3130. ]);
  3131. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['position', 'relative']);
  3132. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}:focus::after`, [
  3133. ['content', '\'\''],
  3134. ['position', 'absolute'],
  3135. ['right', '0'],
  3136. ['height', '100%'],
  3137. ['width', '4px'],
  3138. ]);
  3139. for (const [selector, base, contrast] of _nodes_consts__WEBPACK_IMPORTED_MODULE_2__.NODE_COLOURS) {
  3140. const headSelector = `${selector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.HEAD_CONTAINER}`;
  3141. // focus indicator
  3142. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS})${headSelector}:focus::after`, ['background-color', contrast]);
  3143. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS}`, ['background-color', contrast]);
  3144. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_buttons_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_CLASS}`, ['background-color', contrast]);
  3145. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS}`], [
  3146. ['color', contrast],
  3147. ['background-color', base],
  3148. ]);
  3149. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)([`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS}`], ['color', base]);
  3150. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.BASE_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['background-image', `linear-gradient(to right, transparent, 1.9em, ${base} 3.8em)`]);
  3151. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${headSelector} .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.CONTRAST_CLASS} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_2__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['background-image', `linear-gradient(to right, transparent, 1.9em, ${contrast} 3.8em)`]);
  3152. }
  3153. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID}`, [
  3154. ['position', 'absolute'],
  3155. ['bottom', '0'],
  3156. ['width', '100%'],
  3157. // Prevents zipping to the end of the tree when mousing over the bottom pixel
  3158. ['height', '1px'],
  3159. ['z-index', 'var(--overlayIndex)'],
  3160. ]);
  3161. }
  3162.  
  3163.  
  3164. /***/ }),
  3165.  
  3166. /***/ "./ts/modal/body/nodes/actions/highlight/index.ts":
  3167. /*!********************************************************!*\
  3168. !*** ./ts/modal/body/nodes/actions/highlight/index.ts ***!
  3169. \********************************************************/
  3170. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3171.  
  3172. __webpack_require__.r(__webpack_exports__);
  3173. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3174. /* harmony export */ addSustained: () => (/* binding */ addSustained),
  3175. /* harmony export */ generateEave: () => (/* binding */ generateEave),
  3176. /* harmony export */ isActive: () => (/* binding */ isActive),
  3177. /* harmony export */ mount: () => (/* binding */ mount),
  3178. /* harmony export */ onMount: () => (/* binding */ onMount),
  3179. /* harmony export */ removeSustained: () => (/* binding */ removeSustained),
  3180. /* harmony export */ reset: () => (/* binding */ reset),
  3181. /* harmony export */ setActive: () => (/* binding */ setActive),
  3182. /* harmony export */ shouldMount: () => (/* binding */ shouldMount),
  3183. /* harmony export */ unmount: () => (/* binding */ unmount)
  3184. /* harmony export */ });
  3185. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/highlight/consts.ts");
  3186. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3187. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3188. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3189. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3190. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197. let sustainedNodes = [];
  3198. let activeNode;
  3199. function isActive() {
  3200. return Boolean(activeNode);
  3201. }
  3202. function removeSustained(node) {
  3203. sustainedNodes.splice(sustainedNodes.indexOf(node), 1);
  3204. // Avoid unhighlighting if it's still sustained by another action
  3205. if (node !== activeNode && !sustainedNodes.includes(node)) {
  3206. node.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3207. }
  3208. }
  3209. function addSustained(node) {
  3210. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3211. sustainedNodes.push(node);
  3212. }
  3213. function setActive(node, doFocus = false) {
  3214. if (activeNode && !sustainedNodes.includes(activeNode)) {
  3215. activeNode.element.removeClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3216. }
  3217. activeNode = node;
  3218. if (!node) {
  3219. return;
  3220. }
  3221. node.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_CLASS);
  3222. if (doFocus) {
  3223. node.element.headContainer.focus();
  3224. // focus listeners don't seem to trigger if the document isn't focused
  3225. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)() && !document.hasFocus()) {
  3226. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, false);
  3227. }
  3228. }
  3229. }
  3230. function unmount(node) {
  3231. if (node === activeNode) {
  3232. node.element.headContainer.blur();
  3233. }
  3234. }
  3235. let isTab = false;
  3236. let isListening = false;
  3237. function setTab(value = true) {
  3238. isTab = value;
  3239. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.classList[isTab ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.TAB_CLASS);
  3240. }
  3241. function mount(node) {
  3242. const { backgroundContainer, headContainer, elementContainer, infoContainer, base } = node.element;
  3243. if (base.valueContainer) {
  3244. (new ResizeObserver(() => {
  3245. if (infoContainer.clientWidth > 0) {
  3246. base.valueContainer.style.setProperty('width', `${infoContainer.clientWidth}px`);
  3247. }
  3248. })).observe(infoContainer);
  3249. }
  3250. backgroundContainer.appendChild((() => {
  3251. const background = document.createElement('div');
  3252. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.HIGHLIGHT_BACKGROUND_CLASS);
  3253. return background;
  3254. })());
  3255. headContainer.setAttribute('tabindex', '0');
  3256. headContainer.addEventListener('focusin', (event) => {
  3257. event.stopPropagation();
  3258. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  3259. (0,_scroll__WEBPACK_IMPORTED_MODULE_2__.stickyScroll)(node, false, isTab);
  3260. }
  3261. else if (isTab) {
  3262. node.element.scrollIntoView({ block: 'center', behavior: 'smooth' });
  3263. }
  3264. if (isTab && !isListening) {
  3265. isListening = true;
  3266. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)().addEventListener('mousemove', () => {
  3267. setTab(false);
  3268. isListening = false;
  3269. }, { capture: true, once: true });
  3270. }
  3271. // Filters out events fired from re-focusing the window
  3272. if (event.relatedTarget) {
  3273. setActive(node);
  3274. }
  3275. });
  3276. headContainer.addEventListener('mouseover', (event) => {
  3277. event.stopPropagation();
  3278. if (!isTab) {
  3279. setActive(node, !(0,_edit__WEBPACK_IMPORTED_MODULE_1__.isActive)());
  3280. }
  3281. });
  3282. elementContainer.addEventListener('mouseover', (event) => {
  3283. event.stopPropagation();
  3284. if (!isTab) {
  3285. setActive(node);
  3286. }
  3287. });
  3288. elementContainer.addEventListener('mouseout', (event) => {
  3289. event.stopPropagation();
  3290. if (!isTab) {
  3291. setActive();
  3292. }
  3293. });
  3294. }
  3295. function shouldMount() {
  3296. return true;
  3297. }
  3298. function setEdge(element, isStart) {
  3299. element.setAttribute('tabindex', '0');
  3300. // Prevent tabbing away from the modal
  3301. element.addEventListener('keydown', (event) => {
  3302. if (event.key === 'Tab' && (event.shiftKey === isStart) && element.isSameNode(event.target)) {
  3303. event.preventDefault();
  3304. }
  3305. });
  3306. element.addEventListener('focusin', () => {
  3307. setActive();
  3308. });
  3309. }
  3310. function generateEave(socket) {
  3311. const element = document.createElement('div');
  3312. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.EAVE_ID;
  3313. setEdge(socket, true);
  3314. setEdge(element, false);
  3315. socket.addEventListener('keydown', (event) => {
  3316. switch (event.key) {
  3317. case 'Home':
  3318. socket.focus();
  3319. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  3320. break;
  3321. case 'End':
  3322. element.focus();
  3323. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollHeight;
  3324. break;
  3325. case 'Backspace':
  3326. setActive();
  3327. break;
  3328. default:
  3329. return;
  3330. }
  3331. event.preventDefault();
  3332. });
  3333. return element;
  3334. }
  3335. // Blur focused node & reset focus index
  3336. function reset() {
  3337. setActive();
  3338. }
  3339. function onMount() {
  3340. const socket = (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getSocket)();
  3341. socket.setAttribute('tabindex', '0');
  3342. // Prevent tabbing away from the modal
  3343. socket.addEventListener('keydown', (event) => {
  3344. if (event.key !== 'Tab') {
  3345. return;
  3346. }
  3347. setTab();
  3348. if (event.shiftKey && socket.isSameNode(event.target)) {
  3349. event.preventDefault();
  3350. }
  3351. });
  3352. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getWindow)().addEventListener('blur', () => {
  3353. setActive();
  3354. });
  3355. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.addEventListener('wheel', () => {
  3356. setActive();
  3357. });
  3358. }
  3359.  
  3360.  
  3361. /***/ }),
  3362.  
  3363. /***/ "./ts/modal/body/nodes/actions/history.ts":
  3364. /*!************************************************!*\
  3365. !*** ./ts/modal/body/nodes/actions/history.ts ***!
  3366. \************************************************/
  3367. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3368.  
  3369. __webpack_require__.r(__webpack_exports__);
  3370. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3371. /* harmony export */ onMount: () => (/* binding */ onMount),
  3372. /* harmony export */ register: () => (/* binding */ register)
  3373. /* harmony export */ });
  3374. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3375. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  3376. /* harmony import */ var _highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  3377. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3378. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3379. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  3380.  
  3381.  
  3382.  
  3383.  
  3384.  
  3385.  
  3386. const undoStack = [];
  3387. const redoStack = [];
  3388. function register(target, undo, redo, doAct = true, isUndoDeletion = false, isRedoDeletion = false) {
  3389. if (doAct) {
  3390. redo();
  3391. }
  3392. redoStack.length = 0;
  3393. undoStack.push({ target, undo: { act: undo, isDeletion: isUndoDeletion }, redo: { act: redo, isDeletion: isRedoDeletion } });
  3394. }
  3395. function show(node) {
  3396. const target = node.element.headContainer;
  3397. if (!target.isSameNode((0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)().activeElement)) {
  3398. target.addEventListener('focusin', (event) => {
  3399. event.stopImmediatePropagation();
  3400. }, { capture: true, once: true });
  3401. }
  3402. target.focus({ preventScroll: true });
  3403. const targetRect = target.getBoundingClientRect();
  3404. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.getBoundingClientRect();
  3405. const top = (0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_4__.isActive)() ? (0,_scroll__WEBPACK_IMPORTED_MODULE_0__.getStickyScroll)(node) : (targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop);
  3406. if (top < _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3407. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: top });
  3408. return;
  3409. }
  3410. const bottom = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop + targetRect.height - _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.clientHeight;
  3411. if (bottom > _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTop) {
  3412. _modal_body__WEBPACK_IMPORTED_MODULE_3__.element.scrollTo({ top: bottom });
  3413. }
  3414. }
  3415. function act(from, to, property) {
  3416. if (from.length === 0) {
  3417. return;
  3418. }
  3419. const action = from.pop();
  3420. (0,_focus__WEBPACK_IMPORTED_MODULE_1__.reset)();
  3421. if (action[property].isDeletion) {
  3422. const index = action.target.getIndex();
  3423. const target = index === 0 ? action.target.parent : action.target.parent.children[index - 1];
  3424. action[property].act();
  3425. show(target);
  3426. }
  3427. else {
  3428. action[property].act();
  3429. (0,_highlight__WEBPACK_IMPORTED_MODULE_2__.setActive)(action.target);
  3430. show(action.target);
  3431. }
  3432. to.push(action);
  3433. }
  3434. function onMount() {
  3435. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getSocket)().addEventListener('keydown', (event) => {
  3436. if (event.key === 'Undo' || (event.key.toLowerCase() === 'z' && event.ctrlKey && !event.shiftKey)) {
  3437. act(undoStack, redoStack, 'undo');
  3438. }
  3439. else if (event.key === 'Redo' || (event.key.toLowerCase() === 'y' && event.ctrlKey && !event.shiftKey)) {
  3440. act(redoStack, undoStack, 'redo');
  3441. }
  3442. });
  3443. }
  3444.  
  3445.  
  3446. /***/ }),
  3447.  
  3448. /***/ "./ts/modal/body/nodes/actions/overlays/consts.ts":
  3449. /*!********************************************************!*\
  3450. !*** ./ts/modal/body/nodes/actions/overlays/consts.ts ***!
  3451. \********************************************************/
  3452. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3453.  
  3454. __webpack_require__.r(__webpack_exports__);
  3455. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3456. /* harmony export */ CONTAINER_CLASS: () => (/* binding */ CONTAINER_CLASS)
  3457. /* harmony export */ });
  3458. const CONTAINER_CLASS = 'overlay-container';
  3459.  
  3460.  
  3461. /***/ }),
  3462.  
  3463. /***/ "./ts/modal/body/nodes/actions/overlays/css.ts":
  3464. /*!*****************************************************!*\
  3465. !*** ./ts/modal/body/nodes/actions/overlays/css.ts ***!
  3466. \*****************************************************/
  3467. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3468.  
  3469. __webpack_require__.r(__webpack_exports__);
  3470. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3471. /* harmony export */ "default": () => (/* binding */ generate)
  3472. /* harmony export */ });
  3473. /* harmony import */ var _tooltip_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tooltip/css */ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts");
  3474. /* harmony import */ var _dropdown_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./dropdown/css */ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts");
  3475. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3476. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3477.  
  3478.  
  3479.  
  3480.  
  3481. function generate() {
  3482. (0,_tooltip_css__WEBPACK_IMPORTED_MODULE_0__["default"])();
  3483. (0,_dropdown_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  3484. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS}`, [
  3485. ['z-index', 'var(--overlayIndex)'],
  3486. ['position', 'absolute'],
  3487. ['top', '0'],
  3488. ['pointer-events', 'none'],
  3489. ]);
  3490. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > *`, [
  3491. ['position', 'absolute'],
  3492. ['width', 'inherit'],
  3493. ['display', 'flex'],
  3494. ['flex-direction', 'column'],
  3495. ['align-items', 'center'],
  3496. ]);
  3497. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_2__.CONTAINER_CLASS} > :empty`, ['display', 'none']);
  3498. }
  3499.  
  3500.  
  3501. /***/ }),
  3502.  
  3503. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts":
  3504. /*!*****************************************************************!*\
  3505. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts ***!
  3506. \*****************************************************************/
  3507. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3508.  
  3509. __webpack_require__.r(__webpack_exports__);
  3510. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3511. /* harmony export */ DROPDOWN_ACTIVE_CLASS: () => (/* binding */ DROPDOWN_ACTIVE_CLASS),
  3512. /* harmony export */ DROPDOWN_BACKGROUND_CLASS: () => (/* binding */ DROPDOWN_BACKGROUND_CLASS),
  3513. /* harmony export */ DROPDOWN_CLASS: () => (/* binding */ DROPDOWN_CLASS),
  3514. /* harmony export */ DROPDOWN_CONTAINER_CLASS: () => (/* binding */ DROPDOWN_CONTAINER_CLASS),
  3515. /* harmony export */ DROPDOWN_PARENT_CLASS: () => (/* binding */ DROPDOWN_PARENT_CLASS),
  3516. /* harmony export */ DROPDOWN_SHOW_CLASS: () => (/* binding */ DROPDOWN_SHOW_CLASS),
  3517. /* harmony export */ DROPDOWN_WRAPPER_CLASS: () => (/* binding */ DROPDOWN_WRAPPER_CLASS)
  3518. /* harmony export */ });
  3519. const DROPDOWN_CLASS = 'option';
  3520. const DROPDOWN_CONTAINER_CLASS = 'option-container';
  3521. const DROPDOWN_PARENT_CLASS = 'option-parent';
  3522. const DROPDOWN_WRAPPER_CLASS = 'option-wrapper';
  3523. const DROPDOWN_BACKGROUND_CLASS = 'option-background';
  3524. const DROPDOWN_SHOW_CLASS = 'option-show';
  3525. const DROPDOWN_ACTIVE_CLASS = 'option-active';
  3526.  
  3527.  
  3528. /***/ }),
  3529.  
  3530. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/css.ts":
  3531. /*!**************************************************************!*\
  3532. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/css.ts ***!
  3533. \**************************************************************/
  3534. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3535.  
  3536. __webpack_require__.r(__webpack_exports__);
  3537. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3538. /* harmony export */ "default": () => (/* binding */ generate)
  3539. /* harmony export */ });
  3540. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3541. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  3542. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  3543.  
  3544.  
  3545.  
  3546. function generate() {
  3547. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS}`, [
  3548. ['z-index', 'var(--overlayIndex)'],
  3549. ['position', 'sticky'],
  3550. ['display', 'flex'],
  3551. ['width', '100%'],
  3552. ['pointer-events', 'initial'],
  3553. ]);
  3554. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, [
  3555. ['position', 'absolute'],
  3556. ['display', 'flex'],
  3557. ['flex-direction', 'column'],
  3558. ['width', '100%'],
  3559. ['margin-left', '-1px'],
  3560. ['max-height', 'calc(4.2em + 5px)'],
  3561. ['overflow-y', 'auto'],
  3562. ['border-bottom-left-radius', '12px'],
  3563. ]);
  3564. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [['position', 'relative']]);
  3565. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS} > *`, [['height', '1.4em']]);
  3566. const [, base, contrast] = _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1];
  3567. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS}`, ['border', `1px solid ${base}`]);
  3568. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}`, [
  3569. ['background-color', contrast],
  3570. ['color', base],
  3571. ['border', `1px solid ${base}`],
  3572. ['cursor', 'pointer'],
  3573. ]);
  3574. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [['background-color', base]]);
  3575. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS}`, [['color', contrast]]);
  3576. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [['width', '100%']]);
  3577. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS}`, [
  3578. ['position', 'relative'],
  3579. ['transition-property', 'all'],
  3580. ['transition-duration', '500ms'],
  3581. ['padding', '0 0.6rem'],
  3582. ]);
  3583. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS}`, [
  3584. ['position', 'absolute'],
  3585. ['width', '0'],
  3586. ['transition', 'width 500ms ease 0s'],
  3587. ]);
  3588. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS})`, [['display', 'none']]);
  3589. }
  3590.  
  3591.  
  3592. /***/ }),
  3593.  
  3594. /***/ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts":
  3595. /*!****************************************************************!*\
  3596. !*** ./ts/modal/body/nodes/actions/overlays/dropdown/index.ts ***!
  3597. \****************************************************************/
  3598. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3599.  
  3600. __webpack_require__.r(__webpack_exports__);
  3601. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3602. /* harmony export */ generate: () => (/* binding */ generate),
  3603. /* harmony export */ reset: () => (/* binding */ reset),
  3604. /* harmony export */ update: () => (/* binding */ update)
  3605. /* harmony export */ });
  3606. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  3607. /* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  3608. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3609. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3610. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3611. return new (P || (P = Promise))(function (resolve, reject) {
  3612. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3613. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3614. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3615. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3616. });
  3617. };
  3618.  
  3619.  
  3620.  
  3621. const activeOptions = [];
  3622. const resetCallbacks = [];
  3623. let activeIndex = -1;
  3624. function getTop(target, includeHeight = true) {
  3625. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect();
  3626. const targetRect = target.getBoundingClientRect();
  3627. // todo this had a `+2` before; may be necessary
  3628. return targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + (includeHeight ? targetRect.height : 0);
  3629. }
  3630. // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping
  3631. function escapeRegExp(string) {
  3632. return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
  3633. }
  3634. function setActive(option, isActive = true) {
  3635. option.classList[isActive ? 'add' : 'remove'](_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_ACTIVE_CLASS);
  3636. }
  3637. function deselect() {
  3638. if (activeIndex === -1) {
  3639. return;
  3640. }
  3641. setActive(activeOptions[activeIndex].parentElement, false);
  3642. activeIndex = -1;
  3643. }
  3644. function update(value) {
  3645. // equivalent to `if (!('options' in node))`
  3646. if (activeOptions.length === 0) {
  3647. return;
  3648. }
  3649. const stringValue = `${value}`;
  3650. const regExp = new RegExp(escapeRegExp(stringValue), 'i');
  3651. for (const { parentElement, innerText } of activeOptions) {
  3652. if (stringValue.length <= innerText.length && regExp.test(innerText)) {
  3653. parentElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3654. }
  3655. else {
  3656. parentElement.classList.remove(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS);
  3657. }
  3658. }
  3659. const [{ parentElement: { parentElement: wrapper } }] = activeOptions;
  3660. const top = getTop(wrapper);
  3661. // todo remove? seems pointless
  3662. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top) {
  3663. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight;
  3664. }
  3665. deselect();
  3666. }
  3667. function setValue(node, value) {
  3668. return __awaiter(this, void 0, void 0, function* () {
  3669. node.element.contrast.valueElement.value = value;
  3670. deselect();
  3671. yield (0,_edit__WEBPACK_IMPORTED_MODULE_1__.update)();
  3672. });
  3673. }
  3674. function reset() {
  3675. while (resetCallbacks.length > 0) {
  3676. resetCallbacks.pop()();
  3677. }
  3678. activeOptions.length = 0;
  3679. }
  3680. function addListener(target, type, listener, useCapture = false) {
  3681. target.addEventListener(type, listener, useCapture);
  3682. resetCallbacks.push(() => target.removeEventListener(type, listener, useCapture));
  3683. }
  3684. function generate(node) {
  3685. const wrapper = document.createElement('div');
  3686. const parent = document.createElement('div');
  3687. wrapper.style.width = `${node.element.contrast.valueContainer.clientWidth}px`;
  3688. // avoid blurring an input when dragging the scrollbar
  3689. addListener(wrapper, 'mousedown', (event) => {
  3690. event.stopPropagation();
  3691. event.preventDefault();
  3692. });
  3693. for (const type of ['mouseover', 'mouseout', 'mouseup']) {
  3694. addListener(wrapper, type, (event) => {
  3695. event.stopPropagation();
  3696. });
  3697. }
  3698. for (const value of node.options) {
  3699. const container = document.createElement('div');
  3700. const background = document.createElement('div');
  3701. const option = document.createElement('div');
  3702. option.innerText = value;
  3703. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CONTAINER_CLASS);
  3704. option.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_CLASS);
  3705. background.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_BACKGROUND_CLASS);
  3706. container.append(background, option);
  3707. parent.appendChild(container);
  3708. activeOptions.push(option);
  3709. addListener(container, 'mousedown', (event) => {
  3710. event.stopPropagation();
  3711. event.preventDefault();
  3712. });
  3713. addListener(container, 'click', (event) => __awaiter(this, void 0, void 0, function* () {
  3714. event.stopPropagation();
  3715. yield setValue(node, value);
  3716. node.element.headContainer.focus();
  3717. }));
  3718. addListener(container, 'mouseenter', (event) => {
  3719. event.stopPropagation();
  3720. setActive(container);
  3721. });
  3722. addListener(container, 'mouseleave', (event) => {
  3723. event.stopPropagation();
  3724. setActive(container, false);
  3725. });
  3726. }
  3727. addListener(node.element.contrast.valueElement, 'keydown', (event) => {
  3728. const priorIndex = activeIndex;
  3729. let hasChanged = false;
  3730. switch (event.key) {
  3731. case 'Tab':
  3732. case 'Enter':
  3733. if (activeIndex >= 0) {
  3734. event.stopPropagation();
  3735. event.preventDefault();
  3736. setValue(node, activeOptions[activeIndex].innerText)
  3737. .then(() => node.element.headContainer.focus());
  3738. }
  3739. return;
  3740. case 'ArrowDown':
  3741. for (let i = activeIndex + 1; i < activeOptions.length; ++i) {
  3742. const { parentElement } = activeOptions[i];
  3743. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3744. activeIndex = i;
  3745. hasChanged = true;
  3746. const optionBottom = parentElement.offsetTop + parentElement.clientHeight;
  3747. if (parentElement.parentElement.scrollTop < optionBottom) {
  3748. parentElement.parentElement.scrollTop = optionBottom - parentElement.parentElement.clientHeight;
  3749. }
  3750. const top = getTop(parentElement);
  3751. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight < top - parentElement.parentElement.scrollTop) {
  3752. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.clientHeight - parentElement.parentElement.scrollTop;
  3753. }
  3754. break;
  3755. }
  3756. }
  3757. break;
  3758. case 'ArrowUp':
  3759. for (let i = activeIndex - 1; i >= 0; --i) {
  3760. const { parentElement } = activeOptions[i];
  3761. if (parentElement.classList.contains(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_SHOW_CLASS)) {
  3762. activeIndex = i;
  3763. hasChanged = true;
  3764. // Scroll option list if necessary
  3765. if (parentElement.parentElement.scrollTop > parentElement.offsetTop) {
  3766. parentElement.parentElement.scrollTop = parentElement.offsetTop;
  3767. }
  3768. const top = getTop(parentElement, false);
  3769. // Scroll modal body if necessary
  3770. if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > top - parentElement.parentElement.scrollTop) {
  3771. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = top - parentElement.parentElement.scrollTop;
  3772. }
  3773. break;
  3774. }
  3775. }
  3776. if (hasChanged) {
  3777. break;
  3778. }
  3779. // eslint-disable-next-line no-fallthrough
  3780. default:
  3781. if (activeIndex >= 0) {
  3782. setActive(activeOptions[activeIndex].parentElement, false);
  3783. }
  3784. activeIndex = -1;
  3785. return;
  3786. }
  3787. if (!hasChanged) {
  3788. return;
  3789. }
  3790. if (priorIndex >= 0) {
  3791. setActive(activeOptions[priorIndex].parentElement, false);
  3792. }
  3793. const { parentElement } = activeOptions[activeIndex];
  3794. setActive(parentElement);
  3795. }, true);
  3796. wrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_WRAPPER_CLASS);
  3797. parent.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.DROPDOWN_PARENT_CLASS);
  3798. wrapper.appendChild(parent);
  3799. return wrapper;
  3800. }
  3801.  
  3802.  
  3803. /***/ }),
  3804.  
  3805. /***/ "./ts/modal/body/nodes/actions/overlays/index.ts":
  3806. /*!*******************************************************!*\
  3807. !*** ./ts/modal/body/nodes/actions/overlays/index.ts ***!
  3808. \*******************************************************/
  3809. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3810.  
  3811. __webpack_require__.r(__webpack_exports__);
  3812. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3813. /* harmony export */ dropdown: () => (/* reexport module object */ _dropdown__WEBPACK_IMPORTED_MODULE_3__),
  3814. /* harmony export */ hideTooltip: () => (/* binding */ hideTooltip),
  3815. /* harmony export */ reset: () => (/* binding */ reset),
  3816. /* harmony export */ setNode: () => (/* binding */ setNode),
  3817. /* harmony export */ showTooltip: () => (/* binding */ showTooltip),
  3818. /* harmony export */ tooltip: () => (/* reexport module object */ _tooltip__WEBPACK_IMPORTED_MODULE_2__),
  3819. /* harmony export */ update: () => (/* binding */ update)
  3820. /* harmony export */ });
  3821. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/consts.ts");
  3822. /* harmony import */ var _tooltip_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tooltip/consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  3823. /* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tooltip */ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts");
  3824. /* harmony import */ var _dropdown__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dropdown */ "./ts/modal/body/nodes/actions/overlays/dropdown/index.ts");
  3825. /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scroll */ "./ts/modal/body/nodes/actions/scroll.ts");
  3826. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  3827. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  3828. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  3829. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3830. return new (P || (P = Promise))(function (resolve, reject) {
  3831. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3832. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3833. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3834. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3835. });
  3836. };
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844. let activeContainer;
  3845. let activeTooltip;
  3846. let activeDropdown;
  3847. let activeNode;
  3848. let activeListener;
  3849.  
  3850. function reset() {
  3851. _dropdown__WEBPACK_IMPORTED_MODULE_3__.reset();
  3852. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', activeListener);
  3853. activeContainer.remove();
  3854. activeContainer = undefined;
  3855. activeTooltip = undefined;
  3856. activeDropdown = undefined;
  3857. activeNode = undefined;
  3858. activeListener = undefined;
  3859. }
  3860. function hideTooltip() {
  3861. _tooltip__WEBPACK_IMPORTED_MODULE_2__.hide(activeTooltip);
  3862. }
  3863. function getStickyPositions(parent, space, targetMinTop, targetHeight, nodeHeight, node) {
  3864. const targetTop = (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node);
  3865. const ancestors = node.getAncestors();
  3866. const offset = 'children' in node ? 0 : nodeHeight;
  3867. return [
  3868. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop, [
  3869. [targetMinTop + targetHeight, targetMinTop - targetTop + targetHeight - offset, 0], ...[node, ...ancestors]
  3870. .map((node) => (0,_scroll__WEBPACK_IMPORTED_MODULE_4__.getStickyScroll)(node, false))
  3871. .map((height, index, { length }) => ([
  3872. height + (length - index) * nodeHeight,
  3873. (length - index - 1) * nodeHeight,
  3874. height,
  3875. ])),
  3876. ].map(([height, top, start]) => ({
  3877. container: (() => {
  3878. const container = document.createElement('div');
  3879. container.style.height = `${space - height}px`;
  3880. container.style.top = `${height}px`;
  3881. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3882. parent.appendChild(container);
  3883. return container;
  3884. })(),
  3885. top,
  3886. start,
  3887. })),
  3888. ];
  3889. }
  3890. function getBasicPosition(parent, space, targetMinTop, targetHeight) {
  3891. return [
  3892. () => targetMinTop - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight / 2 > _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop,
  3893. [
  3894. {
  3895. container: (() => {
  3896. const container = document.createElement('div');
  3897. container.style.height = `${targetMinTop}px`;
  3898. container.style.top = '0';
  3899. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_TOP_CLASS);
  3900. parent.appendChild(container);
  3901. return container;
  3902. })(),
  3903. }, {
  3904. container: (() => {
  3905. const container = document.createElement('div');
  3906. container.style.position = 'absolute';
  3907. container.style.height = `${space - targetMinTop - targetHeight}px`;
  3908. container.style.top = '0';
  3909. container.classList.add(_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOTTOM_CLASS);
  3910. parent.appendChild(container);
  3911. return container;
  3912. })(),
  3913. top: targetMinTop + targetHeight,
  3914. },
  3915. ],
  3916. ];
  3917. }
  3918. function applyPosition(basicPositions, stickyPositions, nodeHeight, isAbove, container, tooltipElement, dropdownElement) {
  3919. const containers = [];
  3920. let target;
  3921. tooltipElement.style.removeProperty('transform');
  3922. if (isAbove) {
  3923. tooltipElement.style.top = `${_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientHeight - tooltipElement.clientHeight}px`;
  3924. basicPositions[0].container.appendChild(tooltipElement);
  3925. containers.push(basicPositions[0].container);
  3926. if (!dropdownElement) {
  3927. return containers;
  3928. }
  3929. target = dropdownElement;
  3930. }
  3931. else {
  3932. target = tooltipElement;
  3933. }
  3934. if (!(0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)()) {
  3935. target.style.top = '0';
  3936. basicPositions[1].container.appendChild(target);
  3937. return [basicPositions[1].container, ...containers];
  3938. }
  3939. let index = 0;
  3940. for (; index < stickyPositions.length - 1; ++index) {
  3941. if (_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop < stickyPositions[index + 1].start) {
  3942. break;
  3943. }
  3944. }
  3945. target.style.top = `${stickyPositions[index].top}px`;
  3946. if (stickyPositions[1].start + nodeHeight < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3947. tooltipElement.style.top = `${stickyPositions[index].top}px`;
  3948. stickyPositions[index].container.append(target, tooltipElement);
  3949. return [stickyPositions[index].container];
  3950. }
  3951. if (dropdownElement && stickyPositions[1].start < _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop) {
  3952. tooltipElement.style.transform = `translateY(${(_modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop - stickyPositions[1].start)}px)`;
  3953. }
  3954. stickyPositions[index].container.appendChild(target);
  3955. return [stickyPositions[index].container, ...containers];
  3956. }
  3957. function setPosition(node, container, target, tooltipElement, dropdownElement) {
  3958. const scrollRect = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.getBoundingClientRect();
  3959. const targetRect = target.getBoundingClientRect();
  3960. const nodeRect = node.element.headContainer.getBoundingClientRect();
  3961. const containerLeft = targetRect.left - scrollRect.left;
  3962. container.style.width = `${targetRect.width}px`;
  3963. container.style.left = `${containerLeft}px`;
  3964. const targetMinTop = targetRect.top - scrollRect.top + _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollTop;
  3965. const space = _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.scrollHeight;
  3966. const [isUpBasic, basicPositions] = getBasicPosition(container, space, targetMinTop, targetRect.height);
  3967. const [isUpSticky, stickyPositions] = getStickyPositions(container, space, targetMinTop, targetRect.height, nodeRect.height, node);
  3968. let isAbove;
  3969. const listener = () => {
  3970. isAbove = dropdownElement || ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_6__.isActive)() ? isUpSticky() : isUpBasic());
  3971. applyPosition(basicPositions, stickyPositions, nodeRect.height, isAbove, container, tooltipElement, dropdownElement);
  3972. };
  3973. listener();
  3974. // todo stop using scroll listeners;
  3975. // use intersection observers to detect specific scrollTops & act accordingly
  3976. // try using a branch of divs instead of manually changing styles
  3977. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.addEventListener('scroll', listener);
  3978. return listener;
  3979. }
  3980. function generate(node, target, tooltipElement, dropdownElement) {
  3981. const container = document.createElement('div');
  3982. const { elementContainer: parent } = node.getRoot().element;
  3983. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTAINER_CLASS);
  3984. parent.appendChild(container, parent.firstChild);
  3985. return [container, setPosition(node, container, target, tooltipElement, dropdownElement)];
  3986. }
  3987. function update() {
  3988. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(activeNode.value);
  3989. _tooltip__WEBPACK_IMPORTED_MODULE_2__.fade(activeTooltip);
  3990. // handle possible dropdown height change
  3991. activeListener();
  3992. }
  3993. function setTooltipMessage(message, tooltipElement = activeTooltip, container = activeContainer, isRight = true) {
  3994. const box = tooltipElement.querySelector(`.${_tooltip_consts__WEBPACK_IMPORTED_MODULE_1__.TOOLTIP_BOX_CLASS}`);
  3995. box.innerText = message;
  3996. if (isRight) {
  3997. box.style.right = `${Math.max(0, box.offsetWidth / 2 - _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.clientWidth + container.offsetLeft + container.clientWidth / 2)}px`;
  3998. }
  3999. else {
  4000. box.style.left = `${Math.max(0, box.offsetWidth / 2 - container.offsetLeft - container.clientWidth / 2)}px`;
  4001. }
  4002. }
  4003. function showTooltip(message, node, target) {
  4004. return __awaiter(this, void 0, void 0, function* () {
  4005. if (node === activeNode) {
  4006. // handle possible tooltip height change
  4007. activeListener();
  4008. // handle possible width change
  4009. setTooltipMessage(message);
  4010. return;
  4011. }
  4012. const tooltipElement = _tooltip__WEBPACK_IMPORTED_MODULE_2__.getAnimated();
  4013. const [container, listener] = generate(node, target, tooltipElement);
  4014. setTooltipMessage(message, tooltipElement, container, false);
  4015. yield _tooltip__WEBPACK_IMPORTED_MODULE_2__.animationEnd();
  4016. _modal_body__WEBPACK_IMPORTED_MODULE_5__.element.removeEventListener('scroll', listener);
  4017. container.remove();
  4018. });
  4019. }
  4020. function setNode(node) {
  4021. activeNode = node;
  4022. activeTooltip = _tooltip__WEBPACK_IMPORTED_MODULE_2__.generate(node.element.contrast.valueElement.type === 'color');
  4023. if ('options' in node) {
  4024. activeDropdown = _dropdown__WEBPACK_IMPORTED_MODULE_3__.generate(node);
  4025. _dropdown__WEBPACK_IMPORTED_MODULE_3__.update(node.value);
  4026. }
  4027. [activeContainer, activeListener] = generate(activeNode, node.element.contrast.valueContainer, activeTooltip, activeDropdown);
  4028. }
  4029.  
  4030.  
  4031. /***/ }),
  4032.  
  4033. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts":
  4034. /*!****************************************************************!*\
  4035. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts ***!
  4036. \****************************************************************/
  4037. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4038.  
  4039. __webpack_require__.r(__webpack_exports__);
  4040. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4041. /* harmony export */ MESSAGE_UNRESOLVED: () => (/* binding */ MESSAGE_UNRESOLVED),
  4042. /* harmony export */ TOOLTIP_ANIMATION: () => (/* binding */ TOOLTIP_ANIMATION),
  4043. /* harmony export */ TOOLTIP_ANIMATION_FAST: () => (/* binding */ TOOLTIP_ANIMATION_FAST),
  4044. /* harmony export */ TOOLTIP_ARROW_CLASS: () => (/* binding */ TOOLTIP_ARROW_CLASS),
  4045. /* harmony export */ TOOLTIP_BOTTOM_CLASS: () => (/* binding */ TOOLTIP_BOTTOM_CLASS),
  4046. /* harmony export */ TOOLTIP_BOX_CLASS: () => (/* binding */ TOOLTIP_BOX_CLASS),
  4047. /* harmony export */ TOOLTIP_CONTAINER_CLASS: () => (/* binding */ TOOLTIP_CONTAINER_CLASS),
  4048. /* harmony export */ TOOLTIP_REVERSE_CLASS: () => (/* binding */ TOOLTIP_REVERSE_CLASS),
  4049. /* harmony export */ TOOLTIP_TOP_CLASS: () => (/* binding */ TOOLTIP_TOP_CLASS)
  4050. /* harmony export */ });
  4051. const TOOLTIP_CONTAINER_CLASS = 'tooltip-container';
  4052. const TOOLTIP_ARROW_CLASS = 'modal-arrow-wrapper';
  4053. const TOOLTIP_BOX_CLASS = 'tooltip';
  4054. const TOOLTIP_TOP_CLASS = 'tooltip-above';
  4055. const TOOLTIP_BOTTOM_CLASS = 'tooltip-below';
  4056. const TOOLTIP_REVERSE_CLASS = 'tooltip-reverse';
  4057. const TOOLTIP_ANIMATION = [
  4058. [
  4059. // keyframes
  4060. { opacity: 1 },
  4061. { opacity: 1 },
  4062. { opacity: 0 },
  4063. ], { duration: 2000 },
  4064. ];
  4065. const TOOLTIP_ANIMATION_FAST = [
  4066. [
  4067. // keyframes
  4068. { opacity: 1 },
  4069. { opacity: 0 },
  4070. ], { duration: 1000 },
  4071. ];
  4072. const MESSAGE_UNRESOLVED = 'Please wait for validation';
  4073.  
  4074.  
  4075. /***/ }),
  4076.  
  4077. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/css.ts":
  4078. /*!*************************************************************!*\
  4079. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/css.ts ***!
  4080. \*************************************************************/
  4081. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4082.  
  4083. __webpack_require__.r(__webpack_exports__);
  4084. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4085. /* harmony export */ "default": () => (/* binding */ generate)
  4086. /* harmony export */ });
  4087. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4088. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  4089. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4090. /* harmony import */ var _dropdown_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../dropdown/consts */ "./ts/modal/body/nodes/actions/overlays/dropdown/consts.ts");
  4091.  
  4092.  
  4093.  
  4094.  
  4095. function generate() {
  4096. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`, [
  4097. ['position', 'sticky'],
  4098. ['text-align', 'center'],
  4099. ['display', 'flex'],
  4100. ['flex-direction', 'column'],
  4101. ['align-items', 'center'],
  4102. ['width', '10em'],
  4103. ]);
  4104. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4105. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4106. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4107. `.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS} + * > .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4108. ], [
  4109. ['top', '100%'],
  4110. ['border-color', 'var(--borderTooltip) transparent transparent transparent'],
  4111. ]);
  4112. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4113. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}):not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4114. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}:not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`,
  4115. ], [
  4116. ['bottom', '100%'],
  4117. ['border-color', 'transparent transparent var(--borderTooltip) transparent'],
  4118. ]);
  4119. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4120. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4121. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4122. ], ['translate', '0 -0.5em']);
  4123. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS} + .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`], ['translate', '0px calc(-100% - 0.5em)']);
  4124. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4125. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOTTOM_CLASS}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}):not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4126. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_TOP_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS}:not(:has(.${_dropdown_consts__WEBPACK_IMPORTED_MODULE_3__.DROPDOWN_WRAPPER_CLASS})) .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS}`,
  4127. ], [['translate', '0 0.5em']]);
  4128. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`, [
  4129. ['font-size', '0.9em'],
  4130. ['padding', '3px 15px'],
  4131. ['border-radius', '1em'],
  4132. ['border', 'solid 3px var(--borderTooltip)'],
  4133. ['background-color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][1]],
  4134. ['color', _nodes_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_COLOURS[1][2]],
  4135. ['position', 'relative'],
  4136. ]);
  4137. // Don't show when there's no hint to give
  4138. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`:has(> .${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}:empty)`], ['display', 'none']);
  4139. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS}`, [
  4140. ['position', 'absolute'],
  4141. ['left', '50%'],
  4142. ['margin-left', '-0.5em'],
  4143. ['border-width', '0.5em'],
  4144. ['border-style', 'solid'],
  4145. ]);
  4146. }
  4147.  
  4148.  
  4149. /***/ }),
  4150.  
  4151. /***/ "./ts/modal/body/nodes/actions/overlays/tooltip/index.ts":
  4152. /*!***************************************************************!*\
  4153. !*** ./ts/modal/body/nodes/actions/overlays/tooltip/index.ts ***!
  4154. \***************************************************************/
  4155. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4156.  
  4157. __webpack_require__.r(__webpack_exports__);
  4158. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4159. /* harmony export */ animationEnd: () => (/* binding */ animationEnd),
  4160. /* harmony export */ fade: () => (/* binding */ fade),
  4161. /* harmony export */ generate: () => (/* binding */ generate),
  4162. /* harmony export */ getAnimated: () => (/* binding */ getAnimated),
  4163. /* harmony export */ hide: () => (/* binding */ hide),
  4164. /* harmony export */ kill: () => (/* binding */ kill)
  4165. /* harmony export */ });
  4166. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/actions/overlays/tooltip/consts.ts");
  4167. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  4168. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4169. return new (P || (P = Promise))(function (resolve, reject) {
  4170. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4171. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4172. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4173. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4174. });
  4175. };
  4176.  
  4177. let animation;
  4178. function animationEnd() {
  4179. return __awaiter(this, void 0, void 0, function* () {
  4180. yield new Promise((resolve) => {
  4181. animation.addEventListener('finish', resolve);
  4182. });
  4183. });
  4184. }
  4185. function kill() {
  4186. animation === null || animation === void 0 ? void 0 : animation.finish();
  4187. }
  4188. function generate(doReverse = false) {
  4189. const container = document.createElement('div');
  4190. const arrow = document.createElement('div');
  4191. const box = document.createElement('div');
  4192. container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_CONTAINER_CLASS);
  4193. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ARROW_CLASS);
  4194. box.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS);
  4195. if (doReverse) {
  4196. arrow.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_REVERSE_CLASS);
  4197. }
  4198. container.append(arrow, box);
  4199. return container;
  4200. }
  4201. function getAnimated() {
  4202. const element = generate();
  4203. animation = element.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION);
  4204. animation.onfinish = ({ target }) => {
  4205. element.remove();
  4206. if (target === animation) {
  4207. animation = undefined;
  4208. }
  4209. };
  4210. return element;
  4211. }
  4212. function fade(container) {
  4213. if (container.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).matches(':empty')) {
  4214. return;
  4215. }
  4216. kill();
  4217. animation = container.animate(..._consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_ANIMATION_FAST);
  4218. animation.onfinish = ({ target }) => {
  4219. if (target === animation) {
  4220. animation = undefined;
  4221. }
  4222. };
  4223. }
  4224. function hide(element) {
  4225. element.querySelector(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.TOOLTIP_BOX_CLASS}`).innerText = '';
  4226. }
  4227.  
  4228.  
  4229. /***/ }),
  4230.  
  4231. /***/ "./ts/modal/body/nodes/actions/scroll.ts":
  4232. /*!***********************************************!*\
  4233. !*** ./ts/modal/body/nodes/actions/scroll.ts ***!
  4234. \***********************************************/
  4235. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4236.  
  4237. __webpack_require__.r(__webpack_exports__);
  4238. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4239. /* harmony export */ basicScroll: () => (/* binding */ basicScroll),
  4240. /* harmony export */ getStickyScroll: () => (/* binding */ getStickyScroll),
  4241. /* harmony export */ scroll: () => (/* binding */ scroll),
  4242. /* harmony export */ stickyScroll: () => (/* binding */ stickyScroll)
  4243. /* harmony export */ });
  4244. /* harmony import */ var _focus_consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  4245. /* harmony import */ var _focus__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4246. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  4247. /* harmony import */ var _modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/header/actions/sticky */ "./ts/modal/header/actions/sticky/index.ts");
  4248. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4249.  
  4250.  
  4251.  
  4252.  
  4253.  
  4254. // specifically returns the last *visible* descendant
  4255. function getLastDescendant(node, isFocus = (0,_focus__WEBPACK_IMPORTED_MODULE_1__.isActive)()) {
  4256. if ('children' in node && node.children.length > 0 && (!isFocus || node.element.hasClass(_focus_consts__WEBPACK_IMPORTED_MODULE_0__.FOCUS_CLASS))) {
  4257. for (let i = node.children.length - 1; i >= 0; --i) {
  4258. if (node.children[i].element.elementContainer.clientHeight > 0) {
  4259. return getLastDescendant(node.children[i], isFocus);
  4260. }
  4261. }
  4262. }
  4263. return node;
  4264. }
  4265. // a scrollIntoView replacement for sticky positioning
  4266. function getStickyScroll(node, alignToTop = true) {
  4267. const firstChild = alignToTop ? node : getLastDescendant(node);
  4268. const { height } = node.element.headContainer.getBoundingClientRect();
  4269. let depth = 0;
  4270. for (let root = node; 'parent' in root; root = root.parent) {
  4271. depth++;
  4272. }
  4273. return Math.ceil(firstChild.element.headContainer.getBoundingClientRect().top
  4274. - _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.getBoundingClientRect().top
  4275. + _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop
  4276. - (height + _modal_consts__WEBPACK_IMPORTED_MODULE_4__.SUB_PIXEL_BS) * depth);
  4277. }
  4278. function stickyScroll(node, doSnap = true, alignToTop = true) {
  4279. const scroll = getStickyScroll(node, alignToTop);
  4280. if (alignToTop) {
  4281. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTo({ top: scroll, behavior: doSnap ? 'auto' : 'smooth' });
  4282. }
  4283. else if (_modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop > scroll) {
  4284. _modal_body__WEBPACK_IMPORTED_MODULE_2__.element.scrollTop = scroll;
  4285. }
  4286. }
  4287. function basicScroll(node) {
  4288. node.element.scrollIntoView({ block: 'center' });
  4289. }
  4290. function scroll(node) {
  4291. if ((0,_modal_header_actions_sticky__WEBPACK_IMPORTED_MODULE_3__.isActive)()) {
  4292. stickyScroll(node);
  4293. }
  4294. else {
  4295. basicScroll(node);
  4296. }
  4297. }
  4298.  
  4299.  
  4300. /***/ }),
  4301.  
  4302. /***/ "./ts/modal/body/nodes/child.ts":
  4303. /*!**************************************!*\
  4304. !*** ./ts/modal/body/nodes/child.ts ***!
  4305. \**************************************/
  4306. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4307.  
  4308. __webpack_require__.r(__webpack_exports__);
  4309. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4310. /* harmony export */ "default": () => (/* binding */ Child)
  4311. /* harmony export */ });
  4312. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4313. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4314. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4315. /* harmony import */ var _actions_edit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions/edit */ "./ts/modal/body/nodes/actions/edit/index.ts");
  4316. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4317. /* harmony import */ var _actions_hide__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./actions/hide */ "./ts/modal/body/nodes/actions/hide/index.ts");
  4318. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4319. /* harmony import */ var _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/buttons/disable */ "./ts/modal/body/nodes/actions/buttons/disable/index.ts");
  4320. /* harmony import */ var _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/buttons/move */ "./ts/modal/body/nodes/actions/buttons/move/index.ts");
  4321. /* harmony import */ var _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/buttons/duplicate */ "./ts/modal/body/nodes/actions/buttons/duplicate/index.ts");
  4322. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334. const actions = [
  4335. // No button
  4336. _actions_highlight__WEBPACK_IMPORTED_MODULE_2__,
  4337. _actions_focus__WEBPACK_IMPORTED_MODULE_4__,
  4338. _actions_edit__WEBPACK_IMPORTED_MODULE_3__,
  4339. _actions_hide__WEBPACK_IMPORTED_MODULE_5__,
  4340. // Button
  4341. _actions_buttons_disable__WEBPACK_IMPORTED_MODULE_7__,
  4342. _actions_buttons_move__WEBPACK_IMPORTED_MODULE_8__,
  4343. _actions_buttons_duplicate__WEBPACK_IMPORTED_MODULE_9__,
  4344. ];
  4345. class Child {
  4346. constructor(data, parent, index) {
  4347. this.isActive = true;
  4348. this.element = new _element__WEBPACK_IMPORTED_MODULE_0__["default"](data);
  4349. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4350. if (key in data) {
  4351. this[key] = data[key];
  4352. }
  4353. }
  4354. this.forceValid = !('predicate' in data) && !('options' in data);
  4355. this.attach(parent, index);
  4356. for (const { shouldMount, mount } of actions) {
  4357. if (shouldMount(this)) {
  4358. mount(this);
  4359. }
  4360. }
  4361. if ('predicate' in data) {
  4362. this.predicate = () => data.predicate(this.value);
  4363. }
  4364. if ('onUpdate' in data) {
  4365. this.onUpdate = () => (0,_queue__WEBPACK_IMPORTED_MODULE_1__.onceVisualsUpdate)(() => data.onUpdate(this.value));
  4366. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_6__.handle)(this.onUpdate(), 'onUpdate', this);
  4367. }
  4368. }
  4369. getRoot() {
  4370. return this.parent.getRoot();
  4371. }
  4372. getAncestors() {
  4373. return [this.parent, ...this.parent.getAncestors()];
  4374. }
  4375. getIndex() {
  4376. return this.parent.children.indexOf(this);
  4377. }
  4378. detach() {
  4379. this.parent.children.splice(this.getIndex(), 1);
  4380. this.element.remove();
  4381. this.parent = undefined;
  4382. }
  4383. attach(parent, index = parent.children.length) {
  4384. parent.children.splice(index, 0, this);
  4385. parent.element.addChild(this.element, index);
  4386. this.parent = parent;
  4387. }
  4388. move(parent, to) {
  4389. this.detach();
  4390. this.attach(parent, typeof to === 'number' ? to : to.getIndex() + 1);
  4391. }
  4392. duplicate() {
  4393. return new Child(this.getSeedData(), this.parent, this.getIndex() + 1);
  4394. }
  4395. unmount() {
  4396. for (const action of actions) {
  4397. if ('unmount' in action) {
  4398. action.unmount(this);
  4399. }
  4400. }
  4401. }
  4402. disconnect() {
  4403. this.unmount();
  4404. this.detach();
  4405. }
  4406. getSeedData() {
  4407. const data = {};
  4408. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.LEAF_KEYS) {
  4409. if (key in this) {
  4410. data[key] = this[key];
  4411. }
  4412. }
  4413. return data;
  4414. }
  4415. getPredicateData() {
  4416. const data = {};
  4417. for (const key of _types__WEBPACK_IMPORTED_MODULE_10__.SAVED_KEYS) {
  4418. if (key in this) {
  4419. data[key] = this[key];
  4420. }
  4421. }
  4422. return data;
  4423. }
  4424. getSaveData(isActiveBranch) {
  4425. const tree = this.getPredicateData();
  4426. if (isActiveBranch) {
  4427. return {
  4428. tree,
  4429. activeTree: tree,
  4430. configs: 'get' in this ? [this.get(tree, [])] : [],
  4431. };
  4432. }
  4433. return { tree };
  4434. }
  4435. }
  4436.  
  4437.  
  4438. /***/ }),
  4439.  
  4440. /***/ "./ts/modal/body/nodes/consts.ts":
  4441. /*!***************************************!*\
  4442. !*** ./ts/modal/body/nodes/consts.ts ***!
  4443. \***************************************/
  4444. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4445.  
  4446. __webpack_require__.r(__webpack_exports__);
  4447. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4448. /* harmony export */ BASE_CLASS: () => (/* binding */ BASE_CLASS),
  4449. /* harmony export */ CHECKBOX_WRAPPER_CLASS: () => (/* binding */ CHECKBOX_WRAPPER_CLASS),
  4450. /* harmony export */ CONTRAST_CLASS: () => (/* binding */ CONTRAST_CLASS),
  4451. /* harmony export */ EDITABLE_CLASS: () => (/* binding */ EDITABLE_CLASS),
  4452. /* harmony export */ ELEMENT_CLASSES: () => (/* binding */ ELEMENT_CLASSES),
  4453. /* harmony export */ MIDDLE_CLASS: () => (/* binding */ MIDDLE_CLASS),
  4454. /* harmony export */ NODE_COLOURS: () => (/* binding */ NODE_COLOURS),
  4455. /* harmony export */ ROOT_CLASS: () => (/* binding */ ROOT_CLASS)
  4456. /* harmony export */ });
  4457. const ROOT_CLASS = 'root';
  4458. const MIDDLE_CLASS = 'middle';
  4459. const ELEMENT_CLASSES = {
  4460. ELEMENT_CONTAINER: 'node',
  4461. BACKGROUND_CONTAINER: 'node-background-container',
  4462. CHILD_CONTAINER: 'node-child-container',
  4463. BUTTON_CONTAINER: 'node-button-container',
  4464. INFO_CONTAINER: 'node-info-container',
  4465. HEAD_CONTAINER: 'node-head-container',
  4466. VALUE_CONTAINER: 'node-value-container',
  4467. VALUE: 'node-value',
  4468. LABEL_CONTAINER: 'node-label-container',
  4469. LABEL: 'node-label',
  4470. };
  4471. const BASE_CLASS = 'node-base';
  4472. const CONTRAST_CLASS = 'node-contrast';
  4473. const CHECKBOX_WRAPPER_CLASS = 'checkbox-wrapper';
  4474. const EDITABLE_CLASS = 'editable';
  4475. const NODE_COLOURS = [
  4476. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${EDITABLE_CLASS})`, 'var(--nodeHeaderBase)', 'var(--nodeHeaderContrast)'],
  4477. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}.${MIDDLE_CLASS}.${EDITABLE_CLASS}`, 'var(--nodeBlendBase)', 'var(--nodeBlendContrast)'],
  4478. [`.${ELEMENT_CLASSES.ELEMENT_CONTAINER}:not(.${MIDDLE_CLASS}).${EDITABLE_CLASS}`, 'var(--nodeValueBase)', 'var(--nodeValueContrast)'],
  4479. ];
  4480.  
  4481.  
  4482. /***/ }),
  4483.  
  4484. /***/ "./ts/modal/body/nodes/css.ts":
  4485. /*!************************************!*\
  4486. !*** ./ts/modal/body/nodes/css.ts ***!
  4487. \************************************/
  4488. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4489.  
  4490. __webpack_require__.r(__webpack_exports__);
  4491. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4492. /* harmony export */ "default": () => (/* binding */ generate)
  4493. /* harmony export */ });
  4494. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4495. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  4496. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  4497.  
  4498.  
  4499.  
  4500. function generate() {
  4501. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, [
  4502. ['flex-grow', '1'],
  4503. // Apparently it has min-height 100% without a content-related height value
  4504. ['height', 'fit-content'],
  4505. ]);
  4506. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER}:empty`, ['display', 'none']);
  4507. (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']);
  4508. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, [
  4509. ['user-select', 'none'],
  4510. ['position', 'relative'],
  4511. ['border-width', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.SUB_PIXEL_BS}px`],
  4512. ]);
  4513. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER} > *`], [
  4514. ['position', 'absolute'],
  4515. ['width', '100%'],
  4516. ['height', '100%'],
  4517. ]);
  4518. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`], [
  4519. ['position', 'absolute'],
  4520. ['white-space', 'nowrap'],
  4521. ]);
  4522. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`, ['position', 'relative']);
  4523. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [
  4524. ['position', 'absolute'],
  4525. ['right', '0'],
  4526. ['overflow', 'hidden'],
  4527. ]);
  4528. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  4529. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`,
  4530. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`,
  4531. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`,
  4532. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`,
  4533. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER}`,
  4534. ], [
  4535. ['flex-grow', '1'],
  4536. ['display', 'flex'],
  4537. ['align-items', 'center'],
  4538. ]);
  4539. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`], [['position', 'absolute']]);
  4540. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER}`, [
  4541. ['right', '0'],
  4542. ['pointer-events', 'none'],
  4543. ['height', '100%'],
  4544. ]);
  4545. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`, [
  4546. ['user-select', 'none'],
  4547. ['height', '100%'],
  4548. ]);
  4549. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER}`], [['width', '100%']]);
  4550. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER} > *`, [
  4551. ['height', '100%'],
  4552. ['position', 'absolute'],
  4553. ]);
  4554. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE}`, `.${_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS}`], [
  4555. ['padding-right', '0.6em'],
  4556. ['padding-left', '0.6em'],
  4557. ]);
  4558. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  4559. ['background-color', 'inherit'],
  4560. ['user-select', 'none'],
  4561. ['height', `${_modal_consts__WEBPACK_IMPORTED_MODULE_1__.NODE_HEIGHT}em`],
  4562. ]);
  4563. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER} > *`, ['height', '100%']);
  4564. (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})`, ['border-top-style', 'solid']);
  4565. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS} .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`, ['border-left-style', 'solid']);
  4566. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_CLASS}`, ['border-bottom-style', 'solid']);
  4567. for (const [selector, base, contrast] of _consts__WEBPACK_IMPORTED_MODULE_0__.NODE_COLOURS) {
  4568. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(selector, [
  4569. ['background-color', base],
  4570. ['color', contrast],
  4571. ]);
  4572. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector}`, ['border-color', contrast]);
  4573. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`${selector} > .${_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER}`, ['outline', `1px solid ${contrast}`]);
  4574. }
  4575. }
  4576.  
  4577.  
  4578. /***/ }),
  4579.  
  4580. /***/ "./ts/modal/body/nodes/element.ts":
  4581. /*!****************************************!*\
  4582. !*** ./ts/modal/body/nodes/element.ts ***!
  4583. \****************************************/
  4584. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4585.  
  4586. __webpack_require__.r(__webpack_exports__);
  4587. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4588. /* harmony export */ "default": () => (/* binding */ Element)
  4589. /* harmony export */ });
  4590. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4591.  
  4592. class Element {
  4593. constructor(data) {
  4594. this.elementContainer = document.createElement('div');
  4595. this.backgroundContainer = document.createElement('div');
  4596. this.headContainer = document.createElement('span');
  4597. this.buttonContainer = document.createElement('span');
  4598. this.infoContainer = document.createElement('span');
  4599. this.base = { container: document.createElement('span') };
  4600. this.contrast = { container: document.createElement('span') };
  4601. this.childContainer = document.createElement('div');
  4602. this.elementContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.ELEMENT_CONTAINER);
  4603. this.backgroundContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BACKGROUND_CONTAINER);
  4604. this.childContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.CHILD_CONTAINER);
  4605. this.infoContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.INFO_CONTAINER);
  4606. this.headContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.HEAD_CONTAINER);
  4607. this.buttonContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.BUTTON_CONTAINER);
  4608. this.base.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BASE_CLASS);
  4609. this.contrast.container.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CONTRAST_CLASS);
  4610. if ('value' in data) {
  4611. this.addValueContainer(this.contrast, data);
  4612. this.addValueContainer(this.base, data);
  4613. this.render(data.value);
  4614. }
  4615. if ('label' in data) {
  4616. this.addLabelContainer(this.contrast, data.label);
  4617. this.addLabelContainer(this.base, data.label);
  4618. }
  4619. this.infoContainer.append(this.backgroundContainer, this.contrast.container, this.base.container);
  4620. this.headContainer.append(this.buttonContainer, this.infoContainer);
  4621. this.elementContainer.appendChild(this.headContainer);
  4622. this.elementContainer.appendChild(this.childContainer);
  4623. }
  4624. addLabelContainer({ container }, label) {
  4625. const labelContainer = document.createElement('div');
  4626. const labelElement = document.createElement('span');
  4627. labelContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL_CONTAINER);
  4628. labelElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.LABEL);
  4629. labelElement.innerText = label;
  4630. labelContainer.appendChild(labelElement);
  4631. container.appendChild(labelContainer);
  4632. }
  4633. addValueContainer(field, data) {
  4634. field.valueContainer = document.createElement('label');
  4635. field.valueContainer.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE_CONTAINER);
  4636. if ('value' in data) {
  4637. field.valueElement = document.createElement('input');
  4638. field.valueElement.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.ELEMENT_CLASSES.VALUE);
  4639. if ('inputAttributes' in data) {
  4640. for (const [key, value] of Object.entries(data.inputAttributes)) {
  4641. field.valueElement.setAttribute(key, value);
  4642. }
  4643. }
  4644. field.valueElement.setAttribute('tabindex', '-1');
  4645. if (typeof data.value === 'boolean') {
  4646. field.valueElement.type = 'checkbox';
  4647. // Positions tooltips below checkboxes
  4648. const valueWrapper = document.createElement('span');
  4649. valueWrapper.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.CHECKBOX_WRAPPER_CLASS);
  4650. valueWrapper.appendChild(field.valueElement);
  4651. field.valueContainer.appendChild(valueWrapper);
  4652. }
  4653. else {
  4654. if (typeof data.value === 'number') {
  4655. field.valueElement.type = 'number';
  4656. // Disables a tooltip implying that decimal values are invalid
  4657. field.valueElement.step = 'any';
  4658. }
  4659. else if ('input' in data) {
  4660. field.valueElement.type = data.input;
  4661. }
  4662. field.valueContainer.appendChild(field.valueElement);
  4663. }
  4664. }
  4665. field.container.appendChild(field.valueContainer);
  4666. }
  4667. render(value) {
  4668. if (typeof value === 'boolean') {
  4669. this.base.valueElement.checked = value;
  4670. this.contrast.valueElement.checked = value;
  4671. }
  4672. else {
  4673. this.base.valueElement.value = value.toString();
  4674. this.contrast.valueElement.value = value.toString();
  4675. }
  4676. }
  4677. hasClass(...names) {
  4678. for (const name of names) {
  4679. if (this.elementContainer.classList.contains(name)) {
  4680. return true;
  4681. }
  4682. }
  4683. return false;
  4684. }
  4685. addClass(...names) {
  4686. for (const name of names) {
  4687. this.elementContainer.classList.add(name);
  4688. }
  4689. }
  4690. removeClass(...names) {
  4691. for (const name of names) {
  4692. this.elementContainer.classList.remove(name);
  4693. }
  4694. }
  4695. addChild(child, index) {
  4696. var _a;
  4697. this.childContainer.insertBefore(child.elementContainer, (_a = this.childContainer.children[index]) !== null && _a !== void 0 ? _a : null);
  4698. }
  4699. addButton(button) {
  4700. this.buttonContainer.appendChild(button);
  4701. }
  4702. remove() {
  4703. this.elementContainer.remove();
  4704. }
  4705. scrollIntoView(options) {
  4706. this.backgroundContainer.scrollIntoView(typeof options === 'object' ? Object.assign({ block: 'center' }, options) : options);
  4707. }
  4708. }
  4709.  
  4710.  
  4711. /***/ }),
  4712.  
  4713. /***/ "./ts/modal/body/nodes/middle.ts":
  4714. /*!***************************************!*\
  4715. !*** ./ts/modal/body/nodes/middle.ts ***!
  4716. \***************************************/
  4717. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4718.  
  4719. __webpack_require__.r(__webpack_exports__);
  4720. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4721. /* harmony export */ "default": () => (/* binding */ Middle)
  4722. /* harmony export */ });
  4723. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4724. /* harmony import */ var _root__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./root */ "./ts/modal/body/nodes/root.ts");
  4725. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4726. /* harmony import */ var _pools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pools */ "./ts/modal/body/nodes/pools.ts");
  4727. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4728. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4729.  
  4730.  
  4731.  
  4732.  
  4733.  
  4734.  
  4735. const MIDDLE_KEYS = _types__WEBPACK_IMPORTED_MODULE_5__.MIDDLE_KEYS.filter((key) => key !== 'children');
  4736. const actions = [_actions_buttons_create__WEBPACK_IMPORTED_MODULE_4__];
  4737. class Middle extends _child__WEBPACK_IMPORTED_MODULE_2__["default"] {
  4738. constructor(data, parent, index) {
  4739. super(data, parent, index);
  4740. this.children = [];
  4741. _root__WEBPACK_IMPORTED_MODULE_1__.setup.call(this, data);
  4742. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_0__.MIDDLE_CLASS);
  4743. for (const { shouldMount, mount } of actions) {
  4744. if (shouldMount(this)) {
  4745. mount(this);
  4746. }
  4747. }
  4748. }
  4749. duplicate() {
  4750. return new Middle(this.getSeedData(), this.parent, this.getIndex() + 1);
  4751. }
  4752. unmount() {
  4753. super.unmount();
  4754. for (const action of actions) {
  4755. if ('unmount' in action) {
  4756. action.unmount(this);
  4757. }
  4758. }
  4759. if ('poolId' in this) {
  4760. (0,_pools__WEBPACK_IMPORTED_MODULE_3__.remove)(this.poolId, this);
  4761. }
  4762. for (const child of this.children) {
  4763. child.unmount();
  4764. }
  4765. }
  4766. disconnect() {
  4767. this.unmount();
  4768. this.detach();
  4769. }
  4770. // for duplication
  4771. getSeedData() {
  4772. const data = {};
  4773. for (const key of MIDDLE_KEYS) {
  4774. if (key in this) {
  4775. data[key] = this[key];
  4776. }
  4777. }
  4778. return Object.assign(Object.assign(Object.assign({}, super.getSeedData()), data), { children: this.children.map((child) => child.getSeedData()) });
  4779. }
  4780. getPredicateData() {
  4781. return Object.assign(Object.assign({}, super.getPredicateData()), _root__WEBPACK_IMPORTED_MODULE_1__.getPredicateData.call(this));
  4782. }
  4783. getSaveData(isActiveBranch) {
  4784. const data = _root__WEBPACK_IMPORTED_MODULE_1__.getSaveData.call(this, isActiveBranch);
  4785. const tree = Object.assign(Object.assign({}, super.getPredicateData()), data.tree);
  4786. if (isActiveBranch) {
  4787. const activeTree = Object.assign(Object.assign({}, tree), data.activeTree);
  4788. return {
  4789. tree,
  4790. activeTree,
  4791. configs: 'get' in this ? [this.get(activeTree, data.configs)] : data.configs,
  4792. };
  4793. }
  4794. return { tree };
  4795. }
  4796. }
  4797.  
  4798.  
  4799. /***/ }),
  4800.  
  4801. /***/ "./ts/modal/body/nodes/pools.ts":
  4802. /*!**************************************!*\
  4803. !*** ./ts/modal/body/nodes/pools.ts ***!
  4804. \**************************************/
  4805. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4806.  
  4807. __webpack_require__.r(__webpack_exports__);
  4808. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4809. /* harmony export */ add: () => (/* binding */ add),
  4810. /* harmony export */ get: () => (/* binding */ get),
  4811. /* harmony export */ remove: () => (/* binding */ remove)
  4812. /* harmony export */ });
  4813. const pools = [];
  4814. function get(node) {
  4815. var _a;
  4816. return [...((_a = pools[node.poolId]) !== null && _a !== void 0 ? _a : [node])];
  4817. }
  4818. function add(id, node) {
  4819. var _a;
  4820. (_a = pools[id]) !== null && _a !== void 0 ? _a : (pools[id] = []);
  4821. pools[id].push(node);
  4822. }
  4823. function remove(id, node) {
  4824. pools[id].splice(pools[id].indexOf(node), 1);
  4825. }
  4826.  
  4827.  
  4828. /***/ }),
  4829.  
  4830. /***/ "./ts/modal/body/nodes/queue.ts":
  4831. /*!**************************************!*\
  4832. !*** ./ts/modal/body/nodes/queue.ts ***!
  4833. \**************************************/
  4834. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4835.  
  4836. __webpack_require__.r(__webpack_exports__);
  4837. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4838. /* harmony export */ onceVisualsUpdate: () => (/* binding */ onceVisualsUpdate)
  4839. /* harmony export */ });
  4840. const queue = [];
  4841. // No idea if this works on all machines/browsers
  4842. function onceVisualsUpdate(_callback) {
  4843. return new Promise((resolve) => {
  4844. const callback = () => resolve(_callback());
  4845. if (queue.push(callback) > 1) {
  4846. return;
  4847. }
  4848. // Wait for update to start
  4849. requestAnimationFrame(() => {
  4850. // Wait for everything else to update
  4851. window.setTimeout(() => {
  4852. for (const callback of queue) {
  4853. callback();
  4854. }
  4855. queue.length = 0;
  4856. }, 0);
  4857. });
  4858. });
  4859. }
  4860.  
  4861.  
  4862. /***/ }),
  4863.  
  4864. /***/ "./ts/modal/body/nodes/root.ts":
  4865. /*!*************************************!*\
  4866. !*** ./ts/modal/body/nodes/root.ts ***!
  4867. \*************************************/
  4868. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4869.  
  4870. __webpack_require__.r(__webpack_exports__);
  4871. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4872. /* harmony export */ "default": () => (/* binding */ Root),
  4873. /* harmony export */ getPredicateData: () => (/* binding */ getPredicateData),
  4874. /* harmony export */ getSaveData: () => (/* binding */ getSaveData),
  4875. /* harmony export */ setup: () => (/* binding */ setup)
  4876. /* harmony export */ });
  4877. /* harmony import */ var _middle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./middle */ "./ts/modal/body/nodes/middle.ts");
  4878. /* harmony import */ var _child__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./child */ "./ts/modal/body/nodes/child.ts");
  4879. /* harmony import */ var _element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./element */ "./ts/modal/body/nodes/element.ts");
  4880. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/nodes/consts.ts");
  4881. /* harmony import */ var _queue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./queue */ "./ts/modal/body/nodes/queue.ts");
  4882. /* harmony import */ var _pools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pools */ "./ts/modal/body/nodes/pools.ts");
  4883. /* harmony import */ var _actions_highlight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  4884. /* harmony import */ var _actions_focus__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  4885. /* harmony import */ var _actions_buttons_create__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./actions/buttons/create */ "./ts/modal/body/nodes/actions/buttons/create/index.ts");
  4886. /* harmony import */ var _actions_callbacks_update__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./actions/callbacks/update */ "./ts/modal/body/nodes/actions/callbacks/update.ts");
  4887. /* harmony import */ var _actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./actions/buttons/consts */ "./ts/modal/body/nodes/actions/buttons/consts.ts");
  4888. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  4889. var __rest = (undefined && undefined.__rest) || function (s, e) {
  4890. var t = {};
  4891. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4892. t[p] = s[p];
  4893. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  4894. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  4895. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  4896. t[p[i]] = s[p[i]];
  4897. }
  4898. return t;
  4899. };
  4900.  
  4901.  
  4902.  
  4903.  
  4904.  
  4905.  
  4906.  
  4907.  
  4908.  
  4909.  
  4910.  
  4911.  
  4912. const actions = [_actions_highlight__WEBPACK_IMPORTED_MODULE_6__, _actions_focus__WEBPACK_IMPORTED_MODULE_7__, _actions_buttons_create__WEBPACK_IMPORTED_MODULE_8__];
  4913. function isActive(child) {
  4914. return !('isActive' in child) || child.isActive;
  4915. }
  4916. function getChildPredicateData({ children }) {
  4917. return children
  4918. .filter((child) => isActive(child) && !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__.TEST_REMOVE_CLASS))
  4919. .map((child) => child.getPredicateData());
  4920. }
  4921. function getChildSaveData({ children }, isActiveBranch = true) {
  4922. return children
  4923. .filter((child) => !child.element.hasClass(_actions_buttons_consts__WEBPACK_IMPORTED_MODULE_10__.TEST_ADD_CLASS))
  4924. .map((child) => child.getSaveData(isActive(child) && isActiveBranch));
  4925. }
  4926. function addChildren(children) {
  4927. for (const child of children) {
  4928. if ('children' in child) {
  4929. new _middle__WEBPACK_IMPORTED_MODULE_0__["default"](child, this);
  4930. }
  4931. else {
  4932. new _child__WEBPACK_IMPORTED_MODULE_1__["default"](child, this);
  4933. }
  4934. }
  4935. }
  4936. function setup(_a) {
  4937. var { children } = _a, data = __rest(_a, ["children"]);
  4938. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_OTHER_KEYS) {
  4939. if (key in data) {
  4940. this[key] = data[key];
  4941. }
  4942. }
  4943. addChildren.call(this, children);
  4944. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_PREDICATE_KEYS) {
  4945. if (key in data) {
  4946. this[key] = () => data[key](getChildPredicateData(this));
  4947. }
  4948. }
  4949. for (const key of _types__WEBPACK_IMPORTED_MODULE_11__.ROOT_UPDATE_KEYS) {
  4950. if (key in data) {
  4951. this[key] = () => (0,_queue__WEBPACK_IMPORTED_MODULE_4__.onceVisualsUpdate)(() => data[key](getChildPredicateData(this)));
  4952. (0,_actions_callbacks_update__WEBPACK_IMPORTED_MODULE_9__.handle)(this[key](), key, this);
  4953. }
  4954. }
  4955. if ('poolId' in data) {
  4956. (0,_pools__WEBPACK_IMPORTED_MODULE_5__.add)(data.poolId, this);
  4957. }
  4958. }
  4959. function getPredicateData() {
  4960. return { children: getChildPredicateData(this) };
  4961. }
  4962. function getSaveData(isActiveBranch) {
  4963. const activeChildren = [];
  4964. const children = [];
  4965. const configs = [];
  4966. for (const child of getChildSaveData(this, isActiveBranch)) {
  4967. children.push(child.tree);
  4968. if ('activeTree' in child) {
  4969. activeChildren.push(child.activeTree);
  4970. configs.push(...child.configs);
  4971. }
  4972. }
  4973. return { tree: { children }, activeTree: { children: activeChildren }, configs };
  4974. }
  4975. class Root {
  4976. constructor(data) {
  4977. this.children = [];
  4978. this.addChildren = addChildren;
  4979. this.getPredicateData = getPredicateData;
  4980. this.element = new _element__WEBPACK_IMPORTED_MODULE_2__["default"]({});
  4981. this.element.addClass(_consts__WEBPACK_IMPORTED_MODULE_3__.ROOT_CLASS);
  4982. setup.call(this, data);
  4983. for (const { shouldMount, mount } of actions) {
  4984. if (shouldMount(this)) {
  4985. mount(this);
  4986. }
  4987. }
  4988. }
  4989. getRoot() {
  4990. return this;
  4991. }
  4992. getAncestors() {
  4993. return [];
  4994. }
  4995. getSaveData() {
  4996. const { tree, activeTree, configs } = getSaveData.call(this);
  4997. if ('get' in this) {
  4998. return { tree, activeTree, config: this.get(activeTree, configs) };
  4999. }
  5000. return { tree, activeTree, config: configs.length === 1 ? configs[0] : configs };
  5001. }
  5002. }
  5003.  
  5004.  
  5005. /***/ }),
  5006.  
  5007. /***/ "./ts/modal/body/style/consts.ts":
  5008. /*!***************************************!*\
  5009. !*** ./ts/modal/body/style/consts.ts ***!
  5010. \***************************************/
  5011. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5012.  
  5013. __webpack_require__.r(__webpack_exports__);
  5014. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5015. /* harmony export */ DEFAULT_STYLE: () => (/* binding */ DEFAULT_STYLE),
  5016. /* harmony export */ ROOT_ID: () => (/* binding */ ROOT_ID)
  5017. /* harmony export */ });
  5018. const ROOT_ID = 'root-style';
  5019. const DEFAULT_STYLE = {
  5020. width: 80,
  5021. height: 80,
  5022. fontSize: 18,
  5023. borderTooltip: '#570000',
  5024. borderModal: '#ffffff',
  5025. headBase: '#000000',
  5026. headContrast: 'Black / White',
  5027. headButtonExit: '#f10000',
  5028. headButtonLabel: '#906300',
  5029. headButtonSticky: '#199a00',
  5030. headButtonStyle: '#900091',
  5031. headButtonHide: '#00749a',
  5032. headButtonAlt: '#838f00',
  5033. nodeHeaderBase: '#101010',
  5034. nodeBlendBase: '#101010',
  5035. nodeValueBase: '#303030',
  5036. nodeContrast: 'Black / White',
  5037. nodeButtonCreate: '#40ff40',
  5038. nodeButtonDuplicate: '#40ffff',
  5039. nodeButtonMove: '#ac60ff',
  5040. nodeButtonDisable: '#ffd000',
  5041. nodeButtonDelete: '#ff1111',
  5042. validBackground: '#d9ffc0',
  5043. invalidBackground: '#ffb4be',
  5044. focusBackground: '#e8e8e8',
  5045. };
  5046.  
  5047.  
  5048. /***/ }),
  5049.  
  5050. /***/ "./ts/modal/body/style/css.ts":
  5051. /*!************************************!*\
  5052. !*** ./ts/modal/body/style/css.ts ***!
  5053. \************************************/
  5054. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5055.  
  5056. __webpack_require__.r(__webpack_exports__);
  5057. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5058. /* harmony export */ "default": () => (/* binding */ generate)
  5059. /* harmony export */ });
  5060. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  5061. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../consts */ "./ts/modal/body/consts.ts");
  5062. /* harmony import */ var _data_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/consts */ "./ts/modal/body/data/consts.ts");
  5063. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5064. /* 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");
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070. function generate() {
  5071. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID} > #${_data_consts__WEBPACK_IMPORTED_MODULE_2__.ROOT_ID}`, ['display', 'none']);
  5072. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_1__.MODAL_BODY_ID}:not(.${_modal_header_actions_style_consts__WEBPACK_IMPORTED_MODULE_4__.ACTION_ID}) > #${_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID}`, ['display', 'none']);
  5073. }
  5074.  
  5075.  
  5076. /***/ }),
  5077.  
  5078. /***/ "./ts/modal/body/style/index.ts":
  5079. /*!**************************************!*\
  5080. !*** ./ts/modal/body/style/index.ts ***!
  5081. \**************************************/
  5082. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5083.  
  5084. __webpack_require__.r(__webpack_exports__);
  5085. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5086. /* harmony export */ "default": () => (/* binding */ generate),
  5087. /* harmony export */ getRoot: () => (/* binding */ getRoot),
  5088. /* harmony export */ getUserStyles: () => (/* binding */ getUserStyles),
  5089. /* harmony export */ toJSON: () => (/* binding */ toJSON),
  5090. /* harmony export */ toRawStyle: () => (/* binding */ toRawStyle)
  5091. /* harmony export */ });
  5092. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/body/style/consts.ts");
  5093. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/body/style/css.ts");
  5094. /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./update */ "./ts/modal/body/style/update.ts");
  5095. /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! .. */ "./ts/modal/body/index.ts");
  5096. /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @types */ "./ts/library/validation/types.ts");
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102. function getRoot() {
  5103. return ___WEBPACK_IMPORTED_MODULE_3__.ROOTS[_consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID];
  5104. }
  5105. // Fill any missing entries
  5106. function getFilledStyle(style = {}) {
  5107. return Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5108. }
  5109. function toJSON(style) {
  5110. const filledStyle = Object.assign(Object.assign({}, _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE), style);
  5111. return {
  5112. label: 'Name',
  5113. value: filledStyle.name,
  5114. children: [
  5115. {
  5116. label: 'Style Is Active?',
  5117. value: filledStyle.isActive,
  5118. },
  5119. {
  5120. label: 'Modal',
  5121. children: [
  5122. {
  5123. label: 'Width (%)',
  5124. value: filledStyle.width,
  5125. predicate: (value) => value > 0 || 'Width must be greater than zero',
  5126. },
  5127. {
  5128. label: 'Height (%)',
  5129. value: filledStyle.height,
  5130. predicate: (value) => value > 0 || 'Height must be greater than zero',
  5131. },
  5132. {
  5133. label: 'Font Size (px)',
  5134. value: filledStyle.fontSize,
  5135. predicate: (value) => value > 0 || 'Font size must be greater than zero',
  5136. },
  5137. {
  5138. label: 'Border Color',
  5139. value: filledStyle.borderModal,
  5140. input: 'color',
  5141. },
  5142. ],
  5143. },
  5144. {
  5145. label: 'Header',
  5146. children: [
  5147. {
  5148. label: 'General',
  5149. children: [
  5150. {
  5151. label: 'Base Color',
  5152. value: filledStyle.headBase,
  5153. input: 'color',
  5154. },
  5155. {
  5156. label: 'Contrast Method',
  5157. value: filledStyle.headContrast,
  5158. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5159. },
  5160. ],
  5161. },
  5162. {
  5163. label: 'Buttons',
  5164. children: [
  5165. {
  5166. label: 'Exit Color',
  5167. value: filledStyle.headButtonExit,
  5168. input: 'color',
  5169. },
  5170. {
  5171. label: 'Label Color',
  5172. value: filledStyle.headButtonLabel,
  5173. input: 'color',
  5174. },
  5175. {
  5176. label: 'Sticky Color',
  5177. value: filledStyle.headButtonSticky,
  5178. input: 'color',
  5179. },
  5180. {
  5181. label: 'Style Color',
  5182. value: filledStyle.headButtonStyle,
  5183. input: 'color',
  5184. },
  5185. {
  5186. label: 'Hide Color',
  5187. value: filledStyle.headButtonHide,
  5188. input: 'color',
  5189. },
  5190. {
  5191. label: 'Alt Buttons Color',
  5192. value: filledStyle.headButtonAlt,
  5193. input: 'color',
  5194. },
  5195. ],
  5196. },
  5197. ],
  5198. },
  5199. {
  5200. label: 'Body',
  5201. children: [
  5202. {
  5203. label: 'General',
  5204. children: [
  5205. {
  5206. label: 'Header Node Color',
  5207. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeHeaderBase,
  5208. input: 'color',
  5209. },
  5210. {
  5211. label: 'Blend Node Color',
  5212. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeBlendBase,
  5213. input: 'color',
  5214. },
  5215. {
  5216. label: 'Value Node Color',
  5217. value: _consts__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_STYLE.nodeValueBase,
  5218. input: 'color',
  5219. },
  5220. {
  5221. label: 'Contrast Method',
  5222. value: filledStyle.nodeContrast,
  5223. options: [..._types__WEBPACK_IMPORTED_MODULE_4__.CONTRAST_METHODS],
  5224. },
  5225. ],
  5226. },
  5227. {
  5228. label: 'Buttons',
  5229. children: [
  5230. {
  5231. label: 'Create Color',
  5232. value: filledStyle.nodeButtonCreate,
  5233. input: 'color',
  5234. },
  5235. {
  5236. label: 'Duplicate Color',
  5237. value: filledStyle.nodeButtonDuplicate,
  5238. input: 'color',
  5239. },
  5240. {
  5241. label: 'Move Color',
  5242. value: filledStyle.nodeButtonMove,
  5243. input: 'color',
  5244. },
  5245. {
  5246. label: 'Disable Color',
  5247. value: filledStyle.nodeButtonDisable,
  5248. input: 'color',
  5249. },
  5250. {
  5251. label: 'Delete Color',
  5252. value: filledStyle.nodeButtonDelete,
  5253. input: 'color',
  5254. },
  5255. ],
  5256. },
  5257. {
  5258. label: 'Miscellaneous',
  5259. children: [
  5260. {
  5261. label: 'Valid Color',
  5262. value: filledStyle.validBackground,
  5263. input: 'color',
  5264. },
  5265. {
  5266. label: 'Invalid Color',
  5267. value: filledStyle.invalidBackground,
  5268. input: 'color',
  5269. },
  5270. {
  5271. label: 'Focus Color',
  5272. value: filledStyle.focusBackground,
  5273. input: 'color',
  5274. },
  5275. {
  5276. label: 'Tooltip Color',
  5277. value: filledStyle.borderTooltip,
  5278. input: 'color',
  5279. },
  5280. ],
  5281. },
  5282. ],
  5283. },
  5284. ],
  5285. };
  5286. }
  5287. function toRawStyle(json) {
  5288. const [, modal, header, body] = json.children.map(({ children }) => children);
  5289. const [headerGeneral, headerButtons] = header.map(({ children }) => children);
  5290. const [bodyGeneral, bodyButtons, bodyMisc] = body.map(({ children }) => children);
  5291. return {
  5292. width: modal[0].value,
  5293. height: modal[1].value,
  5294. fontSize: modal[2].value,
  5295. borderModal: modal[3].value,
  5296. headBase: headerGeneral[0].value,
  5297. headContrast: headerGeneral[1].value,
  5298. headButtonExit: headerButtons[0].value,
  5299. headButtonLabel: headerButtons[1].value,
  5300. headButtonSticky: headerButtons[2].value,
  5301. headButtonStyle: headerButtons[3].value,
  5302. headButtonHide: headerButtons[4].value,
  5303. headButtonAlt: headerButtons[5].value,
  5304. nodeHeaderBase: bodyGeneral[0].value,
  5305. nodeBlendBase: bodyGeneral[1].value,
  5306. nodeValueBase: bodyGeneral[2].value,
  5307. nodeContrast: bodyGeneral[3].value,
  5308. nodeButtonCreate: bodyButtons[0].value,
  5309. nodeButtonDuplicate: bodyButtons[1].value,
  5310. nodeButtonMove: bodyButtons[2].value,
  5311. nodeButtonDisable: bodyButtons[3].value,
  5312. nodeButtonDelete: bodyButtons[4].value,
  5313. validBackground: bodyMisc[0].value,
  5314. invalidBackground: bodyMisc[1].value,
  5315. focusBackground: bodyMisc[2].value,
  5316. borderTooltip: bodyMisc[3].value,
  5317. };
  5318. }
  5319. // For returning updated styles to the userscript
  5320. function getUserStyles() {
  5321. const { activeTree: { 'children': styleNodes } } = getRoot().getSaveData();
  5322. const styles = [];
  5323. for (const json of styleNodes) {
  5324. styles.push(Object.assign({ name: json.value, isActive: json.children[0].value }, toRawStyle(json)));
  5325. }
  5326. return styles;
  5327. }
  5328. function generate(userStyles, devStyle) {
  5329. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  5330. const defaultStyle = getFilledStyle(devStyle);
  5331. return (0,___WEBPACK_IMPORTED_MODULE_3__.generateTree)({
  5332. children: userStyles.map(toJSON),
  5333. seed: toJSON(Object.assign({ name: 'New Style', isActive: false }, defaultStyle)),
  5334. descendantPredicate: (styles) => {
  5335. let count = 0;
  5336. for (const { isActive, children: [{ value }] } of styles) {
  5337. if (isActive && value && ++count > 1) {
  5338. return 'Only one color scheme may be active at a time.';
  5339. }
  5340. }
  5341. return true;
  5342. },
  5343. onDescendantUpdate: (styles) => {
  5344. for (const style of styles) {
  5345. if (style.isActive && style.children[0].value) {
  5346. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(toRawStyle(style));
  5347. return;
  5348. }
  5349. }
  5350. (0,_update__WEBPACK_IMPORTED_MODULE_2__["default"])(defaultStyle);
  5351. },
  5352. }, _consts__WEBPACK_IMPORTED_MODULE_0__.ROOT_ID);
  5353. }
  5354.  
  5355.  
  5356. /***/ }),
  5357.  
  5358. /***/ "./ts/modal/body/style/update.ts":
  5359. /*!***************************************!*\
  5360. !*** ./ts/modal/body/style/update.ts ***!
  5361. \***************************************/
  5362. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5363.  
  5364. __webpack_require__.r(__webpack_exports__);
  5365. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5366. /* harmony export */ "default": () => (/* binding */ updateStylesheet)
  5367. /* harmony export */ });
  5368. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5369. var __rest = (undefined && undefined.__rest) || function (s, e) {
  5370. var t = {};
  5371. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  5372. t[p] = s[p];
  5373. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  5374. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  5375. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  5376. t[p[i]] = s[p[i]];
  5377. }
  5378. return t;
  5379. };
  5380.  
  5381. const styleNode = document.createElement('style');
  5382. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.registerStyleNode)(styleNode);
  5383. function getContrast(hex, method) {
  5384. const r = parseInt(hex.slice(1, 3), 16);
  5385. const g = parseInt(hex.slice(3, 5), 16);
  5386. const b = parseInt(hex.slice(5, 7), 16);
  5387. switch (method) {
  5388. case 'Black / White': {
  5389. // https://stackoverflow.com/a/3943023/112731
  5390. const luminosity = r * 0.299 + g * 0.587 + b * 0.114;
  5391. return luminosity > 145 ? 'black' : 'white';
  5392. }
  5393. }
  5394. const toHexPart = (rgb) => {
  5395. const x = (255 - rgb).toString(16);
  5396. return x.length === 2 ? x : `0${x}`;
  5397. };
  5398. return `#${toHexPart(r)}${toHexPart((g))}${toHexPart(b)}`;
  5399. }
  5400. function updateStylesheet(_a) {
  5401. var { fontSize, width, height, headContrast, nodeContrast } = _a, colours = __rest(_a, ["fontSize", "width", "height", "headContrast", "nodeContrast"]);
  5402. for (let i = styleNode.sheet.cssRules.length - 1; i >= 0; --i) {
  5403. styleNode.sheet.deleteRule(i);
  5404. }
  5405. const variables = Object.entries(colours).map(([property, value]) => [`--${property}`, value]);
  5406. variables.push(['--fontSize', `${fontSize}px`], ['--width', `${width}%`], ['--height', `${height}%`]);
  5407. variables.push(['--nodeHeaderContrast', getContrast(colours.nodeHeaderBase, nodeContrast)]);
  5408. variables.push(['--nodeBlendContrast', getContrast(colours.nodeBlendBase, nodeContrast)]);
  5409. variables.push(['--nodeValueContrast', getContrast(colours.nodeValueBase, nodeContrast)]);
  5410. variables.push(['--headContrast', getContrast(colours.headBase, headContrast)]);
  5411. (0,_modal_css__WEBPACK_IMPORTED_MODULE_0__.addVariables)(variables, styleNode);
  5412. }
  5413.  
  5414.  
  5415. /***/ }),
  5416.  
  5417. /***/ "./ts/modal/consts.ts":
  5418. /*!****************************!*\
  5419. !*** ./ts/modal/consts.ts ***!
  5420. \****************************/
  5421. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5422.  
  5423. __webpack_require__.r(__webpack_exports__);
  5424. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5425. /* harmony export */ BUTTON_ACTIVE_CLASS: () => (/* binding */ BUTTON_ACTIVE_CLASS),
  5426. /* harmony export */ MODAL_BACKGROUND_ID: () => (/* binding */ MODAL_BACKGROUND_ID),
  5427. /* harmony export */ MODAL_ID: () => (/* binding */ MODAL_ID),
  5428. /* harmony export */ NODE_HEIGHT: () => (/* binding */ NODE_HEIGHT),
  5429. /* harmony export */ SUB_PIXEL_BS: () => (/* binding */ SUB_PIXEL_BS),
  5430. /* harmony export */ SVG_NAMESPACE: () => (/* binding */ SVG_NAMESPACE)
  5431. /* harmony export */ });
  5432. const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
  5433. // Indicates 'on' state for actions that can be turned on and off
  5434. const BUTTON_ACTIVE_CLASS = 'active';
  5435. const MODAL_BACKGROUND_ID = 'modal-background';
  5436. const MODAL_ID = 'modal-content';
  5437. const SUB_PIXEL_BS = 1 / window.devicePixelRatio;
  5438. const NODE_HEIGHT = 1.6;
  5439.  
  5440.  
  5441. /***/ }),
  5442.  
  5443. /***/ "./ts/modal/css.ts":
  5444. /*!*************************!*\
  5445. !*** ./ts/modal/css.ts ***!
  5446. \*************************/
  5447. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5448.  
  5449. __webpack_require__.r(__webpack_exports__);
  5450. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5451. /* harmony export */ addRule: () => (/* binding */ addRule),
  5452. /* harmony export */ addVariables: () => (/* binding */ addVariables),
  5453. /* harmony export */ "default": () => (/* binding */ generate),
  5454. /* harmony export */ getRuleString: () => (/* binding */ getRuleString),
  5455. /* harmony export */ registerStyleNode: () => (/* binding */ registerStyleNode)
  5456. /* harmony export */ });
  5457. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  5458. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/modal/index.ts");
  5459.  
  5460.  
  5461. const styleNode = document.createElement('style');
  5462. const undockedStyleNodes = [styleNode];
  5463. function registerStyleNode(node) {
  5464. undockedStyleNodes.push(node);
  5465. }
  5466. function mountStyleNodes() {
  5467. const { head } = (0,_index__WEBPACK_IMPORTED_MODULE_1__.getDocument)();
  5468. for (const node of undockedStyleNodes) {
  5469. head.appendChild(node);
  5470. }
  5471. }
  5472. function isStyle(candidate) {
  5473. return candidate.length > 0 && typeof candidate[0] === 'string';
  5474. }
  5475. function getStyleString([property, value]) {
  5476. return `${property}:${value};`;
  5477. }
  5478. function getRuleStrings(styles) {
  5479. return isStyle(styles) ? getStyleString(styles) : styles.map(getStyleString).join('');
  5480. }
  5481. function getRuleString(selectors, styles) {
  5482. const styleString = getRuleStrings(styles);
  5483. const selectorString = typeof selectors === 'string' ? selectors : selectors.join(',');
  5484. return `${selectorString}{${styleString}}`;
  5485. }
  5486. function addRule(selectors, styles, { sheet } = styleNode) {
  5487. sheet.insertRule(getRuleString(selectors, styles));
  5488. }
  5489. function addVariables(rules, { sheet } = styleNode) {
  5490. const styleString = rules.map(getStyleString).join('');
  5491. sheet.insertRule(`:root{${styleString}}`);
  5492. }
  5493. function generate() {
  5494. mountStyleNodes();
  5495. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID}`, [
  5496. ['position', 'fixed'],
  5497. ['left', '0'],
  5498. ['top', '0'],
  5499. ['width', '100%'],
  5500. ['height', '100%'],
  5501. ['background-color', '#0003'],
  5502. ['display', 'flex'],
  5503. ['align-content', 'center'],
  5504. ['flex-wrap', 'wrap'],
  5505. ['justify-content', 'center'],
  5506. ]);
  5507. addRule(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID}`, [
  5508. ['width', 'var(--width)'],
  5509. ['height', 'var(--height)'],
  5510. ['font-size', 'var(--fontSize)'],
  5511. ['font-family', 'Tahoma, Geneva, sans-serif'],
  5512. ['outline', 'var(--borderModal) solid 2px'],
  5513. ['box-shadow', '1px 1px 10px 4px #00000015, 0 0 30px 10px #00000065'],
  5514. ['display', 'flex'],
  5515. ['flex-direction', 'column'],
  5516. ['position', 'relative'],
  5517. ]);
  5518. addRule('button', [
  5519. ['display', 'inline-flex'],
  5520. ['cursor', 'pointer'],
  5521. ['background', 'none'],
  5522. ['font-size', 'inherit'],
  5523. ['padding', '0'],
  5524. ['margin', '0'],
  5525. ['border', 'none'],
  5526. ['outline-offset', '-2px'],
  5527. ]);
  5528. addRule('button *', [['pointer-events', 'none']]);
  5529. addRule('svg', [['fill', 'none']]);
  5530. addRule('input', [
  5531. ['font', 'inherit'],
  5532. ['background', 'inherit'],
  5533. ['color', 'inherit'],
  5534. ['border', 'none'],
  5535. ]);
  5536. addRule(':focus-visible:not(button):not(input)', [['outline', 'none']]);
  5537. addRule('label', [['cursor', 'inherit']]);
  5538. }
  5539.  
  5540.  
  5541. /***/ }),
  5542.  
  5543. /***/ "./ts/modal/header/actions/alternate/button.ts":
  5544. /*!*****************************************************!*\
  5545. !*** ./ts/modal/header/actions/alternate/button.ts ***!
  5546. \*****************************************************/
  5547. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5548.  
  5549. __webpack_require__.r(__webpack_exports__);
  5550. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5551. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5552. /* harmony export */ });
  5553. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5554. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5555. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5556.  
  5557.  
  5558.  
  5559. const ALPHA = Math.PI / 5;
  5560. const RADIUS = 46;
  5561. const points = [];
  5562. // https://stackoverflow.com/questions/14580033/algorithm-for-drawing-a-5-point-star
  5563. for (let i = 0; i < 12; ++i) {
  5564. const r = RADIUS * (i % 2 + 1) / 2;
  5565. const omega = ALPHA * i;
  5566. points.push([r * Math.sin(omega), r * Math.cos(omega)]);
  5567. }
  5568. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5569. outline.setAttribute('stroke-linecap', 'round');
  5570. outline.setAttribute('stroke-width', '7');
  5571. outline.setAttribute('d', points.map(([x, y], i) => `${i === 0 ? 'M' : 'L'} ${x} ${y}`).join(' '));
  5572. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5573. g.append(outline);
  5574. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Special Buttons');
  5575. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5576.  
  5577.  
  5578. /***/ }),
  5579.  
  5580. /***/ "./ts/modal/header/actions/alternate/consts.ts":
  5581. /*!*****************************************************!*\
  5582. !*** ./ts/modal/header/actions/alternate/consts.ts ***!
  5583. \*****************************************************/
  5584. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5585.  
  5586. __webpack_require__.r(__webpack_exports__);
  5587. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5588. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID)
  5589. /* harmony export */ });
  5590. const ACTION_ID = 'modal-alt';
  5591.  
  5592.  
  5593. /***/ }),
  5594.  
  5595. /***/ "./ts/modal/header/actions/alternate/css.ts":
  5596. /*!**************************************************!*\
  5597. !*** ./ts/modal/header/actions/alternate/css.ts ***!
  5598. \**************************************************/
  5599. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5600.  
  5601. __webpack_require__.r(__webpack_exports__);
  5602. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5603. /* harmony export */ "default": () => (/* binding */ generate)
  5604. /* harmony export */ });
  5605. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5606. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  5607.  
  5608.  
  5609. function generate() {
  5610. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonAlt');
  5611. }
  5612.  
  5613.  
  5614. /***/ }),
  5615.  
  5616. /***/ "./ts/modal/header/actions/alternate/index.ts":
  5617. /*!****************************************************!*\
  5618. !*** ./ts/modal/header/actions/alternate/index.ts ***!
  5619. \****************************************************/
  5620. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5621.  
  5622. __webpack_require__.r(__webpack_exports__);
  5623. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5624. /* harmony export */ "default": () => (/* binding */ generate),
  5625. /* harmony export */ doAction: () => (/* binding */ doAction),
  5626. /* harmony export */ isActive: () => (/* binding */ isActive)
  5627. /* harmony export */ });
  5628. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/alternate/button.ts");
  5629. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/alternate/consts.ts");
  5630. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/alternate/css.ts");
  5631. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5632. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  5633. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5634.  
  5635.  
  5636.  
  5637.  
  5638.  
  5639.  
  5640. let _isActive = false;
  5641. let toggledOn = false;
  5642. function isActive() {
  5643. return _isActive;
  5644. }
  5645. function doAction(doActivate = !_isActive) {
  5646. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, doActivate);
  5647. _isActive = doActivate;
  5648. }
  5649. function generate() {
  5650. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5651. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], () => {
  5652. toggledOn = !toggledOn;
  5653. doAction(toggledOn);
  5654. });
  5655. _button__WEBPACK_IMPORTED_MODULE_0__["default"].title += ' (Ctrl)';
  5656. const target = (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getDocument)();
  5657. target.addEventListener('keydown', (event) => {
  5658. if (event.key === 'Control' && !toggledOn) {
  5659. doAction(true);
  5660. }
  5661. });
  5662. target.addEventListener('keyup', (event) => {
  5663. if (event.key === 'Control' && !toggledOn) {
  5664. doAction(false);
  5665. }
  5666. });
  5667. (0,_modal__WEBPACK_IMPORTED_MODULE_5__.getWindow)().addEventListener('blur', () => {
  5668. if (!toggledOn) {
  5669. doAction(false);
  5670. }
  5671. });
  5672. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5673. }
  5674.  
  5675.  
  5676. /***/ }),
  5677.  
  5678. /***/ "./ts/modal/header/actions/button.ts":
  5679. /*!*******************************************!*\
  5680. !*** ./ts/modal/header/actions/button.ts ***!
  5681. \*******************************************/
  5682. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5683.  
  5684. __webpack_require__.r(__webpack_exports__);
  5685. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5686. /* harmony export */ bindAction: () => (/* binding */ bindAction),
  5687. /* harmony export */ getNewButton: () => (/* binding */ getNewButton)
  5688. /* harmony export */ });
  5689. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5690. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5691. /* harmony import */ var _modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal */ "./ts/modal/index.ts");
  5692.  
  5693.  
  5694.  
  5695. // Adds the template to the DOM
  5696. function bindAction(button, doAction, hotkey) {
  5697. const bound = (event) => {
  5698. event.stopPropagation();
  5699. button.blur();
  5700. doAction();
  5701. };
  5702. button.addEventListener('click', bound);
  5703. if (hotkey) {
  5704. button.title += ` (Alt+${hotkey})`;
  5705. (0,_modal__WEBPACK_IMPORTED_MODULE_2__.getDocument)().addEventListener('keydown', (event) => {
  5706. if (event.altKey && event.key.toUpperCase() === hotkey) {
  5707. bound(event);
  5708. }
  5709. });
  5710. }
  5711. return bound;
  5712. }
  5713. // Creates a template
  5714. const getNewButton = (function () {
  5715. const buttonTemplate = document.createElement('button');
  5716. const svgTemplate = document.createElementNS(_consts__WEBPACK_IMPORTED_MODULE_1__.SVG_NAMESPACE, 'svg');
  5717. buttonTemplate.classList.add(_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS);
  5718. buttonTemplate.setAttribute('tabindex', '-1');
  5719. svgTemplate.setAttribute('viewBox', `-70 -70 140 140`);
  5720. return function (group, actionId, description) {
  5721. const button = buttonTemplate.cloneNode(true);
  5722. const svg = svgTemplate.cloneNode(true);
  5723. button.id = actionId;
  5724. button.title = description;
  5725. svg.append(group);
  5726. button.append(svg);
  5727. return button;
  5728. };
  5729. })();
  5730.  
  5731.  
  5732. /***/ }),
  5733.  
  5734. /***/ "./ts/modal/header/actions/close/button.ts":
  5735. /*!*************************************************!*\
  5736. !*** ./ts/modal/header/actions/close/button.ts ***!
  5737. \*************************************************/
  5738. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5739.  
  5740. __webpack_require__.r(__webpack_exports__);
  5741. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5742. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5743. /* harmony export */ });
  5744. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5745. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5746. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5747.  
  5748.  
  5749.  
  5750. const line0 = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'line');
  5751. line0.setAttribute('stroke-linecap', 'round');
  5752. line0.setAttribute('stroke-width', '12');
  5753. line0.setAttribute('x1', '-30');
  5754. line0.setAttribute('x2', '30');
  5755. line0.setAttribute('y1', '-30');
  5756. line0.setAttribute('y2', '30');
  5757. const line1 = line0.cloneNode(true);
  5758. line1.setAttribute('transform', 'rotate(90 0 0)');
  5759. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5760. g.append(line0, line1);
  5761. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Save & Exit');
  5762. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5763.  
  5764.  
  5765. /***/ }),
  5766.  
  5767. /***/ "./ts/modal/header/actions/close/consts.ts":
  5768. /*!*************************************************!*\
  5769. !*** ./ts/modal/header/actions/close/consts.ts ***!
  5770. \*************************************************/
  5771. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5772.  
  5773. __webpack_require__.r(__webpack_exports__);
  5774. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5775. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5776. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5777. /* harmony export */ });
  5778. const ACTION_ID = 'modal-close';
  5779. const HOTKEY = 'X';
  5780.  
  5781.  
  5782. /***/ }),
  5783.  
  5784. /***/ "./ts/modal/header/actions/close/css.ts":
  5785. /*!**********************************************!*\
  5786. !*** ./ts/modal/header/actions/close/css.ts ***!
  5787. \**********************************************/
  5788. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5789.  
  5790. __webpack_require__.r(__webpack_exports__);
  5791. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5792. /* harmony export */ "default": () => (/* binding */ generate)
  5793. /* harmony export */ });
  5794. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5795. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  5796.  
  5797.  
  5798. function generate() {
  5799. (0,_modal_css__WEBPACK_IMPORTED_MODULE_1__.addRule)([
  5800. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:focus > svg`,
  5801. `#${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:hover > svg`,
  5802. ], ['background-color', 'var(--headButtonExit)']);
  5803. }
  5804.  
  5805.  
  5806. /***/ }),
  5807.  
  5808. /***/ "./ts/modal/header/actions/close/index.ts":
  5809. /*!************************************************!*\
  5810. !*** ./ts/modal/header/actions/close/index.ts ***!
  5811. \************************************************/
  5812. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5813.  
  5814. __webpack_require__.r(__webpack_exports__);
  5815. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5816. /* harmony export */ "default": () => (/* binding */ generate),
  5817. /* harmony export */ setCallback: () => (/* binding */ setCallback)
  5818. /* harmony export */ });
  5819. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/close/button.ts");
  5820. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/close/consts.ts");
  5821. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/close/css.ts");
  5822. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5823. /* harmony import */ var _modal_body_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data */ "./ts/modal/body/data/index.ts");
  5824. /* harmony import */ var _modal_body_style__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style */ "./ts/modal/body/style/index.ts");
  5825. /* harmony import */ var _nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  5826. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  5827.  
  5828.  
  5829.  
  5830.  
  5831.  
  5832.  
  5833.  
  5834.  
  5835. let callback;
  5836. function setCallback(_callback) {
  5837. callback = _callback;
  5838. }
  5839. // TODO Maybe add a white, 0.5 opacity foreground over everything with a loading symbol.
  5840. // Do the same when waiting for a config.
  5841. // Prevent interaction during loading by adding a stopPropagation click listener to the foreground.
  5842. function doAction() {
  5843. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  5844. (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_7__.reset)();
  5845. callback === null || callback === void 0 ? void 0 : callback(Object.assign(Object.assign({}, (0,_modal_body_data__WEBPACK_IMPORTED_MODULE_4__.getSaveData)()), { styles: (0,_modal_body_style__WEBPACK_IMPORTED_MODULE_5__.getUserStyles)() }));
  5846. callback = undefined;
  5847. }
  5848. function generate(background) {
  5849. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  5850. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  5851. background.addEventListener('click', (event) => {
  5852. if (background.isSameNode(event.target)) {
  5853. doAction();
  5854. }
  5855. });
  5856. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  5857. }
  5858.  
  5859.  
  5860. /***/ }),
  5861.  
  5862. /***/ "./ts/modal/header/actions/consts.ts":
  5863. /*!*******************************************!*\
  5864. !*** ./ts/modal/header/actions/consts.ts ***!
  5865. \*******************************************/
  5866. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5867.  
  5868. __webpack_require__.r(__webpack_exports__);
  5869. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5870. /* harmony export */ BUTTON_CLASS: () => (/* binding */ BUTTON_CLASS),
  5871. /* harmony export */ BUTTON_CONTAINER_ID: () => (/* binding */ BUTTON_CONTAINER_ID)
  5872. /* harmony export */ });
  5873. const BUTTON_CLASS = 'modal-button';
  5874. const BUTTON_CONTAINER_ID = 'modal-button-container';
  5875.  
  5876.  
  5877. /***/ }),
  5878.  
  5879. /***/ "./ts/modal/header/actions/css.ts":
  5880. /*!****************************************!*\
  5881. !*** ./ts/modal/header/actions/css.ts ***!
  5882. \****************************************/
  5883. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5884.  
  5885. __webpack_require__.r(__webpack_exports__);
  5886. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5887. /* harmony export */ addColourRule: () => (/* binding */ addColourRule),
  5888. /* harmony export */ "default": () => (/* binding */ generate)
  5889. /* harmony export */ });
  5890. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  5891. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../consts */ "./ts/modal/consts.ts");
  5892. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  5893.  
  5894.  
  5895.  
  5896. const ACTIVE_SELECTOR = `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}.${_consts__WEBPACK_IMPORTED_MODULE_1__.BUTTON_ACTIVE_CLASS}`;
  5897. function addColourRule(actionId, colour) {
  5898. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${actionId}${ACTIVE_SELECTOR} > svg`, [['fill', `var(${colour})`]]);
  5899. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([`#${actionId}${ACTIVE_SELECTOR}:not(:hover):not(:focus) > svg`], [['stroke', `var(${colour})`]]);
  5900. }
  5901. function generate() {
  5902. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CONTAINER_ID}`, [
  5903. ['display', 'inline-flex'],
  5904. ['flex-direction', 'row-reverse'],
  5905. ['max-width', '80%'],
  5906. ['overflow-x', 'scroll'],
  5907. ['scrollbar-width', 'none'],
  5908. ['overscroll-behavior', 'contain'],
  5909. ['border-left', '2px solid var(--headContrast)'],
  5910. ]);
  5911. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5912. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5913. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5914. `${ACTIVE_SELECTOR} > svg`,
  5915. ], ['background-color', `var(--headContrast)`]);
  5916. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:last-child)`, ['border-left', '2px solid var(--headContrast)']);
  5917. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5918. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):focus`,
  5919. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:not(:first-child):hover`,
  5920. `${ACTIVE_SELECTOR}:not(:first-child)`,
  5921. ], ['border-color', 'var(--headBase)']);
  5922. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)([
  5923. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:focus > svg`,
  5924. `.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS}:hover > svg`,
  5925. ], ['stroke', `var(--headBase)`]);
  5926. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`.${_consts__WEBPACK_IMPORTED_MODULE_0__.BUTTON_CLASS} > svg`, [
  5927. ['width', '1.7em'],
  5928. ['stroke', 'var(--headContrast)'],
  5929. ['fill', `var(--headContrast)`],
  5930. // Fixes pixel gap between button border & svg
  5931. ['margin-left', '-0.5px'],
  5932. ]);
  5933. }
  5934.  
  5935.  
  5936. /***/ }),
  5937.  
  5938. /***/ "./ts/modal/header/actions/hide/button.ts":
  5939. /*!************************************************!*\
  5940. !*** ./ts/modal/header/actions/hide/button.ts ***!
  5941. \************************************************/
  5942. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5943.  
  5944. __webpack_require__.r(__webpack_exports__);
  5945. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5946. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  5947. /* harmony export */ });
  5948. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  5949. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  5950. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  5951.  
  5952.  
  5953.  
  5954. const edgeTop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  5955. edgeTop.setAttribute('stroke-linecap', 'round');
  5956. edgeTop.setAttribute('stroke-width', '7');
  5957. edgeTop.setAttribute('d', 'M -55 0'
  5958. + ' Q 0 60 55 0');
  5959. edgeTop.setAttribute('fill', 'none');
  5960. const edgeBottom = edgeTop.cloneNode(true);
  5961. edgeBottom.setAttribute('transform', 'scale(1,-1)');
  5962. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  5963. circle.setAttribute('cx', '0');
  5964. circle.setAttribute('cy', '0');
  5965. circle.setAttribute('r', '26');
  5966. circle.setAttribute('stroke-width', '6');
  5967. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  5968. g.append(edgeTop, edgeBottom, circle);
  5969. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Disabled Node Visibility');
  5970. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  5971.  
  5972.  
  5973. /***/ }),
  5974.  
  5975. /***/ "./ts/modal/header/actions/hide/consts.ts":
  5976. /*!************************************************!*\
  5977. !*** ./ts/modal/header/actions/hide/consts.ts ***!
  5978. \************************************************/
  5979. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5980.  
  5981. __webpack_require__.r(__webpack_exports__);
  5982. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5983. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  5984. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  5985. /* harmony export */ });
  5986. const ACTION_ID = 'modal-hide';
  5987. const HOTKEY = 'H';
  5988.  
  5989.  
  5990. /***/ }),
  5991.  
  5992. /***/ "./ts/modal/header/actions/hide/css.ts":
  5993. /*!*********************************************!*\
  5994. !*** ./ts/modal/header/actions/hide/css.ts ***!
  5995. \*********************************************/
  5996. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5997.  
  5998. __webpack_require__.r(__webpack_exports__);
  5999. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6000. /* harmony export */ "default": () => (/* binding */ generate)
  6001. /* harmony export */ });
  6002. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  6003. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6004. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6005. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6006. /* harmony import */ var _nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/buttons/disable/consts */ "./ts/modal/body/nodes/actions/buttons/disable/consts.ts");
  6007.  
  6008.  
  6009.  
  6010.  
  6011.  
  6012. function generate() {
  6013. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_actions_buttons_disable_consts__WEBPACK_IMPORTED_MODULE_4__.DISABLED_CLASS}`, ['display', 'none']);
  6014. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonHide');
  6015. }
  6016.  
  6017.  
  6018. /***/ }),
  6019.  
  6020. /***/ "./ts/modal/header/actions/hide/index.ts":
  6021. /*!***********************************************!*\
  6022. !*** ./ts/modal/header/actions/hide/index.ts ***!
  6023. \***********************************************/
  6024. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6025.  
  6026. __webpack_require__.r(__webpack_exports__);
  6027. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6028. /* harmony export */ "default": () => (/* binding */ generate)
  6029. /* harmony export */ });
  6030. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/hide/button.ts");
  6031. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/hide/consts.ts");
  6032. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/hide/css.ts");
  6033. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6034. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040. let isActive = false;
  6041. function doAction() {
  6042. isActive = !isActive;
  6043. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6044. }
  6045. function generate() {
  6046. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6047. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6048. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6049. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6050. }
  6051.  
  6052.  
  6053. /***/ }),
  6054.  
  6055. /***/ "./ts/modal/header/actions/index.ts":
  6056. /*!******************************************!*\
  6057. !*** ./ts/modal/header/actions/index.ts ***!
  6058. \******************************************/
  6059. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6060.  
  6061. __webpack_require__.r(__webpack_exports__);
  6062. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6063. /* harmony export */ "default": () => (/* binding */ generate)
  6064. /* harmony export */ });
  6065. /* harmony import */ var _close__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./close */ "./ts/modal/header/actions/close/index.ts");
  6066. /* harmony import */ var _sticky__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sticky */ "./ts/modal/header/actions/sticky/index.ts");
  6067. /* harmony import */ var _labels__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./labels */ "./ts/modal/header/actions/labels/index.ts");
  6068. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./ts/modal/header/actions/style/index.ts");
  6069. /* harmony import */ var _hide__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hide */ "./ts/modal/header/actions/hide/index.ts");
  6070. /* harmony import */ var _alternate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./alternate */ "./ts/modal/header/actions/alternate/index.ts");
  6071. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/css.ts");
  6072. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/consts.ts");
  6073.  
  6074.  
  6075.  
  6076.  
  6077.  
  6078.  
  6079.  
  6080.  
  6081. function generate(background) {
  6082. (0,_css__WEBPACK_IMPORTED_MODULE_6__["default"])();
  6083. const element = document.createElement('span');
  6084. element.id = _consts__WEBPACK_IMPORTED_MODULE_7__.BUTTON_CONTAINER_ID;
  6085. element.setAttribute('tabindex', '-1');
  6086. element.append((0,_close__WEBPACK_IMPORTED_MODULE_0__["default"])(background), (0,_style__WEBPACK_IMPORTED_MODULE_3__["default"])(), (0,_sticky__WEBPACK_IMPORTED_MODULE_1__["default"])(), (0,_labels__WEBPACK_IMPORTED_MODULE_2__["default"])(), (0,_hide__WEBPACK_IMPORTED_MODULE_4__["default"])(), (0,_alternate__WEBPACK_IMPORTED_MODULE_5__["default"])());
  6087. return element;
  6088. }
  6089.  
  6090.  
  6091. /***/ }),
  6092.  
  6093. /***/ "./ts/modal/header/actions/labels/button.ts":
  6094. /*!**************************************************!*\
  6095. !*** ./ts/modal/header/actions/labels/button.ts ***!
  6096. \**************************************************/
  6097. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6098.  
  6099. __webpack_require__.r(__webpack_exports__);
  6100. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6101. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6102. /* harmony export */ });
  6103. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6104. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6105. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6106.  
  6107.  
  6108.  
  6109. const outline = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6110. outline.setAttribute('stroke-linecap', 'round');
  6111. outline.setAttribute('stroke-width', '7');
  6112. outline.setAttribute('d', 'M 20 -30'
  6113. + ' L -40 -30'
  6114. + ' L -40 30'
  6115. + ' L 20 30'
  6116. + ' L 50 0'
  6117. + ' L 20 -30');
  6118. const circle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'circle');
  6119. circle.setAttribute('stroke-width', '5');
  6120. circle.setAttribute('r', '5');
  6121. circle.setAttribute('cx', '20');
  6122. circle.setAttribute('cy', '0');
  6123. const loop = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6124. loop.setAttribute('fill', 'none');
  6125. loop.setAttribute('stroke-linecap', 'round');
  6126. loop.setAttribute('stroke-width', '6');
  6127. loop.setAttribute('d', 'M 20 0'
  6128. + ' C -70 50 -30 50 15 30');
  6129. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6130. g.setAttribute('transform', 'rotate(-60 0 0)');
  6131. g.append(outline, circle, loop);
  6132. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Labels');
  6133. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6134.  
  6135.  
  6136. /***/ }),
  6137.  
  6138. /***/ "./ts/modal/header/actions/labels/consts.ts":
  6139. /*!**************************************************!*\
  6140. !*** ./ts/modal/header/actions/labels/consts.ts ***!
  6141. \**************************************************/
  6142. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6143.  
  6144. __webpack_require__.r(__webpack_exports__);
  6145. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6146. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6147. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6148. /* harmony export */ });
  6149. const ACTION_ID = 'modal-labels';
  6150. const HOTKEY = 'N';
  6151.  
  6152.  
  6153. /***/ }),
  6154.  
  6155. /***/ "./ts/modal/header/actions/labels/css.ts":
  6156. /*!***********************************************!*\
  6157. !*** ./ts/modal/header/actions/labels/css.ts ***!
  6158. \***********************************************/
  6159. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6160.  
  6161. __webpack_require__.r(__webpack_exports__);
  6162. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6163. /* harmony export */ "default": () => (/* binding */ generate)
  6164. /* harmony export */ });
  6165. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6166. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6167. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6168. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6169. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175. function generate() {
  6176. (0,_modal_css__WEBPACK_IMPORTED_MODULE_2__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_3__.MODAL_BODY_ID}:not(.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}) .${_nodes_consts__WEBPACK_IMPORTED_MODULE_4__.ELEMENT_CLASSES.LABEL_CONTAINER}`, ['display', 'none']);
  6177. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonLabel');
  6178. }
  6179.  
  6180.  
  6181. /***/ }),
  6182.  
  6183. /***/ "./ts/modal/header/actions/labels/index.ts":
  6184. /*!*************************************************!*\
  6185. !*** ./ts/modal/header/actions/labels/index.ts ***!
  6186. \*************************************************/
  6187. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6188.  
  6189. __webpack_require__.r(__webpack_exports__);
  6190. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6191. /* harmony export */ "default": () => (/* binding */ generate)
  6192. /* harmony export */ });
  6193. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/labels/button.ts");
  6194. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/labels/consts.ts");
  6195. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/labels/css.ts");
  6196. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6197. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6198.  
  6199.  
  6200.  
  6201.  
  6202.  
  6203. let isActive = false;
  6204. function doAction() {
  6205. isActive = !isActive;
  6206. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6207. }
  6208. function generate() {
  6209. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6210. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6211. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6212. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6213. }
  6214.  
  6215.  
  6216. /***/ }),
  6217.  
  6218. /***/ "./ts/modal/header/actions/sticky/button.ts":
  6219. /*!**************************************************!*\
  6220. !*** ./ts/modal/header/actions/sticky/button.ts ***!
  6221. \**************************************************/
  6222. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6223.  
  6224. __webpack_require__.r(__webpack_exports__);
  6225. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6226. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6227. /* harmony export */ });
  6228. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6229. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6230. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6231.  
  6232.  
  6233.  
  6234. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6235. const HANDLE_WIDTH = 50;
  6236. const CURVE_RADIUS = 10;
  6237. handle.setAttribute('stroke-width', '7');
  6238. handle.setAttribute('d', `M ${-HANDLE_WIDTH / 2} -40`
  6239. + ` q 0 ${CURVE_RADIUS} ${CURVE_RADIUS} ${CURVE_RADIUS}`
  6240. + ` q ${CURVE_RADIUS / 2} ${CURVE_RADIUS * 1.5} 0 ${CURVE_RADIUS * 3}`
  6241. + ` q ${-CURVE_RADIUS} 0 ${-CURVE_RADIUS} ${CURVE_RADIUS}`
  6242. + ` l ${HANDLE_WIDTH} 0`
  6243. + ` q 0 ${-CURVE_RADIUS} ${-CURVE_RADIUS} ${-CURVE_RADIUS}`
  6244. + ` q ${-CURVE_RADIUS / 2} ${-CURVE_RADIUS * 1.5} 0 ${-CURVE_RADIUS * 3}`
  6245. + ` q ${CURVE_RADIUS} 0 ${CURVE_RADIUS} ${-CURVE_RADIUS}`
  6246. + ' Z');
  6247. const point = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6248. point.setAttribute('fill', 'none');
  6249. point.setAttribute('stroke-width', '4');
  6250. point.setAttribute('d', 'M -2 -20'
  6251. + ' l 0 50'
  6252. + ' l 2 20'
  6253. + ' l 2 -20'
  6254. + ' l 0 -50'
  6255. + ' Z');
  6256. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6257. g.append(point, handle);
  6258. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Sticky');
  6259. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6260.  
  6261.  
  6262. /***/ }),
  6263.  
  6264. /***/ "./ts/modal/header/actions/sticky/consts.ts":
  6265. /*!**************************************************!*\
  6266. !*** ./ts/modal/header/actions/sticky/consts.ts ***!
  6267. \**************************************************/
  6268. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6269.  
  6270. __webpack_require__.r(__webpack_exports__);
  6271. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6272. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6273. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6274. /* harmony export */ });
  6275. const ACTION_ID = 'modal-sticky';
  6276. const HOTKEY = 'S';
  6277.  
  6278.  
  6279. /***/ }),
  6280.  
  6281. /***/ "./ts/modal/header/actions/sticky/css.ts":
  6282. /*!***********************************************!*\
  6283. !*** ./ts/modal/header/actions/sticky/css.ts ***!
  6284. \***********************************************/
  6285. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6286.  
  6287. __webpack_require__.r(__webpack_exports__);
  6288. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6289. /* harmony export */ "default": () => (/* binding */ generate)
  6290. /* harmony export */ });
  6291. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6292. /* harmony import */ var _style_consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../style/consts */ "./ts/modal/header/actions/style/consts.ts");
  6293. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6294. /* harmony import */ var _modal_css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/css */ "./ts/modal/css.ts");
  6295. /* harmony import */ var _modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body/data/consts */ "./ts/modal/body/data/consts.ts");
  6296. /* harmony import */ var _modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/modal/body/style/consts */ "./ts/modal/body/style/consts.ts");
  6297. /* harmony import */ var _modal_body_consts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/modal/body/consts */ "./ts/modal/body/consts.ts");
  6298. /* harmony import */ var _nodes_consts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @nodes/consts */ "./ts/modal/body/nodes/consts.ts");
  6299. /* harmony import */ var _nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @nodes/actions/focus/consts */ "./ts/modal/body/nodes/actions/focus/consts.ts");
  6300. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6301.  
  6302.  
  6303.  
  6304.  
  6305.  
  6306.  
  6307.  
  6308.  
  6309.  
  6310.  
  6311. function _getHeight(node, pools, depth = 0) {
  6312. if ('poolId' in node) {
  6313. if (!pools[node.poolId]) {
  6314. pools[node.poolId] = [depth, 1];
  6315. }
  6316. else {
  6317. pools[node.poolId][0] = Math.max(pools[node.poolId][0], depth);
  6318. }
  6319. pools[node.poolId][1] = [...node.children, ...('seed' in node ? [node.seed] : [])]
  6320. .reduce((height, child) => Math.max(_getHeight(child, pools, 1), height), pools[node.poolId][1]);
  6321. return 0;
  6322. }
  6323. if ('seed' in node) {
  6324. return _getHeight(node.seed, pools, depth + 1);
  6325. }
  6326. if ('children' in node) {
  6327. return node.children.reduce((height, child) => Math.max(_getHeight(child, pools, depth + 1), height), depth + 1);
  6328. }
  6329. return depth;
  6330. }
  6331. function getHeight(node) {
  6332. const pools = [];
  6333. const height = _getHeight(node, pools);
  6334. return pools.reduce((max, [poolDepth, poolHeight]) => Math.max(max, poolDepth + poolHeight), height);
  6335. }
  6336. function generate(roots) {
  6337. const heights = {
  6338. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: getHeight(roots[_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]),
  6339. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: getHeight(roots[_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]),
  6340. };
  6341. const maxHeight = Math.max(heights[_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID], heights[_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]);
  6342. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addVariables)([['--overlayIndex', `${maxHeight + 1}`]]);
  6343. (0,_css__WEBPACK_IMPORTED_MODULE_2__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonSticky');
  6344. let nodeSelector = `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`;
  6345. for (let depth = 0; depth <= maxHeight; ++depth) {
  6346. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${nodeSelector} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.HEAD_CONTAINER}`, [
  6347. ['position', 'sticky'],
  6348. ['top', `calc(${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em + ${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px)`],
  6349. ['z-index', `${maxHeight - depth}`],
  6350. ]);
  6351. nodeSelector += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.ELEMENT_CONTAINER}`;
  6352. }
  6353. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}::after`, [
  6354. ['content', '\'\''],
  6355. ['display', 'block'],
  6356. ['visibility', 'hidden'],
  6357. ]);
  6358. const selectors = {
  6359. basic: {
  6360. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:has(> #${_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID}:not(.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`,
  6361. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}.${_style_consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID}:has(> #${_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID}:not(.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}) > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`,
  6362. },
  6363. focus: {
  6364. [_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}:has(> #${_modal_body_data_consts__WEBPACK_IMPORTED_MODULE_4__.ROOT_ID}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}`,
  6365. [_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID]: `#${_modal_body_consts__WEBPACK_IMPORTED_MODULE_6__.MODAL_BODY_ID}.${_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID}.${_style_consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID}:has(> #${_modal_body_style_consts__WEBPACK_IMPORTED_MODULE_5__.ROOT_ID}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_CLASS}`,
  6366. },
  6367. };
  6368. for (const [id, height] of Object.entries(heights)) {
  6369. for (let depth = 1; depth <= height + 1; ++depth) {
  6370. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${selectors.basic[id]}:empty)::after`, ['height', `calc(100% - ${(depth) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px - ${depth * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em)`]);
  6371. (0,_modal_css__WEBPACK_IMPORTED_MODULE_3__.addRule)(`${selectors.focus[id]}.${_nodes_actions_focus_consts__WEBPACK_IMPORTED_MODULE_8__.FOCUS_SOURCE_CLASS})::after`, ['height', `calc(100% - ${(depth + 1) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.SUB_PIXEL_BS}px - ${(depth + 1) * _modal_consts__WEBPACK_IMPORTED_MODULE_9__.NODE_HEIGHT}em)`]);
  6372. selectors.basic[id] += ` > :last-child > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER}`;
  6373. selectors.focus[id] += ` > .${_nodes_consts__WEBPACK_IMPORTED_MODULE_7__.ELEMENT_CLASSES.CHILD_CONTAINER} > *`;
  6374. }
  6375. }
  6376. }
  6377.  
  6378.  
  6379. /***/ }),
  6380.  
  6381. /***/ "./ts/modal/header/actions/sticky/index.ts":
  6382. /*!*************************************************!*\
  6383. !*** ./ts/modal/header/actions/sticky/index.ts ***!
  6384. \*************************************************/
  6385. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6386.  
  6387. __webpack_require__.r(__webpack_exports__);
  6388. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6389. /* harmony export */ "default": () => (/* binding */ generate),
  6390. /* harmony export */ isActive: () => (/* binding */ isActive)
  6391. /* harmony export */ });
  6392. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/sticky/button.ts");
  6393. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/sticky/consts.ts");
  6394. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6395. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6396.  
  6397.  
  6398.  
  6399.  
  6400. let _isActive = false;
  6401. function isActive() {
  6402. return _isActive;
  6403. }
  6404. function doAction() {
  6405. _isActive = !_isActive;
  6406. (0,_modal_body__WEBPACK_IMPORTED_MODULE_3__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, _isActive);
  6407. }
  6408. function generate() {
  6409. (0,_button__WEBPACK_IMPORTED_MODULE_2__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6410. _button__WEBPACK_IMPORTED_MODULE_0__["default"].click();
  6411. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6412. }
  6413.  
  6414.  
  6415. /***/ }),
  6416.  
  6417. /***/ "./ts/modal/header/actions/style/button.ts":
  6418. /*!*************************************************!*\
  6419. !*** ./ts/modal/header/actions/style/button.ts ***!
  6420. \*************************************************/
  6421. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6422.  
  6423. __webpack_require__.r(__webpack_exports__);
  6424. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6425. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  6426. /* harmony export */ });
  6427. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6428. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6429. /* harmony import */ var _modal_consts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/modal/consts */ "./ts/modal/consts.ts");
  6430.  
  6431.  
  6432.  
  6433. const handle = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6434. handle.setAttribute('stroke-linecap', 'round');
  6435. handle.setAttribute('stroke-width', '6');
  6436. handle.setAttribute('x', '-5');
  6437. handle.setAttribute('y', '15');
  6438. handle.setAttribute('width', '15');
  6439. handle.setAttribute('height', '40');
  6440. handle.setAttribute('rx', '5');
  6441. const frame = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6442. frame.setAttribute('fill', 'none');
  6443. frame.setAttribute('stroke-linecap', 'round');
  6444. frame.setAttribute('stroke-width', '3');
  6445. frame.setAttribute('d', 'M 2.5 15'
  6446. + ' L 2.5 0'
  6447. + ' L -36 -15'
  6448. + ' L -36 -35'
  6449. + ' L -30 -35');
  6450. const curveLeft = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'path');
  6451. curveLeft.setAttribute('fill', 'none');
  6452. curveLeft.setAttribute('stroke-linecap', 'round');
  6453. curveLeft.setAttribute('stroke-width', '6');
  6454. curveLeft.setAttribute('d', 'M -25 -30'
  6455. + ' Q -30 -35 -25 -40');
  6456. const curveRight = curveLeft.cloneNode(true);
  6457. curveRight.setAttribute('transform', 'scale(-1,1) translate(-10,0)');
  6458. const roller = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'rect');
  6459. roller.setAttribute('stroke-linecap', 'round');
  6460. roller.setAttribute('stroke-width', '6');
  6461. roller.setAttribute('x', '-22.5');
  6462. roller.setAttribute('y', '-47.5');
  6463. roller.setAttribute('width', '55');
  6464. roller.setAttribute('height', '25');
  6465. roller.setAttribute('rx', '1');
  6466. const g = document.createElementNS(_modal_consts__WEBPACK_IMPORTED_MODULE_2__.SVG_NAMESPACE, 'g');
  6467. g.append(handle, frame, curveLeft, curveRight, roller);
  6468. const BUTTON = (0,_button__WEBPACK_IMPORTED_MODULE_1__.getNewButton)(g, _consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, 'Toggle Style Editor');
  6469. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BUTTON);
  6470.  
  6471.  
  6472. /***/ }),
  6473.  
  6474. /***/ "./ts/modal/header/actions/style/consts.ts":
  6475. /*!*************************************************!*\
  6476. !*** ./ts/modal/header/actions/style/consts.ts ***!
  6477. \*************************************************/
  6478. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6479.  
  6480. __webpack_require__.r(__webpack_exports__);
  6481. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6482. /* harmony export */ ACTION_ID: () => (/* binding */ ACTION_ID),
  6483. /* harmony export */ HOTKEY: () => (/* binding */ HOTKEY)
  6484. /* harmony export */ });
  6485. const ACTION_ID = 'modal-style';
  6486. const HOTKEY = 'C';
  6487.  
  6488.  
  6489. /***/ }),
  6490.  
  6491. /***/ "./ts/modal/header/actions/style/css.ts":
  6492. /*!**********************************************!*\
  6493. !*** ./ts/modal/header/actions/style/css.ts ***!
  6494. \**********************************************/
  6495. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6496.  
  6497. __webpack_require__.r(__webpack_exports__);
  6498. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6499. /* harmony export */ "default": () => (/* binding */ generate)
  6500. /* harmony export */ });
  6501. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6502. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/header/actions/css.ts");
  6503.  
  6504.  
  6505. function generate() {
  6506. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addColourRule)(_consts__WEBPACK_IMPORTED_MODULE_0__.ACTION_ID, '--headButtonStyle');
  6507. }
  6508.  
  6509.  
  6510. /***/ }),
  6511.  
  6512. /***/ "./ts/modal/header/actions/style/index.ts":
  6513. /*!************************************************!*\
  6514. !*** ./ts/modal/header/actions/style/index.ts ***!
  6515. \************************************************/
  6516. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6517.  
  6518. __webpack_require__.r(__webpack_exports__);
  6519. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6520. /* harmony export */ "default": () => (/* binding */ generate)
  6521. /* harmony export */ });
  6522. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./ts/modal/header/actions/style/button.ts");
  6523. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/actions/style/consts.ts");
  6524. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./css */ "./ts/modal/header/actions/style/css.ts");
  6525. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../button */ "./ts/modal/header/actions/button.ts");
  6526. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/modal/body */ "./ts/modal/body/index.ts");
  6527. /* harmony import */ var _nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @nodes/actions/focus */ "./ts/modal/body/nodes/actions/focus/index.ts");
  6528. /* harmony import */ var _nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @nodes/actions/buttons/position */ "./ts/modal/body/nodes/actions/buttons/position/index.ts");
  6529.  
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.  
  6536. let isActive = false;
  6537. function doAction() {
  6538. isActive = !isActive;
  6539. (0,_modal_body__WEBPACK_IMPORTED_MODULE_4__.setActive)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], _consts__WEBPACK_IMPORTED_MODULE_1__.ACTION_ID, isActive);
  6540. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.scrollTop = 0;
  6541. (0,_nodes_actions_focus__WEBPACK_IMPORTED_MODULE_5__.reset)();
  6542. (0,_nodes_actions_buttons_position__WEBPACK_IMPORTED_MODULE_6__.reset)();
  6543. // Reset tab index & highlight
  6544. _modal_body__WEBPACK_IMPORTED_MODULE_4__.element.focus();
  6545. }
  6546. function generate() {
  6547. (0,_css__WEBPACK_IMPORTED_MODULE_2__["default"])();
  6548. (0,_button__WEBPACK_IMPORTED_MODULE_3__.bindAction)(_button__WEBPACK_IMPORTED_MODULE_0__["default"], doAction, _consts__WEBPACK_IMPORTED_MODULE_1__.HOTKEY);
  6549. return _button__WEBPACK_IMPORTED_MODULE_0__["default"];
  6550. }
  6551.  
  6552.  
  6553. /***/ }),
  6554.  
  6555. /***/ "./ts/modal/header/consts.ts":
  6556. /*!***********************************!*\
  6557. !*** ./ts/modal/header/consts.ts ***!
  6558. \***********************************/
  6559. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6560.  
  6561. __webpack_require__.r(__webpack_exports__);
  6562. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6563. /* harmony export */ HEADER_ID: () => (/* binding */ HEADER_ID)
  6564. /* harmony export */ });
  6565. const HEADER_ID = 'modal-header';
  6566.  
  6567.  
  6568. /***/ }),
  6569.  
  6570. /***/ "./ts/modal/header/css.ts":
  6571. /*!********************************!*\
  6572. !*** ./ts/modal/header/css.ts ***!
  6573. \********************************/
  6574. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6575.  
  6576. __webpack_require__.r(__webpack_exports__);
  6577. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6578. /* harmony export */ "default": () => (/* binding */ generate)
  6579. /* harmony export */ });
  6580. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  6581. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../css */ "./ts/modal/css.ts");
  6582.  
  6583.  
  6584. function generate() {
  6585. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID}`, [
  6586. ['display', 'flex'],
  6587. ['align-items', 'center'],
  6588. ['background-color', 'var(--headBase)'],
  6589. ['color', 'var(--headContrast)'],
  6590. ['border-bottom', '2px solid var(--borderModal)'],
  6591. ['font-size', '1.5em'],
  6592. ['text-align', 'center'],
  6593. ]);
  6594. }
  6595.  
  6596.  
  6597. /***/ }),
  6598.  
  6599. /***/ "./ts/modal/header/index.ts":
  6600. /*!**********************************!*\
  6601. !*** ./ts/modal/header/index.ts ***!
  6602. \**********************************/
  6603. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6604.  
  6605. __webpack_require__.r(__webpack_exports__);
  6606. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6607. /* harmony export */ "default": () => (/* binding */ generate)
  6608. /* harmony export */ });
  6609. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/consts.ts");
  6610. /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./title */ "./ts/modal/header/title/index.ts");
  6611. /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./ts/modal/header/actions/index.ts");
  6612. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./css */ "./ts/modal/header/css.ts");
  6613.  
  6614.  
  6615.  
  6616.  
  6617. function generate({ title }, background) {
  6618. (0,_css__WEBPACK_IMPORTED_MODULE_3__["default"])();
  6619. const element = document.createElement('div');
  6620. element.id = _consts__WEBPACK_IMPORTED_MODULE_0__.HEADER_ID;
  6621. element.append((0,_title__WEBPACK_IMPORTED_MODULE_1__["default"])(title), (0,_actions__WEBPACK_IMPORTED_MODULE_2__["default"])(background));
  6622. return element;
  6623. }
  6624.  
  6625.  
  6626. /***/ }),
  6627.  
  6628. /***/ "./ts/modal/header/title/consts.ts":
  6629. /*!*****************************************!*\
  6630. !*** ./ts/modal/header/title/consts.ts ***!
  6631. \*****************************************/
  6632. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6633.  
  6634. __webpack_require__.r(__webpack_exports__);
  6635. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6636. /* harmony export */ TITLE_CONTAINER_ID: () => (/* binding */ TITLE_CONTAINER_ID),
  6637. /* harmony export */ TITLE_ID: () => (/* binding */ TITLE_ID)
  6638. /* harmony export */ });
  6639. const TITLE_CONTAINER_ID = 'title-container';
  6640. const TITLE_ID = 'title';
  6641.  
  6642.  
  6643. /***/ }),
  6644.  
  6645. /***/ "./ts/modal/header/title/css.ts":
  6646. /*!**************************************!*\
  6647. !*** ./ts/modal/header/title/css.ts ***!
  6648. \**************************************/
  6649. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6650.  
  6651. __webpack_require__.r(__webpack_exports__);
  6652. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6653. /* harmony export */ "default": () => (/* binding */ generate)
  6654. /* harmony export */ });
  6655. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6656. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css */ "./ts/modal/css.ts");
  6657.  
  6658.  
  6659. function generate() {
  6660. (0,_css__WEBPACK_IMPORTED_MODULE_1__.addRule)(`#${_consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID}`, [
  6661. ['flex-grow', '1'],
  6662. ['white-space', 'nowrap'],
  6663. ['overflow', 'hidden'],
  6664. ['text-overflow', 'ellipsis'],
  6665. ['padding', '0 0.5em'],
  6666. ]);
  6667. }
  6668.  
  6669.  
  6670. /***/ }),
  6671.  
  6672. /***/ "./ts/modal/header/title/index.ts":
  6673. /*!****************************************!*\
  6674. !*** ./ts/modal/header/title/index.ts ***!
  6675. \****************************************/
  6676. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6677.  
  6678. __webpack_require__.r(__webpack_exports__);
  6679. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6680. /* harmony export */ "default": () => (/* binding */ generate)
  6681. /* harmony export */ });
  6682. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/header/title/consts.ts");
  6683. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/header/title/css.ts");
  6684.  
  6685.  
  6686. function generate(title) {
  6687. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6688. const titleContainer = document.createElement('span');
  6689. const titleElement = document.createElement('span');
  6690. titleContainer.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_CONTAINER_ID;
  6691. titleElement.id = _consts__WEBPACK_IMPORTED_MODULE_0__.TITLE_ID;
  6692. titleElement.innerText = title;
  6693. // In case the text is too long to fit
  6694. titleElement.title = title;
  6695. titleContainer.append(titleElement);
  6696. return titleContainer;
  6697. }
  6698.  
  6699.  
  6700. /***/ }),
  6701.  
  6702. /***/ "./ts/modal/index.ts":
  6703. /*!***************************!*\
  6704. !*** ./ts/modal/index.ts ***!
  6705. \***************************/
  6706. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6707.  
  6708. __webpack_require__.r(__webpack_exports__);
  6709. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6710. /* harmony export */ "default": () => (/* binding */ generate),
  6711. /* harmony export */ getDocument: () => (/* binding */ getDocument),
  6712. /* harmony export */ getSocket: () => (/* binding */ getSocket),
  6713. /* harmony export */ getWindow: () => (/* binding */ getWindow)
  6714. /* harmony export */ });
  6715. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./consts */ "./ts/modal/consts.ts");
  6716. /* harmony import */ var _css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css */ "./ts/modal/css.ts");
  6717. /* harmony import */ var _header__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./header */ "./ts/modal/header/index.ts");
  6718. /* harmony import */ var _body__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./body */ "./ts/modal/body/index.ts");
  6719. /* harmony import */ var _nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @nodes/actions/highlight */ "./ts/modal/body/nodes/actions/highlight/index.ts");
  6720.  
  6721.  
  6722.  
  6723.  
  6724.  
  6725. let socket;
  6726. let ownerDocument;
  6727. let ownerWindow;
  6728. function getSocket() {
  6729. return socket;
  6730. }
  6731. function getDocument() {
  6732. return ownerDocument;
  6733. }
  6734. function getWindow() {
  6735. return ownerWindow;
  6736. }
  6737. function generate(config, _socket, _window) {
  6738. socket = _socket;
  6739. ownerDocument = socket.ownerDocument;
  6740. ownerWindow = _window;
  6741. (0,_css__WEBPACK_IMPORTED_MODULE_1__["default"])();
  6742. const background = document.createElement('div');
  6743. const foreground = document.createElement('div');
  6744. background.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_BACKGROUND_ID;
  6745. foreground.id = _consts__WEBPACK_IMPORTED_MODULE_0__.MODAL_ID;
  6746. background.append(foreground);
  6747. socket.append(background);
  6748. foreground.append((0,_header__WEBPACK_IMPORTED_MODULE_2__["default"])(config, background), (0,_body__WEBPACK_IMPORTED_MODULE_3__["default"])(config), (0,_nodes_actions_highlight__WEBPACK_IMPORTED_MODULE_4__.generateEave)(socket));
  6749. }
  6750.  
  6751.  
  6752. /***/ }),
  6753.  
  6754. /***/ "./ts/predicate.ts":
  6755. /*!*************************!*\
  6756. !*** ./ts/predicate.ts ***!
  6757. \*************************/
  6758. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6759.  
  6760. __webpack_require__.r(__webpack_exports__);
  6761. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6762. /* harmony export */ getPredicatePromise: () => (/* binding */ getPredicatePromise),
  6763. /* harmony export */ isUnresolved: () => (/* binding */ isUnresolved)
  6764. /* harmony export */ });
  6765. var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
  6766. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  6767. return new (P || (P = Promise))(function (resolve, reject) {
  6768. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6769. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6770. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  6771. step((generator = generator.apply(thisArg, _arguments || [])).next());
  6772. });
  6773. };
  6774. let count = 0;
  6775. function isUnresolved() {
  6776. return count > 0;
  6777. }
  6778. function getPredicatePromise(_response) {
  6779. return __awaiter(this, void 0, void 0, function* () {
  6780. count++;
  6781. try {
  6782. const response = yield _response;
  6783. count--;
  6784. return typeof response === 'string' ? Promise.reject(response) : Promise[response ? 'resolve' : 'reject']();
  6785. }
  6786. catch (response) {
  6787. count--;
  6788. if (response instanceof Error) {
  6789. return Promise.reject(response.message);
  6790. }
  6791. return Promise.reject(typeof response === 'string' ? response : undefined);
  6792. }
  6793. });
  6794. }
  6795.  
  6796.  
  6797. /***/ })
  6798.  
  6799. /******/ });
  6800. /************************************************************************/
  6801. /******/ // The module cache
  6802. /******/ var __webpack_module_cache__ = {};
  6803. /******/
  6804. /******/ // The require function
  6805. /******/ function __webpack_require__(moduleId) {
  6806. /******/ // Check if module is in cache
  6807. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  6808. /******/ if (cachedModule !== undefined) {
  6809. /******/ return cachedModule.exports;
  6810. /******/ }
  6811. /******/ // Create a new module (and put it into the cache)
  6812. /******/ var module = __webpack_module_cache__[moduleId] = {
  6813. /******/ // no module.id needed
  6814. /******/ // no module.loaded needed
  6815. /******/ exports: {}
  6816. /******/ };
  6817. /******/
  6818. /******/ // Execute the module function
  6819. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  6820. /******/
  6821. /******/ // Return the exports of the module
  6822. /******/ return module.exports;
  6823. /******/ }
  6824. /******/
  6825. /************************************************************************/
  6826. /******/ /* webpack/runtime/define property getters */
  6827. /******/ (() => {
  6828. /******/ // define getter functions for harmony exports
  6829. /******/ __webpack_require__.d = (exports, definition) => {
  6830. /******/ for(var key in definition) {
  6831. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  6832. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  6833. /******/ }
  6834. /******/ }
  6835. /******/ };
  6836. /******/ })();
  6837. /******/
  6838. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  6839. /******/ (() => {
  6840. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  6841. /******/ })();
  6842. /******/
  6843. /******/ /* webpack/runtime/make namespace object */
  6844. /******/ (() => {
  6845. /******/ // define __esModule on exports
  6846. /******/ __webpack_require__.r = (exports) => {
  6847. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  6848. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  6849. /******/ }
  6850. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  6851. /******/ };
  6852. /******/ })();
  6853. /******/
  6854. /************************************************************************/
  6855. var __webpack_exports__ = {};
  6856. // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
  6857. (() => {
  6858. /*!*******************************!*\
  6859. !*** ./ts/library/$Config.js ***!
  6860. \*******************************/
  6861. __webpack_require__.r(__webpack_exports__);
  6862. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6863. /* harmony export */ "default": () => (/* binding */ $Config)
  6864. /* harmony export */ });
  6865. /* harmony import */ var _consts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../consts */ "./ts/consts.ts");
  6866. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./ts/library/index.ts");
  6867. /* harmony import */ var _modal_body__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modal/body */ "./ts/modal/body/index.ts");
  6868.  
  6869.  
  6870.  
  6871.  
  6872.  
  6873. const VERSION = 1;
  6874.  
  6875. const KEY_VERSION = 'TREE_FRAME_VERSION';
  6876. const KEY_STYLES = 'TREE_FRAME_USER_STYLES';
  6877.  
  6878. const STYLE_OUTER_DEFAULTS = {
  6879. position: 'fixed',
  6880. top: '0',
  6881. height: '100vh',
  6882. width: '100vw',
  6883. };
  6884.  
  6885. class $Config {
  6886. constructor(treeKey, defaultTree, defaultStyle = {}, outerStyle = {}) {
  6887. // PERMISSION CHECKS
  6888. const getError = (reason, error) => {
  6889. const message = `[${GM.info.script.name}]${reason.includes('\n') ? '\n\n' : ' '}${reason}`;
  6890. if (error) {
  6891. error.message = message;
  6892. return error;
  6893. }
  6894. return new Error(message);
  6895. };
  6896. if (typeof GM.getValue !== 'function') {
  6897. throw getError('Missing GM.getValue permission.');
  6898. }
  6899. if (typeof GM.setValue !== 'function') {
  6900. throw getError('Missing GM.setValue permission.');
  6901. }
  6902. if (typeof treeKey !== 'string' || !(/^[a-z_][a-z0-9_]*$/i.test(treeKey))) {
  6903. throw getError(`'${treeKey}' is not a valid storage key.`);
  6904. }
  6905. // PRIVATE
  6906. const displayStyle = outerStyle.display ?? 'initial';
  6907. const target = (() => {
  6908. let targetWindow = window;
  6909. while (targetWindow.frameElement) {
  6910. targetWindow = window.parent;
  6911. }
  6912. const id = `${_consts__WEBPACK_IMPORTED_MODULE_0__.SOCKET_ID}-${treeKey}`;
  6913. for (const child of targetWindow.document.body.children) {
  6914. if (child.id === id) {
  6915. child.remove();
  6916. break;
  6917. }
  6918. }
  6919. const target = document.createElement('iframe');
  6920. target.id = id;
  6921. for (const [property, value] of Object.entries({...STYLE_OUTER_DEFAULTS, ...outerStyle})) {
  6922. target.style[property] = value;
  6923. }
  6924. target.style.display = 'none';
  6925. targetWindow.document.body.appendChild(target);
  6926. return target;
  6927. })();
  6928. let isOpen = false;
  6929. const open = (doOpen = true) => new Promise((resolve) => {
  6930. isOpen = doOpen;
  6931. target.style.display = doOpen ? displayStyle : 'none';
  6932. // Delay script execution until visual update
  6933. setTimeout(resolve, 0);
  6934. });
  6935. const disconnect = () => new Promise((resolve) => {
  6936. isOpen = false;
  6937. target.remove();
  6938. // Delay script execution until visual update
  6939. setTimeout(resolve, 0);
  6940. });
  6941. // PUBLIC
  6942. this.ready = Promise.all([
  6943. GM.getValue(treeKey),
  6944. GM.getValue(KEY_STYLES, []),
  6945. GM.getValue(KEY_VERSION, -1),
  6946. ])
  6947. // Retrieve data
  6948. .then(([userTree, userStyles, version]) => {
  6949. // Patch to current version
  6950. (() => {
  6951. if (!userTree) {
  6952. return;
  6953. }
  6954. switch (version) {
  6955. case -1: {
  6956. const patch = (node) => {
  6957. delete node.predicate;
  6958. delete node.childPredicate;
  6959. delete node.descendantPredicate;
  6960. delete node.seed;
  6961. if ('children' in node) {
  6962. for (const child of node.children) {
  6963. patch(child);
  6964. }
  6965. }
  6966. };
  6967. patch(userTree);
  6968. }
  6969. // eslint-disable-next-line no-fallthrough
  6970. case 0: {
  6971. const patch = (node) => {
  6972. delete node.input;
  6973. if ('children' in node) {
  6974. for (const child of node.children) {
  6975. patch(child);
  6976. }
  6977. }
  6978. };
  6979. patch(userTree);
  6980. }
  6981. }
  6982. })();
  6983. /**
  6984. * @name $Config#reset
  6985. * @description Deletes the user's data.
  6986. * @returns {Promise<void>} Resolves upon completing the deletion.
  6987. */
  6988. this.reset = async () => {
  6989. if (isOpen) {
  6990. throw getError('Cannot reset while the UI is open.');
  6991. }
  6992. if (typeof GM.deleteValue !== 'function') {
  6993. throw getError('Missing GM.deleteValue permission.');
  6994. }
  6995. await GM.deleteValue(treeKey);
  6996. // It may have previously been a rejected promise
  6997. this.ready = () => Promise.resolve();
  6998. (0,_modal_body__WEBPACK_IMPORTED_MODULE_2__.reset)();
  6999. };
  7000. /**
  7001. * @name $Config#edit
  7002. * @description Allows the user to edit the active config.
  7003. * @returns {Promise<void>} Resolves when the user closes the config editor.
  7004. */
  7005. this.edit = async () => {
  7006. if (isOpen) {
  7007. throw getError('A config editor is already open.');
  7008. }
  7009. open();
  7010. const {tree, config, styles} = await (0,_index__WEBPACK_IMPORTED_MODULE_1__.edit)();
  7011. GM.setValue(treeKey, tree);
  7012. GM.setValue(KEY_STYLES, styles);
  7013. GM.setValue(KEY_VERSION, VERSION);
  7014. this.get = ((config) => config).bind(null, Object.freeze(config));
  7015. await open(false);
  7016. };
  7017. // Pass data
  7018. return (0,_index__WEBPACK_IMPORTED_MODULE_1__.init)({
  7019. userStyles,
  7020. defaultTree,
  7021. title: GM.info.script.name,
  7022. defaultStyle,
  7023. ...(userTree ? {userTree} : {}),
  7024. }, target.contentDocument.body, target.contentWindow);
  7025. })
  7026. .catch(async (error) => {
  7027. delete this.reset;
  7028. await disconnect();
  7029. throw getError(
  7030. 'Your config is invalid.'
  7031. + '\nThis could be due to a script update or your data being corrupted.'
  7032. + `\n\nReason:\n${error.message.replaceAll(/\n+/g, '\n')}`,
  7033. error,
  7034. );
  7035. })
  7036. .then((response) => {
  7037. this.get = ((config) => config).bind(null, Object.freeze(response.config));
  7038. if (response.requireReset) {
  7039. throw getError(
  7040. 'Your config is invalid.'
  7041. + '\nThis could be due to a script update or your data being corrupted.'
  7042. + `\n\nReason:\n${response.error.message.replaceAll(/\n+/g, '\n')}`,
  7043. response.error,
  7044. );
  7045. }
  7046. });
  7047. }
  7048. }
  7049.  
  7050. })();
  7051.  
  7052. $Config = __webpack_exports__["default"];
  7053. /******/ })()
  7054. ;

QingJ © 2025

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