atom.io 0.6.8 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/index.d.mts +226 -258
  2. package/dist/index.d.ts +226 -258
  3. package/dist/index.js +28 -1917
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +5 -1877
  6. package/dist/index.mjs.map +1 -1
  7. package/introspection/dist/index.d.mts +117 -171
  8. package/introspection/dist/index.d.ts +117 -171
  9. package/introspection/dist/index.js +6 -346
  10. package/introspection/dist/index.js.map +1 -1
  11. package/introspection/dist/index.mjs +5 -324
  12. package/introspection/dist/index.mjs.map +1 -1
  13. package/json/dist/index.d.mts +32 -1
  14. package/json/dist/index.d.ts +32 -1
  15. package/json/dist/index.js +31 -48
  16. package/json/dist/index.js.map +1 -1
  17. package/json/dist/index.mjs +6 -14
  18. package/json/dist/index.mjs.map +1 -1
  19. package/package.json +22 -14
  20. package/react/dist/index.js +34 -83
  21. package/react/dist/index.js.map +1 -1
  22. package/react/dist/index.mjs +7 -43
  23. package/react/dist/index.mjs.map +1 -1
  24. package/react-devtools/dist/index.css +1 -50
  25. package/react-devtools/dist/index.css.map +1 -1
  26. package/react-devtools/dist/index.d.mts +124 -188
  27. package/react-devtools/dist/index.d.ts +124 -188
  28. package/react-devtools/dist/index.js +56 -4674
  29. package/react-devtools/dist/index.js.map +1 -1
  30. package/react-devtools/dist/index.mjs +19 -4642
  31. package/react-devtools/dist/index.mjs.map +1 -1
  32. package/realtime/dist/index.d.mts +1 -3
  33. package/realtime/dist/index.d.ts +1 -3
  34. package/realtime/dist/index.js +26 -184
  35. package/realtime/dist/index.js.map +1 -1
  36. package/realtime/dist/index.mjs +4 -148
  37. package/realtime/dist/index.mjs.map +1 -1
  38. package/realtime-react/dist/index.d.mts +2 -4
  39. package/realtime-react/dist/index.d.ts +2 -4
  40. package/realtime-react/dist/index.js +41 -214
  41. package/realtime-react/dist/index.js.map +1 -1
  42. package/realtime-react/dist/index.mjs +9 -169
  43. package/realtime-react/dist/index.mjs.map +1 -1
  44. package/src/atom.ts +4 -3
  45. package/src/index.ts +12 -9
  46. package/src/logger.ts +5 -5
  47. package/src/selector.ts +3 -3
  48. package/src/silo.ts +36 -39
  49. package/src/subscribe.ts +24 -19
  50. package/src/timeline.ts +9 -4
  51. package/src/transaction.ts +3 -4
  52. package/src/internal/atom-internal.ts +0 -54
  53. package/src/internal/families-internal.ts +0 -144
  54. package/src/internal/get.ts +0 -129
  55. package/src/internal/index.ts +0 -15
  56. package/src/internal/is-default.ts +0 -35
  57. package/src/internal/operation.ts +0 -139
  58. package/src/internal/selector/create-read-write-selector.ts +0 -68
  59. package/src/internal/selector/create-readonly-selector.ts +0 -48
  60. package/src/internal/selector/index.ts +0 -4
  61. package/src/internal/selector/lookup-selector-sources.ts +0 -16
  62. package/src/internal/selector/register-selector.ts +0 -57
  63. package/src/internal/selector/trace-selector-atoms.ts +0 -43
  64. package/src/internal/selector/update-selector-atoms.ts +0 -33
  65. package/src/internal/selector-internal.ts +0 -58
  66. package/src/internal/set.ts +0 -99
  67. package/src/internal/store.ts +0 -151
  68. package/src/internal/subscribe-internal.ts +0 -88
  69. package/src/internal/time-travel-internal.ts +0 -91
  70. package/src/internal/timeline/add-atom-to-timeline.ts +0 -168
  71. package/src/internal/timeline/index.ts +0 -1
  72. package/src/internal/timeline-internal.ts +0 -107
  73. package/src/internal/transaction/abort-transaction.ts +0 -12
  74. package/src/internal/transaction/apply-transaction.ts +0 -57
  75. package/src/internal/transaction/build-transaction.ts +0 -33
  76. package/src/internal/transaction/index.ts +0 -25
  77. package/src/internal/transaction/redo-transaction.ts +0 -23
  78. package/src/internal/transaction/undo-transaction.ts +0 -23
  79. package/src/internal/transaction-internal.ts +0 -61
  80. package/src/introspection/attach-atom-index.ts +0 -73
  81. package/src/introspection/attach-introspection-states.ts +0 -42
  82. package/src/introspection/attach-selector-index.ts +0 -77
  83. package/src/introspection/attach-timeline-family.ts +0 -59
  84. package/src/introspection/attach-timeline-index.ts +0 -36
  85. package/src/introspection/attach-transaction-index.ts +0 -38
  86. package/src/introspection/attach-transaction-logs.ts +0 -40
  87. package/src/introspection/index.ts +0 -20
  88. package/src/json/index.ts +0 -1
  89. package/src/json/select-json.ts +0 -18
  90. package/src/react/index.ts +0 -2
  91. package/src/react/store-context.tsx +0 -13
  92. package/src/react/store-hooks.ts +0 -47
  93. package/src/react-devtools/AtomIODevtools.tsx +0 -107
  94. package/src/react-devtools/Button.tsx +0 -24
  95. package/src/react-devtools/StateEditor.tsx +0 -74
  96. package/src/react-devtools/StateIndex.tsx +0 -156
  97. package/src/react-devtools/TimelineIndex.tsx +0 -92
  98. package/src/react-devtools/TransactionIndex.tsx +0 -70
  99. package/src/react-devtools/Updates.tsx +0 -145
  100. package/src/react-devtools/devtools.scss +0 -310
  101. package/src/react-devtools/index.ts +0 -72
  102. package/src/react-explorer/AtomIOExplorer.tsx +0 -218
  103. package/src/react-explorer/explorer-effects.ts +0 -20
  104. package/src/react-explorer/explorer-states.ts +0 -217
  105. package/src/react-explorer/index.ts +0 -23
  106. package/src/react-explorer/space-states.ts +0 -72
  107. package/src/react-explorer/view-states.ts +0 -41
  108. package/src/realtime/README.md +0 -33
  109. package/src/realtime/hook-composition/expose-family.ts +0 -101
  110. package/src/realtime/hook-composition/expose-single.ts +0 -38
  111. package/src/realtime/hook-composition/expose-timeline.ts +0 -60
  112. package/src/realtime/hook-composition/index.ts +0 -12
  113. package/src/realtime/hook-composition/receive-state.ts +0 -29
  114. package/src/realtime/hook-composition/receive-transaction.ts +0 -18
  115. package/src/realtime/index.ts +0 -1
  116. package/src/realtime-react/index.ts +0 -3
  117. package/src/realtime-react/realtime-context.tsx +0 -30
  118. package/src/realtime-react/realtime-hooks.ts +0 -39
  119. package/src/realtime-react/realtime-state.ts +0 -10
  120. package/src/realtime-react/use-pull-family-member.ts +0 -26
  121. package/src/realtime-react/use-pull-family.ts +0 -24
  122. package/src/realtime-react/use-pull.ts +0 -24
  123. package/src/realtime-react/use-push.ts +0 -27
  124. package/src/realtime-react/use-server-action.ts +0 -33
  125. package/src/realtime-testing/index.ts +0 -1
  126. package/src/realtime-testing/setup-realtime-test.tsx +0 -159
  127. package/src/tracker/index.ts +0 -3
  128. package/src/tracker/tracker.ts +0 -61
  129. package/src/web-effects/index.ts +0 -1
  130. package/src/web-effects/storage.ts +0 -30
@@ -1,4643 +1,20 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a2, b2) => {
9
- for (var prop in b2 || (b2 = {}))
10
- if (__hasOwnProp.call(b2, prop))
11
- __defNormalProp(a2, prop, b2[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b2)) {
14
- if (__propIsEnum.call(b2, prop))
15
- __defNormalProp(a2, prop, b2[prop]);
16
- }
17
- return a2;
18
- };
19
- var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
20
- var __restKey = (key) => typeof key === "symbol" ? key : key + "";
21
- var __objRest = (source, exclude) => {
22
- var target2 = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target2[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target2[prop] = source[prop];
30
- }
31
- return target2;
32
- };
33
-
34
- // ../../anvl/src/object/index.ts
35
- import { pipe as pipe3 } from "fp-ts/function";
36
-
37
- // ../../anvl/src/object/refinement.ts
38
- import { pipe as pipe2 } from "fp-ts/function";
39
-
40
- // ../../anvl/src/object/access.ts
41
- var access = (k) => Object.assign((obj) => obj[k], {
42
- in: (obj) => obj[k]
43
- });
44
-
45
- // ../../anvl/src/object/entries.ts
46
- var recordToEntries = (obj) => Object.entries(obj);
47
- var entriesToRecord = (entries) => Object.fromEntries(entries);
48
-
49
- // ../../anvl/src/object/mapObject.ts
50
- import { pipe } from "fp-ts/function";
51
-
52
- // ../../anvl/src/array/venn.ts
53
- var includesAll = (items) => (array) => {
54
- for (const item of items) {
55
- if (!array.includes(item))
56
- return false;
57
- }
58
- return true;
59
- };
60
- var comprises = (items) => (array) => includesAll(items)(array) && includesAll(array)(items);
61
-
62
- // ../../anvl/src/array/index.ts
63
- var isArray = (isType) => (input) => Array.isArray(input) && input.every((item) => isType(item));
64
- var map = (f) => (a2) => a2.map(f);
65
- var every = (f = Boolean) => (a2) => a2.every(f);
66
- var allTrue = every((x) => x === true);
67
- var addTo = (a2) => (x) => a2.includes(x) ? a2 : [...a2, x];
68
- var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
69
- var isOneOf = (...args) => (input) => args.includes(input);
70
-
71
- // ../../anvl/src/object/mapObject.ts
72
- var mapObject = (obj, fn) => pipe(
73
- obj,
74
- recordToEntries,
75
- map(([key, val]) => [key, fn(val, key)]),
76
- entriesToRecord
77
- );
78
- var mob = (fn) => (obj) => mapObject(obj, fn);
79
-
80
- // ../../anvl/src/function/index.ts
81
- var doNothing = () => void 0;
82
- var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
83
- originalThing instanceof Function ? originalThing() : originalThing
84
- ) : nextVersionOfThing;
85
- var isModifier = (validate) => (sample) => {
86
- const sampleIsValid = validate(sample);
87
- if (!sampleIsValid) {
88
- throw new Error(`Invalid test case: JSON.stringify(${sample})`);
89
- }
90
- return (input) => {
91
- if (typeof input !== `function`)
92
- return false;
93
- const testResult = input(sample);
94
- return validate(testResult);
95
- };
96
- };
97
- var pass = (...params) => (fn) => fn(...params);
98
- var raiseError = (message) => {
99
- throw new Error(message);
100
- };
101
- var fallback = (fn, fallbackValue) => {
102
- try {
103
- return fn();
104
- } catch (_) {
105
- return fallbackValue;
106
- }
107
- };
108
-
109
- // ../../anvl/src/nullish/index.ts
110
- var isUndefined = (input) => input === void 0;
111
- var ifDefined = (validate) => (input) => isUndefined(input) || validate(input);
112
- var ifNullish = (alt) => (input) => input != null ? input : alt;
113
-
114
- // ../../anvl/src/object/refinement.ts
115
- var isNonNullObject = (input) => typeof input === `object` && input !== null;
116
- var isPlainObject = (input) => isNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype;
117
- var isEmptyObject = (input) => isPlainObject(input) && Object.keys(input).length === 0;
118
- var isRecord = (isKey, isValue) => (input) => isPlainObject(input) && Object.entries(input).every(([k, v]) => isKey(k) && isValue(v));
119
- var hasProperties = (isValue, options = { allowExtraProperties: false }) => {
120
- const name = `{${recordToEntries(
121
- isValue
122
- ).map(([k, v]) => String(k) + `:` + v.name).join(`,`)}}`;
123
- const _ = {
124
- [name]: (input) => isPlainObject(input) && pipe2(
125
- isValue,
126
- Object.entries,
127
- every(([key, val]) => key in input || val(void 0))
128
- ) && pipe2(
129
- input,
130
- mob(
131
- (val, key) => pipe2(
132
- isValue,
133
- access(key),
134
- ifNullish(() => options.allowExtraProperties),
135
- pass(val)
136
- )
137
- ),
138
- Object.values,
139
- allTrue
140
- )
141
- };
142
- return _[name];
143
- };
144
- var doesExtend = (
145
- /* alias for hasExactProperties with allowExtraProperties */
146
- (isValue) => hasProperties(isValue, { allowExtraProperties: true })
147
- );
148
- var hasExactProperties = (
149
- /* alias for hasProperties without allowExtraProperties */
150
- (isValue) => hasProperties(isValue, { allowExtraProperties: false })
151
- );
152
-
153
- // ../../anvl/src/object/sprawl.ts
154
- var sprawl = (tree, inspector) => {
155
- const walk = (path, node) => {
156
- const inspect = (path2, node2) => {
157
- const result2 = inspector(path2, node2);
158
- if (result2)
159
- return result2;
160
- return null;
161
- };
162
- const result = inspect(path, node);
163
- if ((result == null ? void 0 : result.jobComplete) || (result == null ? void 0 : result.pathComplete)) {
164
- return result;
165
- }
166
- const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
167
- for (const [k, v] of childEntries) {
168
- const subResult = walk([...path, k], v);
169
- if (subResult == null ? void 0 : subResult.jobComplete) {
170
- return subResult;
171
- }
172
- }
173
- return {};
174
- };
175
- walk([], tree);
176
- };
177
-
178
- // ../../anvl/src/object/index.ts
179
- var treeShake = (shouldDiscard = isUndefined) => (obj) => {
180
- const newObj = {};
181
- const entries = Object.entries(obj);
182
- entries.forEach(
183
- ([key, val]) => !shouldDiscard(val, key) ? newObj[key] = val : null
184
- );
185
- return newObj;
186
- };
187
- var delve = (obj, path) => {
188
- const found = path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
189
- return found === void 0 ? new Error(`Not found`) : { found };
190
- };
191
-
192
- // ../../anvl/src/refinement/refinery.ts
193
- var Refinery = class {
194
- constructor(supported) {
195
- this.supported = supported;
196
- }
197
- refine(input) {
198
- for (const [key, refiner] of Object.entries(this.supported)) {
199
- try {
200
- if (
201
- // @ts-expect-error that's the point
202
- refiner(input) === true && refiner !== Boolean
203
- ) {
204
- return { type: key, data: input };
205
- }
206
- } catch (e) {
207
- try {
208
- if (input instanceof refiner) {
209
- return { type: key, data: input };
210
- }
211
- } catch (e2) {
212
- }
213
- }
214
- }
215
- return null;
216
- }
217
- };
218
- var jsonRefinery = new Refinery({
219
- number: (input) => typeof input === `number`,
220
- string: (input) => typeof input === `string`,
221
- boolean: (input) => typeof input === `boolean`,
222
- object: isPlainObject,
223
- array: (input) => Array.isArray(input),
224
- null: (input) => input === null
225
- });
226
- var discoverType = (input) => {
227
- if (input === void 0) {
228
- return `undefined`;
229
- }
230
- const refined = jsonRefinery.refine(input);
231
- if (refined) {
232
- return refined.type;
233
- }
234
- return Object.getPrototypeOf(input).constructor.name;
235
- };
236
-
237
- // ../../anvl/src/tree/differ.ts
238
- function diffNumber(a2, b2) {
239
- const sign = a2 < b2 ? `+` : `-`;
240
- return {
241
- summary: `${sign}${Math.abs(a2 - b2)} (${a2} \u2192 ${b2})`
242
- };
243
- }
244
- function diffString(a2, b2) {
245
- const sign = a2.length < b2.length ? `+` : `-`;
246
- return {
247
- summary: `${sign}${Math.abs(a2.length - b2.length)} ("${a2}" \u2192 "${b2}")`
248
- };
249
- }
250
- function diffBoolean(a2, b2) {
251
- return {
252
- summary: `${a2} \u2192 ${b2}`
253
- };
254
- }
255
- function diffObject(a2, b2, recurse) {
256
- let summary = ``;
257
- const added = [];
258
- const removed = [];
259
- const changed = [];
260
- sprawl(a2, (path, nodeA) => {
261
- let key;
262
- for (key of path) {
263
- const nodeB = b2[key];
264
- if (nodeB === void 0) {
265
- removed.push([key, JSON.stringify(nodeA)]);
266
- } else {
267
- const delta = recurse(nodeA, nodeB);
268
- if (delta.summary !== `No Change`) {
269
- changed.push([key, delta]);
270
- }
271
- }
272
- }
273
- });
274
- sprawl(b2, (path, nodeB) => {
275
- let key;
276
- for (key of path) {
277
- const nodeA = a2[key];
278
- if (nodeA === void 0) {
279
- added.push([key, JSON.stringify(nodeB)]);
280
- }
281
- }
282
- });
283
- summary = `\uFF5E${changed.length} \uFF0B${added.length} \uFF0D${removed.length}`;
284
- return {
285
- summary,
286
- added,
287
- removed,
288
- changed
289
- };
290
- }
291
- function diffArray(a2, b2, recurse) {
292
- return diffObject(a2, b2, recurse);
293
- }
294
- var Differ = class {
295
- constructor(leafRefinery, treeRefinery, diffFunctions) {
296
- this.leafRefinery = leafRefinery;
297
- this.treeRefinery = treeRefinery;
298
- this.leafDiffers = {};
299
- this.treeDiffers = {};
300
- for (const key of Object.keys(leafRefinery.supported)) {
301
- const diffFunction = diffFunctions[key];
302
- this.leafDiffers[key] = diffFunction;
303
- }
304
- for (const key of Object.keys(treeRefinery.supported)) {
305
- const diffFunction = diffFunctions[key];
306
- this.treeDiffers[key] = diffFunction;
307
- }
308
- }
309
- diff(a2, b2) {
310
- var _a2, _b;
311
- if (a2 === b2) {
312
- return { summary: `No Change` };
313
- }
314
- try {
315
- if (JSON.stringify(a2) === JSON.stringify(b2)) {
316
- return { summary: `No Change` };
317
- }
318
- } catch (thrown) {
319
- console.error(`Error stringifying`, a2, b2);
320
- }
321
- const aRefined = (_a2 = this.leafRefinery.refine(a2)) != null ? _a2 : this.treeRefinery.refine(a2);
322
- const bRefined = (_b = this.leafRefinery.refine(b2)) != null ? _b : this.treeRefinery.refine(b2);
323
- if (aRefined !== null && bRefined !== null) {
324
- if (aRefined.type === bRefined.type) {
325
- if (aRefined.type in this.leafDiffers) {
326
- const delta = this.leafDiffers[aRefined.type](
327
- aRefined.data,
328
- bRefined.data
329
- );
330
- return delta;
331
- }
332
- if (aRefined.type in this.treeDiffers) {
333
- const delta = this.treeDiffers[aRefined.type](
334
- aRefined.data,
335
- bRefined.data,
336
- (x, y) => this.diff(x, y)
337
- );
338
- return delta;
339
- }
340
- }
341
- }
342
- const typeA = discoverType(a2);
343
- const typeB = discoverType(b2);
344
- if (typeA === typeB) {
345
- return {
346
- summary: `${typeA} \u2192 ${typeB}`
347
- };
348
- }
349
- return {
350
- summary: `Type change: ${typeA} \u2192 ${typeB}`
351
- };
352
- }
353
- };
354
-
355
- // ../../anvl/src/string/capitalize.ts
356
- var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
357
-
358
- // ../src/internal/get.ts
359
- var computeSelectorState = (selector) => selector.get();
360
- function lookup(key, store) {
361
- const core = target(store);
362
- const type = core.atoms.has(key) ? `atom` : core.selectors.has(key) ? `selector` : `readonly_selector`;
363
- return { key, type };
364
- }
365
- function withdraw(token, store) {
366
- var _a2, _b, _c, _d, _e;
367
- const core = target(store);
368
- return (_e = (_d = (_c = (_b = (_a2 = core.atoms.get(token.key)) != null ? _a2 : core.selectors.get(token.key)) != null ? _b : core.readonlySelectors.get(token.key)) != null ? _c : core.transactions.get(token.key)) != null ? _d : core.timelines.get(token.key)) != null ? _e : null;
369
- }
370
- function deposit(state) {
371
- return __spreadValues({
372
- key: state.key,
373
- type: state.type
374
- }, `family` in state && { family: state.family });
375
- }
376
- var getState__INTERNAL = (state, store = IMPLICIT.STORE) => {
377
- var _a2, _b, _c;
378
- if (isValueCached(state.key, store)) {
379
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(`>> read "${state.key}"`);
380
- return readCachedValue(state.key, store);
381
- }
382
- if (state.type !== `atom`) {
383
- (_b = store.config.logger) == null ? void 0 : _b.info(`-> calc "${state.key}"`);
384
- return computeSelectorState(state);
385
- }
386
- (_c = store.config.logger) == null ? void 0 : _c.error(
387
- `Attempted to get atom "${state.key}", which was never initialized in store "${store.config.name}".`
388
- );
389
- return state.default;
390
- };
391
-
392
- // ../src/internal/is-default.ts
393
- var isAtomDefault = (key, store = IMPLICIT.STORE) => {
394
- const core = target(store);
395
- return core.atomsThatAreDefault.has(key);
396
- };
397
- var markAtomAsDefault = (key, store = IMPLICIT.STORE) => {
398
- const core = target(store);
399
- core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
400
- };
401
- var markAtomAsNotDefault = (key, store = IMPLICIT.STORE) => {
402
- const core = target(store);
403
- core.atomsThatAreDefault = new Set(target(store).atomsThatAreDefault);
404
- core.atomsThatAreDefault.delete(key);
405
- };
406
-
407
- // ../../anvl/src/join/core-relation-data.ts
408
- import { isString } from "fp-ts/string";
409
-
410
- // ../../anvl/src/refinement/index.ts
411
- var canExist = (_) => true;
412
- var cannotExist = (_) => false;
413
- var isLiteral = (value) => (input) => input === value;
414
- var isWithin = (args) => (input) => args.includes(input);
415
- var couldBe = (isTypeA, logging = false, refinements = [isTypeA]) => {
416
- const name = `(${refinements.map((r) => r.name || `anon`).join(` | `)})`;
417
- const _ = {
418
- [name]: (input) => refinements.some(
419
- (refinement) => {
420
- var _a2;
421
- return logging && console.log(
422
- refinements.map((r) => r.name || `anon`).join(` | `),
423
- `>`,
424
- (_a2 = refinement.name) != null ? _a2 : `anon`,
425
- `:`,
426
- refinement(input)
427
- ), refinement(input);
428
- }
429
- )
430
- };
431
- const checkTypes = Object.assign(_[name], {
432
- or: (isTypeB) => couldBe(isTypeB, logging, [...refinements, isTypeB])
433
- });
434
- return checkTypes;
435
- };
436
- var isUnion = couldBe(cannotExist);
437
- var mustBe = (isTypeA, logging = false, refinements = [isTypeA]) => {
438
- const name = `(${refinements.map((r) => r.name || `anon`).join(` & `)})`;
439
- const _ = {
440
- [name]: (input) => refinements.every(
441
- (refinement) => (logging && console.log(
442
- refinements.map((r) => r.name || `anon`).join(` & `),
443
- `>`,
444
- refinement.name || `anon`,
445
- `:`,
446
- refinement(input)
447
- ), refinement(input))
448
- )
449
- };
450
- const checkTypes = Object.assign(_[name], {
451
- and: (isTypeB) => mustBe(isTypeB, logging, [...refinements, isTypeB])
452
- });
453
- return checkTypes;
454
- };
455
- var isIntersection = mustBe(canExist);
456
-
457
- // ../../anvl/src/join/core-relation-data.ts
458
- var RELATION_TYPES = [`1:1`, `1:n`, `n:n`];
459
- var isRelationType = (x) => RELATION_TYPES.includes(x);
460
- var EMPTY_RELATION_DATA = {
461
- contents: {},
462
- relations: {},
463
- relationType: `n:n`,
464
- a: `from`,
465
- b: `to`
466
- };
467
- var isRelationData = ({
468
- from: a2 = `from`,
469
- to: b2 = `to`,
470
- isContent
471
- } = {}) => (input) => {
472
- return hasExactProperties({
473
- contents: isContent ? isRecord(isString, isContent) : hasExactProperties({}),
474
- relations: isRecord(isString, isArray(isString)),
475
- relationType: isRelationType,
476
- a: isLiteral(a2),
477
- b: isLiteral(b2)
478
- })(input);
479
- };
480
-
481
- // ../../anvl/src/join/get-related-ids.ts
482
- var getRelatedIds = (relationMap, id) => {
483
- var _a2;
484
- return (_a2 = relationMap.relations[id]) != null ? _a2 : [];
485
- };
486
- var getRelatedId = (relationMap, id) => {
487
- const relations = getRelatedIds(relationMap, id);
488
- if (relations.length > 1) {
489
- console.warn(
490
- `entry with id ${id} was not expected to have multiple relations`
491
- );
492
- }
493
- return relations[0];
494
- };
495
-
496
- // ../../anvl/src/join/make-json-interface.ts
497
- var makeJsonInterface = (join, ...params) => {
498
- const isContent = params[0];
499
- const { a: a2, b: b2 } = join;
500
- const options = {
501
- from: a2,
502
- to: b2,
503
- isContent
504
- };
505
- return {
506
- toJson: (join2) => join2.toJSON(),
507
- fromJson: (json) => Join.fromJSON(json, options)
508
- };
509
- };
510
-
511
- // ../../anvl/src/join/relation-contents.ts
512
- import { pipe as pipe5 } from "fp-ts/function";
513
-
514
- // ../../anvl/src/join/relation-record.ts
515
- var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
516
- idB,
517
- getContent(relationMap, idA, idB)
518
- ]);
519
- var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
520
-
521
- // ../../anvl/src/join/remove-relation.ts
522
- import { pipe as pipe4 } from "fp-ts/function";
523
- import { isString as isString2 } from "fp-ts/string";
524
-
525
- // ../../anvl/src/string/split.ts
526
- var split = (separator) => (str) => str.split(separator);
527
-
528
- // ../../anvl/src/join/remove-relation.ts
529
- var removeSpecific = (current, idA, idB) => {
530
- const isIdForRemoval = isOneOf(idA, idB);
531
- return __spreadProps(__spreadValues({}, current), {
532
- relations: pipe4(
533
- current.relations,
534
- recordToEntries,
535
- map(([id, relations]) => [
536
- id,
537
- isIdForRemoval(id) ? relations.filter((relation) => !isIdForRemoval(relation)) : relations
538
- ]),
539
- entriesToRecord,
540
- treeShake(isEmptyArray)
541
- ),
542
- contents: pipe4(
543
- current.contents,
544
- treeShake(
545
- (_, key) => isString2(key) && pipe4(key, split(`/`), comprises([idA, idB]))
546
- )
547
- )
548
- });
549
- };
550
- var removeAll = (current, idToRemove) => {
551
- const next = __spreadProps(__spreadValues({}, current), {
552
- relations: pipe4(
553
- current.relations,
554
- recordToEntries,
555
- map(([id, relations]) => [
556
- id,
557
- relations.filter((relation) => relation !== idToRemove)
558
- ]),
559
- entriesToRecord,
560
- treeShake((val, key) => key === idToRemove || isEmptyArray(val))
561
- ),
562
- contents: pipe4(
563
- current.contents,
564
- treeShake(
565
- (_, key) => isString2(key) && key.split(`/`).includes(idToRemove)
566
- )
567
- )
568
- });
569
- return next;
570
- };
571
- var removeRelation = (current, relation) => {
572
- const idA = relation[current.a];
573
- const idB = relation[current.b];
574
- return idB ? removeSpecific(current, idA, idB) : removeAll(current, idA);
575
- };
576
-
577
- // ../../anvl/src/join/set-relation.ts
578
- var setManyToMany = (map2, idA, idB, ...rest) => {
579
- var _a2, _b;
580
- const next = __spreadProps(__spreadValues({}, map2), {
581
- relations: __spreadProps(__spreadValues({}, map2.relations), {
582
- [idA]: addTo((_a2 = map2.relations[idA]) != null ? _a2 : [])(idB),
583
- [idB]: addTo((_b = map2.relations[idB]) != null ? _b : [])(idA)
584
- })
585
- });
586
- const content = rest[0];
587
- return content ? setContent(next, idA, idB, content) : next;
588
- };
589
- var removeEmpties = treeShake(isEmptyArray);
590
- var set1ToMany = (current, leaderId, followerId, ...rest) => {
591
- var _a2;
592
- const relations = __spreadValues({}, current.relations);
593
- const prevLeaderId = getRelatedId(current, followerId);
594
- const next = __spreadProps(__spreadValues({}, current), {
595
- relations: removeEmpties(__spreadProps(__spreadValues(__spreadValues({}, relations), prevLeaderId && prevLeaderId !== leaderId && {
596
- [prevLeaderId]: relations[prevLeaderId].filter(
597
- (id) => id !== followerId
598
- )
599
- }), {
600
- [followerId]: [leaderId],
601
- [leaderId]: addTo((_a2 = relations[leaderId]) != null ? _a2 : [])(followerId)
602
- }))
603
- });
604
- const content = rest[0];
605
- return content ? setContent(next, leaderId, followerId, content) : next;
606
- };
607
- var set1To1 = (current, wifeId, husbandId, ...rest) => {
608
- const prevWifeId = getRelatedId(current, husbandId);
609
- const prevHusbandId = getRelatedId(current, wifeId);
610
- const next = __spreadProps(__spreadValues({}, current), {
611
- relations: removeEmpties(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, current.relations), prevWifeId && { [prevWifeId]: [] }), prevHusbandId && { [prevHusbandId]: [] }), {
612
- [wifeId]: [husbandId],
613
- [husbandId]: [wifeId]
614
- }))
615
- });
616
- const content = rest[0];
617
- return content ? setContent(next, wifeId, husbandId, content) : next;
618
- };
619
- var setRelationWithContent = (current, relation, ...rest) => {
620
- const { [current.a]: idA, [current.b]: idB } = relation;
621
- switch (current.relationType) {
622
- case `1:1`:
623
- return set1To1(current, idA, idB, ...rest);
624
- case `1:n`:
625
- return set1ToMany(current, idA, idB, ...rest);
626
- case `n:n`:
627
- return setManyToMany(current, idA, idB, ...rest);
628
- }
629
- };
630
-
631
- // ../../anvl/src/join/relation-contents.ts
632
- var makeContentId = (idA, idB) => [idA, idB].sort().join(`/`);
633
- var getContent = (relationMap, idA, idB) => relationMap.contents[makeContentId(idA, idB)];
634
- var setContent = (map2, idA, idB, content) => __spreadProps(__spreadValues({}, map2), {
635
- contents: __spreadProps(__spreadValues({}, map2.contents), {
636
- [makeContentId(idA, idB)]: content
637
- })
638
- });
639
- var getRelations = (relationMap, id) => getRelationEntries(relationMap, id).map(
640
- ([id2, content]) => __spreadValues({
641
- id: id2
642
- }, content)
643
- );
644
- var setRelations = (current, subject, relations) => {
645
- const idA = subject[current.a];
646
- const idB = subject[current.b];
647
- return pipe5(
648
- current,
649
- (relationData) => {
650
- const relatedIds = getRelatedIds(current, idA);
651
- const removedIds = relatedIds.filter(
652
- (id) => !relations.some((r) => r.id === id)
653
- );
654
- let step = relationData;
655
- for (const id of removedIds) {
656
- const remove = {
657
- [current.a]: idA != null ? idA : id,
658
- [current.b]: idB != null ? idB : id
659
- };
660
- step = removeRelation(step, remove);
661
- }
662
- return step;
663
- },
664
- (relationData) => {
665
- let step = relationData;
666
- for (const _a2 of relations) {
667
- const _b = _a2, { id } = _b, rest = __objRest(_b, ["id"]);
668
- const content = isEmptyObject(rest) ? void 0 : rest;
669
- step = setRelationWithContent(
670
- step,
671
- { [current.a]: idA != null ? idA : id, [current.b]: idB != null ? idB : id },
672
- // @ts-expect-error hacky
673
- content
674
- );
675
- }
676
- return step;
677
- },
678
- (relationData) => {
679
- const newlyOrderedIds = relations.map((r) => r.id);
680
- return __spreadProps(__spreadValues({}, relationData), {
681
- relations: __spreadProps(__spreadValues({}, relationData.relations), {
682
- [idA != null ? idA : idB]: newlyOrderedIds
683
- })
684
- });
685
- }
686
- );
687
- };
688
-
689
- // ../../anvl/src/join/index.ts
690
- var Join = class _Join {
691
- constructor(json) {
692
- this.a = `from`;
693
- this.b = `to`;
694
- this.makeJsonInterface = (...params) => {
695
- return makeJsonInterface(this, ...params);
696
- };
697
- Object.assign(this, __spreadProps(__spreadValues(__spreadValues({}, EMPTY_RELATION_DATA), json), {
698
- makeJsonInterface: this.makeJsonInterface
699
- }));
700
- }
701
- toJSON() {
702
- return {
703
- relationType: this.relationType,
704
- relations: this.relations,
705
- contents: this.contents,
706
- a: this.a,
707
- b: this.b
708
- };
709
- }
710
- static fromJSON(json, options) {
711
- const isValid = isRelationData(options)(json);
712
- if (isValid) {
713
- return new _Join(json);
714
- }
715
- throw new Error(
716
- `Saved JSON for this Join is invalid: ${JSON.stringify(json)}`
717
- );
718
- }
719
- from(newA) {
720
- return new _Join(__spreadProps(__spreadValues({}, this), { a: newA }));
721
- }
722
- to(newB) {
723
- return new _Join(__spreadProps(__spreadValues({}, this), { b: newB }));
724
- }
725
- getRelatedId(id) {
726
- return getRelatedId(this, id);
727
- }
728
- getRelatedIds(id) {
729
- return getRelatedIds(this, id);
730
- }
731
- getContent(idA, idB) {
732
- return getContent(this, idA, idB);
733
- }
734
- getRelationEntries(id) {
735
- return getRelationEntries(this, id);
736
- }
737
- getRelationRecord(id) {
738
- return getRelationRecord(this, id);
739
- }
740
- getRelation(id) {
741
- return getRelations(this, id)[0];
742
- }
743
- getRelations(id) {
744
- return getRelations(this, id);
745
- }
746
- setRelations(subject, relations) {
747
- return new _Join(setRelations(this, subject, relations));
748
- }
749
- set(relation, ...rest) {
750
- return new _Join(setRelationWithContent(this, relation, ...rest));
751
- }
752
- remove(relation) {
753
- return new _Join(
754
- removeRelation(this, relation)
755
- );
756
- }
757
- };
758
-
759
- // ../src/internal/store.ts
760
- var createStore = (name, store = null) => {
761
- var _a2;
762
- const created = __spreadProps(__spreadValues({}, store != null ? store : (() => ({
763
- atomsThatAreDefault: /* @__PURE__ */ new Set(),
764
- selectorAtoms: new Join({ relationType: `n:n` }).from(`selectorKey`).to(`atomKey`),
765
- selectorGraph: new Join({ relationType: `n:n` })
766
- }))()), {
767
- valueMap: new Map(store == null ? void 0 : store.valueMap),
768
- atoms: /* @__PURE__ */ new Map(),
769
- readonlySelectors: /* @__PURE__ */ new Map(),
770
- selectors: /* @__PURE__ */ new Map(),
771
- transactions: /* @__PURE__ */ new Map(),
772
- timelines: /* @__PURE__ */ new Map(),
773
- timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
774
- subject: {
775
- atomCreation: new Subject(),
776
- selectorCreation: new Subject(),
777
- transactionCreation: new Subject(),
778
- timelineCreation: new Subject(),
779
- operationStatus: new Subject()
780
- },
781
- operation: __spreadValues({
782
- open: false
783
- }, store == null ? void 0 : store.operation),
784
- transactionStatus: __spreadValues({
785
- phase: `idle`
786
- }, store == null ? void 0 : store.transactionStatus),
787
- config: __spreadProps(__spreadValues({
788
- logger: __spreadValues(__spreadProps(__spreadValues({}, console), {
789
- info: doNothing
790
- }), (_a2 = store == null ? void 0 : store.config) == null ? void 0 : _a2.logger),
791
- logger__INTERNAL: console
792
- }, store == null ? void 0 : store.config), {
793
- name
794
- })
795
- });
796
- store == null ? void 0 : store.atoms.forEach((atom2) => {
797
- const copiedAtom = __spreadProps(__spreadValues({}, atom2), { subject: new Subject() });
798
- created.atoms.set(atom2.key, copiedAtom);
799
- });
800
- store == null ? void 0 : store.readonlySelectors.forEach((selector) => {
801
- selector.install(created);
802
- });
803
- store == null ? void 0 : store.selectors.forEach((selector) => {
804
- selector.install(created);
805
- });
806
- store == null ? void 0 : store.transactions.forEach((tx) => {
807
- tx.install(created);
808
- });
809
- store == null ? void 0 : store.timelines.forEach((timeline2) => {
810
- timeline2.install(created);
811
- });
812
- return created;
813
- };
814
- var IMPLICIT = {
815
- STORE_INTERNAL: void 0,
816
- get STORE() {
817
- var _a2;
818
- return (_a2 = this.STORE_INTERNAL) != null ? _a2 : this.STORE_INTERNAL = createStore(`DEFAULT`);
819
- }
820
- };
821
-
822
- // ../src/internal/operation.ts
823
- var openOperation = (token, store) => {
824
- var _a2, _b;
825
- const core = target(store);
826
- if (core.operation.open) {
827
- (_a2 = store.config.logger) == null ? void 0 : _a2.error(
828
- `\u274C failed to setState to "${token.key}" during a setState for "${core.operation.token.key}"`
829
- );
830
- throw Symbol(`violation`);
831
- }
832
- core.operation = {
833
- open: true,
834
- done: /* @__PURE__ */ new Set(),
835
- prev: new Map(store.valueMap),
836
- time: Date.now(),
837
- token
838
- };
839
- (_b = store.config.logger) == null ? void 0 : _b.info(
840
- `\u2B55 operation start from "${token.key}" in store "${store.config.name}"`
841
- );
842
- };
843
- var closeOperation = (store) => {
844
- var _a2;
845
- const core = target(store);
846
- core.operation = { open: false };
847
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(`\u{1F534} operation done`);
848
- store.subject.operationStatus.next(core.operation);
849
- };
850
- var isDone = (key, store = IMPLICIT.STORE) => {
851
- var _a2;
852
- const core = target(store);
853
- if (!core.operation.open) {
854
- (_a2 = store.config.logger) == null ? void 0 : _a2.warn(
855
- `isDone called outside of an operation. This is probably a bug.`
856
- );
857
- return true;
858
- }
859
- return core.operation.done.has(key);
860
- };
861
- var markDone = (key, store = IMPLICIT.STORE) => {
862
- var _a2;
863
- const core = target(store);
864
- if (!core.operation.open) {
865
- (_a2 = store.config.logger) == null ? void 0 : _a2.warn(
866
- `markDone called outside of an operation. This is probably a bug.`
867
- );
868
- return;
869
- }
870
- core.operation.done.add(key);
871
- };
872
- var recallState = (state, store = IMPLICIT.STORE) => {
873
- var _a2;
874
- const core = target(store);
875
- if (!core.operation.open) {
876
- (_a2 = store.config.logger) == null ? void 0 : _a2.warn(
877
- `recall called outside of an operation. This is probably a bug.`
878
- );
879
- return core.valueMap.get(state.key);
880
- }
881
- return core.operation.prev.get(state.key);
882
- };
883
- var cacheValue = (key, value, store = IMPLICIT.STORE) => {
884
- const core = target(store);
885
- core.valueMap.set(key, value);
886
- };
887
- var evictCachedValue = (key, store = IMPLICIT.STORE) => {
888
- const core = target(store);
889
- core.valueMap.delete(key);
890
- };
891
- var readCachedValue = (key, store = IMPLICIT.STORE) => target(store).valueMap.get(key);
892
- var isValueCached = (key, store = IMPLICIT.STORE) => target(store).valueMap.has(key);
893
-
894
- // ../src/internal/transaction-internal.ts
895
- var target = (store = IMPLICIT.STORE) => store.transactionStatus.phase === `building` ? store.transactionStatus.core : store;
896
-
897
- // ../src/internal/atom-internal.ts
898
- function atom__INTERNAL(options, family, store = IMPLICIT.STORE) {
899
- var _a2, _b, _c;
900
- const core = target(store);
901
- const existing = core.atoms.get(options.key);
902
- if (existing) {
903
- (_b = (_a2 = store.config.logger) == null ? void 0 : _a2.error) == null ? void 0 : _b.call(
904
- _a2,
905
- `Key "${options.key}" already exists in the store.`
906
- );
907
- return deposit(existing);
908
- }
909
- const subject = new Subject();
910
- const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
911
- subject,
912
- type: `atom`
913
- }), family && { family });
914
- const initialValue = options.default instanceof Function ? options.default() : options.default;
915
- core.atoms.set(newAtom.key, newAtom);
916
- markAtomAsDefault(options.key, store);
917
- cacheValue(options.key, initialValue, store);
918
- const token = deposit(newAtom);
919
- (_c = options.effects) == null ? void 0 : _c.forEach(
920
- (effect) => effect({
921
- setSelf: (next) => setState(token, next, store),
922
- onSet: (handle) => subscribe(token, handle, store)
923
- })
924
- );
925
- store.subject.atomCreation.next(token);
926
- return token;
927
- }
928
-
929
- // ../../anvl/src/json/index.ts
930
- var stringifyJson = (json) => JSON.stringify(json);
931
- var JSON_TYPE_NAMES = [
932
- `array`,
933
- `boolean`,
934
- `null`,
935
- `number`,
936
- `object`,
937
- `string`
938
- ];
939
- var JSON_DEFAULTS = {
940
- array: [],
941
- boolean: false,
942
- null: null,
943
- number: 0,
944
- object: {},
945
- string: ``
946
- };
947
-
948
- // ../src/internal/families-internal.ts
949
- function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
950
- const subject = new Subject();
951
- return Object.assign(
952
- (key) => {
953
- const subKey = stringifyJson(key);
954
- const family = { key: options.key, subKey };
955
- const fullKey = `${options.key}(${subKey})`;
956
- const existing = withdraw({ key: fullKey, type: `atom` }, store);
957
- let token;
958
- if (existing) {
959
- token = deposit(existing);
960
- } else {
961
- const individualOptions = {
962
- key: fullKey,
963
- default: options.default instanceof Function ? options.default(key) : options.default
964
- };
965
- if (options.effects) {
966
- individualOptions.effects = options.effects(key);
967
- }
968
- token = atom__INTERNAL(individualOptions, family, store);
969
- }
970
- subject.next(token);
971
- return token;
972
- },
973
- {
974
- key: options.key,
975
- type: `atom_family`,
976
- subject
977
- }
978
- );
979
- }
980
-
981
- // ../src/internal/selector/lookup-selector-sources.ts
982
- var lookupSelectorSources = (key, store) => target(store).selectorGraph.getRelations(key).filter(({ source }) => source !== key).map(({ source }) => lookup(source, store));
983
-
984
- // ../src/internal/selector/trace-selector-atoms.ts
985
- var traceSelectorAtoms = (selectorKey, dependency, store) => {
986
- const roots = [];
987
- const sources = lookupSelectorSources(dependency.key, store);
988
- let depth = 0;
989
- while (sources.length > 0) {
990
- const source = sources.shift();
991
- ++depth;
992
- if (depth > 999) {
993
- throw new Error(
994
- `Maximum selector dependency depth exceeded in selector "${selectorKey}".`
995
- );
996
- }
997
- if (source.type !== `atom`) {
998
- sources.push(...lookupSelectorSources(source.key, store));
999
- } else {
1000
- roots.push(source);
1001
- }
1002
- }
1003
- return roots;
1004
- };
1005
- var traceAllSelectorAtoms = (selectorKey, store) => {
1006
- const sources = lookupSelectorSources(selectorKey, store);
1007
- return sources.flatMap(
1008
- (source) => source.type === `atom` ? source : traceSelectorAtoms(selectorKey, source, store)
1009
- );
1010
- };
1011
-
1012
- // ../src/internal/set.ts
1013
- var evictDownStream = (state, store = IMPLICIT.STORE) => {
1014
- var _a2, _b;
1015
- const core = target(store);
1016
- const downstream = core.selectorAtoms.getRelations(state.key);
1017
- const downstreamKeys = downstream.map(({ id }) => id);
1018
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1019
- ` || ${downstreamKeys.length} downstream:`,
1020
- downstreamKeys
1021
- );
1022
- if (core.operation.open) {
1023
- (_b = store.config.logger) == null ? void 0 : _b.info(` ||`, [...core.operation.done], `already done`);
1024
- }
1025
- downstream.forEach(({ id: stateKey }) => {
1026
- var _a3, _b2, _c, _d;
1027
- if (isDone(stateKey, store)) {
1028
- (_a3 = store.config.logger) == null ? void 0 : _a3.info(` || ${stateKey} already done`);
1029
- return;
1030
- }
1031
- const state2 = (_b2 = core.selectors.get(stateKey)) != null ? _b2 : core.readonlySelectors.get(stateKey);
1032
- if (!state2) {
1033
- (_c = store.config.logger) == null ? void 0 : _c.info(
1034
- ` || ${stateKey} is an atom, and can't be downstream`
1035
- );
1036
- return;
1037
- }
1038
- evictCachedValue(stateKey, store);
1039
- (_d = store.config.logger) == null ? void 0 : _d.info(` xx evicted "${stateKey}"`);
1040
- markDone(stateKey, store);
1041
- });
1042
- };
1043
- var setAtomState = (atom2, next, store = IMPLICIT.STORE) => {
1044
- var _a2, _b;
1045
- const oldValue = getState__INTERNAL(atom2, store);
1046
- const newValue = become(next)(oldValue);
1047
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(`<< setting atom "${atom2.key}" to`, newValue);
1048
- cacheValue(atom2.key, newValue, store);
1049
- if (isAtomDefault(atom2.key, store)) {
1050
- markAtomAsNotDefault(atom2.key, store);
1051
- }
1052
- markDone(atom2.key, store);
1053
- (_b = store.config.logger) == null ? void 0 : _b.info(
1054
- ` || evicting caches downstream from "${atom2.key}"`
1055
- );
1056
- evictDownStream(atom2, store);
1057
- const update = { oldValue, newValue };
1058
- if (store.transactionStatus.phase !== `building`) {
1059
- emitUpdate(atom2, update, store);
1060
- } else {
1061
- stowUpdate(atom2, update, store);
1062
- }
1063
- };
1064
- var setSelectorState = (selector, next, store = IMPLICIT.STORE) => {
1065
- var _a2, _b;
1066
- const oldValue = getState__INTERNAL(selector, store);
1067
- const newValue = become(next)(oldValue);
1068
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(`<< setting selector "${selector.key}" to`, newValue);
1069
- (_b = store.config.logger) == null ? void 0 : _b.info(` || propagating change made to "${selector.key}"`);
1070
- selector.set(newValue);
1071
- };
1072
- var setState__INTERNAL = (state, value, store = IMPLICIT.STORE) => {
1073
- if (`set` in state) {
1074
- setSelectorState(state, value, store);
1075
- } else {
1076
- setAtomState(state, value, store);
1077
- }
1078
- };
1079
-
1080
- // ../../anvl/reactivity/subject.ts
1081
- var Subject = class {
1082
- constructor() {
1083
- this.subscribers = [];
1084
- }
1085
- subscribe(subscriber) {
1086
- this.subscribers.push(subscriber);
1087
- const unsubscribe = () => this.unsubscribe(subscriber);
1088
- return { unsubscribe };
1089
- }
1090
- unsubscribe(subscriber) {
1091
- const subscriberIndex = this.subscribers.indexOf(subscriber);
1092
- if (subscriberIndex !== -1) {
1093
- this.subscribers.splice(subscriberIndex, 1);
1094
- }
1095
- }
1096
- next(value) {
1097
- for (const subscriber of this.subscribers) {
1098
- subscriber(value);
1099
- }
1100
- }
1101
- };
1102
-
1103
- // ../src/internal/subscribe-internal.ts
1104
- var stowUpdate = (state, update, store) => {
1105
- var _a2;
1106
- const { key } = state;
1107
- const { logger } = store.config;
1108
- if (store.transactionStatus.phase !== `building`) {
1109
- (_a2 = store.config.logger) == null ? void 0 : _a2.warn(
1110
- `stowUpdate called outside of a transaction. This is probably a bug.`
1111
- );
1112
- return;
1113
- }
1114
- store.transactionStatus.atomUpdates.push(__spreadValues({ key }, update));
1115
- logger == null ? void 0 : logger.info(`\u{1F4DD} ${key} stowed (`, update.oldValue, `->`, update.newValue, `)`);
1116
- };
1117
- var emitUpdate = (state, update, store) => {
1118
- const { key } = state;
1119
- const { logger } = store.config;
1120
- logger == null ? void 0 : logger.info(
1121
- `\u{1F4E2} ${state.type} "${key}" went (`,
1122
- update.oldValue,
1123
- `->`,
1124
- update.newValue,
1125
- `)`
1126
- );
1127
- state.subject.next(update);
1128
- };
1129
- var subscribeToRootAtoms = (state, store) => {
1130
- const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomToken) => {
1131
- const atom2 = withdraw(atomToken, store);
1132
- if (atom2 === null) {
1133
- throw new Error(
1134
- `Atom "${atomToken.key}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
1135
- );
1136
- }
1137
- return atom2.subject.subscribe((atomChange) => {
1138
- var _a2, _b;
1139
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1140
- `\u{1F4E2} selector "${state.key}" saw root "${atomToken.key}" go (`,
1141
- atomChange.oldValue,
1142
- `->`,
1143
- atomChange.newValue,
1144
- `)`
1145
- );
1146
- const oldValue = recallState(state, store);
1147
- const newValue = getState__INTERNAL(state, store);
1148
- (_b = store.config.logger) == null ? void 0 : _b.info(
1149
- ` <- "${state.key}" went (`,
1150
- oldValue,
1151
- `->`,
1152
- newValue,
1153
- `)`
1154
- );
1155
- state.subject.next({ newValue, oldValue });
1156
- });
1157
- });
1158
- return dependencySubscriptions;
1159
- };
1160
-
1161
- // ../src/atom.ts
1162
- function atom(options) {
1163
- return atom__INTERNAL(options);
1164
- }
1165
- function atomFamily(options) {
1166
- return atomFamily__INTERNAL(options);
1167
- }
1168
-
1169
- // ../src/subscribe.ts
1170
- var subscribe = (token, handleUpdate, store = IMPLICIT.STORE) => {
1171
- var _a2;
1172
- const state = withdraw(token, store);
1173
- if (state === null) {
1174
- throw new Error(
1175
- `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
1176
- );
1177
- }
1178
- const subscription = state.subject.subscribe(handleUpdate);
1179
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(`\u{1F440} subscribe to "${state.key}"`);
1180
- const dependencySubscriptions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
1181
- const unsubscribe = dependencySubscriptions === null ? () => {
1182
- var _a3;
1183
- (_a3 = store.config.logger) == null ? void 0 : _a3.info(`\u{1F648} unsubscribe from "${state.key}"`);
1184
- subscription.unsubscribe();
1185
- } : () => {
1186
- var _a3;
1187
- (_a3 = store.config.logger) == null ? void 0 : _a3.info(
1188
- `\u{1F648} unsubscribe from "${state.key}" and its dependencies`
1189
- );
1190
- subscription.unsubscribe();
1191
- for (const dependencySubscription of dependencySubscriptions) {
1192
- dependencySubscription.unsubscribe();
1193
- }
1194
- };
1195
- return unsubscribe;
1196
- };
1197
-
1198
- // ../src/index.ts
1199
- var setState = (token, value, store = IMPLICIT.STORE) => {
1200
- try {
1201
- openOperation(token, store);
1202
- } catch (thrown) {
1203
- if (!(typeof thrown === `symbol`)) {
1204
- throw thrown;
1205
- }
1206
- return;
1207
- }
1208
- const state = withdraw(token, store);
1209
- if (state === null) {
1210
- throw new Error(
1211
- `${capitalize(token.type)} "${token.key}" not found in store "${store.config.name}".`
1212
- );
1213
- }
1214
- setState__INTERNAL(state, value, store);
1215
- closeOperation(store);
1216
- };
1217
-
1218
- // ../src/introspection/attach-introspection-states.ts
1219
- import { __INTERNAL__ as __INTERNAL__7 } from "atom.io";
1220
-
1221
- // ../src/introspection/attach-atom-index.ts
1222
- import { __INTERNAL__ } from "atom.io";
1223
- var attachAtomIndex = (store = __INTERNAL__.IMPLICIT.STORE) => {
1224
- const atomTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL(
1225
- {
1226
- key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
1227
- default: () => [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
1228
- acc[key] = { key, type: `atom` };
1229
- return acc;
1230
- }, {}),
1231
- effects: [
1232
- ({ setSelf }) => {
1233
- store.subject.atomCreation.subscribe((atomToken) => {
1234
- if (store.operation.open) {
1235
- return;
1236
- }
1237
- if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
1238
- return;
1239
- }
1240
- setSelf((state) => {
1241
- const { key, family } = atomToken;
1242
- if (family) {
1243
- const { key: familyKey, subKey } = family;
1244
- const current = state[familyKey];
1245
- if (current === void 0 || `familyMembers` in current) {
1246
- const familyKeyState = current || {
1247
- key: familyKey,
1248
- familyMembers: {}
1249
- };
1250
- return __spreadProps(__spreadValues({}, state), {
1251
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1252
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1253
- [subKey]: atomToken
1254
- })
1255
- })
1256
- });
1257
- }
1258
- }
1259
- return __spreadProps(__spreadValues({}, state), {
1260
- [key]: atomToken
1261
- });
1262
- });
1263
- });
1264
- }
1265
- ]
1266
- },
1267
- void 0,
1268
- store
1269
- );
1270
- return __INTERNAL__.selector__INTERNAL(
1271
- {
1272
- key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
1273
- get: ({ get }) => get(atomTokenIndexState__INTERNAL)
1274
- },
1275
- void 0,
1276
- store
1277
- );
1278
- };
1279
-
1280
- // ../src/introspection/attach-selector-index.ts
1281
- import { __INTERNAL__ as __INTERNAL__2 } from "atom.io";
1282
- var attachSelectorIndex = (store = __INTERNAL__2.IMPLICIT.STORE) => {
1283
- const readonlySelectorTokenIndexState__INTERNAL = __INTERNAL__2.atom__INTERNAL(
1284
- {
1285
- key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
1286
- default: () => Object.assign(
1287
- [...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
1288
- acc[key] = { key, type: `readonly_selector` };
1289
- return acc;
1290
- }, {}),
1291
- [...store.selectors].reduce((acc, [key]) => {
1292
- acc[key] = { key, type: `selector` };
1293
- return acc;
1294
- }, {})
1295
- ),
1296
- effects: [
1297
- ({ setSelf }) => {
1298
- store.subject.selectorCreation.subscribe((selectorToken) => {
1299
- if (store.operation.open) {
1300
- return;
1301
- }
1302
- if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
1303
- return;
1304
- }
1305
- setSelf((state) => {
1306
- const { key, family } = selectorToken;
1307
- if (family) {
1308
- const { key: familyKey, subKey } = family;
1309
- const current = state[familyKey];
1310
- if (current === void 0 || `familyMembers` in current) {
1311
- const familyKeyState = current || {
1312
- key: familyKey,
1313
- familyMembers: {}
1314
- };
1315
- return __spreadProps(__spreadValues({}, state), {
1316
- [familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
1317
- familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
1318
- [subKey]: selectorToken
1319
- })
1320
- })
1321
- });
1322
- }
1323
- }
1324
- return __spreadProps(__spreadValues({}, state), {
1325
- [key]: selectorToken
1326
- });
1327
- });
1328
- });
1329
- }
1330
- ]
1331
- },
1332
- void 0,
1333
- store
1334
- );
1335
- return __INTERNAL__2.selector__INTERNAL({
1336
- key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
1337
- get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
1338
- });
1339
- };
1340
-
1341
- // ../src/introspection/attach-timeline-family.ts
1342
- import { __INTERNAL__ as __INTERNAL__3 } from "atom.io";
1343
- var attachTimelineFamily = (store = __INTERNAL__3.IMPLICIT.STORE) => {
1344
- const findTimelineLogState__INTERNAL = __INTERNAL__3.atomFamily__INTERNAL(
1345
- {
1346
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
1347
- default: (key) => {
1348
- var _a2;
1349
- return (_a2 = store.timelines.get(key)) != null ? _a2 : {
1350
- key: ``,
1351
- at: 0,
1352
- timeTraveling: null,
1353
- history: [],
1354
- selectorTime: null,
1355
- transactionKey: null,
1356
- install: () => {
1357
- },
1358
- subject: new Subject()
1359
- };
1360
- },
1361
- effects: (key) => [
1362
- ({ setSelf }) => {
1363
- const tl = store.timelines.get(key);
1364
- tl == null ? void 0 : tl.subject.subscribe((_) => {
1365
- if (store.operation.open === true) {
1366
- const subscription = store.subject.operationStatus.subscribe(
1367
- (operationStatus) => {
1368
- if (operationStatus.open === false) {
1369
- subscription.unsubscribe();
1370
- setSelf(__spreadValues({}, tl));
1371
- }
1372
- }
1373
- );
1374
- } else {
1375
- setSelf(__spreadValues({}, tl));
1376
- }
1377
- });
1378
- }
1379
- ]
1380
- },
1381
- store
1382
- );
1383
- const findTimelineLogState = __INTERNAL__3.selectorFamily__INTERNAL(
1384
- {
1385
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
1386
- get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
1387
- },
1388
- store
1389
- );
1390
- return findTimelineLogState;
1391
- };
1392
-
1393
- // ../src/introspection/attach-timeline-index.ts
1394
- import { __INTERNAL__ as __INTERNAL__4 } from "atom.io";
1395
- var attachTimelineIndex = (store = __INTERNAL__4.IMPLICIT.STORE) => {
1396
- const timelineTokenIndexState__INTERNAL = __INTERNAL__4.atom__INTERNAL(
1397
- {
1398
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
1399
- default: () => [...store.timelines].map(([key]) => {
1400
- return { key, type: `timeline` };
1401
- }),
1402
- effects: [
1403
- ({ setSelf }) => {
1404
- store.subject.timelineCreation.subscribe((timelineToken) => {
1405
- setSelf((state) => [...state, timelineToken]);
1406
- });
1407
- }
1408
- ]
1409
- },
1410
- void 0,
1411
- store
1412
- );
1413
- const timelineTokenIndex = __INTERNAL__4.selector__INTERNAL(
1414
- {
1415
- key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
1416
- get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
1417
- },
1418
- void 0,
1419
- store
1420
- );
1421
- return timelineTokenIndex;
1422
- };
1423
-
1424
- // ../src/introspection/attach-transaction-index.ts
1425
- import { __INTERNAL__ as __INTERNAL__5 } from "atom.io";
1426
- var attachTransactionIndex = (store = __INTERNAL__5.IMPLICIT.STORE) => {
1427
- const transactionTokenIndexState__INTERNAL = __INTERNAL__5.atom__INTERNAL(
1428
- {
1429
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
1430
- default: () => [...store.transactions].map(([key]) => {
1431
- return { key, type: `transaction` };
1432
- }),
1433
- effects: [
1434
- ({ setSelf }) => {
1435
- store.subject.transactionCreation.subscribe((transactionToken) => {
1436
- setSelf((state) => [...state, transactionToken]);
1437
- });
1438
- }
1439
- ]
1440
- },
1441
- void 0,
1442
- store
1443
- );
1444
- const transactionTokenIndex = __INTERNAL__5.selector__INTERNAL(
1445
- {
1446
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
1447
- get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
1448
- },
1449
- void 0,
1450
- store
1451
- );
1452
- return transactionTokenIndex;
1453
- };
1454
-
1455
- // ../src/introspection/attach-transaction-logs.ts
1456
- import { __INTERNAL__ as __INTERNAL__6 } from "atom.io";
1457
- var attachTransactionLogs = (store = __INTERNAL__6.IMPLICIT.STORE) => {
1458
- const findTransactionUpdateLog = __INTERNAL__6.atomFamily__INTERNAL(
1459
- {
1460
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
1461
- default: () => [],
1462
- effects: (key) => [
1463
- ({ setSelf }) => {
1464
- const tx = store.transactions.get(key);
1465
- tx == null ? void 0 : tx.subject.subscribe((transactionUpdate) => {
1466
- if (transactionUpdate.key === key) {
1467
- setSelf((state) => [...state, transactionUpdate]);
1468
- }
1469
- });
1470
- }
1471
- ]
1472
- },
1473
- store
1474
- );
1475
- const findTransactionUpdateLogState = __INTERNAL__6.selectorFamily__INTERNAL(
1476
- {
1477
- key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
1478
- get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
1479
- },
1480
- store
1481
- );
1482
- return findTransactionUpdateLogState;
1483
- };
1484
-
1485
- // ../src/introspection/attach-introspection-states.ts
1486
- var attachIntrospectionStates = (store = __INTERNAL__7.IMPLICIT.STORE) => {
1487
- return {
1488
- atomIndex: attachAtomIndex(store),
1489
- selectorIndex: attachSelectorIndex(store),
1490
- transactionIndex: attachTransactionIndex(store),
1491
- findTransactionLogState: attachTransactionLogs(store),
1492
- timelineIndex: attachTimelineIndex(store),
1493
- findTimelineState: attachTimelineFamily(store)
1494
- };
1495
- };
1496
-
1497
- // ../src/web-effects/storage.ts
1498
- var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
1499
- const savedValue = storage.getItem(key);
1500
- if (savedValue != null)
1501
- setSelf(parse(savedValue));
1502
- onSet(({ newValue }) => {
1503
- if (newValue == null) {
1504
- storage.removeItem(key);
1505
- return;
1506
- }
1507
- storage.setItem(key, stringify(newValue));
1508
- });
1509
- };
1510
- var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
1511
-
1512
- // ../src/react-devtools/AtomIODevtools.tsx
1513
- import { useO as useO5, useIO as useIO5 } from "atom.io/react";
1514
- import { LayoutGroup, motion, spring } from "framer-motion";
1515
- import { useRef as useRef4 } from "react";
1516
-
1517
- // ../src/react-devtools/StateIndex.tsx
1518
- import { getState, selectorFamily } from "atom.io";
1519
- import { useO as useO2, useIO as useIO2 } from "atom.io/react";
1520
-
1521
- // ../../anvl/src/refinement/refine-json.ts
1522
- import { isBoolean } from "fp-ts/boolean";
1523
- import { isNumber } from "fp-ts/number";
1524
- import { isString as isString3 } from "fp-ts/string";
1525
- var JSON_PROTOTYPES = [
1526
- `Array`,
1527
- `Boolean`,
1528
- `Number`,
1529
- `Object`,
1530
- `String`
1531
- ];
1532
- var refineJsonType = (data) => data === null ? { type: `null`, data: null } : isBoolean(data) ? { type: `boolean`, data } : isNumber(data) ? { type: `number`, data } : isString3(data) ? { type: `string`, data } : Array.isArray(data) ? { type: `array`, data } : isPlainObject(data) ? { type: `object`, data } : raiseError(
1533
- data === void 0 ? `undefined passed to refineJsonType. This is not valid JSON.` : `${stringifyJson(data)} with prototype "${Object.getPrototypeOf(data).constructor.name}" passed to refineJsonType. This is not valid JSON.`
1534
- );
1535
- var isJson = (input) => {
1536
- var _a2;
1537
- if (input === null)
1538
- return true;
1539
- if (input === void 0)
1540
- return false;
1541
- const prototype = (_a2 = Object.getPrototypeOf(input)) == null ? void 0 : _a2.constructor.name;
1542
- const isJson2 = JSON_PROTOTYPES.includes(prototype);
1543
- return isJson2;
1544
- };
1545
-
1546
- // ../src/react-devtools/Button.tsx
1547
- import { jsxDEV } from "react/jsx-dev-runtime";
1548
- var OpenClose = ({ isOpen, setIsOpen, disabled }) => {
1549
- return /* @__PURE__ */ jsxDEV(
1550
- "button",
1551
- {
1552
- type: "button",
1553
- className: `carat ${isOpen ? `open` : `closed`}`,
1554
- onClick: () => setIsOpen((isOpen2) => !isOpen2),
1555
- disabled,
1556
- children: "\u25B6"
1557
- },
1558
- void 0,
1559
- false,
1560
- {
1561
- fileName: "../src/react-devtools/Button.tsx",
1562
- lineNumber: 11,
1563
- columnNumber: 3
1564
- },
1565
- this
1566
- );
1567
- };
1568
- var button = {
1569
- OpenClose
1570
- };
1571
-
1572
- // ../src/react-devtools/StateEditor.tsx
1573
- import { useO, useIO } from "atom.io/react";
1574
-
1575
- // ../../hamr/src/react-json-editor/editors-by-type/utilities/array-elements.ts
1576
- var makeElementSetters = (data, set) => data.map(
1577
- (value, index) => (newValue) => set(() => {
1578
- const newData = [...data];
1579
- newData[index] = become(newValue)(value);
1580
- return newData;
1581
- })
1582
- );
1583
-
1584
- // ../../hamr/src/react-elastic-input/ElasticInput.tsx
1585
- import {
1586
- useLayoutEffect,
1587
- useImperativeHandle,
1588
- forwardRef,
1589
- useRef,
1590
- useState
1591
- } from "react";
1592
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
1593
- var ElasticInput = forwardRef(function ElasticInputFC(props, ref) {
1594
- var _a2, _b, _c, _d;
1595
- const inputRef = useRef(null);
1596
- const spanRef = useRef(null);
1597
- const [inputWidth, setInputWidth] = useState(`auto`);
1598
- useImperativeHandle(ref, () => ({
1599
- focus: () => {
1600
- var _a3;
1601
- (_a3 = inputRef.current) == null ? void 0 : _a3.focus();
1602
- }
1603
- }));
1604
- const extraWidth = props.type === `number` ? 15 : 0;
1605
- useLayoutEffect(() => {
1606
- if (spanRef.current) {
1607
- setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
1608
- const interval = setInterval(() => {
1609
- if (spanRef.current) {
1610
- setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
1611
- }
1612
- }, 1e3);
1613
- return () => clearInterval(interval);
1614
- }
1615
- }, [(_a2 = inputRef.current) == null ? void 0 : _a2.value, props.value]);
1616
- return /* @__PURE__ */ jsxDEV2("div", { style: { display: `inline-block`, position: `relative` }, children: [
1617
- /* @__PURE__ */ jsxDEV2(
1618
- "input",
1619
- __spreadProps(__spreadValues({}, props), {
1620
- ref: inputRef,
1621
- style: __spreadValues({
1622
- padding: 0,
1623
- borderRadius: 0,
1624
- border: `none`,
1625
- fontFamily: `inherit`,
1626
- fontSize: `inherit`,
1627
- width: inputWidth
1628
- }, props.style)
1629
- }),
1630
- void 0,
1631
- false,
1632
- {
1633
- fileName: "../../hamr/src/react-elastic-input/ElasticInput.tsx",
1634
- lineNumber: 45,
1635
- columnNumber: 4
1636
- },
1637
- this
1638
- ),
1639
- /* @__PURE__ */ jsxDEV2(
1640
- "span",
1641
- {
1642
- ref: spanRef,
1643
- style: {
1644
- padding: (_b = props.style) == null ? void 0 : _b.padding,
1645
- position: `absolute`,
1646
- visibility: `hidden`,
1647
- // color: `red`,
1648
- whiteSpace: `pre`,
1649
- fontFamily: ((_c = props.style) == null ? void 0 : _c.fontFamily) || `inherit`,
1650
- fontSize: ((_d = props.style) == null ? void 0 : _d.fontSize) || `inherit`
1651
- },
1652
- children: props.value
1653
- },
1654
- void 0,
1655
- false,
1656
- {
1657
- fileName: "../../hamr/src/react-elastic-input/ElasticInput.tsx",
1658
- lineNumber: 58,
1659
- columnNumber: 4
1660
- },
1661
- this
1662
- )
1663
- ] }, void 0, true, {
1664
- fileName: "../../hamr/src/react-elastic-input/ElasticInput.tsx",
1665
- lineNumber: 44,
1666
- columnNumber: 3
1667
- }, this);
1668
- });
1669
-
1670
- // ../../hamr/src/react-elastic-input/NumberInput.tsx
1671
- import { pipe as pipe6 } from "fp-ts/function";
1672
- import { useState as useState2, useId, useRef as useRef2 } from "react";
1673
-
1674
- // ../../anvl/src/number/clamp.ts
1675
- var clampInto = (min, max) => (value) => value < min ? min : value > max ? max : value;
1676
-
1677
- // ../../anvl/src/number/wrap.ts
1678
- var wrapInto = (min, max) => (value) => value < min ? max - (min - value) % (max - min) : min + (value - min) % (max - min);
1679
-
1680
- // ../../hamr/src/react-elastic-input/NumberInput.tsx
1681
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
1682
- function round(value, decimalPlaces) {
1683
- if (decimalPlaces === void 0)
1684
- return value;
1685
- const factor = 10 ** decimalPlaces;
1686
- return Math.round(value * factor) / factor;
1687
- }
1688
- var VALID_NON_NUMBERS = [``, `-`, `.`, `-.`];
1689
- var isValidNonNumber = (input) => VALID_NON_NUMBERS.includes(input);
1690
- var VALID_NON_NUMBER_INTERPRETATIONS = {
1691
- "": null,
1692
- "-": 0,
1693
- ".": 0,
1694
- "-.": 0
1695
- };
1696
- var isDecimalInProgress = (input) => input === `0` || !isNaN(Number(input)) && input.includes(`.`);
1697
- var textToValue = (input, allowDecimal) => {
1698
- if (isValidNonNumber(input))
1699
- return VALID_NON_NUMBER_INTERPRETATIONS[input];
1700
- return allowDecimal ? parseFloat(input) : Math.round(parseFloat(input));
1701
- };
1702
- var DEFAULT_NUMBER_CONSTRAINTS = {
1703
- max: Infinity,
1704
- min: -Infinity,
1705
- decimalPlaces: 100,
1706
- nullable: true
1707
- };
1708
- var initRefinery = (constraints) => (input) => {
1709
- if (input === null && constraints.nullable === true) {
1710
- return null;
1711
- }
1712
- const { max, min, decimalPlaces } = __spreadValues(__spreadValues({}, DEFAULT_NUMBER_CONSTRAINTS), constraints);
1713
- const constrained = pipe6(
1714
- input != null ? input : 0,
1715
- clampInto(min, max),
1716
- (n) => decimalPlaces ? round(n, decimalPlaces) : n
1717
- );
1718
- return constrained;
1719
- };
1720
- var valueToText = (numericValue) => {
1721
- if (numericValue === null || numericValue === void 0) {
1722
- return ``;
1723
- }
1724
- return numericValue.toString();
1725
- };
1726
- var NumberInput = ({
1727
- autoSize = false,
1728
- customCss,
1729
- decimalPlaces,
1730
- disabled = false,
1731
- label,
1732
- max,
1733
- min,
1734
- name,
1735
- onChange,
1736
- onClick,
1737
- placeholder = ``,
1738
- set = () => null,
1739
- testId,
1740
- value = null
1741
- }) => {
1742
- const id = useId();
1743
- const [temporaryEntry, setTemporaryEntry] = useState2(null);
1744
- const userHasMadeDeliberateChange = useRef2(false);
1745
- const refine = initRefinery({ max, min, decimalPlaces, nullable: true });
1746
- const allowDecimal = decimalPlaces === void 0 || decimalPlaces > 0;
1747
- const handleBlur = () => {
1748
- if (userHasMadeDeliberateChange.current) {
1749
- set(refine(value != null ? value : null));
1750
- setTemporaryEntry(null);
1751
- }
1752
- userHasMadeDeliberateChange.current = false;
1753
- };
1754
- const handleChange = (event) => {
1755
- var _a2;
1756
- if (onChange)
1757
- onChange(event);
1758
- if (set === void 0)
1759
- return;
1760
- userHasMadeDeliberateChange.current = true;
1761
- const input = event.target.value;
1762
- if (isValidNonNumber(input) || isDecimalInProgress(input)) {
1763
- setTemporaryEntry(input);
1764
- const textInterpretation = isDecimalInProgress(input) ? input : (_a2 = min == null ? void 0 : min.toString()) != null ? _a2 : `0`;
1765
- const newValue = textToValue(textInterpretation, allowDecimal);
1766
- set(refine(newValue));
1767
- return;
1768
- }
1769
- setTemporaryEntry(null);
1770
- const inputIsNumeric = !isNaN(Number(input)) && !input.includes(` `) || allowDecimal && input === `.` || allowDecimal && input === `-.` || input === `` || input === `-`;
1771
- const numericValue = textToValue(input, allowDecimal);
1772
- if (inputIsNumeric) {
1773
- set(refine(numericValue));
1774
- }
1775
- };
1776
- const displayValue = temporaryEntry != null ? temporaryEntry : valueToText(value ? refine(value) : value);
1777
- return /* @__PURE__ */ jsxDEV3("span", { css: customCss, children: [
1778
- label && /* @__PURE__ */ jsxDEV3("label", { htmlFor: id, children: label }, void 0, false, {
1779
- fileName: "../../hamr/src/react-elastic-input/NumberInput.tsx",
1780
- lineNumber: 168,
1781
- columnNumber: 14
1782
- }, this),
1783
- autoSize ? /* @__PURE__ */ jsxDEV3(
1784
- ElasticInput,
1785
- {
1786
- type: "text",
1787
- value: displayValue,
1788
- placeholder: placeholder != null ? placeholder : `-`,
1789
- onChange: handleChange,
1790
- onBlur: handleBlur,
1791
- disabled,
1792
- name: name != null ? name : id,
1793
- id,
1794
- onClick,
1795
- "data-testid": `number-input-${testId != null ? testId : id}`
1796
- },
1797
- void 0,
1798
- false,
1799
- {
1800
- fileName: "../../hamr/src/react-elastic-input/NumberInput.tsx",
1801
- lineNumber: 170,
1802
- columnNumber: 5
1803
- },
1804
- this
1805
- ) : /* @__PURE__ */ jsxDEV3(
1806
- "input",
1807
- {
1808
- type: "text",
1809
- value: displayValue,
1810
- placeholder: placeholder != null ? placeholder : `-`,
1811
- onChange: handleChange,
1812
- onBlur: handleBlur,
1813
- disabled,
1814
- name: name != null ? name : id,
1815
- id,
1816
- onClick,
1817
- "data-testid": `number-input-${testId != null ? testId : id}`
1818
- },
1819
- void 0,
1820
- false,
1821
- {
1822
- fileName: "../../hamr/src/react-elastic-input/NumberInput.tsx",
1823
- lineNumber: 183,
1824
- columnNumber: 5
1825
- },
1826
- this
1827
- )
1828
- ] }, void 0, true, {
1829
- fileName: "../../hamr/src/react-elastic-input/NumberInput.tsx",
1830
- lineNumber: 167,
1831
- columnNumber: 3
1832
- }, this);
1833
- };
1834
-
1835
- // ../../hamr/src/react-elastic-input/TextInput.tsx
1836
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
1837
- var TextInput = ({
1838
- value,
1839
- set,
1840
- label,
1841
- placeholder,
1842
- customCss,
1843
- autoSize = false
1844
- }) => {
1845
- return /* @__PURE__ */ jsxDEV4("span", { css: customCss, children: [
1846
- /* @__PURE__ */ jsxDEV4("label", { children: label }, void 0, false, {
1847
- fileName: "../../hamr/src/react-elastic-input/TextInput.tsx",
1848
- lineNumber: 26,
1849
- columnNumber: 4
1850
- }, this),
1851
- autoSize ? /* @__PURE__ */ jsxDEV4(
1852
- ElasticInput,
1853
- {
1854
- type: "text",
1855
- value,
1856
- onChange: (e) => set == null ? void 0 : set(e.target.value),
1857
- disabled: set === void 0,
1858
- placeholder
1859
- },
1860
- void 0,
1861
- false,
1862
- {
1863
- fileName: "../../hamr/src/react-elastic-input/TextInput.tsx",
1864
- lineNumber: 28,
1865
- columnNumber: 5
1866
- },
1867
- this
1868
- ) : /* @__PURE__ */ jsxDEV4(
1869
- "input",
1870
- {
1871
- type: "text",
1872
- value,
1873
- onChange: (e) => set == null ? void 0 : set(e.target.value),
1874
- disabled: set === void 0,
1875
- placeholder
1876
- },
1877
- void 0,
1878
- false,
1879
- {
1880
- fileName: "../../hamr/src/react-elastic-input/TextInput.tsx",
1881
- lineNumber: 36,
1882
- columnNumber: 5
1883
- },
1884
- this
1885
- )
1886
- ] }, void 0, true, {
1887
- fileName: "../../hamr/src/react-elastic-input/TextInput.tsx",
1888
- lineNumber: 25,
1889
- columnNumber: 3
1890
- }, this);
1891
- };
1892
-
1893
- // ../../hamr/src/react-json-editor/editors-by-type/non-json.tsx
1894
- import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
1895
- var NonJsonEditor = ({ data }) => {
1896
- return data === void 0 ? /* @__PURE__ */ jsxDEV5(ElasticInput, { disabled: true, value: "undefined" }, void 0, false, {
1897
- fileName: "../../hamr/src/react-json-editor/editors-by-type/non-json.tsx",
1898
- lineNumber: 6,
1899
- columnNumber: 3
1900
- }, this) : /* @__PURE__ */ jsxDEV5(
1901
- ElasticInput,
1902
- {
1903
- disabled: true,
1904
- value: Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data)
1905
- },
1906
- void 0,
1907
- false,
1908
- {
1909
- fileName: "../../hamr/src/react-json-editor/editors-by-type/non-json.tsx",
1910
- lineNumber: 8,
1911
- columnNumber: 3
1912
- },
1913
- this
1914
- );
1915
- };
1916
-
1917
- // ../../hamr/src/react-json-editor/json-editor-internal.tsx
1918
- import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
1919
- var JsonEditor_INTERNAL = ({
1920
- data,
1921
- set,
1922
- schema,
1923
- name,
1924
- rename,
1925
- remove,
1926
- recast,
1927
- path = [],
1928
- isReadonly = () => false,
1929
- isHidden = () => false,
1930
- className,
1931
- customCss,
1932
- Header: HeaderDisplay,
1933
- Components
1934
- }) => {
1935
- const dataIsJson = isJson(data);
1936
- const refined = dataIsJson ? refineJsonType(data) : { type: `non-json`, data };
1937
- const SubEditor = dataIsJson ? SubEditors[refined.type] : NonJsonEditor;
1938
- const disabled = isReadonly(path);
1939
- return isHidden(path) ? null : /* @__PURE__ */ jsxDEV6(Components.ErrorBoundary, { children: /* @__PURE__ */ jsxDEV6(Components.EditorWrapper, { className, customCss, children: [
1940
- remove && /* @__PURE__ */ jsxDEV6(
1941
- Components.Button,
1942
- {
1943
- onClick: disabled ? doNothing : remove,
1944
- disabled,
1945
- children: /* @__PURE__ */ jsxDEV6(Components.DeleteIcon, {}, void 0, false, {
1946
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
1947
- lineNumber: 65,
1948
- columnNumber: 7
1949
- }, this)
1950
- },
1951
- void 0,
1952
- false,
1953
- {
1954
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
1955
- lineNumber: 61,
1956
- columnNumber: 6
1957
- },
1958
- this
1959
- ),
1960
- HeaderDisplay && /* @__PURE__ */ jsxDEV6(HeaderDisplay, { data, schema }, void 0, false, {
1961
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
1962
- lineNumber: 68,
1963
- columnNumber: 23
1964
- }, this),
1965
- rename && /* @__PURE__ */ jsxDEV6(Components.KeyWrapper, { children: /* @__PURE__ */ jsxDEV6(
1966
- ElasticInput,
1967
- {
1968
- value: name,
1969
- onChange: disabled ? doNothing : (e) => rename(e.target.value),
1970
- disabled
1971
- },
1972
- void 0,
1973
- false,
1974
- {
1975
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
1976
- lineNumber: 71,
1977
- columnNumber: 7
1978
- },
1979
- this
1980
- ) }, void 0, false, {
1981
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
1982
- lineNumber: 70,
1983
- columnNumber: 6
1984
- }, this),
1985
- /* @__PURE__ */ jsxDEV6(
1986
- SubEditor,
1987
- {
1988
- data: refined.data,
1989
- set,
1990
- schema,
1991
- remove,
1992
- rename,
1993
- path,
1994
- isReadonly,
1995
- isHidden,
1996
- Components
1997
- },
1998
- void 0,
1999
- false,
2000
- {
2001
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
2002
- lineNumber: 78,
2003
- columnNumber: 5
2004
- },
2005
- this
2006
- ),
2007
- recast && dataIsJson ? /* @__PURE__ */ jsxDEV6(
2008
- "select",
2009
- {
2010
- onChange: disabled ? doNothing : (e) => recast(e.target.value),
2011
- value: refined.type,
2012
- disabled,
2013
- children: Object.keys(SubEditors).map((type) => /* @__PURE__ */ jsxDEV6("option", { value: type, children: type }, type, false, {
2014
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
2015
- lineNumber: 100,
2016
- columnNumber: 8
2017
- }, this))
2018
- },
2019
- void 0,
2020
- false,
2021
- {
2022
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
2023
- lineNumber: 90,
2024
- columnNumber: 6
2025
- },
2026
- this
2027
- ) : null
2028
- ] }, void 0, true, {
2029
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
2030
- lineNumber: 59,
2031
- columnNumber: 4
2032
- }, this) }, void 0, false, {
2033
- fileName: "../../hamr/src/react-json-editor/json-editor-internal.tsx",
2034
- lineNumber: 58,
2035
- columnNumber: 3
2036
- }, this);
2037
- };
2038
-
2039
- // ../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx
2040
- import { Fragment, jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
2041
- var ArrayEditor = ({
2042
- path = [],
2043
- isReadonly = () => false,
2044
- isHidden = () => false,
2045
- data,
2046
- set,
2047
- Components
2048
- }) => {
2049
- const setElement = makeElementSetters(data, set);
2050
- return /* @__PURE__ */ jsxDEV7(Fragment, { children: data.map((element, index) => {
2051
- const newPath = [...path, index];
2052
- return /* @__PURE__ */ jsxDEV7(
2053
- JsonEditor_INTERNAL,
2054
- {
2055
- path: newPath,
2056
- isReadonly,
2057
- isHidden,
2058
- data: element,
2059
- set: setElement[index],
2060
- Components
2061
- },
2062
- newPath.join(``),
2063
- false,
2064
- {
2065
- fileName: "../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx",
2066
- lineNumber: 23,
2067
- columnNumber: 6
2068
- },
2069
- this
2070
- );
2071
- }) }, void 0, false, {
2072
- fileName: "../../hamr/src/react-json-editor/editors-by-type/array-editor.tsx",
2073
- lineNumber: 19,
2074
- columnNumber: 3
2075
- }, this);
2076
- };
2077
-
2078
- // ../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx
2079
- import { useRef as useRef3 } from "react";
2080
-
2081
- // ../../anvl/src/json-schema/json-schema.ts
2082
- import { isBoolean as isBoolean2 } from "fp-ts/boolean";
2083
- import { isNumber as isNumber2 } from "fp-ts/number";
2084
- import { isString as isString6 } from "fp-ts/string";
2085
-
2086
- // ../../anvl/src/json-schema/integer.ts
2087
- import { pipe as pipe7 } from "fp-ts/function";
2088
- var isInteger = (input) => Number.isInteger(input);
2089
- var parseInteger = (input) => {
2090
- if (isInteger(input))
2091
- return input;
2092
- throw new IntegerParseError(input);
2093
- };
2094
- var _a;
2095
- var Fraction = class extends Number {
2096
- constructor(n, d) {
2097
- super(n / d);
2098
- this[_a] = () => this.numerator / this.denominator;
2099
- if (d === 0) {
2100
- throw new Error(`Denominator cannot be zero`);
2101
- }
2102
- this.numerator = parseInteger(n);
2103
- this.denominator = parseInteger(d);
2104
- }
2105
- };
2106
- _a = Symbol.toPrimitive;
2107
- var IntegerParseError = class extends Error {
2108
- constructor(value) {
2109
- super(`Could not parse integer from ${JSON.stringify(value)}`);
2110
- }
2111
- };
2112
- var Int = Object.assign((input) => parseInteger(input), {
2113
- from: (input) => pipe7(
2114
- input,
2115
- String,
2116
- parseFloat,
2117
- (num) => isInteger(num) ? {
2118
- value: num,
2119
- error: null,
2120
- round: null,
2121
- upper: null,
2122
- lower: null,
2123
- ratio: null
2124
- } : {
2125
- value: null,
2126
- error: new IntegerParseError(input),
2127
- round: Math.round(num),
2128
- upper: Math.ceil(num),
2129
- lower: Math.floor(num),
2130
- ratio: null
2131
- }
2132
- ),
2133
- formula: (fm) => {
2134
- return (input) => {
2135
- return fm(
2136
- input
2137
- );
2138
- };
2139
- }
2140
- });
2141
- function asNumber(input) {
2142
- return input;
2143
- }
2144
- var a = asNumber(new Fraction(1, 2));
2145
- var b = asNumber([new Fraction(1, 2)]);
2146
- var c = asNumber({ a: new Fraction(1, 2) });
2147
-
2148
- // ../../anvl/src/json-schema/refs.ts
2149
- import { isString as isString4 } from "fp-ts/string";
2150
- function isJsonSchemaRef(input) {
2151
- return doesExtend({
2152
- $ref: isString4
2153
- })(input);
2154
- }
2155
- var colorPalette = {
2156
- $defs: {
2157
- colorChannel: {
2158
- type: `integer`,
2159
- minimum: Int(0),
2160
- maximum: Int(255)
2161
- },
2162
- color: {
2163
- type: `object`,
2164
- properties: {
2165
- red: { $ref: `#/$defs/colorChannel` },
2166
- green: { $ref: `#/$defs/colorChannel` },
2167
- blue: { $ref: `#/$defs/colorChannel` }
2168
- }
2169
- }
2170
- },
2171
- type: `array`,
2172
- items: {
2173
- $ref: `#/$defs/color`
2174
- }
2175
- };
2176
- var retrieveRef = ({
2177
- refNode: { $ref },
2178
- refMap = {},
2179
- root
2180
- }) => {
2181
- if (typeof root === `boolean`) {
2182
- throw new TypeError(`The root is a boolean and cannot be indexed`);
2183
- }
2184
- if ($ref in refMap)
2185
- return { node: refMap[$ref], refMap };
2186
- const [_, ...refPath] = $ref.split(`/`);
2187
- const discovery = delve(root, refPath);
2188
- if (discovery instanceof Error)
2189
- throw discovery;
2190
- let node = discovery.found;
2191
- while (isJsonSchemaRef(node)) {
2192
- const result = retrieveRef({ refNode: node, refMap, root });
2193
- node = result.node;
2194
- refMap = result.refMap;
2195
- }
2196
- if (isJsonSchema(node)) {
2197
- return { node, refMap: __spreadProps(__spreadValues({}, refMap), { [$ref]: node }) };
2198
- }
2199
- throw new TypeError(`The refNode is not a JsonSchema`);
2200
- };
2201
-
2202
- // ../../anvl/src/json-schema/string-formats.ts
2203
- import { isString as isString5 } from "fp-ts/string";
2204
- var JSON_SCHEMA_STRING_FORMATS = [
2205
- `date-time`,
2206
- `date`,
2207
- `email`,
2208
- `hostname`,
2209
- `ipv4`,
2210
- `ipv6`,
2211
- `regex`,
2212
- `time`,
2213
- `uri-reference`,
2214
- `uri-template`,
2215
- `uri`,
2216
- `uuid`
2217
- ];
2218
-
2219
- // ../../anvl/src/json-schema/json-schema.ts
2220
- var JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`];
2221
- var JSON_SCHEMA_META_TYPE_NAMES = [
2222
- ...JSON_SCHEMA_TYPE_NAMES,
2223
- `any`,
2224
- `never`
2225
- ];
2226
- var JSON_SCHEMA_REFINERY = {
2227
- array: isArraySchema,
2228
- boolean: isBooleanSchema,
2229
- integer: isIntegerSchema,
2230
- null: isNullSchema,
2231
- number: isNumberSchema,
2232
- object: isObjectSchema,
2233
- string: isStringSchema,
2234
- any: isLiteral(true),
2235
- never: isLiteral(false),
2236
- union: isUnionSchema,
2237
- intersection: isIntersectionSchema,
2238
- negation: isNegationSchema,
2239
- conditional: isConditionalSchema
2240
- };
2241
- var stringSchemaStructure = {
2242
- type: isLiteral(`string`),
2243
- enum: ifDefined(isArray(isString6)),
2244
- minLength: ifDefined(isInteger),
2245
- maxLength: ifDefined(isInteger),
2246
- pattern: ifDefined(isString6),
2247
- format: ifDefined(isWithin(JSON_SCHEMA_STRING_FORMATS))
2248
- };
2249
- function isStringSchema(input) {
2250
- return doesExtend(stringSchemaStructure)(input);
2251
- }
2252
- var numberSchemaStructure = {
2253
- type: isLiteral(`number`),
2254
- enum: ifDefined(isArray(isNumber2)),
2255
- minimum: ifDefined(isNumber2),
2256
- maximum: ifDefined(isNumber2),
2257
- exclusiveMinimum: ifDefined(isNumber2),
2258
- exclusiveMaximum: ifDefined(isNumber2),
2259
- multipleOf: ifDefined(isNumber2)
2260
- };
2261
- function isNumberSchema(input) {
2262
- return doesExtend(numberSchemaStructure)(input);
2263
- }
2264
- var integerSchemaStructure = {
2265
- type: isLiteral(`integer`),
2266
- enum: ifDefined(isArray(isInteger)),
2267
- minimum: ifDefined(isInteger),
2268
- maximum: ifDefined(isInteger),
2269
- exclusiveMinimum: ifDefined(isInteger),
2270
- exclusiveMaximum: ifDefined(isInteger),
2271
- multipleOf: ifDefined(isInteger)
2272
- };
2273
- function isIntegerSchema(input) {
2274
- return doesExtend(integerSchemaStructure)(input);
2275
- }
2276
- var booleanSchemaStructure = {
2277
- type: isLiteral(`boolean`),
2278
- enum: ifDefined(isArray(isBoolean2))
2279
- };
2280
- function isBooleanSchema(input) {
2281
- return doesExtend(booleanSchemaStructure)(input);
2282
- }
2283
- var nullSchemaStructure = {
2284
- type: isLiteral(`null`)
2285
- };
2286
- function isNullSchema(input) {
2287
- return doesExtend(nullSchemaStructure)(input);
2288
- }
2289
- var objectSchemaStructure = {
2290
- type: isLiteral(`object`),
2291
- properties: ifDefined(isRecord(isString6, isJsonSchema)),
2292
- required: ifDefined(isArray(isString6)),
2293
- additionalProperties: ifDefined(isJsonSchema),
2294
- propertyNames: ifDefined(isStringSchema),
2295
- minProperties: ifDefined(isInteger),
2296
- maxProperties: ifDefined(isInteger),
2297
- dependentSchemas: ifDefined(isRecord(isString6, isJsonSchema))
2298
- };
2299
- function isObjectSchema(input) {
2300
- return doesExtend(objectSchemaStructure)(input);
2301
- }
2302
- var arraySchemaStructure = {
2303
- type: isLiteral(`array`),
2304
- items: ifDefined(couldBe(isJsonSchema).or(isArray(isJsonSchema))),
2305
- minItems: ifDefined(isInteger),
2306
- maxItems: ifDefined(isInteger),
2307
- uniqueItems: ifDefined(isBoolean2)
2308
- };
2309
- function isArraySchema(input) {
2310
- return doesExtend(arraySchemaStructure)(input);
2311
- }
2312
- var unionSchemaStructure = { anyOf: isArray(isJsonSchema) };
2313
- function isUnionSchema(input) {
2314
- return doesExtend(unionSchemaStructure)(input);
2315
- }
2316
- var exclusiveSchemaStructure = { oneOf: isArray(isJsonSchema) };
2317
- function isExclusiveSchema(input) {
2318
- return doesExtend(exclusiveSchemaStructure)(input);
2319
- }
2320
- var intersectionSchemaStructure = { allOf: isArray(isJsonSchema) };
2321
- function isIntersectionSchema(input) {
2322
- return doesExtend(intersectionSchemaStructure)(input);
2323
- }
2324
- var conditionalSchemaStructure = {
2325
- if: isJsonSchema,
2326
- then: ifDefined(isJsonSchema),
2327
- else: ifDefined(isJsonSchema)
2328
- };
2329
- function isConditionalSchema(input) {
2330
- return doesExtend(conditionalSchemaStructure)(input);
2331
- }
2332
- var negationSchemaStructure = { not: isJsonSchema };
2333
- function isNegationSchema(input) {
2334
- return doesExtend(negationSchemaStructure)(input);
2335
- }
2336
- var mixedSchemaStructure = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, arraySchemaStructure), booleanSchemaStructure), integerSchemaStructure), nullSchemaStructure), numberSchemaStructure), objectSchemaStructure), stringSchemaStructure), {
2337
- type: isArray(isWithin(JSON_SCHEMA_TYPE_NAMES)),
2338
- enum: ifDefined(
2339
- isArray(isUnion.or(isInteger).or(isBoolean2).or(isNumber2).or(isString6))
2340
- )
2341
- });
2342
- function isMixedSchema(input) {
2343
- return doesExtend(mixedSchemaStructure)(input);
2344
- }
2345
- var isJsonSchemaCore = isUnion.or(isArraySchema).or(isBooleanSchema).or(isConditionalSchema).or(isExclusiveSchema).or(isIntegerSchema).or(isIntersectionSchema).or(isMixedSchema).or(isNegationSchema).or(isNullSchema).or(isNumberSchema).or(isObjectSchema).or(isStringSchema).or(isUnionSchema);
2346
- var isJsonSchemaRoot = doesExtend({
2347
- $id: ifDefined(isString6),
2348
- $schema: ifDefined(isString6)
2349
- });
2350
- var isJsonSchemaObject = isIntersection.and(isJsonSchemaCore).and(isJsonSchemaRoot);
2351
- function isJsonSchema(input) {
2352
- return couldBe(isJsonSchemaObject).or(isBoolean2).or(isJsonSchemaRef)(input);
2353
- }
2354
-
2355
- // ../../anvl/src/json-schema/path-into.ts
2356
- var expandPathForSchema = (path) => {
2357
- try {
2358
- return path.flatMap((key) => {
2359
- switch (typeof key) {
2360
- case `string`:
2361
- return [`properties`, key];
2362
- case `number`:
2363
- return [`items`, key];
2364
- case `symbol`:
2365
- throw new TypeError(
2366
- `The key ${String(
2367
- key
2368
- )} is not a valid JSON key; expected string or number, got symbol`
2369
- );
2370
- default:
2371
- throw new TypeError(
2372
- `The key ${key} is not a valid JSON key; expected string or number, got ${typeof key}`
2373
- );
2374
- }
2375
- });
2376
- } catch (caught) {
2377
- if (caught instanceof TypeError)
2378
- return caught;
2379
- throw caught;
2380
- }
2381
- };
2382
-
2383
- // ../../anvl/src/json-schema/find-sub-schema.ts
2384
- var findSubSchema = (schema) => {
2385
- if (typeof schema === `boolean`) {
2386
- throw new Error(`The schema does not contain subSchemas`);
2387
- }
2388
- return (path) => {
2389
- const pathIntoSchema = expandPathForSchema(path);
2390
- if (pathIntoSchema instanceof Error)
2391
- return pathIntoSchema;
2392
- if (typeof schema === `boolean`) {
2393
- return new TypeError(`The schema is not a JsonSchema`);
2394
- }
2395
- const { node, refMap } = pathIntoSchema.reduce(
2396
- ({ node: node2, refMap: refMap2 = void 0 }, key) => (console.log({ node: node2, key }), isJsonSchemaRef(node2) ? retrieveRef({ refNode: node2, root: schema, refMap: refMap2 }) : { node: node2[key], refMap: refMap2 }),
2397
- { node: schema, refMap: void 0 }
2398
- );
2399
- if (node instanceof Error)
2400
- throw node;
2401
- let subSchema = node;
2402
- while (isJsonSchemaRef(subSchema)) {
2403
- console.log({ subSchema });
2404
- subSchema = retrieveRef({ refNode: subSchema, root: schema, refMap }).node;
2405
- }
2406
- console.log({ subSchema });
2407
- if (isJsonSchema(subSchema)) {
2408
- return subSchema;
2409
- }
2410
- throw new TypeError(`The subSchema is not a JsonSchema`);
2411
- };
2412
- };
2413
-
2414
- // ../../anvl/src/json/cast-json.ts
2415
- var stringToBoolean = (str) => str === `true`;
2416
- var stringToNumber = (str) => Number(str);
2417
- var stringToArray = (str) => str.split(`,`);
2418
- var stringToObject = (str) => {
2419
- try {
2420
- return JSON.parse(str);
2421
- } catch (e) {
2422
- return { [str]: str };
2423
- }
2424
- };
2425
- var objectToString = (obj) => JSON.stringify(obj);
2426
- var objectToBoolean = (obj) => obj.true === true;
2427
- var objectToNumber = (obj) => {
2428
- var _a2, _b, _c;
2429
- return Number((_c = (_b = (_a2 = obj.number) != null ? _a2 : obj.size) != null ? _b : obj.count) != null ? _c : 0);
2430
- };
2431
- var objectToArray = (obj) => Object.entries(obj);
2432
- var booleanToString = (bool) => bool.toString();
2433
- var booleanToNumber = (bool) => +bool;
2434
- var booleanToObject = (bool) => ({
2435
- [bool.toString()]: bool
2436
- });
2437
- var booleanToArray = (bool) => [bool];
2438
- var numberToString = (num) => num.toString();
2439
- var numberToBoolean = (num) => num === 1;
2440
- var numberToObject = (num) => ({
2441
- number: num
2442
- });
2443
- var numberToArray = (num) => Array(num).fill(null);
2444
- var arrayToString = (arr) => arr.join(`,`);
2445
- var arrayToNumber = (arr) => arr.length;
2446
- var arrayToBoolean = (arr) => typeof arr[0] === `boolean` ? arr[0] : arr.length > 0;
2447
- var arrayToObject = (arr) => arr.reduce((acc, cur, idx) => {
2448
- acc[`${idx}`] = cur;
2449
- return acc;
2450
- }, {});
2451
- var nullToString = () => ``;
2452
- var nullToNumber = () => 0;
2453
- var nullToBoolean = () => false;
2454
- var nullToArray = () => [];
2455
- var nullToObject = () => ({});
2456
-
2457
- // ../../anvl/src/refinement/smart-cast-json.ts
2458
- var castToJson = (input) => {
2459
- const json = refineJsonType(input);
2460
- return {
2461
- to: {
2462
- array: () => {
2463
- switch (json.type) {
2464
- case `array`:
2465
- return json.data;
2466
- case `object`:
2467
- return objectToArray(json.data);
2468
- case `string`:
2469
- return stringToArray(json.data);
2470
- case `boolean`:
2471
- return booleanToArray(json.data);
2472
- case `number`:
2473
- return numberToArray(json.data);
2474
- case `null`:
2475
- return nullToArray();
2476
- }
2477
- },
2478
- boolean: () => {
2479
- switch (json.type) {
2480
- case `array`:
2481
- return arrayToBoolean(json.data);
2482
- case `object`:
2483
- return objectToBoolean(json.data);
2484
- case `string`:
2485
- return stringToBoolean(json.data);
2486
- case `boolean`:
2487
- return json.data;
2488
- case `number`:
2489
- return numberToBoolean(json.data);
2490
- case `null`:
2491
- return nullToBoolean();
2492
- }
2493
- },
2494
- number: () => {
2495
- switch (json.type) {
2496
- case `array`:
2497
- return arrayToNumber(json.data);
2498
- case `object`:
2499
- return objectToNumber(json.data);
2500
- case `string`:
2501
- return stringToNumber(json.data);
2502
- case `boolean`:
2503
- return booleanToNumber(json.data);
2504
- case `number`:
2505
- return json.data;
2506
- case `null`:
2507
- return nullToNumber();
2508
- }
2509
- },
2510
- object: () => {
2511
- switch (json.type) {
2512
- case `array`:
2513
- return arrayToObject(json.data);
2514
- case `object`:
2515
- return json.data;
2516
- case `string`:
2517
- return stringToObject(json.data);
2518
- case `boolean`:
2519
- return booleanToObject(json.data);
2520
- case `number`:
2521
- return numberToObject(json.data);
2522
- case `null`:
2523
- return nullToObject();
2524
- }
2525
- },
2526
- string: () => {
2527
- switch (json.type) {
2528
- case `array`:
2529
- return arrayToString(json.data);
2530
- case `object`:
2531
- return objectToString(json.data);
2532
- case `string`:
2533
- return json.data;
2534
- case `boolean`:
2535
- return booleanToString(json.data);
2536
- case `number`:
2537
- return numberToString(json.data);
2538
- case `null`:
2539
- return nullToString();
2540
- }
2541
- },
2542
- null: () => null
2543
- }
2544
- };
2545
- };
2546
-
2547
- // ../../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts
2548
- var makePropertySetters = (data, set) => mapObject(
2549
- data,
2550
- (value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]: become(newValue)(value[key]) }))
2551
- );
2552
- var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
2553
- data,
2554
- (value, key) => (newKey) => Object.hasOwn(data, newKey) ? null : set(() => {
2555
- const entries = Object.entries(data);
2556
- const index = entries.findIndex(([k]) => k === key);
2557
- entries[index] = [newKey, value];
2558
- const stableKeyMap = stableKeyMapRef.current;
2559
- stableKeyMapRef.current = __spreadProps(__spreadValues({}, stableKeyMap), {
2560
- [newKey]: stableKeyMap[key]
2561
- });
2562
- return Object.fromEntries(entries);
2563
- })
2564
- );
2565
- var makePropertyRemovers = (data, set) => mapObject(
2566
- data,
2567
- (_, key) => () => set(() => {
2568
- const _a2 = data, { [key]: _2 } = _a2, rest = __objRest(_a2, [__restKey(key)]);
2569
- return rest;
2570
- })
2571
- );
2572
- var makePropertyRecasters = (data, set) => mapObject(
2573
- data,
2574
- (value, key) => (newType) => set(() => __spreadProps(__spreadValues({}, data), {
2575
- [key]: castToJson(value).to[newType]()
2576
- }))
2577
- );
2578
- var makePropertyCreationInterface = (data, set) => (key, type) => (value) => set(__spreadProps(__spreadValues({}, data), { [key]: value != null ? value : JSON_DEFAULTS[type] }));
2579
- var makePropertySorter = (data, set, sortFn) => () => {
2580
- const sortedKeys = Object.keys(data).sort(sortFn);
2581
- const sortedObj = {};
2582
- sortedKeys.forEach((key) => sortedObj[key] = data[key]);
2583
- set(sortedObj);
2584
- };
2585
-
2586
- // ../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx
2587
- import { Fragment as Fragment2, jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
2588
- var PropertyAdder = ({
2589
- addProperty,
2590
- disabled,
2591
- propertyKey,
2592
- Components
2593
- }) => /* @__PURE__ */ jsxDEV8(Components.MissingPropertyWrapper, { children: [
2594
- /* @__PURE__ */ jsxDEV8(ElasticInput, { disabled: true, defaultValue: propertyKey }, void 0, false, {
2595
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2596
- lineNumber: 38,
2597
- columnNumber: 3
2598
- }, this),
2599
- ` `,
2600
- /* @__PURE__ */ jsxDEV8(ElasticInput, { disabled: true, defaultValue: "is missing" }, void 0, false, {
2601
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2602
- lineNumber: 40,
2603
- columnNumber: 3
2604
- }, this),
2605
- /* @__PURE__ */ jsxDEV8(Components.Button, { onClick: () => addProperty(), disabled, children: "+" }, void 0, false, {
2606
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2607
- lineNumber: 41,
2608
- columnNumber: 3
2609
- }, this)
2610
- ] }, void 0, true, {
2611
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2612
- lineNumber: 37,
2613
- columnNumber: 2
2614
- }, this);
2615
- var ObjectEditor = ({
2616
- schema,
2617
- path = [],
2618
- isReadonly = () => false,
2619
- isHidden = () => false,
2620
- data,
2621
- set,
2622
- Components
2623
- }) => {
2624
- var _a2;
2625
- const disabled = isReadonly(path);
2626
- const stableKeyMap = useRef3(
2627
- Object.keys(data).reduce((acc, key) => {
2628
- acc[key] = key;
2629
- return acc;
2630
- }, {})
2631
- );
2632
- const setProperty = makePropertySetters(data, set);
2633
- const renameProperty = makePropertyRenamers(data, set, stableKeyMap);
2634
- const removeProperty = makePropertyRemovers(data, set);
2635
- const recastProperty = makePropertyRecasters(data, set);
2636
- const sortProperties = makePropertySorter(data, set);
2637
- const makePropertyAdder = makePropertyCreationInterface(data, set);
2638
- const subSchema = isPlainObject(schema) ? findSubSchema(schema)(path) : true;
2639
- const schemaKeys = isLiteral(true)(subSchema) ? true : isObjectSchema(subSchema) ? Object.keys((_a2 = subSchema.properties) != null ? _a2 : {}) : [];
2640
- const dataKeys = Object.keys(data);
2641
- const [unofficialKeys, officialKeys] = dataKeys.reduce(
2642
- ([unofficial, official], key) => {
2643
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
2644
- return isOfficial ? [unofficial, [...official, key]] : [[...unofficial, key], official];
2645
- },
2646
- [[], []]
2647
- );
2648
- const missingKeys = schemaKeys === true ? [] : schemaKeys.filter((key) => !dataKeys.includes(key));
2649
- return /* @__PURE__ */ jsxDEV8(Fragment2, { children: [
2650
- /* @__PURE__ */ jsxDEV8(Components.Button, { onClick: () => sortProperties(), disabled, children: "Sort" }, void 0, false, {
2651
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2652
- lineNumber: 95,
2653
- columnNumber: 4
2654
- }, this),
2655
- /* @__PURE__ */ jsxDEV8(Components.ObjectWrapper, { children: [
2656
- /* @__PURE__ */ jsxDEV8("div", { className: "json_editor_properties", children: [...missingKeys, ...officialKeys, ...unofficialKeys].map((key) => {
2657
- const originalKey = stableKeyMap.current[key];
2658
- const newPath = [...path, key];
2659
- const originalPath = [...path, originalKey];
2660
- const isOfficial = schemaKeys === true || schemaKeys.includes(key);
2661
- const isMissing = missingKeys.includes(key);
2662
- return isMissing ? /* @__PURE__ */ jsxDEV8(
2663
- PropertyAdder,
2664
- {
2665
- propertyKey: key,
2666
- addProperty: makePropertyAdder(key, `string`),
2667
- disabled,
2668
- Components
2669
- },
2670
- key + `IsMissing`,
2671
- false,
2672
- {
2673
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2674
- lineNumber: 108,
2675
- columnNumber: 8
2676
- },
2677
- this
2678
- ) : /* @__PURE__ */ jsxDEV8(
2679
- JsonEditor_INTERNAL,
2680
- {
2681
- schema,
2682
- path: newPath,
2683
- name: key,
2684
- isReadonly,
2685
- isHidden,
2686
- data: data[key],
2687
- set: setProperty[key],
2688
- rename: renameProperty[key],
2689
- remove: removeProperty[key],
2690
- recast: recastProperty[key],
2691
- className: `json_editor_property ${isOfficial ? `json_editor_official` : `json_editor_unofficial`}`,
2692
- Components
2693
- },
2694
- originalPath.join(`.`),
2695
- false,
2696
- {
2697
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2698
- lineNumber: 116,
2699
- columnNumber: 8
2700
- },
2701
- this
2702
- );
2703
- }) }, void 0, false, {
2704
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2705
- lineNumber: 99,
2706
- columnNumber: 5
2707
- }, this),
2708
- /* @__PURE__ */ jsxDEV8(
2709
- Components.Button,
2710
- {
2711
- onClick: disabled ? doNothing : () => makePropertyAdder(`new_property`, `string`)(),
2712
- disabled,
2713
- children: "+"
2714
- },
2715
- void 0,
2716
- false,
2717
- {
2718
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2719
- lineNumber: 136,
2720
- columnNumber: 5
2721
- },
2722
- this
2723
- )
2724
- ] }, void 0, true, {
2725
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2726
- lineNumber: 98,
2727
- columnNumber: 4
2728
- }, this)
2729
- ] }, void 0, true, {
2730
- fileName: "../../hamr/src/react-json-editor/editors-by-type/object-editor.tsx",
2731
- lineNumber: 94,
2732
- columnNumber: 3
2733
- }, this);
2734
- };
2735
-
2736
- // ../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx
2737
- import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
2738
- var BooleanEditor = ({
2739
- data,
2740
- set,
2741
- Components
2742
- }) => /* @__PURE__ */ jsxDEV9(Components.BooleanWrapper, { children: /* @__PURE__ */ jsxDEV9(
2743
- "input",
2744
- {
2745
- type: "checkbox",
2746
- checked: data,
2747
- onChange: (event) => set(event.target.checked)
2748
- },
2749
- void 0,
2750
- false,
2751
- {
2752
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2753
- lineNumber: 12,
2754
- columnNumber: 3
2755
- },
2756
- this
2757
- ) }, void 0, false, {
2758
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2759
- lineNumber: 11,
2760
- columnNumber: 2
2761
- }, this);
2762
- var NullEditor = ({
2763
- Components
2764
- }) => /* @__PURE__ */ jsxDEV9(Components.NullWrapper, { children: '" "' }, void 0, false, {
2765
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2766
- lineNumber: 23,
2767
- columnNumber: 2
2768
- }, this);
2769
- var NumberEditor = ({
2770
- path = [],
2771
- isReadonly = () => false,
2772
- data,
2773
- set,
2774
- Components
2775
- }) => /* @__PURE__ */ jsxDEV9(Components.NumberWrapper, { children: /* @__PURE__ */ jsxDEV9(
2776
- NumberInput,
2777
- {
2778
- value: data,
2779
- set: isReadonly(path) ? void 0 : (newValue) => set(Number(newValue)),
2780
- autoSize: true
2781
- },
2782
- void 0,
2783
- false,
2784
- {
2785
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2786
- lineNumber: 34,
2787
- columnNumber: 3
2788
- },
2789
- this
2790
- ) }, void 0, false, {
2791
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2792
- lineNumber: 33,
2793
- columnNumber: 2
2794
- }, this);
2795
- var StringEditor = ({
2796
- path = [],
2797
- isReadonly = () => false,
2798
- data,
2799
- set,
2800
- Components
2801
- }) => {
2802
- return /* @__PURE__ */ jsxDEV9(Components.StringWrapper, { children: /* @__PURE__ */ jsxDEV9(
2803
- TextInput,
2804
- {
2805
- value: data,
2806
- set: isReadonly(path) ? void 0 : set,
2807
- autoSize: true
2808
- },
2809
- void 0,
2810
- false,
2811
- {
2812
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2813
- lineNumber: 51,
2814
- columnNumber: 4
2815
- },
2816
- this
2817
- ) }, void 0, false, {
2818
- fileName: "../../hamr/src/react-json-editor/editors-by-type/primitive-editors.tsx",
2819
- lineNumber: 50,
2820
- columnNumber: 3
2821
- }, this);
2822
- };
2823
-
2824
- // ../../hamr/src/react-error-boundary/ReactErrorBoundary.tsx
2825
- import { Component, useState as useState3 } from "react";
2826
-
2827
- // ../../hamr/src/react-error-boundary/DefaultFallback.tsx
2828
- import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
2829
- var DefaultFallback = ({ error, errorInfo }) => {
2830
- var _a2, _b;
2831
- const component = errorInfo == null ? void 0 : errorInfo.componentStack.split(` `).filter(Boolean)[2];
2832
- const message = (_b = (_a2 = error == null ? void 0 : error.toString()) != null ? _a2 : errorInfo == null ? void 0 : errorInfo.componentStack) != null ? _b : `Unknown error`;
2833
- return /* @__PURE__ */ jsxDEV10(
2834
- "div",
2835
- {
2836
- "data-testid": "error-boundary",
2837
- style: {
2838
- flex: `1`,
2839
- background: `black`,
2840
- backgroundImage: `url(./src/assets/kablooey.gif)`,
2841
- backgroundPosition: `center`,
2842
- // backgroundRepeat: `no-repeat`,
2843
- backgroundSize: `overlay`
2844
- },
2845
- children: /* @__PURE__ */ jsxDEV10(
2846
- "div",
2847
- {
2848
- style: {
2849
- margin: `50px`,
2850
- marginTop: `0`,
2851
- padding: `50px`,
2852
- border: `1px solid dashed`
2853
- },
2854
- children: /* @__PURE__ */ jsxDEV10(
2855
- "span",
2856
- {
2857
- style: {
2858
- background: `black`,
2859
- color: `white`,
2860
- padding: 10,
2861
- paddingTop: 5
2862
- },
2863
- children: [
2864
- `\u26A0\uFE0F `,
2865
- /* @__PURE__ */ jsxDEV10("span", { style: { color: `#fc0`, fontWeight: 700 }, children: component }, void 0, false, {
2866
- fileName: "../../hamr/src/react-error-boundary/DefaultFallback.tsx",
2867
- lineNumber: 42,
2868
- columnNumber: 6
2869
- }, this),
2870
- ` \u26A0\uFE0F `,
2871
- message
2872
- ]
2873
- },
2874
- void 0,
2875
- true,
2876
- {
2877
- fileName: "../../hamr/src/react-error-boundary/DefaultFallback.tsx",
2878
- lineNumber: 33,
2879
- columnNumber: 5
2880
- },
2881
- this
2882
- )
2883
- },
2884
- void 0,
2885
- false,
2886
- {
2887
- fileName: "../../hamr/src/react-error-boundary/DefaultFallback.tsx",
2888
- lineNumber: 25,
2889
- columnNumber: 4
2890
- },
2891
- this
2892
- )
2893
- },
2894
- void 0,
2895
- false,
2896
- {
2897
- fileName: "../../hamr/src/react-error-boundary/DefaultFallback.tsx",
2898
- lineNumber: 13,
2899
- columnNumber: 3
2900
- },
2901
- this
2902
- );
2903
- };
2904
-
2905
- // ../../hamr/src/react-error-boundary/ReactErrorBoundary.tsx
2906
- import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
2907
- var ErrorBoundary = class extends Component {
2908
- constructor(props) {
2909
- super(props);
2910
- this.state = {};
2911
- }
2912
- componentDidCatch(error, errorInfo) {
2913
- var _a2, _b;
2914
- (_b = (_a2 = this.props).onError) == null ? void 0 : _b.call(_a2, error, errorInfo);
2915
- this.setState({
2916
- error,
2917
- errorInfo
2918
- });
2919
- }
2920
- render() {
2921
- const { error, errorInfo } = this.state;
2922
- const { children, Fallback = DefaultFallback } = this.props;
2923
- return errorInfo ? /* @__PURE__ */ jsxDEV11(Fallback, { error, errorInfo }, void 0, false, {
2924
- fileName: "../../hamr/src/react-error-boundary/ReactErrorBoundary.tsx",
2925
- lineNumber: 51,
2926
- columnNumber: 4
2927
- }, this) : children;
2928
- }
2929
- };
2930
-
2931
- // ../../hamr/src/react-json-editor/default-components.tsx
2932
- import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
2933
- var DEFAULT_JSON_EDITOR_COMPONENTS = {
2934
- ErrorBoundary: ({ children }) => /* @__PURE__ */ jsxDEV12(ErrorBoundary, { children }, void 0, false, {
2935
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2936
- lineNumber: 49,
2937
- columnNumber: 35
2938
- }, this),
2939
- Button: ({ onClick, children, disabled }) => /* @__PURE__ */ jsxDEV12(
2940
- "button",
2941
- {
2942
- type: "button",
2943
- className: "json_editor_button",
2944
- onClick,
2945
- disabled,
2946
- children
2947
- },
2948
- void 0,
2949
- false,
2950
- {
2951
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2952
- lineNumber: 51,
2953
- columnNumber: 3
2954
- },
2955
- this
2956
- ),
2957
- EditorWrapper: ({ children, customCss, className }) => /* @__PURE__ */ jsxDEV12("div", { className: `json_editor ` + className, css: customCss, children }, void 0, false, {
2958
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2959
- lineNumber: 61,
2960
- columnNumber: 3
2961
- }, this),
2962
- EditorLayout: ({
2963
- DeleteButton,
2964
- Header,
2965
- KeyInput,
2966
- TypeSelect,
2967
- ValueEditor,
2968
- Wrapper
2969
- }) => {
2970
- return /* @__PURE__ */ jsxDEV12(Wrapper, { children: [
2971
- DeleteButton && /* @__PURE__ */ jsxDEV12(DeleteButton, {}, void 0, false, {
2972
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2973
- lineNumber: 75,
2974
- columnNumber: 22
2975
- }, this),
2976
- Header && /* @__PURE__ */ jsxDEV12(Header, {}, void 0, false, {
2977
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2978
- lineNumber: 76,
2979
- columnNumber: 16
2980
- }, this),
2981
- KeyInput && /* @__PURE__ */ jsxDEV12(KeyInput, {}, void 0, false, {
2982
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2983
- lineNumber: 77,
2984
- columnNumber: 18
2985
- }, this),
2986
- TypeSelect && /* @__PURE__ */ jsxDEV12(TypeSelect, {}, void 0, false, {
2987
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2988
- lineNumber: 78,
2989
- columnNumber: 20
2990
- }, this),
2991
- /* @__PURE__ */ jsxDEV12(ValueEditor, {}, void 0, false, {
2992
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2993
- lineNumber: 79,
2994
- columnNumber: 5
2995
- }, this)
2996
- ] }, void 0, true, {
2997
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
2998
- lineNumber: 74,
2999
- columnNumber: 4
3000
- }, this);
3001
- },
3002
- ArrayWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("div", { className: "json_editor_array", children }, void 0, false, {
3003
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3004
- lineNumber: 84,
3005
- columnNumber: 3
3006
- }, this),
3007
- ObjectWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("div", { className: "json_editor_object", children }, void 0, false, {
3008
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3009
- lineNumber: 87,
3010
- columnNumber: 3
3011
- }, this),
3012
- StringWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_string", children }, void 0, false, {
3013
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3014
- lineNumber: 90,
3015
- columnNumber: 3
3016
- }, this),
3017
- NumberWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_number", children }, void 0, false, {
3018
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3019
- lineNumber: 93,
3020
- columnNumber: 3
3021
- }, this),
3022
- BooleanWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_boolean", children }, void 0, false, {
3023
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3024
- lineNumber: 96,
3025
- columnNumber: 3
3026
- }, this),
3027
- NullWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_null", children }, void 0, false, {
3028
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3029
- lineNumber: 99,
3030
- columnNumber: 3
3031
- }, this),
3032
- MissingPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("div", { className: "json_editor_property json_editor_missing", children }, void 0, false, {
3033
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3034
- lineNumber: 102,
3035
- columnNumber: 3
3036
- }, this),
3037
- MiscastPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("div", { className: "json_editor_property json_editor_miscast", children }, void 0, false, {
3038
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3039
- lineNumber: 105,
3040
- columnNumber: 3
3041
- }, this),
3042
- IllegalPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_property json_editor_illegal", children }, void 0, false, {
3043
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3044
- lineNumber: 108,
3045
- columnNumber: 3
3046
- }, this),
3047
- OfficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_property json_editor_official", children }, void 0, false, {
3048
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3049
- lineNumber: 111,
3050
- columnNumber: 3
3051
- }, this),
3052
- UnofficialPropertyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_property json_editor_unofficial", children }, void 0, false, {
3053
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3054
- lineNumber: 114,
3055
- columnNumber: 3
3056
- }, this),
3057
- DeleteIcon: () => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_icon json_editor_delete", children: "x" }, void 0, false, {
3058
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3059
- lineNumber: 119,
3060
- columnNumber: 3
3061
- }, this),
3062
- KeyWrapper: ({ children }) => /* @__PURE__ */ jsxDEV12("span", { className: "json_editor_key", children }, void 0, false, {
3063
- fileName: "../../hamr/src/react-json-editor/default-components.tsx",
3064
- lineNumber: 122,
3065
- columnNumber: 3
3066
- }, this)
3067
- };
3068
-
3069
- // ../../hamr/src/react-json-editor/developer-interface.tsx
3070
- import Ajv from "ajv";
3071
- import { useMemo } from "react";
3072
- import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
3073
- var JsonEditor = ({
3074
- data,
3075
- set,
3076
- schema = true,
3077
- name,
3078
- rename,
3079
- remove,
3080
- isReadonly = () => false,
3081
- isHidden = () => false,
3082
- // isIllegal = () => false,
3083
- className,
3084
- customCss,
3085
- Header,
3086
- Components: CustomComponents = {}
3087
- }) => {
3088
- const Components = __spreadValues(__spreadValues({}, DEFAULT_JSON_EDITOR_COMPONENTS), CustomComponents);
3089
- const ajv = new Ajv({ allErrors: true, verbose: true });
3090
- const validate = useMemo(() => {
3091
- return ajv.compile(schema);
3092
- }, [schema]);
3093
- const validationResults = validate(data);
3094
- return /* @__PURE__ */ jsxDEV13(
3095
- JsonEditor_INTERNAL,
3096
- {
3097
- data,
3098
- set,
3099
- name,
3100
- schema,
3101
- rename,
3102
- remove,
3103
- path: [],
3104
- isReadonly,
3105
- isHidden,
3106
- className,
3107
- customCss,
3108
- Header,
3109
- Components
3110
- },
3111
- void 0,
3112
- false,
3113
- {
3114
- fileName: "../../hamr/src/react-json-editor/developer-interface.tsx",
3115
- lineNumber: 77,
3116
- columnNumber: 3
3117
- },
3118
- this
3119
- );
3120
- };
3121
-
3122
- // ../../hamr/src/react-json-editor/index.ts
3123
- var SubEditors = {
3124
- array: ArrayEditor,
3125
- boolean: BooleanEditor,
3126
- null: NullEditor,
3127
- number: NumberEditor,
3128
- object: ObjectEditor,
3129
- string: StringEditor
3130
- };
3131
-
3132
- // ../../hamr/src/react-data-designer/RelationEditor.module.scss
3133
- var RelationEditor_module_default = {};
3134
-
3135
- // ../../hamr/src/react-id/Id.tsx
3136
- import {
3137
- FloatingPortal,
3138
- useClick,
3139
- useFloating,
3140
- useInteractions
3141
- } from "@floating-ui/react";
3142
- import { pipe as pipe12 } from "fp-ts/function";
3143
- import * as React from "react";
3144
-
3145
- // ../../anvl/src/string/string-to-color.ts
3146
- function stringToColor(input) {
3147
- let hash = 0;
3148
- for (let i = 0; i < input.length; i++) {
3149
- const char = input.charCodeAt(i);
3150
- hash = (hash << 5) - hash + char;
3151
- hash |= 0;
3152
- }
3153
- let hexColor = (hash & 16777215).toString(16);
3154
- while (hexColor.length < 6) {
3155
- hexColor = `0` + hexColor;
3156
- }
3157
- return `#${hexColor}`;
3158
- }
3159
-
3160
- // ../../luum/src/constants/index.ts
3161
- var CHANNEL_SPECIFIC_LUM = {
3162
- R: 0.3,
3163
- G: 0.5,
3164
- B: 0.2
3165
- };
3166
-
3167
- // ../../luum/src/constants/filters.ts
3168
- var unfiltered = [
3169
- { sat: 255, hue: 0 },
3170
- { sat: 255, hue: 360 }
3171
- ];
3172
-
3173
- // ../../luum/src/export/channelsToHex.ts
3174
- var channelsToHex = (channels) => `#${Object.values(channels).map((channel) => {
3175
- let channelHex = channel.toString(16);
3176
- if (channelHex.length === 1)
3177
- channelHex = 0 + channelHex;
3178
- return channelHex;
3179
- }).join(``)}`;
3180
- var channelsToHex_default = channelsToHex;
3181
-
3182
- // ../../luum/src/import/hueToRelativeChannels.ts
3183
- var hueToRelativeChannels_default = (hue) => {
3184
- const hueWrapped = wrapInto(0, 360)(hue);
3185
- const hueReduced = hueWrapped / 60;
3186
- const hueInteger = Math.floor(hueReduced);
3187
- const hueDecimal = hueReduced - hueInteger;
3188
- const x = hueDecimal;
3189
- const y = 1 - hueDecimal;
3190
- switch (hueInteger) {
3191
- case 0:
3192
- return [1, x, 0];
3193
- case 1:
3194
- return [y, 1, 0];
3195
- case 2:
3196
- return [0, 1, x];
3197
- case 3:
3198
- return [0, y, 1];
3199
- case 4:
3200
- return [x, 0, 1];
3201
- case 5:
3202
- return [1, 0, y];
3203
- default:
3204
- throw new Error(`invalid hue served: ${hue}`);
3205
- }
3206
- };
3207
-
3208
- // ../../luum/src/solveFor/hueFromChannels.ts
3209
- var hueFromChannels = ({ R, G, B }) => {
3210
- let hue = 0;
3211
- if (R > G && G >= B)
3212
- hue = 60 * (0 + (G - B) / (R - B));
3213
- if (G >= R && R > B)
3214
- hue = 60 * (2 - (R - B) / (G - B));
3215
- if (G > B && B >= R)
3216
- hue = 60 * (2 + (B - R) / (G - R));
3217
- if (B >= G && G > R)
3218
- hue = 60 * (4 - (G - R) / (B - R));
3219
- if (B > R && R >= G)
3220
- hue = 60 * (4 + (R - G) / (B - G));
3221
- if (R >= B && B > G)
3222
- hue = 60 * (6 - (B - G) / (R - G));
3223
- return hue;
3224
- };
3225
- var hueFromChannels_default = hueFromChannels;
3226
-
3227
- // ../../luum/src/solveFor/lumFromChannels.ts
3228
- var lumFromChannels = ({ R, G, B }) => {
3229
- const lum = CHANNEL_SPECIFIC_LUM.R * R / 255 + CHANNEL_SPECIFIC_LUM.G * G / 255 + CHANNEL_SPECIFIC_LUM.B * B / 255;
3230
- return lum;
3231
- };
3232
- var lumFromChannels_default = lumFromChannels;
3233
-
3234
- // ../../luum/src/solveFor/maxSatForHueInFilter.ts
3235
- var maxSatForHueInFilter_default = (hue, filter) => {
3236
- let maxSat = 255;
3237
- const hueWrapped = wrapInto(0, 360)(hue);
3238
- for (let a2 = -1, b2 = 0; b2 < filter.length; a2++, b2++) {
3239
- a2 = wrapInto(0, filter.length)(a2);
3240
- const hueDoubleWrapped = a2 > b2 ? wrapInto(-180, 180)(hueWrapped) : void 0;
3241
- const tuningPointA = filter[a2];
3242
- const tuningPointB = filter[b2];
3243
- const hueA = a2 > b2 ? wrapInto(-180, 180)(tuningPointA.hue) : tuningPointA.hue;
3244
- const hueB = tuningPointB.hue;
3245
- if ((hueDoubleWrapped || hueWrapped) >= hueA && (hueDoubleWrapped || hueWrapped) < hueB) {
3246
- let $ = hueDoubleWrapped || hueWrapped;
3247
- $ -= hueA;
3248
- $ /= hueB - hueA;
3249
- $ *= tuningPointB.sat - tuningPointA.sat;
3250
- $ += tuningPointA.sat;
3251
- Math.round($);
3252
- maxSat = $;
3253
- }
3254
- }
3255
- return maxSat;
3256
- };
3257
-
3258
- // ../../luum/src/solveFor/satFromChannels.ts
3259
- var satFromChannels = ({ R, G, B }) => {
3260
- const sat = Math.max(R, G, B) - Math.min(R, G, B);
3261
- return sat;
3262
- };
3263
- var satFromChannels_default = satFromChannels;
3264
-
3265
- // ../../luum/src/solveFor/specificLumFromHue.ts
3266
- var specificLumFromHue_default = (hue) => {
3267
- const [factorR, factorG, factorB] = hueToRelativeChannels_default(hue);
3268
- const lumR = CHANNEL_SPECIFIC_LUM.R * factorR;
3269
- const lumG = CHANNEL_SPECIFIC_LUM.G * factorG;
3270
- const lumB = CHANNEL_SPECIFIC_LUM.B * factorB;
3271
- const specificLum = lumR + lumG + lumB;
3272
- return specificLum;
3273
- };
3274
-
3275
- // ../../luum/src/export/specToChannelsFixLimit.ts
3276
- var minChannelsForSaturationFromHue = (hue) => {
3277
- const relativeChannels = hueToRelativeChannels_default(hue);
3278
- const channelSpreader = (trueSaturation) => {
3279
- const makeMinChannel = (idx) => Math.round(relativeChannels[idx] * trueSaturation);
3280
- return {
3281
- R: makeMinChannel(0),
3282
- G: makeMinChannel(1),
3283
- B: makeMinChannel(2)
3284
- };
3285
- };
3286
- return channelSpreader;
3287
- };
3288
- var channelsFromIlluminationObj = ({
3289
- minChannels,
3290
- trueLuminosity,
3291
- minLum
3292
- }) => {
3293
- const { max, round: round2 } = Math;
3294
- const maxWhite = 255 - max(...Object.values(minChannels));
3295
- const white = clampInto(0, maxWhite)(round2((trueLuminosity - minLum) * 255));
3296
- const channels = {
3297
- R: minChannels.R + white,
3298
- G: minChannels.G + white,
3299
- B: minChannels.B + white
3300
- };
3301
- return channels;
3302
- };
3303
- var specToChannelsFixLimit = ({ hue, sat, lum, prefer = `lum` }, filter = unfiltered) => {
3304
- const minChannelsForSaturation = minChannelsForSaturationFromHue(hue);
3305
- let trueSaturation;
3306
- let trueLuminosity;
3307
- let minChannels;
3308
- let maxChannels;
3309
- let specificLum;
3310
- let minLum = 0;
3311
- let maxLum = 1;
3312
- let maxSat = maxSatForHueInFilter_default(hue, filter);
3313
- switch (prefer) {
3314
- case `sat`:
3315
- trueSaturation = clampInto(0, 255)(Math.min(sat, maxSat));
3316
- minChannels = minChannelsForSaturation(trueSaturation);
3317
- maxChannels = {
3318
- R: minChannels.R + 255 - trueSaturation,
3319
- G: minChannels.G + 255 - trueSaturation,
3320
- B: minChannels.B + 255 - trueSaturation
3321
- };
3322
- minLum = lumFromChannels_default(minChannels);
3323
- maxLum = lumFromChannels_default(maxChannels);
3324
- trueLuminosity = clampInto(minLum, maxLum)(lum);
3325
- break;
3326
- case `lum`:
3327
- trueLuminosity = clampInto(0, 1)(lum);
3328
- specificLum = specificLumFromHue_default(hue);
3329
- maxSat = Math.min(
3330
- maxSat,
3331
- Math.round(
3332
- trueLuminosity <= specificLum ? 255 * (trueLuminosity / specificLum) : 255 * (1 - trueLuminosity) / (1 - specificLum)
3333
- )
3334
- );
3335
- trueSaturation = Math.min(sat, maxSat);
3336
- minChannels = minChannelsForSaturation(trueSaturation);
3337
- minLum = lumFromChannels_default(minChannels);
3338
- break;
3339
- }
3340
- const channels = channelsFromIlluminationObj({
3341
- minChannels,
3342
- trueLuminosity,
3343
- minLum
3344
- });
3345
- return {
3346
- channels,
3347
- fix: {
3348
- sat: trueSaturation,
3349
- lum: trueLuminosity
3350
- },
3351
- limit: {
3352
- sat: [0, maxSat],
3353
- lum: [prefer === `lum` ? 0 : minLum, maxLum]
3354
- }
3355
- };
3356
- };
3357
- var specToChannelsFixLimit_default = specToChannelsFixLimit;
3358
-
3359
- // ../../luum/src/export/specToHexFixLimit.ts
3360
- var specToHexFixLimit = ({ hue, sat, lum, prefer }, filter) => {
3361
- const { channels, fix, limit } = specToChannelsFixLimit_default(
3362
- {
3363
- hue,
3364
- sat,
3365
- lum,
3366
- prefer
3367
- },
3368
- filter
3369
- );
3370
- const { R, G, B } = channels;
3371
- const hex = channelsToHex_default({ R, G, B });
3372
- return { hex, fix, limit };
3373
- };
3374
- var specToHexFixLimit_default = specToHexFixLimit;
3375
-
3376
- // ../../luum/src/export/specToHex.ts
3377
- var specToHex = ({ hue, sat, lum, prefer }, filter) => {
3378
- const { hex } = specToHexFixLimit_default({ hue, sat, lum, prefer }, filter);
3379
- return hex;
3380
- };
3381
- var specToHex_default = specToHex;
3382
-
3383
- // ../../luum/src/import/channelsToSpec.ts
3384
- var channelsToSpec = ({ R, G, B }) => {
3385
- const hue = hueFromChannels_default({ R, G, B });
3386
- const sat = satFromChannels_default({ R, G, B });
3387
- const lum = lumFromChannels_default({ R, G, B });
3388
- return { hue, sat, lum };
3389
- };
3390
- var channelsToSpec_default = channelsToSpec;
3391
-
3392
- // ../../luum/src/import/normalizeHex.ts
3393
- var BASE_16_CHAR_SET = `[a-fA-F0-9]+`;
3394
- var miniHexToHex = (miniHex) => {
3395
- const miniHexArray = miniHex.split(``);
3396
- const hexTemplate = [0, 0, 1, 1, 2, 2];
3397
- return hexTemplate.map((idx) => miniHexArray[idx]).join(``);
3398
- };
3399
- var normalizeHex = (maybeHex) => {
3400
- const hex = maybeHex.replace(/^#/, ``);
3401
- const hexIsCorrectLength = hex.length === 6 || hex.length === 3;
3402
- const hexIsCorrectCharSet = hex.match(new RegExp(`^${BASE_16_CHAR_SET}$`)) !== null;
3403
- const hexIsValid = hexIsCorrectLength && hexIsCorrectCharSet;
3404
- if (!hexIsValid) {
3405
- throw new Error(`${maybeHex} is not a valid hex code`);
3406
- }
3407
- if (hex.length === 3) {
3408
- return miniHexToHex(hex);
3409
- }
3410
- return hex;
3411
- };
3412
- var normalizeHex_default = normalizeHex;
3413
-
3414
- // ../../luum/src/import/hexToChannels.ts
3415
- var hexToChannels_default = (maybeHex) => {
3416
- const hex = normalizeHex_default(maybeHex);
3417
- return {
3418
- R: parseInt(hex.slice(0, 2), 16),
3419
- G: parseInt(hex.slice(2, 4), 16),
3420
- B: parseInt(hex.slice(4, 6), 16)
3421
- };
3422
- };
3423
-
3424
- // ../../luum/src/import/hexToSpec.ts
3425
- var hexToSpec = (hex) => {
3426
- const { R, G, B } = hexToChannels_default(hex);
3427
- const { hue, sat, lum } = channelsToSpec_default({ R, G, B });
3428
- return { hue, sat, lum };
3429
- };
3430
- var hexToSpec_default = hexToSpec;
3431
-
3432
- // ../../luum/src/mixers/lum.ts
3433
- import { pipe as pipe8 } from "fp-ts/function";
3434
- var resetColor = (color) => pipe8(color, specToHex_default, hexToSpec_default, (hsl) => __spreadProps(__spreadValues({}, hsl), {
3435
- prefer: color.prefer
3436
- }));
3437
- var setLum = (newLum) => (currentColor) => {
3438
- const newColor = __spreadProps(__spreadValues({}, currentColor), {
3439
- lum: pipe8(currentColor.lum, become(newLum), clampInto(0, 1))
3440
- });
3441
- return newColor;
3442
- };
3443
- var shadeBy = (shadeAmount) => (color) => setLum((lum) => (lum * 100 - shadeAmount) / 100)(resetColor(color));
3444
-
3445
- // ../../luum/src/mixers/sat.ts
3446
- import { pipe as pipe9 } from "fp-ts/function";
3447
-
3448
- // ../../luum/src/mixers/hue.ts
3449
- import { pipe as pipe10 } from "fp-ts/function";
3450
-
3451
- // ../../luum/src/mixers/contrast.ts
3452
- var contrastMax = (color) => __spreadProps(__spreadValues({}, color), {
3453
- lum: color.lum > 0.666 ? 0 : 1
3454
- });
3455
- var offset = (offsetAmount) => (color) => __spreadProps(__spreadValues({}, color), {
3456
- lum: color.lum > 0.666 ? color.lum - offsetAmount : color.lum + offsetAmount
3457
- });
3458
-
3459
- // ../../luum/src/scheme/index.ts
3460
- import { pipe as pipe11 } from "fp-ts/function";
3461
- import { isString as isString7 } from "fp-ts/string";
3462
-
3463
- // ../../luum/src/constants/luum-spec.ts
3464
- var defaultSpec = {
3465
- hue: 0,
3466
- lum: 0,
3467
- sat: 0,
3468
- prefer: `lum`
3469
- };
3470
-
3471
- // ../../luum/src/scheme/index.ts
3472
- var isLuumSpec = (input) => typeof input === `object` && input !== null && typeof input.hue === `number` && typeof input.sat === `number` && typeof input.lum === `number` && [`sat`, `lum`].includes(input.prefer);
3473
- var isLuumSpecModifier = isModifier(isLuumSpec)(defaultSpec);
3474
- var RED = {
3475
- hue: 0,
3476
- sat: 255,
3477
- lum: 0.5,
3478
- prefer: `sat`
3479
- };
3480
- var WAYFORGE_CORE_COLOR_NAMES = [
3481
- `Red`,
3482
- `Orange`,
3483
- `Yellow`,
3484
- `Lime`,
3485
- `Green`,
3486
- `Teal`,
3487
- `Cyan`,
3488
- `Blue`,
3489
- `Indigo`,
3490
- `Violet`,
3491
- `Magenta`,
3492
- `Pink`
3493
- ];
3494
- var WAYFORGE_CORE_COLORS = WAYFORGE_CORE_COLOR_NAMES.reduce((acc, name, idx) => {
3495
- acc[name] = {
3496
- hue: idx * 30,
3497
- sat: 255,
3498
- lum: 0.5,
3499
- prefer: `sat`
3500
- };
3501
- return acc;
3502
- }, {});
3503
- var PAINT_MY_WAGON_RED = {
3504
- rootSelectors: [`.wagon`],
3505
- root: RED,
3506
- attributes: [`background-color`, shadeBy(5)],
3507
- states: [
3508
- [
3509
- [`:hover`, `:focus`],
3510
- [`background-color`, shadeBy(10)]
3511
- ],
3512
- [`:active`, [`background-color`, shadeBy(15)]]
3513
- ]
3514
- };
3515
-
3516
- // ../../hamr/src/react-id/Id.tsx
3517
- import { Fragment as Fragment3, jsxDEV as jsxDEV14 } from "react/jsx-dev-runtime";
3518
- var Id = ({ id }) => {
3519
- const [isOpen, setIsOpen] = React.useState(false);
3520
- const { refs, floatingStyles, context } = useFloating({
3521
- open: isOpen,
3522
- onOpenChange: setIsOpen,
3523
- placement: `bottom-start`
3524
- });
3525
- const click = useClick(context);
3526
- const { getReferenceProps, getFloatingProps } = useInteractions([click]);
3527
- const bgColor = stringToColor(id);
3528
- const contrastColor = pipe12(bgColor, hexToSpec_default, contrastMax, specToHex_default);
3529
- const offsetColor = pipe12(bgColor, hexToSpec_default, offset(0.25), specToHex_default);
3530
- const contrastOffsetColor = pipe12(
3531
- offsetColor,
3532
- hexToSpec_default,
3533
- contrastMax,
3534
- specToHex_default
3535
- );
3536
- return /* @__PURE__ */ jsxDEV14(Fragment3, { children: [
3537
- /* @__PURE__ */ jsxDEV14(
3538
- "span",
3539
- __spreadProps(__spreadValues({
3540
- role: "content",
3541
- ref: refs.setReference
3542
- }, getReferenceProps()), {
3543
- style: {
3544
- background: bgColor,
3545
- cursor: `pointer`,
3546
- padding: `0px 4px`,
3547
- color: contrastColor,
3548
- userSelect: `none`,
3549
- whiteSpace: `nowrap`
3550
- },
3551
- children: id.substring(0, 3)
3552
- }),
3553
- void 0,
3554
- false,
3555
- {
3556
- fileName: "../../hamr/src/react-id/Id.tsx",
3557
- lineNumber: 36,
3558
- columnNumber: 4
3559
- },
3560
- this
3561
- ),
3562
- isOpen && /* @__PURE__ */ jsxDEV14(FloatingPortal, { children: /* @__PURE__ */ jsxDEV14(
3563
- "span",
3564
- __spreadProps(__spreadValues({
3565
- role: "popup",
3566
- ref: refs.setFloating
3567
- }, getFloatingProps()), {
3568
- style: __spreadProps(__spreadValues({}, floatingStyles), {
3569
- color: contrastOffsetColor,
3570
- background: offsetColor,
3571
- padding: `0px 4px`,
3572
- boxShadow: `0px 2px 10px rgba(0, 0, 0, 0.1)`
3573
- }),
3574
- children: id
3575
- }),
3576
- void 0,
3577
- false,
3578
- {
3579
- fileName: "../../hamr/src/react-id/Id.tsx",
3580
- lineNumber: 53,
3581
- columnNumber: 6
3582
- },
3583
- this
3584
- ) }, void 0, false, {
3585
- fileName: "../../hamr/src/react-id/Id.tsx",
3586
- lineNumber: 52,
3587
- columnNumber: 5
3588
- }, this)
3589
- ] }, void 0, true, {
3590
- fileName: "../../hamr/src/react-id/Id.tsx",
3591
- lineNumber: 35,
3592
- columnNumber: 3
3593
- }, this);
3594
- };
3595
-
3596
- // ../../hamr/src/react-data-designer/RelationEditor.tsx
3597
- import { jsxDEV as jsxDEV15 } from "react/jsx-dev-runtime";
3598
- var RelationEditor = (props) => {
3599
- const seen = /* @__PURE__ */ new Set();
3600
- const data = Object.entries(props.data.relations).sort(([_, a2], [__, b2]) => b2.length - a2.length).filter(([head, tail]) => {
3601
- if (seen.has(head))
3602
- return false;
3603
- seen.add(head);
3604
- for (const tailElement of tail) {
3605
- seen.add(tailElement);
3606
- }
3607
- return true;
3608
- });
3609
- return /* @__PURE__ */ jsxDEV15("article", { className: RelationEditor_module_default.class, children: data.map(([head, tail]) => /* @__PURE__ */ jsxDEV15("section", { children: [
3610
- /* @__PURE__ */ jsxDEV15("span", { children: /* @__PURE__ */ jsxDEV15(Id, { id: head }, void 0, false, {
3611
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3612
- lineNumber: 26,
3613
- columnNumber: 7
3614
- }, this) }, void 0, false, {
3615
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3616
- lineNumber: 25,
3617
- columnNumber: 6
3618
- }, this),
3619
- ":",
3620
- /* @__PURE__ */ jsxDEV15("span", { children: tail.map((child) => /* @__PURE__ */ jsxDEV15(Id, { id: child }, void 0, false, {
3621
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3622
- lineNumber: 31,
3623
- columnNumber: 8
3624
- }, this)) }, void 0, false, {
3625
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3626
- lineNumber: 29,
3627
- columnNumber: 6
3628
- }, this)
3629
- ] }, void 0, true, {
3630
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3631
- lineNumber: 24,
3632
- columnNumber: 5
3633
- }, this)) }, void 0, false, {
3634
- fileName: "../../hamr/src/react-data-designer/RelationEditor.tsx",
3635
- lineNumber: 21,
3636
- columnNumber: 3
3637
- }, this);
3638
- };
3639
-
3640
- // ../src/react-devtools/StateEditor.tsx
3641
- import { jsxDEV as jsxDEV16 } from "react/jsx-dev-runtime";
3642
- var StateEditor = ({ token }) => {
3643
- const [data, set] = useIO(token);
3644
- return isJson(data) ? /* @__PURE__ */ jsxDEV16(JsonEditor, { data, set, schema: true }, void 0, false, {
3645
- fileName: "../src/react-devtools/StateEditor.tsx",
3646
- lineNumber: 17,
3647
- columnNumber: 3
3648
- }, this) : data instanceof Join ? /* @__PURE__ */ jsxDEV16(RelationEditor, { data, set }, void 0, false, {
3649
- fileName: "../src/react-devtools/StateEditor.tsx",
3650
- lineNumber: 19,
3651
- columnNumber: 3
3652
- }, this) : /* @__PURE__ */ jsxDEV16("div", { className: "json_editor", children: /* @__PURE__ */ jsxDEV16(
3653
- ElasticInput,
3654
- {
3655
- value: data instanceof Set ? `Set { ${JSON.stringify([...data]).slice(1, -1)} }` : data instanceof Map ? `Map ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + fallback(() => JSON.stringify(data), `?`),
3656
- disabled: true
3657
- },
3658
- void 0,
3659
- false,
3660
- {
3661
- fileName: "../src/react-devtools/StateEditor.tsx",
3662
- lineNumber: 22,
3663
- columnNumber: 4
3664
- },
3665
- this
3666
- ) }, void 0, false, {
3667
- fileName: "../src/react-devtools/StateEditor.tsx",
3668
- lineNumber: 21,
3669
- columnNumber: 3
3670
- }, this);
3671
- };
3672
- var ReadonlySelectorViewer = ({ token }) => {
3673
- const data = useO(token);
3674
- return isJson(data) ? /* @__PURE__ */ jsxDEV16(
3675
- JsonEditor,
3676
- {
3677
- data,
3678
- set: () => null,
3679
- schema: true,
3680
- isReadonly: () => true
3681
- },
3682
- void 0,
3683
- false,
3684
- {
3685
- fileName: "../src/react-devtools/StateEditor.tsx",
3686
- lineNumber: 43,
3687
- columnNumber: 3
3688
- },
3689
- this
3690
- ) : /* @__PURE__ */ jsxDEV16("div", { className: "json_editor", children: /* @__PURE__ */ jsxDEV16(
3691
- ElasticInput,
3692
- {
3693
- value: data instanceof Set ? `Set ` + JSON.stringify([...data]) : data instanceof Map ? `Map ` + JSON.stringify([...data]) : Object.getPrototypeOf(data).constructor.name + ` ` + JSON.stringify(data),
3694
- disabled: true
3695
- },
3696
- void 0,
3697
- false,
3698
- {
3699
- fileName: "../src/react-devtools/StateEditor.tsx",
3700
- lineNumber: 51,
3701
- columnNumber: 4
3702
- },
3703
- this
3704
- ) }, void 0, false, {
3705
- fileName: "../src/react-devtools/StateEditor.tsx",
3706
- lineNumber: 50,
3707
- columnNumber: 3
3708
- }, this);
3709
- };
3710
- var StoreEditor = ({ token }) => {
3711
- if (token.type === `readonly_selector`) {
3712
- return /* @__PURE__ */ jsxDEV16(ReadonlySelectorViewer, { token }, void 0, false, {
3713
- fileName: "../src/react-devtools/StateEditor.tsx",
3714
- lineNumber: 71,
3715
- columnNumber: 10
3716
- }, this);
3717
- }
3718
- return /* @__PURE__ */ jsxDEV16(StateEditor, { token }, void 0, false, {
3719
- fileName: "../src/react-devtools/StateEditor.tsx",
3720
- lineNumber: 73,
3721
- columnNumber: 9
3722
- }, this);
3723
- };
3724
-
3725
- // ../src/react-devtools/StateIndex.tsx
3726
- import { Fragment as Fragment4, jsxDEV as jsxDEV17 } from "react/jsx-dev-runtime";
3727
- var findStateTypeState = selectorFamily({
3728
- key: `\u{1F441}\u200D\u{1F5E8} State Type`,
3729
- get: (token) => ({ get }) => {
3730
- let state;
3731
- try {
3732
- state = get(token);
3733
- } catch (error) {
3734
- return `error`;
3735
- }
3736
- if (state === void 0)
3737
- return `undefined`;
3738
- if (isJson(state))
3739
- return refineJsonType(state).type;
3740
- return Object.getPrototypeOf(state).constructor.name;
3741
- }
3742
- });
3743
- var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
3744
- var _a2, _b;
3745
- const [isOpen, setIsOpen] = useIO2(isOpenState);
3746
- const state = useO2(node);
3747
- const stateType = useO2(typeState);
3748
- const isPrimitive = Boolean(primitiveRefinery.refine(state));
3749
- return /* @__PURE__ */ jsxDEV17(Fragment4, { children: [
3750
- /* @__PURE__ */ jsxDEV17("header", { children: [
3751
- /* @__PURE__ */ jsxDEV17(
3752
- button.OpenClose,
3753
- {
3754
- isOpen: isOpen && !isPrimitive,
3755
- setIsOpen,
3756
- disabled: isPrimitive
3757
- },
3758
- void 0,
3759
- false,
3760
- {
3761
- fileName: "../src/react-devtools/StateIndex.tsx",
3762
- lineNumber: 48,
3763
- columnNumber: 5
3764
- },
3765
- this
3766
- ),
3767
- /* @__PURE__ */ jsxDEV17(
3768
- "label",
3769
- {
3770
- onClick: () => console.log(node, getState(node)),
3771
- onKeyUp: () => console.log(node, getState(node)),
3772
- children: [
3773
- /* @__PURE__ */ jsxDEV17("h2", { children: (_b = (_a2 = node.family) == null ? void 0 : _a2.subKey) != null ? _b : node.key }, void 0, false, {
3774
- fileName: "../src/react-devtools/StateIndex.tsx",
3775
- lineNumber: 57,
3776
- columnNumber: 6
3777
- }, this),
3778
- /* @__PURE__ */ jsxDEV17("span", { className: "type detail", children: [
3779
- "(",
3780
- stateType,
3781
- ")"
3782
- ] }, void 0, true, {
3783
- fileName: "../src/react-devtools/StateIndex.tsx",
3784
- lineNumber: 58,
3785
- columnNumber: 6
3786
- }, this)
3787
- ]
3788
- },
3789
- void 0,
3790
- true,
3791
- {
3792
- fileName: "../src/react-devtools/StateIndex.tsx",
3793
- lineNumber: 53,
3794
- columnNumber: 5
3795
- },
3796
- this
3797
- ),
3798
- isPrimitive ? /* @__PURE__ */ jsxDEV17(StoreEditor, { token: node }, void 0, false, {
3799
- fileName: "../src/react-devtools/StateIndex.tsx",
3800
- lineNumber: 60,
3801
- columnNumber: 20
3802
- }, this) : null
3803
- ] }, void 0, true, {
3804
- fileName: "../src/react-devtools/StateIndex.tsx",
3805
- lineNumber: 47,
3806
- columnNumber: 4
3807
- }, this),
3808
- isOpen && !isPrimitive ? /* @__PURE__ */ jsxDEV17("main", { children: /* @__PURE__ */ jsxDEV17(StoreEditor, { token: node }, void 0, false, {
3809
- fileName: "../src/react-devtools/StateIndex.tsx",
3810
- lineNumber: 64,
3811
- columnNumber: 6
3812
- }, this) }, void 0, false, {
3813
- fileName: "../src/react-devtools/StateIndex.tsx",
3814
- lineNumber: 63,
3815
- columnNumber: 5
3816
- }, this) : null
3817
- ] }, void 0, true, {
3818
- fileName: "../src/react-devtools/StateIndex.tsx",
3819
- lineNumber: 46,
3820
- columnNumber: 3
3821
- }, this);
3822
- };
3823
- var StateIndexTreeNode = ({ node, isOpenState }) => {
3824
- const [isOpen, setIsOpen] = useIO2(isOpenState);
3825
- Object.entries(node.familyMembers).forEach(([key, childNode]) => {
3826
- findViewIsOpenState(key);
3827
- findStateTypeState(childNode);
3828
- });
3829
- return /* @__PURE__ */ jsxDEV17(Fragment4, { children: [
3830
- /* @__PURE__ */ jsxDEV17("header", { children: [
3831
- /* @__PURE__ */ jsxDEV17(button.OpenClose, { isOpen, setIsOpen }, void 0, false, {
3832
- fileName: "../src/react-devtools/StateIndex.tsx",
3833
- lineNumber: 84,
3834
- columnNumber: 5
3835
- }, this),
3836
- /* @__PURE__ */ jsxDEV17("label", { children: [
3837
- /* @__PURE__ */ jsxDEV17("h2", { children: node.key }, void 0, false, {
3838
- fileName: "../src/react-devtools/StateIndex.tsx",
3839
- lineNumber: 86,
3840
- columnNumber: 6
3841
- }, this),
3842
- /* @__PURE__ */ jsxDEV17("span", { className: "type detail", children: " (family)" }, void 0, false, {
3843
- fileName: "../src/react-devtools/StateIndex.tsx",
3844
- lineNumber: 87,
3845
- columnNumber: 6
3846
- }, this)
3847
- ] }, void 0, true, {
3848
- fileName: "../src/react-devtools/StateIndex.tsx",
3849
- lineNumber: 85,
3850
- columnNumber: 5
3851
- }, this)
3852
- ] }, void 0, true, {
3853
- fileName: "../src/react-devtools/StateIndex.tsx",
3854
- lineNumber: 83,
3855
- columnNumber: 4
3856
- }, this),
3857
- isOpen ? Object.entries(node.familyMembers).map(([key, childNode]) => /* @__PURE__ */ jsxDEV17(
3858
- StateIndexNode,
3859
- {
3860
- node: childNode,
3861
- isOpenState: findViewIsOpenState(childNode.key),
3862
- typeState: findStateTypeState(childNode)
3863
- },
3864
- key,
3865
- false,
3866
- {
3867
- fileName: "../src/react-devtools/StateIndex.tsx",
3868
- lineNumber: 92,
3869
- columnNumber: 7
3870
- },
3871
- this
3872
- )) : null
3873
- ] }, void 0, true, {
3874
- fileName: "../src/react-devtools/StateIndex.tsx",
3875
- lineNumber: 82,
3876
- columnNumber: 3
3877
- }, this);
3878
- };
3879
- var StateIndexNode = ({ node, isOpenState, typeState }) => {
3880
- if (node.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)) {
3881
- return null;
3882
- }
3883
- return /* @__PURE__ */ jsxDEV17("section", { className: "node state", children: `type` in node ? /* @__PURE__ */ jsxDEV17(
3884
- StateIndexLeafNode,
3885
- {
3886
- node,
3887
- isOpenState,
3888
- typeState
3889
- },
3890
- void 0,
3891
- false,
3892
- {
3893
- fileName: "../src/react-devtools/StateIndex.tsx",
3894
- lineNumber: 117,
3895
- columnNumber: 5
3896
- },
3897
- this
3898
- ) : /* @__PURE__ */ jsxDEV17(StateIndexTreeNode, { node, isOpenState }, void 0, false, {
3899
- fileName: "../src/react-devtools/StateIndex.tsx",
3900
- lineNumber: 123,
3901
- columnNumber: 5
3902
- }, this) }, void 0, false, {
3903
- fileName: "../src/react-devtools/StateIndex.tsx",
3904
- lineNumber: 115,
3905
- columnNumber: 3
3906
- }, this);
3907
- };
3908
- var StateIndex = ({ tokenIndex }) => {
3909
- const tokenIds = useO2(tokenIndex);
3910
- return /* @__PURE__ */ jsxDEV17("article", { className: "index state_index", children: Object.entries(tokenIds).filter(([key]) => !key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).sort().map(([key, node]) => {
3911
- return /* @__PURE__ */ jsxDEV17(
3912
- StateIndexNode,
3913
- {
3914
- node,
3915
- isOpenState: findViewIsOpenState(node.key),
3916
- typeState: findStateTypeState(node)
3917
- },
3918
- key,
3919
- false,
3920
- {
3921
- fileName: "../src/react-devtools/StateIndex.tsx",
3922
- lineNumber: 146,
3923
- columnNumber: 7
3924
- },
3925
- this
3926
- );
3927
- }) }, void 0, false, {
3928
- fileName: "../src/react-devtools/StateIndex.tsx",
3929
- lineNumber: 140,
3930
- columnNumber: 3
3931
- }, this);
3932
- };
3933
-
3934
- // ../src/react-devtools/TimelineIndex.tsx
3935
- import {
3936
- undo,
3937
- redo
3938
- } from "atom.io";
3939
- import { useIO as useIO3, useO as useO3 } from "atom.io/react";
3940
- import { Fragment as Fragment6 } from "react";
3941
-
3942
- // ../src/react-devtools/Updates.tsx
3943
- import { Fragment as Fragment5, jsxDEV as jsxDEV18 } from "react/jsx-dev-runtime";
3944
- var AtomUpdateFC = ({ atomUpdate }) => {
3945
- return /* @__PURE__ */ jsxDEV18(
3946
- "article",
3947
- {
3948
- className: "node atom_update",
3949
- onClick: () => console.log(atomUpdate),
3950
- onKeyUp: () => console.log(atomUpdate),
3951
- children: [
3952
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: [
3953
- atomUpdate.key,
3954
- ": "
3955
- ] }, void 0, true, {
3956
- fileName: "../src/react-devtools/Updates.tsx",
3957
- lineNumber: 20,
3958
- columnNumber: 4
3959
- }, this),
3960
- /* @__PURE__ */ jsxDEV18("span", { children: /* @__PURE__ */ jsxDEV18("span", { className: "summary", children: prettyJson.diff(atomUpdate.oldValue, atomUpdate.newValue).summary }, void 0, false, {
3961
- fileName: "../src/react-devtools/Updates.tsx",
3962
- lineNumber: 22,
3963
- columnNumber: 5
3964
- }, this) }, void 0, false, {
3965
- fileName: "../src/react-devtools/Updates.tsx",
3966
- lineNumber: 21,
3967
- columnNumber: 4
3968
- }, this)
3969
- ]
3970
- },
3971
- atomUpdate.key,
3972
- true,
3973
- {
3974
- fileName: "../src/react-devtools/Updates.tsx",
3975
- lineNumber: 14,
3976
- columnNumber: 3
3977
- },
3978
- this
3979
- );
3980
- };
3981
- var TransactionUpdateFC = ({ serialNumber, transactionUpdate }) => {
3982
- return /* @__PURE__ */ jsxDEV18("article", { className: "node transaction_update", children: [
3983
- /* @__PURE__ */ jsxDEV18("header", { children: /* @__PURE__ */ jsxDEV18("h4", { children: serialNumber }, void 0, false, {
3984
- fileName: "../src/react-devtools/Updates.tsx",
3985
- lineNumber: 37,
3986
- columnNumber: 5
3987
- }, this) }, void 0, false, {
3988
- fileName: "../src/react-devtools/Updates.tsx",
3989
- lineNumber: 36,
3990
- columnNumber: 4
3991
- }, this),
3992
- /* @__PURE__ */ jsxDEV18("main", { children: [
3993
- /* @__PURE__ */ jsxDEV18("section", { className: "transaction_params", children: [
3994
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: "params: " }, void 0, false, {
3995
- fileName: "../src/react-devtools/Updates.tsx",
3996
- lineNumber: 41,
3997
- columnNumber: 6
3998
- }, this),
3999
- transactionUpdate.params.map((param, index) => {
4000
- return /* @__PURE__ */ jsxDEV18(
4001
- "article",
4002
- {
4003
- className: "node transaction_param",
4004
- onClick: () => console.log(transactionUpdate),
4005
- onKeyUp: () => console.log(transactionUpdate),
4006
- children: [
4007
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: [
4008
- discoverType(param),
4009
- ": "
4010
- ] }, void 0, true, {
4011
- fileName: "../src/react-devtools/Updates.tsx",
4012
- lineNumber: 50,
4013
- columnNumber: 9
4014
- }, this),
4015
- /* @__PURE__ */ jsxDEV18("span", { className: "summary", children: typeof param === `object` && `type` in param && `target` in param ? /* @__PURE__ */ jsxDEV18(Fragment5, { children: JSON.stringify(param.type) }, void 0, false, {
4016
- fileName: "../src/react-devtools/Updates.tsx",
4017
- lineNumber: 55,
4018
- columnNumber: 11
4019
- }, this) : /* @__PURE__ */ jsxDEV18(Fragment5, { children: JSON.stringify(param) }, void 0, false, {
4020
- fileName: "../src/react-devtools/Updates.tsx",
4021
- lineNumber: 57,
4022
- columnNumber: 11
4023
- }, this) }, void 0, false, {
4024
- fileName: "../src/react-devtools/Updates.tsx",
4025
- lineNumber: 51,
4026
- columnNumber: 9
4027
- }, this)
4028
- ]
4029
- },
4030
- `param` + index,
4031
- true,
4032
- {
4033
- fileName: "../src/react-devtools/Updates.tsx",
4034
- lineNumber: 44,
4035
- columnNumber: 8
4036
- },
4037
- this
4038
- );
4039
- })
4040
- ] }, void 0, true, {
4041
- fileName: "../src/react-devtools/Updates.tsx",
4042
- lineNumber: 40,
4043
- columnNumber: 5
4044
- }, this),
4045
- /* @__PURE__ */ jsxDEV18("section", { className: "node transaction_output", children: [
4046
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: "output: " }, void 0, false, {
4047
- fileName: "../src/react-devtools/Updates.tsx",
4048
- lineNumber: 65,
4049
- columnNumber: 6
4050
- }, this),
4051
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: discoverType(transactionUpdate.output) }, void 0, false, {
4052
- fileName: "../src/react-devtools/Updates.tsx",
4053
- lineNumber: 66,
4054
- columnNumber: 6
4055
- }, this),
4056
- transactionUpdate.output ? /* @__PURE__ */ jsxDEV18("span", { className: "summary", children: [
4057
- ": ",
4058
- JSON.stringify(transactionUpdate.output)
4059
- ] }, void 0, true, {
4060
- fileName: "../src/react-devtools/Updates.tsx",
4061
- lineNumber: 70,
4062
- columnNumber: 7
4063
- }, this) : null
4064
- ] }, void 0, true, {
4065
- fileName: "../src/react-devtools/Updates.tsx",
4066
- lineNumber: 64,
4067
- columnNumber: 5
4068
- }, this),
4069
- /* @__PURE__ */ jsxDEV18("section", { className: "transaction_impact", children: [
4070
- /* @__PURE__ */ jsxDEV18("span", { className: "detail", children: "impact: " }, void 0, false, {
4071
- fileName: "../src/react-devtools/Updates.tsx",
4072
- lineNumber: 76,
4073
- columnNumber: 6
4074
- }, this),
4075
- transactionUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
4076
- return /* @__PURE__ */ jsxDEV18(
4077
- article.AtomUpdate,
4078
- {
4079
- serialNumber: index,
4080
- atomUpdate
4081
- },
4082
- `${transactionUpdate.key}:${index}:${atomUpdate.key}`,
4083
- false,
4084
- {
4085
- fileName: "../src/react-devtools/Updates.tsx",
4086
- lineNumber: 81,
4087
- columnNumber: 9
4088
- },
4089
- this
4090
- );
4091
- })
4092
- ] }, void 0, true, {
4093
- fileName: "../src/react-devtools/Updates.tsx",
4094
- lineNumber: 75,
4095
- columnNumber: 5
4096
- }, this)
4097
- ] }, void 0, true, {
4098
- fileName: "../src/react-devtools/Updates.tsx",
4099
- lineNumber: 39,
4100
- columnNumber: 4
4101
- }, this)
4102
- ] }, void 0, true, {
4103
- fileName: "../src/react-devtools/Updates.tsx",
4104
- lineNumber: 35,
4105
- columnNumber: 3
4106
- }, this);
4107
- };
4108
- var TimelineUpdateFC = ({ timelineUpdate }) => {
4109
- return /* @__PURE__ */ jsxDEV18("article", { className: "node timeline_update", children: [
4110
- /* @__PURE__ */ jsxDEV18("header", { children: /* @__PURE__ */ jsxDEV18("h4", { children: [
4111
- timelineUpdate.timestamp,
4112
- ": ",
4113
- timelineUpdate.type,
4114
- " (",
4115
- timelineUpdate.key,
4116
- ")"
4117
- ] }, void 0, true, {
4118
- fileName: "../src/react-devtools/Updates.tsx",
4119
- lineNumber: 100,
4120
- columnNumber: 5
4121
- }, this) }, void 0, false, {
4122
- fileName: "../src/react-devtools/Updates.tsx",
4123
- lineNumber: 99,
4124
- columnNumber: 4
4125
- }, this),
4126
- /* @__PURE__ */ jsxDEV18("main", { children: timelineUpdate.type === `transaction_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
4127
- return /* @__PURE__ */ jsxDEV18(
4128
- article.AtomUpdate,
4129
- {
4130
- serialNumber: index,
4131
- atomUpdate
4132
- },
4133
- `${timelineUpdate.key}:${index}:${atomUpdate.key}`,
4134
- false,
4135
- {
4136
- fileName: "../src/react-devtools/Updates.tsx",
4137
- lineNumber: 111,
4138
- columnNumber: 9
4139
- },
4140
- this
4141
- );
4142
- }) : timelineUpdate.type === `selector_update` ? timelineUpdate.atomUpdates.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((atomUpdate, index) => {
4143
- return /* @__PURE__ */ jsxDEV18(
4144
- article.AtomUpdate,
4145
- {
4146
- serialNumber: index,
4147
- atomUpdate
4148
- },
4149
- `${timelineUpdate.key}:${index}:${atomUpdate.key}`,
4150
- false,
4151
- {
4152
- fileName: "../src/react-devtools/Updates.tsx",
4153
- lineNumber: 123,
4154
- columnNumber: 9
4155
- },
4156
- this
4157
- );
4158
- }) : timelineUpdate.type === `atom_update` ? /* @__PURE__ */ jsxDEV18(
4159
- article.AtomUpdate,
4160
- {
4161
- serialNumber: timelineUpdate.timestamp,
4162
- atomUpdate: timelineUpdate
4163
- },
4164
- void 0,
4165
- false,
4166
- {
4167
- fileName: "../src/react-devtools/Updates.tsx",
4168
- lineNumber: 131,
4169
- columnNumber: 6
4170
- },
4171
- this
4172
- ) : null }, void 0, false, {
4173
- fileName: "../src/react-devtools/Updates.tsx",
4174
- lineNumber: 105,
4175
- columnNumber: 4
4176
- }, this)
4177
- ] }, void 0, true, {
4178
- fileName: "../src/react-devtools/Updates.tsx",
4179
- lineNumber: 98,
4180
- columnNumber: 3
4181
- }, this);
4182
- };
4183
- var article = {
4184
- AtomUpdate: AtomUpdateFC,
4185
- TransactionUpdate: TransactionUpdateFC,
4186
- TimelineUpdate: TimelineUpdateFC
4187
- };
4188
-
4189
- // ../src/react-devtools/TimelineIndex.tsx
4190
- import { jsxDEV as jsxDEV19 } from "react/jsx-dev-runtime";
4191
- var YouAreHere = () => {
4192
- return /* @__PURE__ */ jsxDEV19("span", { className: "you_are_here", children: "you are here" }, void 0, false, {
4193
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4194
- lineNumber: 17,
4195
- columnNumber: 9
4196
- }, this);
4197
- };
4198
- var TimelineLog = ({ token, isOpenState, timelineState }) => {
4199
- const timeline2 = useO3(timelineState);
4200
- const [isOpen, setIsOpen] = useIO3(isOpenState);
4201
- return /* @__PURE__ */ jsxDEV19("section", { className: "node timeline_log", children: [
4202
- /* @__PURE__ */ jsxDEV19("header", { children: [
4203
- /* @__PURE__ */ jsxDEV19(button.OpenClose, { isOpen, setIsOpen }, void 0, false, {
4204
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4205
- lineNumber: 31,
4206
- columnNumber: 5
4207
- }, this),
4208
- /* @__PURE__ */ jsxDEV19("label", { children: [
4209
- /* @__PURE__ */ jsxDEV19("h2", { children: token.key }, void 0, false, {
4210
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4211
- lineNumber: 33,
4212
- columnNumber: 6
4213
- }, this),
4214
- /* @__PURE__ */ jsxDEV19("span", { className: "detail length", children: [
4215
- "(",
4216
- timeline2.at,
4217
- "/",
4218
- timeline2.history.length,
4219
- ")"
4220
- ] }, void 0, true, {
4221
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4222
- lineNumber: 34,
4223
- columnNumber: 6
4224
- }, this),
4225
- /* @__PURE__ */ jsxDEV19("span", { className: "gap" }, void 0, false, {
4226
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4227
- lineNumber: 37,
4228
- columnNumber: 6
4229
- }, this),
4230
- /* @__PURE__ */ jsxDEV19("nav", { children: [
4231
- /* @__PURE__ */ jsxDEV19(
4232
- "button",
4233
- {
4234
- type: "button",
4235
- onClick: () => undo(token),
4236
- disabled: timeline2.at === 0,
4237
- children: "undo"
4238
- },
4239
- void 0,
4240
- false,
4241
- {
4242
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4243
- lineNumber: 39,
4244
- columnNumber: 7
4245
- },
4246
- this
4247
- ),
4248
- /* @__PURE__ */ jsxDEV19(
4249
- "button",
4250
- {
4251
- type: "button",
4252
- onClick: () => redo(token),
4253
- disabled: timeline2.at === timeline2.history.length,
4254
- children: "redo"
4255
- },
4256
- void 0,
4257
- false,
4258
- {
4259
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4260
- lineNumber: 46,
4261
- columnNumber: 7
4262
- },
4263
- this
4264
- )
4265
- ] }, void 0, true, {
4266
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4267
- lineNumber: 38,
4268
- columnNumber: 6
4269
- }, this)
4270
- ] }, void 0, true, {
4271
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4272
- lineNumber: 32,
4273
- columnNumber: 5
4274
- }, this)
4275
- ] }, void 0, true, {
4276
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4277
- lineNumber: 30,
4278
- columnNumber: 4
4279
- }, this),
4280
- isOpen ? /* @__PURE__ */ jsxDEV19("main", { children: timeline2.history.map((update, index) => /* @__PURE__ */ jsxDEV19(Fragment6, { children: [
4281
- index === timeline2.at ? /* @__PURE__ */ jsxDEV19(YouAreHere, {}, void 0, false, {
4282
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4283
- lineNumber: 60,
4284
- columnNumber: 33
4285
- }, this) : null,
4286
- /* @__PURE__ */ jsxDEV19(article.TimelineUpdate, { timelineUpdate: update }, void 0, false, {
4287
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4288
- lineNumber: 61,
4289
- columnNumber: 8
4290
- }, this),
4291
- index === timeline2.history.length - 1 && timeline2.at === timeline2.history.length ? /* @__PURE__ */ jsxDEV19(YouAreHere, {}, void 0, false, {
4292
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4293
- lineNumber: 64,
4294
- columnNumber: 9
4295
- }, this) : null
4296
- ] }, update.key + index + timeline2.at, true, {
4297
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4298
- lineNumber: 59,
4299
- columnNumber: 7
4300
- }, this)) }, void 0, false, {
4301
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4302
- lineNumber: 57,
4303
- columnNumber: 5
4304
- }, this) : null
4305
- ] }, void 0, true, {
4306
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4307
- lineNumber: 29,
4308
- columnNumber: 3
4309
- }, this);
4310
- };
4311
- var TimelineIndex = () => {
4312
- const tokenIds = useO3(timelineIndex);
4313
- return /* @__PURE__ */ jsxDEV19("article", { className: "index timeline_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
4314
- return /* @__PURE__ */ jsxDEV19(
4315
- TimelineLog,
4316
- {
4317
- token,
4318
- isOpenState: findViewIsOpenState(token.key),
4319
- timelineState: findTimelineState(token.key)
4320
- },
4321
- token.key,
4322
- false,
4323
- {
4324
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4325
- lineNumber: 82,
4326
- columnNumber: 7
4327
- },
4328
- this
4329
- );
4330
- }) }, void 0, false, {
4331
- fileName: "../src/react-devtools/TimelineIndex.tsx",
4332
- lineNumber: 77,
4333
- columnNumber: 3
4334
- }, this);
4335
- };
4336
-
4337
- // ../src/react-devtools/TransactionIndex.tsx
4338
- import { useIO as useIO4, useO as useO4 } from "atom.io/react";
4339
- import { jsxDEV as jsxDEV20 } from "react/jsx-dev-runtime";
4340
- var TransactionLog = ({ token, isOpenState, logState }) => {
4341
- const log = useO4(logState);
4342
- const [isOpen, setIsOpen] = useIO4(isOpenState);
4343
- return /* @__PURE__ */ jsxDEV20("section", { className: "node transaction_log", children: [
4344
- /* @__PURE__ */ jsxDEV20("header", { children: [
4345
- /* @__PURE__ */ jsxDEV20(button.OpenClose, { isOpen, setIsOpen }, void 0, false, {
4346
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4347
- lineNumber: 31,
4348
- columnNumber: 5
4349
- }, this),
4350
- /* @__PURE__ */ jsxDEV20("label", { children: [
4351
- /* @__PURE__ */ jsxDEV20("h2", { children: token.key }, void 0, false, {
4352
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4353
- lineNumber: 33,
4354
- columnNumber: 6
4355
- }, this),
4356
- /* @__PURE__ */ jsxDEV20("span", { className: "detail length", children: [
4357
- "(",
4358
- log.length,
4359
- ")"
4360
- ] }, void 0, true, {
4361
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4362
- lineNumber: 34,
4363
- columnNumber: 6
4364
- }, this)
4365
- ] }, void 0, true, {
4366
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4367
- lineNumber: 32,
4368
- columnNumber: 5
4369
- }, this)
4370
- ] }, void 0, true, {
4371
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4372
- lineNumber: 30,
4373
- columnNumber: 4
4374
- }, this),
4375
- isOpen ? /* @__PURE__ */ jsxDEV20("main", { children: log.map((update, index) => /* @__PURE__ */ jsxDEV20(
4376
- article.TransactionUpdate,
4377
- {
4378
- serialNumber: index,
4379
- transactionUpdate: update
4380
- },
4381
- update.key + index,
4382
- false,
4383
- {
4384
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4385
- lineNumber: 40,
4386
- columnNumber: 7
4387
- },
4388
- this
4389
- )) }, void 0, false, {
4390
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4391
- lineNumber: 38,
4392
- columnNumber: 5
4393
- }, this) : null
4394
- ] }, void 0, true, {
4395
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4396
- lineNumber: 29,
4397
- columnNumber: 3
4398
- }, this);
4399
- };
4400
- var TransactionIndex = () => {
4401
- const tokenIds = useO4(transactionIndex);
4402
- return /* @__PURE__ */ jsxDEV20("article", { className: "index transaction_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
4403
- return /* @__PURE__ */ jsxDEV20(
4404
- TransactionLog,
4405
- {
4406
- token,
4407
- isOpenState: findViewIsOpenState(token.key),
4408
- logState: findTransactionLogState(token.key)
4409
- },
4410
- token.key,
4411
- false,
4412
- {
4413
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4414
- lineNumber: 60,
4415
- columnNumber: 7
4416
- },
4417
- this
4418
- );
4419
- }) }, void 0, false, {
4420
- fileName: "../src/react-devtools/TransactionIndex.tsx",
4421
- lineNumber: 55,
4422
- columnNumber: 3
4423
- }, this);
4424
- };
4425
-
4426
- // ../src/react-devtools/AtomIODevtools.tsx
4427
- import { Fragment as Fragment7, jsxDEV as jsxDEV21 } from "react/jsx-dev-runtime";
4428
- var AtomIODevtools = () => {
4429
- const constraintsRef = useRef4(null);
4430
- const [devtoolsAreOpen, setDevtoolsAreOpen] = useIO5(devtoolsAreOpenState);
4431
- const [devtoolsView, setDevtoolsView] = useIO5(devtoolsViewSelectionState);
4432
- const devtoolsViewOptions = useO5(devtoolsViewOptionsState);
4433
- const mouseHasMoved = useRef4(false);
4434
- return /* @__PURE__ */ jsxDEV21(Fragment7, { children: [
4435
- /* @__PURE__ */ jsxDEV21(
4436
- motion.span,
4437
- {
4438
- ref: constraintsRef,
4439
- className: "atom_io_devtools_zone",
4440
- style: {
4441
- position: `fixed`,
4442
- top: 0,
4443
- left: 0,
4444
- right: 0,
4445
- bottom: 0,
4446
- pointerEvents: `none`
4447
- }
4448
- },
4449
- void 0,
4450
- false,
4451
- {
4452
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4453
- lineNumber: 29,
4454
- columnNumber: 4
4455
- },
4456
- this
4457
- ),
4458
- /* @__PURE__ */ jsxDEV21(
4459
- motion.main,
4460
- {
4461
- drag: true,
4462
- dragConstraints: constraintsRef,
4463
- className: "atom_io_devtools",
4464
- transition: spring,
4465
- style: devtoolsAreOpen ? {} : {
4466
- backgroundColor: `#0000`,
4467
- borderColor: `#0000`,
4468
- maxHeight: 28,
4469
- maxWidth: 33
4470
- },
4471
- children: [
4472
- devtoolsAreOpen ? /* @__PURE__ */ jsxDEV21(Fragment7, { children: [
4473
- /* @__PURE__ */ jsxDEV21(motion.header, { children: [
4474
- /* @__PURE__ */ jsxDEV21("h1", { children: "atom.io" }, void 0, false, {
4475
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4476
- lineNumber: 60,
4477
- columnNumber: 8
4478
- }, this),
4479
- /* @__PURE__ */ jsxDEV21("nav", { children: devtoolsViewOptions.map((viewOption) => /* @__PURE__ */ jsxDEV21(
4480
- "button",
4481
- {
4482
- type: "button",
4483
- className: viewOption === devtoolsView ? `active` : ``,
4484
- onClick: () => setDevtoolsView(viewOption),
4485
- disabled: viewOption === devtoolsView,
4486
- children: viewOption
4487
- },
4488
- viewOption,
4489
- false,
4490
- {
4491
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4492
- lineNumber: 63,
4493
- columnNumber: 10
4494
- },
4495
- this
4496
- )) }, void 0, false, {
4497
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4498
- lineNumber: 61,
4499
- columnNumber: 8
4500
- }, this)
4501
- ] }, void 0, true, {
4502
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4503
- lineNumber: 59,
4504
- columnNumber: 7
4505
- }, this),
4506
- /* @__PURE__ */ jsxDEV21(motion.main, { children: /* @__PURE__ */ jsxDEV21(LayoutGroup, { children: devtoolsView === `atoms` ? /* @__PURE__ */ jsxDEV21(StateIndex, { tokenIndex: atomIndex }, void 0, false, {
4507
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4508
- lineNumber: 78,
4509
- columnNumber: 10
4510
- }, this) : devtoolsView === `selectors` ? /* @__PURE__ */ jsxDEV21(StateIndex, { tokenIndex: selectorIndex }, void 0, false, {
4511
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4512
- lineNumber: 80,
4513
- columnNumber: 10
4514
- }, this) : devtoolsView === `transactions` ? /* @__PURE__ */ jsxDEV21(TransactionIndex, {}, void 0, false, {
4515
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4516
- lineNumber: 82,
4517
- columnNumber: 10
4518
- }, this) : devtoolsView === `timelines` ? /* @__PURE__ */ jsxDEV21(TimelineIndex, {}, void 0, false, {
4519
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4520
- lineNumber: 84,
4521
- columnNumber: 10
4522
- }, this) : null }, void 0, false, {
4523
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4524
- lineNumber: 76,
4525
- columnNumber: 8
4526
- }, this) }, void 0, false, {
4527
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4528
- lineNumber: 75,
4529
- columnNumber: 7
4530
- }, this)
4531
- ] }, void 0, true, {
4532
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4533
- lineNumber: 58,
4534
- columnNumber: 6
4535
- }, this) : null,
4536
- /* @__PURE__ */ jsxDEV21("footer", { children: /* @__PURE__ */ jsxDEV21(
4537
- "button",
4538
- {
4539
- type: "button",
4540
- onMouseDown: () => mouseHasMoved.current = false,
4541
- onMouseMove: () => mouseHasMoved.current = true,
4542
- onMouseUp: () => {
4543
- if (!mouseHasMoved.current) {
4544
- setDevtoolsAreOpen((open) => !open);
4545
- }
4546
- },
4547
- children: "\u{1F441}\u200D\u{1F5E8}"
4548
- },
4549
- void 0,
4550
- false,
4551
- {
4552
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4553
- lineNumber: 91,
4554
- columnNumber: 6
4555
- },
4556
- this
4557
- ) }, void 0, false, {
4558
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4559
- lineNumber: 90,
4560
- columnNumber: 5
4561
- }, this)
4562
- ]
4563
- },
4564
- void 0,
4565
- true,
4566
- {
4567
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4568
- lineNumber: 41,
4569
- columnNumber: 4
4570
- },
4571
- this
4572
- )
4573
- ] }, void 0, true, {
4574
- fileName: "../src/react-devtools/AtomIODevtools.tsx",
4575
- lineNumber: 28,
4576
- columnNumber: 3
4577
- }, this);
4578
- };
4579
-
4580
- // ../src/react-devtools/index.ts
4581
- var {
4582
- atomIndex,
4583
- selectorIndex,
4584
- transactionIndex,
4585
- findTransactionLogState,
4586
- timelineIndex,
4587
- findTimelineState
4588
- } = attachIntrospectionStates();
4589
- var devtoolsAreOpenState = atom({
4590
- key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
4591
- default: true,
4592
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
4593
- });
4594
- var devtoolsViewSelectionState = atom({
4595
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
4596
- default: `atoms`,
4597
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View`)]
4598
- });
4599
- var devtoolsViewOptionsState = atom({
4600
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
4601
- default: [`atoms`, `selectors`, `transactions`, `timelines`],
4602
- effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
4603
- });
4604
- var findViewIsOpenState = atomFamily({
4605
- key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
4606
- default: false,
4607
- effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)]
4608
- });
4609
- var primitiveRefinery = new Refinery({
4610
- number: (input) => typeof input === `number`,
4611
- string: (input) => typeof input === `string`,
4612
- boolean: (input) => typeof input === `boolean`,
4613
- null: (input) => input === null
4614
- });
4615
- var jsonTreeRefinery = new Refinery({
4616
- object: isPlainObject,
4617
- array: (input) => Array.isArray(input)
4618
- });
4619
- var prettyJson = new Differ(primitiveRefinery, jsonTreeRefinery, {
4620
- number: diffNumber,
4621
- string: diffString,
4622
- boolean: diffBoolean,
4623
- null: () => ({ summary: `No Change` }),
4624
- object: diffObject,
4625
- array: diffArray
4626
- });
4627
- export {
4628
- AtomIODevtools,
4629
- atomIndex,
4630
- devtoolsAreOpenState,
4631
- devtoolsViewOptionsState,
4632
- devtoolsViewSelectionState,
4633
- findTimelineState,
4634
- findTransactionLogState,
4635
- findViewIsOpenState,
4636
- jsonTreeRefinery,
4637
- prettyJson,
4638
- primitiveRefinery,
4639
- selectorIndex,
4640
- timelineIndex,
4641
- transactionIndex
4642
- };
1
+ import { selectorFamily, atom, atomFamily, undo, redo, getState } from 'atom.io';
2
+ import { attachIntrospectionStates } from 'atom.io/introspection';
3
+ import { lazyLocalStorageEffect } from 'atom.io/web-effects';
4
+ import { pipe } from 'fp-ts/function';
5
+ import { useIO, useO } from 'atom.io/react';
6
+ import { motion, spring, LayoutGroup } from 'framer-motion';
7
+ import * as Wo from 'react';
8
+ import { forwardRef, useRef, useState, useImperativeHandle, useLayoutEffect, Fragment as Fragment$1, useMemo, Component, useId } from 'react';
9
+ import { isBoolean } from 'fp-ts/boolean';
10
+ import { isNumber } from 'fp-ts/number';
11
+ import { isString } from 'fp-ts/string';
12
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
+ import Rs from 'ajv';
14
+ import { useFloating, useClick, useInteractions, FloatingPortal } from '@floating-ui/react';
15
+
16
+ var br=Object.defineProperty,xr=Object.defineProperties;var gr=Object.getOwnPropertyDescriptors;var Je=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var jt=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))Lt.call(t,n)&&jt(e,n,t[n]);if(Je)for(var n of Je(t))_t.call(t,n)&&jt(e,n,t[n]);return e},u=(e,t)=>xr(e,gr(t));var Pt=e=>typeof e=="symbol"?e:e+"",ve=(e,t)=>{var n={};for(var o in e)Lt.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&Je)for(var o of Je(e))t.indexOf(o)<0&&_t.call(e,o)&&(n[o]=e[o]);return n};var Bt=e=>t=>{for(let n of e)if(!t.includes(n))return !1;return !0};var Ft=e=>t=>Bt(e)(t)&&Bt(t)(e);var w=e=>t=>Array.isArray(t)&&t.every(n=>e(n));var Te=e=>t=>t.map(e);var Xe=(e=Boolean)=>t=>t.every(e),Mt=Xe(e=>e===!0),Ie=e=>t=>e.includes(t)?e:[...e,t],Se=e=>Array.isArray(e)&&e.length===0,Dt=(...e)=>t=>e.includes(t);var Ge=e=>e===void 0,f=e=>t=>Ge(t)||e(t);var Kt=e=>t=>t!=null?t:e;var se=()=>{},ie=e=>t=>e instanceof Function?e(t instanceof Function?t():t):e,Wt=e=>t=>{if(!e(t))throw new Error(`Invalid test case: JSON.stringify(${t})`);return o=>{if(typeof o!="function")return !1;let r=o(t);return e(r)}},Ht=(...e)=>t=>t(...e);var $t=e=>{throw new Error(e)};var Vt=(e,t)=>{try{return e()}catch(n){return t}};var Ut=e=>Object.assign(t=>t[e],{in:t=>t[e]});var z=e=>Object.entries(e),Oe=e=>Object.fromEntries(e);var ae=(e,t)=>pipe(e,z,Te(([n,o])=>[n,t(o,n)]),Oe),zt=e=>t=>ae(t,e);var Tr=e=>typeof e=="object"&&e!==null,v=e=>Tr(e)&&Object.getPrototypeOf(e)===Object.prototype,Yt=e=>v(e)&&Object.keys(e).length===0,pe=(e,t)=>n=>v(n)&&Object.entries(n).every(([o,r])=>e(o)&&t(r)),qt=(e,t={allowExtraProperties:!1})=>{let n=`{${z(e).map(([r,s])=>String(r)+":"+s.name).join(",")}}`;return {[n]:r=>v(r)&&pipe(e,Object.entries,Xe(([s,i])=>s in r||i(void 0)))&&pipe(r,zt((s,i)=>pipe(e,Ut(i),Kt(()=>t.allowExtraProperties),Ht(s))),Object.values,Mt)}[n]},T=e=>qt(e,{allowExtraProperties:!0}),Qe=e=>qt(e,{allowExtraProperties:!1});var et=(e,t)=>{let n=(o,r)=>{let i=((p,l)=>{let m=t(p,l);return m||null})(o,r);if(i!=null&&i.jobComplete||i!=null&&i.pathComplete)return i;let a=Array.isArray(r)?r.map((p,l)=>[l,p]):v(r)?Object.entries(r):[];for(let[p,l]of a){let m=n([...o,p],l);if(m!=null&&m.jobComplete)return m}return {}};n([],e);};var Y=(e=Ge)=>t=>{let n={};return Object.entries(t).forEach(([r,s])=>e(s,r)?null:n[r]=s),n};var Xt=(e,t)=>{let n=t.reduce((o,r)=>o==null?void 0:o[r],e);return n===void 0?new Error("Not found"):{found:n}};var le=class{constructor(t){this.supported=t;}refine(t){for(let[n,o]of Object.entries(this.supported))try{if(o(t)===!0&&o!==Boolean)return {type:n,data:t}}catch(r){try{if(t instanceof o)return {type:n,data:t}}catch(s){}}return null}},Sr=new le({number:e=>typeof e=="number",string:e=>typeof e=="string",boolean:e=>typeof e=="boolean",object:v,array:e=>Array.isArray(e),null:e=>e===null}),ce=e=>{if(e===void 0)return "undefined";let t=Sr.refine(e);return t?t.type:Object.getPrototypeOf(e).constructor.name};function Gt(e,t){return {summary:`${e<t?"+":"-"}${Math.abs(e-t)} (${e} \u2192 ${t})`}}function Zt(e,t){return {summary:`${e.length<t.length?"+":"-"}${Math.abs(e.length-t.length)} ("${e}" \u2192 "${t}")`}}function Qt(e,t){return {summary:`${e} \u2192 ${t}`}}function tt(e,t,n){let o="",r=[],s=[],i=[];return et(e,(a,p)=>{let l;for(l of a){let m=t[l];if(m===void 0)s.push([l,JSON.stringify(p)]);else {let d=n(p,m);d.summary!=="No Change"&&i.push([l,d]);}}}),et(t,(a,p)=>{let l;for(l of a)e[l]===void 0&&r.push([l,JSON.stringify(p)]);}),o=`\uFF5E${i.length} \uFF0B${r.length} \uFF0D${s.length}`,{summary:o,added:r,removed:s,changed:i}}function en(e,t,n){return tt(e,t,n)}var je=class{constructor(t,n,o){this.leafRefinery=t,this.treeRefinery=n,this.leafDiffers={},this.treeDiffers={};for(let r of Object.keys(t.supported)){let s=o[r];this.leafDiffers[r]=s;}for(let r of Object.keys(n.supported)){let s=o[r];this.treeDiffers[r]=s;}}diff(t,n){var a,p;if(t===n)return {summary:"No Change"};try{if(JSON.stringify(t)===JSON.stringify(n))return {summary:"No Change"}}catch(l){console.error("Error stringifying",t,n);}let o=(a=this.leafRefinery.refine(t))!=null?a:this.treeRefinery.refine(t),r=(p=this.leafRefinery.refine(n))!=null?p:this.treeRefinery.refine(n);if(o!==null&&r!==null&&o.type===r.type){if(o.type in this.leafDiffers)return this.leafDiffers[o.type](o.data,r.data);if(o.type in this.treeDiffers)return this.treeDiffers[o.type](o.data,r.data,(m,d)=>this.diff(m,d))}let s=ce(t),i=ce(n);return s===i?{summary:`${s} \u2192 ${i}`}:{summary:`Type change: ${s} \u2192 ${i}`}}};var tn=e=>JSON.stringify(e),nn=["array","boolean","null","number","object","string"],on={array:[],boolean:!1,null:null,number:0,object:{},string:""};var Rr=["Array","Boolean","Number","Object","String"],me=e=>e===null?{type:"null",data:null}:isBoolean(e)?{type:"boolean",data:e}:isNumber(e)?{type:"number",data:e}:isString(e)?{type:"string",data:e}:Array.isArray(e)?{type:"array",data:e}:v(e)?{type:"object",data:e}:$t(e===void 0?"undefined passed to refineJsonType. This is not valid JSON.":`${tn(e)} with prototype "${Object.getPrototypeOf(e).constructor.name}" passed to refineJsonType. This is not valid JSON.`),q=e=>{var o;if(e===null)return !0;if(e===void 0)return !1;let t=(o=Object.getPrototypeOf(e))==null?void 0:o.constructor.name;return Rr.includes(t)};var Cr=({isOpen:e,setIsOpen:t,disabled:n})=>jsx("button",{type:"button",className:`carat ${e?"open":"closed"}`,onClick:()=>t(o=>!o),disabled:n,children:"\u25B6"}),X={OpenClose:Cr};var wr=e=>!0,Ar=e=>!1,R=e=>t=>t===e,nt=e=>t=>e.includes(t);var Ne=(e,t=!1,n=[e])=>{let o=`(${n.map(i=>i.name||"anon").join(" | ")})`,r={[o]:i=>n.some(a=>{var p;return t&&console.log(n.map(l=>l.name||"anon").join(" | "),">",(p=a.name)!=null?p:"anon",":",a(i)),a(i)})};return Object.assign(r[o],{or:i=>Ne(i,t,[...n,i])})},ot=Ne(Ar),rn=(e,t=!1,n=[e])=>{let o=`(${n.map(i=>i.name||"anon").join(" & ")})`,r={[o]:i=>n.every(a=>(t&&console.log(n.map(p=>p.name||"anon").join(" & "),">",a.name||"anon",":",a(i)),a(i)))};return Object.assign(r[o],{and:i=>rn(i,t,[...n,i])})},sn=rn(wr);var Jr=["1:1","1:n","n:n"],vr=e=>Jr.includes(e),an={contents:{},relations:{},relationType:"n:n",a:"from",b:"to"},pn=({from:e="from",to:t="to",isContent:n}={})=>o=>Qe({contents:n?pe(isString,n):Qe({}),relations:pe(isString,w(isString)),relationType:vr,a:R(e),b:R(t)})(o);var G=(e,t)=>{var n;return (n=e.relations[t])!=null?n:[]},ue=(e,t)=>{let n=G(e,t);return n.length>1&&console.warn(`entry with id ${t} was not expected to have multiple relations`),n[0]};var ln=(e,...t)=>{let n=t[0],{a:o,b:r}=e,s={from:o,to:r,isContent:n};return {toJson:i=>i.toJSON(),fromJson:i=>de.fromJSON(i,s)}};var ke=(e,t)=>G(e,t).map(n=>[n,Le(e,t,n)]),cn=(e,t)=>Object.fromEntries(ke(e,t));var mn=e=>t=>t.split(e);var Ir=(e,t,n)=>{let o=Dt(t,n);return u(c({},e),{relations:pipe(e.relations,z,Te(([r,s])=>[r,o(r)?s.filter(i=>!o(i)):s]),Oe,Y(Se)),contents:pipe(e.contents,Y((r,s)=>isString(s)&&pipe(s,mn("/"),Ft([t,n]))))})},jr=(e,t)=>u(c({},e),{relations:pipe(e.relations,z,Te(([o,r])=>[o,r.filter(s=>s!==t)]),Oe,Y((o,r)=>r===t||Se(o))),contents:pipe(e.contents,Y((o,r)=>isString(r)&&r.split("/").includes(t)))}),_e=(e,t)=>{let n=t[e.a],o=t[e.b];return o?Ir(e,n,o):jr(e,n)};var Lr=(e,t,n,...o)=>{var i,a;let r=u(c({},e),{relations:u(c({},e.relations),{[t]:Ie((i=e.relations[t])!=null?i:[])(n),[n]:Ie((a=e.relations[n])!=null?a:[])(t)})}),s=o[0];return s?Be(r,t,n,s):r},dn=Y(Se),_r=(e,t,n,...o)=>{var p;let r=c({},e.relations),s=ue(e,n),i=u(c({},e),{relations:dn(u(c(c({},r),s&&s!==t&&{[s]:r[s].filter(l=>l!==n)}),{[n]:[t],[t]:Ie((p=r[t])!=null?p:[])(n)}))}),a=o[0];return a?Be(i,t,n,a):i},Pr=(e,t,n,...o)=>{let r=ue(e,n),s=ue(e,t),i=u(c({},e),{relations:dn(u(c(c(c({},e.relations),r&&{[r]:[]}),s&&{[s]:[]}),{[t]:[n],[n]:[t]}))}),a=o[0];return a?Be(i,t,n,a):i},Pe=(e,t,...n)=>{let{[e.a]:o,[e.b]:r}=t;switch(e.relationType){case"1:1":return Pr(e,o,r,...n);case"1:n":return _r(e,o,r,...n);case"n:n":return Lr(e,o,r,...n)}};var fn=(e,t)=>[e,t].sort().join("/"),Le=(e,t,n)=>e.contents[fn(t,n)],Be=(e,t,n,o)=>u(c({},e),{contents:u(c({},e.contents),{[fn(t,n)]:o})}),st=(e,t)=>ke(e,t).map(([n,o])=>c({id:n},o)),yn=(e,t,n)=>{let o=t[e.a],r=t[e.b];return pipe(e,s=>{let a=G(e,o).filter(l=>!n.some(m=>m.id===l)),p=s;for(let l of a){let m={[e.a]:o!=null?o:l,[e.b]:r!=null?r:l};p=_e(p,m);}return p},s=>{let i=s;for(let a of n){let p=a,{id:l}=p,m=ve(p,["id"]);let d=Yt(m)?void 0:m;i=Pe(i,{[e.a]:o!=null?o:l,[e.b]:r!=null?r:l},d);}return i},s=>{let i=n.map(a=>a.id);return u(c({},s),{relations:u(c({},s.relations),{[o!=null?o:r]:i})})})};var de=class e{constructor(t){this.a="from";this.b="to";this.makeJsonInterface=(...t)=>ln(this,...t);Object.assign(this,u(c(c({},an),t),{makeJsonInterface:this.makeJsonInterface}));}toJSON(){return {relationType:this.relationType,relations:this.relations,contents:this.contents,a:this.a,b:this.b}}static fromJSON(t,n){if(pn(n)(t))return new e(t);throw new Error(`Saved JSON for this Join is invalid: ${JSON.stringify(t)}`)}from(t){return new e(u(c({},this),{a:t}))}to(t){return new e(u(c({},this),{b:t}))}getRelatedId(t){return ue(this,t)}getRelatedIds(t){return G(this,t)}getContent(t,n){return Le(this,t,n)}getRelationEntries(t){return ke(this,t)}getRelationRecord(t){return cn(this,t)}getRelation(t){return st(this,t)[0]}getRelations(t){return st(this,t)}setRelations(t,n){return new e(yn(this,t,n))}set(t,...n){return new e(Pe(this,t,...n))}remove(t){return new e(_e(this,t))}};var C=forwardRef(function(t,n){var p,l,m,d;let o=useRef(null),r=useRef(null),[s,i]=useState("auto");useImperativeHandle(n,()=>({focus:()=>{var y;(y=o.current)==null||y.focus();}}));let a=t.type==="number"?15:0;return useLayoutEffect(()=>{if(r.current){i(`${r.current.offsetWidth+a}px`);let y=setInterval(()=>{r.current&&i(`${r.current.offsetWidth+a}px`);},1e3);return ()=>clearInterval(y)}},[(p=o.current)==null?void 0:p.value,t.value]),jsxs("div",{style:{display:"inline-block",position:"relative"},children:[jsx("input",u(c({},t),{ref:o,style:c({padding:0,borderRadius:0,border:"none",fontFamily:"inherit",fontSize:"inherit",width:s},t.style)})),jsx("span",{ref:r,style:{padding:(l=t.style)==null?void 0:l.padding,position:"absolute",visibility:"hidden",whiteSpace:"pre",fontFamily:((m=t.style)==null?void 0:m.fontFamily)||"inherit",fontSize:((d=t.style)==null?void 0:d.fontSize)||"inherit"},children:t.value})]})});var F=(e,t)=>n=>n<e?e:n>t?t:n;var Z=(e,t)=>n=>n<e?t-(e-n)%(t-e):e+(n-e)%(t-e);function zr(e,t){if(t===void 0)return e;let n=10**t;return Math.round(e*n)/n}var Yr=["","-",".","-."],Tn=e=>Yr.includes(e),qr={"":null,"-":0,".":0,"-.":0},gn=e=>e==="0"||!isNaN(Number(e))&&e.includes("."),hn=(e,t)=>Tn(e)?qr[e]:t?parseFloat(e):Math.round(parseFloat(e)),Xr={max:1/0,min:-1/0,decimalPlaces:100,nullable:!0},Gr=e=>t=>{if(t===null&&e.nullable===!0)return null;let{max:n,min:o,decimalPlaces:r}=c(c({},Xr),e);return pipe(t!=null?t:0,F(o,n),i=>r?zr(i,r):i)},Zr=e=>e==null?"":e.toString(),Sn=({autoSize:e=!1,customCss:t,decimalPlaces:n,disabled:o=!1,label:r,max:s,min:i,name:a,onChange:p,onClick:l,placeholder:m="",set:d=()=>null,testId:y,value:x=null})=>{let O=useId(),[I,j]=useState(null),J=useRef(!1),E=Gr({max:s,min:i,decimalPlaces:n,nullable:!0}),re=n===void 0||n>0,ge=()=>{J.current&&(d(E(x!=null?x:null)),j(null)),J.current=!1;},he=B=>{var qe;if(p&&p(B),d===void 0)return;J.current=!0;let h=B.target.value;if(Tn(h)||gn(h)){j(h);let fr=gn(h)?h:(qe=i==null?void 0:i.toString())!=null?qe:"0",yr=hn(fr,re);d(E(yr));return}j(null);let Ae=!isNaN(Number(h))&&!h.includes(" ")||re&&h==="."||re&&h==="-."||h===""||h==="-",Ye=hn(h,re);Ae&&d(E(Ye));},b=I!=null?I:Zr(x&&E(x));return jsxs("span",{css:t,children:[r&&jsx("label",{htmlFor:O,children:r}),e?jsx(C,{type:"text",value:b,placeholder:m!=null?m:"-",onChange:he,onBlur:ge,disabled:o,name:a!=null?a:O,id:O,onClick:l,"data-testid":`number-input-${y!=null?y:O}`}):jsx("input",{type:"text",value:b,placeholder:m!=null?m:"-",onChange:he,onBlur:ge,disabled:o,name:a!=null?a:O,id:O,onClick:l,"data-testid":`number-input-${y!=null?y:O}`})]})};var On=({value:e,set:t,label:n,placeholder:o,customCss:r,autoSize:s=!1})=>jsxs("span",{css:r,children:[jsx("label",{children:n}),s?jsx(C,{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),disabled:t===void 0,placeholder:o}):jsx("input",{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),disabled:t===void 0,placeholder:o})]});var kn=({data:e})=>e===void 0?jsx(C,{disabled:!0,value:"undefined"}):jsx(C,{disabled:!0,value:Object.getPrototypeOf(e).constructor.name+" "+JSON.stringify(e)});var fe=({data:e,set:t,schema:n,name:o,rename:r,remove:s,recast:i,path:a=[],isReadonly:p=()=>!1,isHidden:l=()=>!1,className:m,customCss:d,Header:y,Components:x})=>{let O=q(e),I=O?me(e):{type:"non-json",data:e},j=O?pt[I.type]:kn,J=p(a);return l(a)?null:jsx(x.ErrorBoundary,{children:jsxs(x.EditorWrapper,{className:m,customCss:d,children:[s&&jsx(x.Button,{onClick:J?se:s,disabled:J,children:jsx(x.DeleteIcon,{})}),y&&jsx(y,{data:e,schema:n}),r&&jsx(x.KeyWrapper,{children:jsx(C,{value:o,onChange:J?se:E=>r(E.target.value),disabled:J})}),jsx(j,{data:I.data,set:t,schema:n,remove:s,rename:r,path:a,isReadonly:p,isHidden:l,Components:x}),i&&O?jsx("select",{onChange:J?se:E=>i(E.target.value),value:I.type,disabled:J,children:Object.keys(pt).map(E=>jsx("option",{value:E,children:E},E))}):null]})})};var Rn=(e,t)=>e.map((n,o)=>r=>t(()=>{let s=[...e];return s[o]=ie(r)(n),s}));var En=({path:e=[],isReadonly:t=()=>!1,isHidden:n=()=>!1,data:o,set:r,Components:s})=>{let i=Rn(o,r);return jsx(Fragment,{children:o.map((a,p)=>{let l=[...e,p];return jsx(fe,{path:l,isReadonly:t,isHidden:n,data:a,set:i[p],Components:s},l.join(""))})})};var N=e=>Number.isInteger(e),lt=e=>{if(N(e))return e;throw new Fe(e)},rs,Ce=class extends Number{constructor(n,o){super(n/o);this[rs]=()=>this.numerator/this.denominator;if(o===0)throw new Error("Denominator cannot be zero");this.numerator=lt(n),this.denominator=lt(o);}};rs=Symbol.toPrimitive;var Fe=class extends Error{constructor(t){super(`Could not parse integer from ${JSON.stringify(t)}`);}},ct=Object.assign(e=>lt(e),{from:e=>pipe(e,String,parseFloat,t=>N(t)?{value:t,error:null,round:null,upper:null,lower:null,ratio:null}:{value:null,error:new Fe(e),round:Math.round(t),upper:Math.ceil(t),lower:Math.floor(t),ratio:null}),formula:e=>t=>e(t)});new Ce(1,2);[new Ce(1,2)];({a:new Ce(1,2)});function ye(e){return T({$ref:isString})(e)}({$defs:{colorChannel:{type:"integer",minimum:ct(0),maximum:ct(255)},color:{type:"object",properties:{red:{$ref:"#/$defs/colorChannel"},green:{$ref:"#/$defs/colorChannel"},blue:{$ref:"#/$defs/colorChannel"}}}},type:"array",items:{$ref:"#/$defs/color"}});var Me=({refNode:{$ref:e},refMap:t={},root:n})=>{if(typeof n=="boolean")throw new TypeError("The root is a boolean and cannot be indexed");if(e in t)return {node:t[e],refMap:t};let[o,...r]=e.split("/"),s=Xt(n,r);if(s instanceof Error)throw s;let i=s.found;for(;ye(i);){let a=Me({refNode:i,refMap:t,root:n});i=a.node,t=a.refMap;}if(k(i))return {node:i,refMap:u(c({},t),{[e]:i})};throw new TypeError("The refNode is not a JsonSchema")};var wn=["date-time","date","email","hostname","ipv4","ipv6","regex","time","uri-reference","uri-template","uri","uuid"];var An=[...nn,"integer"];[...An,"any","never"];var Jn={type:R("string"),enum:f(w(isString)),minLength:f(N),maxLength:f(N),pattern:f(isString),format:f(nt(wn))};function mt(e){return T(Jn)(e)}var vn={type:R("number"),enum:f(w(isNumber)),minimum:f(isNumber),maximum:f(isNumber),exclusiveMinimum:f(isNumber),exclusiveMaximum:f(isNumber),multipleOf:f(isNumber)};function In(e){return T(vn)(e)}var jn={type:R("integer"),enum:f(w(N)),minimum:f(N),maximum:f(N),exclusiveMinimum:f(N),exclusiveMaximum:f(N),multipleOf:f(N)};function Ln(e){return T(jn)(e)}var _n={type:R("boolean"),enum:f(w(isBoolean))};function Pn(e){return T(_n)(e)}var Bn={type:R("null")};function Fn(e){return T(Bn)(e)}var Mn={type:R("object"),properties:f(pe(isString,k)),required:f(w(isString)),additionalProperties:f(k),propertyNames:f(mt),minProperties:f(N),maxProperties:f(N),dependentSchemas:f(pe(isString,k))};function Ke(e){return T(Mn)(e)}var Dn={type:R("array"),items:f(Ne(k).or(w(k))),minItems:f(N),maxItems:f(N),uniqueItems:f(isBoolean)};function Kn(e){return T(Dn)(e)}var is={anyOf:w(k)};function Wn(e){return T(is)(e)}var as={oneOf:w(k)};function ps(e){return T(as)(e)}var ls={allOf:w(k)};function Hn(e){return T(ls)(e)}var cs={if:k,then:f(k),else:f(k)};function $n(e){return T(cs)(e)}var ms={not:k};function Vn(e){return T(ms)(e)}var us=u(c(c(c(c(c(c(c({},Dn),_n),jn),Bn),vn),Mn),Jn),{type:w(nt(An)),enum:f(w(ot.or(N).or(isBoolean).or(isNumber).or(isString)))});function ds(e){return T(us)(e)}var fs=ot.or(Kn).or(Pn).or($n).or(ps).or(Ln).or(Hn).or(ds).or(Vn).or(Fn).or(In).or(Ke).or(mt).or(Wn);var ys=T({$id:f(isString),$schema:f(isString)}),bs=sn.and(fs).and(ys);function k(e){return Ne(bs).or(isBoolean).or(ye)(e)}var Un=e=>{try{return e.flatMap(t=>{switch(typeof t){case"string":return ["properties",t];case"number":return ["items",t];case"symbol":throw new TypeError(`The key ${String(t)} is not a valid JSON key; expected string or number, got symbol`);default:throw new TypeError(`The key ${t} is not a valid JSON key; expected string or number, got ${typeof t}`)}})}catch(t){if(t instanceof TypeError)return t;throw t}};var zn=e=>{if(typeof e=="boolean")throw new Error("The schema does not contain subSchemas");return t=>{let n=Un(t);if(n instanceof Error)return n;if(typeof e=="boolean")return new TypeError("The schema is not a JsonSchema");let{node:o,refMap:r}=n.reduce(({node:i,refMap:a=void 0},p)=>(console.log({node:i,key:p}),ye(i)?Me({refNode:i,root:e,refMap:a}):{node:i[p],refMap:a}),{node:e,refMap:void 0});if(o instanceof Error)throw o;let s=o;for(;ye(s);)console.log({subSchema:s}),s=Me({refNode:s,root:e,refMap:r}).node;if(console.log({subSchema:s}),k(s))return s;throw new TypeError("The subSchema is not a JsonSchema")}};var Yn=e=>e==="true",qn=e=>Number(e),Xn=e=>e.split(","),Gn=e=>{try{return JSON.parse(e)}catch(t){return {[e]:e}}},Zn=e=>JSON.stringify(e),Qn=e=>e.true===!0,eo=e=>{var t,n,o;return Number((o=(n=(t=e.number)!=null?t:e.size)!=null?n:e.count)!=null?o:0)},to=e=>Object.entries(e),no=e=>e.toString(),oo=e=>+e,ro=e=>({[e.toString()]:e}),so=e=>[e],io=e=>e.toString(),ao=e=>e===1,po=e=>({number:e}),lo=e=>Array(e).fill(null),co=e=>e.join(","),mo=e=>e.length,uo=e=>typeof e[0]=="boolean"?e[0]:e.length>0,fo=e=>e.reduce((t,n,o)=>(t[`${o}`]=n,t),{}),yo=()=>"",bo=()=>0,xo=()=>!1,go=()=>[],ho=()=>({});var To=e=>{let t=me(e);return {to:{array:()=>{switch(t.type){case"array":return t.data;case"object":return to(t.data);case"string":return Xn(t.data);case"boolean":return so(t.data);case"number":return lo(t.data);case"null":return go()}},boolean:()=>{switch(t.type){case"array":return uo(t.data);case"object":return Qn(t.data);case"string":return Yn(t.data);case"boolean":return t.data;case"number":return ao(t.data);case"null":return xo()}},number:()=>{switch(t.type){case"array":return mo(t.data);case"object":return eo(t.data);case"string":return qn(t.data);case"boolean":return oo(t.data);case"number":return t.data;case"null":return bo()}},object:()=>{switch(t.type){case"array":return fo(t.data);case"object":return t.data;case"string":return Gn(t.data);case"boolean":return ro(t.data);case"number":return po(t.data);case"null":return ho()}},string:()=>{switch(t.type){case"array":return co(t.data);case"object":return Zn(t.data);case"string":return t.data;case"boolean":return no(t.data);case"number":return io(t.data);case"null":return yo()}},null:()=>null}}};var So=(e,t)=>ae(e,(n,o)=>r=>t(u(c({},e),{[o]:ie(r)(n[o])}))),Oo=(e,t,n)=>ae(e,(o,r)=>s=>Object.hasOwn(e,s)?null:t(()=>{let i=Object.entries(e),a=i.findIndex(([l])=>l===r);i[a]=[s,o];let p=n.current;return n.current=u(c({},p),{[s]:p[r]}),Object.fromEntries(i)})),No=(e,t)=>ae(e,(n,o)=>()=>t(()=>{let i=e;return ve(i,[Pt(o)])})),ko=(e,t)=>ae(e,(n,o)=>r=>t(()=>u(c({},e),{[o]:To(n).to[r]()}))),Ro=(e,t)=>(n,o)=>r=>t(u(c({},e),{[n]:r!=null?r:on[o]})),Co=(e,t,n)=>()=>{let o=Object.keys(e).sort(n),r={};o.forEach(s=>r[s]=e[s]),t(r);};var hs=({addProperty:e,disabled:t,propertyKey:n,Components:o})=>jsxs(o.MissingPropertyWrapper,{children:[jsx(C,{disabled:!0,defaultValue:n})," ",jsx(C,{disabled:!0,defaultValue:"is missing"}),jsx(o.Button,{onClick:()=>e(),disabled:t,children:"+"})]}),Eo=({schema:e,path:t=[],isReadonly:n=()=>!1,isHidden:o=()=>!1,data:r,set:s,Components:i})=>{var he;let a=n(t),p=useRef(Object.keys(r).reduce((b,B)=>(b[B]=B,b),{})),l=So(r,s),m=Oo(r,s,p),d=No(r,s),y=ko(r,s),x=Co(r,s),O=Ro(r,s),I=v(e)?zn(e)(t):!0,j=R(!0)(I)?!0:Ke(I)?Object.keys((he=I.properties)!=null?he:{}):[],J=Object.keys(r),[E,re]=J.reduce(([b,B],h)=>j===!0||j.includes(h)?[b,[...B,h]]:[[...b,h],B],[[],[]]),ge=j===!0?[]:j.filter(b=>!J.includes(b));return jsxs(Fragment,{children:[jsx(i.Button,{onClick:()=>x(),disabled:a,children:"Sort"}),jsxs(i.ObjectWrapper,{children:[jsx("div",{className:"json_editor_properties",children:[...ge,...re,...E].map(b=>{let B=p.current[b],h=[...t,b],Ae=[...t,B],Ye=j===!0||j.includes(b);return ge.includes(b)?jsx(hs,{propertyKey:b,addProperty:O(b,"string"),disabled:a,Components:i},b+"IsMissing"):jsx(fe,{schema:e,path:h,name:b,isReadonly:n,isHidden:o,data:r[b],set:l[b],rename:m[b],remove:d[b],recast:y[b],className:`json_editor_property ${Ye?"json_editor_official":"json_editor_unofficial"}`,Components:i},Ae.join("."))})}),jsx(i.Button,{onClick:a?se:()=>O("new_property","string")(),disabled:a,children:"+"})]})]})};var wo=({data:e,set:t,Components:n})=>jsx(n.BooleanWrapper,{children:jsx("input",{type:"checkbox",checked:e,onChange:o=>t(o.target.checked)})}),Ao=({Components:e})=>jsx(e.NullWrapper,{children:'" "'}),Jo=({path:e=[],isReadonly:t=()=>!1,data:n,set:o,Components:r})=>jsx(r.NumberWrapper,{children:jsx(Sn,{value:n,set:t(e)?void 0:s=>o(Number(s)),autoSize:!0})}),vo=({path:e=[],isReadonly:t=()=>!1,data:n,set:o,Components:r})=>jsx(r.StringWrapper,{children:jsx(On,{value:n,set:t(e)?void 0:o,autoSize:!0})});var Io=({error:e,errorInfo:t})=>{var r,s;let n=t==null?void 0:t.componentStack.split(" ").filter(Boolean)[2],o=(s=(r=e==null?void 0:e.toString())!=null?r:t==null?void 0:t.componentStack)!=null?s:"Unknown error";return jsx("div",{"data-testid":"error-boundary",style:{flex:"1",background:"black",backgroundImage:"url(./src/assets/kablooey.gif)",backgroundPosition:"center",backgroundSize:"overlay"},children:jsx("div",{style:{margin:"50px",marginTop:"0",padding:"50px",border:"1px solid dashed"},children:jsxs("span",{style:{background:"black",color:"white",padding:10,paddingTop:5},children:["\u26A0\uFE0F ",jsx("span",{style:{color:"#fc0",fontWeight:700},children:n})," \u26A0\uFE0F ",o]})})})};var We=class extends Component{constructor(t){super(t),this.state={};}componentDidCatch(t,n){var o,r;(r=(o=this.props).onError)==null||r.call(o,t,n),this.setState({error:t,errorInfo:n});}render(){let{error:t,errorInfo:n}=this.state,{children:o,Fallback:r=Io}=this.props;return n?jsx(r,{error:t,errorInfo:n}):o}};var jo={ErrorBoundary:({children:e})=>jsx(We,{children:e}),Button:({onClick:e,children:t,disabled:n})=>jsx("button",{type:"button",className:"json_editor_button",onClick:e,disabled:n,children:t}),EditorWrapper:({children:e,customCss:t,className:n})=>jsx("div",{className:"json_editor "+n,css:t,children:e}),EditorLayout:({DeleteButton:e,Header:t,KeyInput:n,TypeSelect:o,ValueEditor:r,Wrapper:s})=>jsxs(s,{children:[e&&jsx(e,{}),t&&jsx(t,{}),n&&jsx(n,{}),o&&jsx(o,{}),jsx(r,{})]}),ArrayWrapper:({children:e})=>jsx("div",{className:"json_editor_array",children:e}),ObjectWrapper:({children:e})=>jsx("div",{className:"json_editor_object",children:e}),StringWrapper:({children:e})=>jsx("span",{className:"json_editor_string",children:e}),NumberWrapper:({children:e})=>jsx("span",{className:"json_editor_number",children:e}),BooleanWrapper:({children:e})=>jsx("span",{className:"json_editor_boolean",children:e}),NullWrapper:({children:e})=>jsx("span",{className:"json_editor_null",children:e}),MissingPropertyWrapper:({children:e})=>jsx("div",{className:"json_editor_property json_editor_missing",children:e}),MiscastPropertyWrapper:({children:e})=>jsx("div",{className:"json_editor_property json_editor_miscast",children:e}),IllegalPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_illegal",children:e}),OfficialPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_official",children:e}),UnofficialPropertyWrapper:({children:e})=>jsx("span",{className:"json_editor_property json_editor_unofficial",children:e}),DeleteIcon:()=>jsx("span",{className:"json_editor_icon json_editor_delete",children:"x"}),KeyWrapper:({children:e})=>jsx("span",{className:"json_editor_key",children:e})};var ft=({data:e,set:t,schema:n=!0,name:o,rename:r,remove:s,isReadonly:i=()=>!1,isHidden:a=()=>!1,className:p,customCss:l,Header:m,Components:d={}})=>{let y=c(c({},jo),d),x=new Rs({allErrors:!0,verbose:!0});useMemo(()=>x.compile(n),[n])(e);return jsx(fe,{data:e,set:t,name:o,schema:n,rename:r,remove:s,path:[],isReadonly:i,isHidden:a,className:p,customCss:l,Header:m,Components:y})};var pt={array:En,boolean:wo,null:Ao,number:Jo,object:Eo,string:vo};function Lo(e){let t=0;for(let o=0;o<e.length;o++){let r=e.charCodeAt(o);t=(t<<5)-t+r,t|=0;}let n=(t&16777215).toString(16);for(;n.length<6;)n="0"+n;return `#${n}`}var $={R:.3,G:.5,B:.2};var _o=[{sat:255,hue:0},{sat:255,hue:360}];var ws=e=>`#${Object.values(e).map(t=>{let n=t.toString(16);return n.length===1&&(n=0+n),n}).join("")}`,Po=ws;var Ee=e=>{let n=Z(0,360)(e)/60,o=Math.floor(n),r=n-o,s=r,i=1-r;switch(o){case 0:return [1,s,0];case 1:return [i,1,0];case 2:return [0,1,s];case 3:return [0,i,1];case 4:return [s,0,1];case 5:return [1,0,i];default:throw new Error(`invalid hue served: ${e}`)}};var As=({R:e,G:t,B:n})=>{let o=0;return e>t&&t>=n&&(o=60*(0+(t-n)/(e-n))),t>=e&&e>n&&(o=60*(2-(e-n)/(t-n))),t>n&&n>=e&&(o=60*(2+(n-e)/(t-e))),n>=t&&t>e&&(o=60*(4-(t-e)/(n-e))),n>e&&e>=t&&(o=60*(4+(e-t)/(n-t))),e>=n&&n>t&&(o=60*(6-(n-t)/(e-t))),o},yt=As;var Js=({R:e,G:t,B:n})=>$.R*e/255+$.G*t/255+$.B*n/255,te=Js;var bt=(e,t)=>{let n=255,o=Z(0,360)(e);for(let r=-1,s=0;s<t.length;r++,s++){r=Z(0,t.length)(r);let i=r>s?Z(-180,180)(o):void 0,a=t[r],p=t[s],l=r>s?Z(-180,180)(a.hue):a.hue,m=p.hue;if((i||o)>=l&&(i||o)<m){let d=i||o;d-=l,d/=m-l,d*=p.sat-a.sat,d+=a.sat,n=d;}}return n};var vs=({R:e,G:t,B:n})=>Math.max(e,t,n)-Math.min(e,t,n),xt=vs;var gt=e=>{let[t,n,o]=Ee(e),r=$.R*t,s=$.G*n,i=$.B*o;return r+s+i};var Is=e=>{let t=Ee(e);return o=>{let r=s=>Math.round(t[s]*o);return {R:r(0),G:r(1),B:r(2)}}},js=({minChannels:e,trueLuminosity:t,minLum:n})=>{let{max:o,round:r}=Math,s=255-o(...Object.values(e)),i=F(0,s)(r((t-n)*255));return {R:e.R+i,G:e.G+i,B:e.B+i}},Ls=({hue:e,sat:t,lum:n,prefer:o="lum"},r=_o)=>{let s=Is(e),i,a,p,l,m,d=0,y=1,x=bt(e,r);switch(o){case"sat":i=F(0,255)(Math.min(t,x)),p=s(i),l={R:p.R+255-i,G:p.G+255-i,B:p.B+255-i},d=te(p),y=te(l),a=F(d,y)(n);break;case"lum":a=F(0,1)(n),m=gt(e),x=Math.min(x,Math.round(a<=m?255*(a/m):255*(1-a)/(1-m))),i=Math.min(t,x),p=s(i),d=te(p);break}return {channels:js({minChannels:p,trueLuminosity:a,minLum:d}),fix:{sat:i,lum:a},limit:{sat:[0,x],lum:[o==="lum"?0:d,y]}}},Bo=Ls;var _s=({hue:e,sat:t,lum:n,prefer:o},r)=>{let{channels:s,fix:i,limit:a}=Bo({hue:e,sat:t,lum:n,prefer:o},r),{R:p,G:l,B:m}=s;return {hex:Po({R:p,G:l,B:m}),fix:i,limit:a}},ht=_s;var Ps=({hue:e,sat:t,lum:n,prefer:o},r)=>{let{hex:s}=ht({hue:e,sat:t,lum:n,prefer:o},r);return s},D=Ps;var Bs=({R:e,G:t,B:n})=>{let o=yt({R:e,G:t,B:n}),r=xt({R:e,G:t,B:n}),s=te({R:e,G:t,B:n});return {hue:o,sat:r,lum:s}},Tt=Bs;var Fs="[a-fA-F0-9]+",Ms=e=>{let t=e.split("");return [0,0,1,1,2,2].map(o=>t[o]).join("")},Ds=e=>{let t=e.replace(/^#/,""),n=t.length===6||t.length===3,o=t.match(new RegExp(`^${Fs}$`))!==null;if(!(n&&o))throw new Error(`${e} is not a valid hex code`);return t.length===3?Ms(t):t},St=Ds;var Ot=e=>{let t=St(e);return {R:parseInt(t.slice(0,2),16),G:parseInt(t.slice(2,4),16),B:parseInt(t.slice(4,6),16)}};var Ks=e=>{let{R:t,G:n,B:o}=Ot(e),{hue:r,sat:s,lum:i}=Tt({R:t,G:n,B:o});return {hue:r,sat:s,lum:i}},ne=Ks;var Nt=e=>u(c({},e),{lum:e.lum>.666?0:1});var Do=e=>t=>u(c({},t),{lum:t.lum>.666?t.lum-e:t.lum+e});var Ko={hue:0,lum:0,sat:0,prefer:"lum"};var Mo=e=>typeof e=="object"&&e!==null&&typeof e.hue=="number"&&typeof e.sat=="number"&&typeof e.lum=="number"&&["sat","lum"].includes(e.prefer);Wt(Mo)(Ko);var Vs=["Red","Orange","Yellow","Lime","Green","Teal","Cyan","Blue","Indigo","Violet","Magenta","Pink"];Vs.reduce((e,t,n)=>(e[t]={hue:n*30,sat:255,lum:.5,prefer:"sat"},e),{});var Ct=({id:e})=>{let[t,n]=Wo.useState(!1),{refs:o,floatingStyles:r,context:s}=useFloating({open:t,onOpenChange:n,placement:"bottom-start"}),i=useClick(s),{getReferenceProps:a,getFloatingProps:p}=useInteractions([i]),l=Lo(e),m=pipe(l,ne,Nt,D),d=pipe(l,ne,Do(.25),D),y=pipe(d,ne,Nt,D);return jsxs(Fragment,{children:[jsx("span",u(c({role:"content",ref:o.setReference},a()),{style:{background:l,cursor:"pointer",padding:"0px 4px",color:m,userSelect:"none",whiteSpace:"nowrap"},children:e.substring(0,3)})),t&&jsx(FloatingPortal,{children:jsx("span",u(c({role:"popup",ref:o.setFloating},p()),{style:u(c({},r),{color:y,background:d,padding:"0px 4px",boxShadow:"0px 2px 10px rgba(0, 0, 0, 0.1)"}),children:e}))})]})};var Ho={};var $o=e=>{let t=new Set,n=Object.entries(e.data.relations).sort(([o,r],[s,i])=>i.length-r.length).filter(([o,r])=>{if(t.has(o))return !1;t.add(o);for(let s of r)t.add(s);return !0});return jsx("article",{className:Ho.class,children:n.map(([o,r])=>jsxs("section",{children:[jsx("span",{children:jsx(Ct,{id:o})}),":",jsx("span",{children:r.map(s=>jsx(Ct,{id:s}))})]}))})};var ni=({token:e})=>{let[t,n]=useIO(e);return q(t)?jsx(ft,{data:t,set:n,schema:!0}):t instanceof de?jsx($o,{data:t,set:n}):jsx("div",{className:"json_editor",children:jsx(C,{value:t instanceof Set?`Set { ${JSON.stringify([...t]).slice(1,-1)} }`:t instanceof Map?"Map "+JSON.stringify([...t]):Object.getPrototypeOf(t).constructor.name+" "+Vt(()=>JSON.stringify(t),"?"),disabled:!0})})},oi=({token:e})=>{let t=useO(e);return q(t)?jsx(ft,{data:t,set:()=>null,schema:!0,isReadonly:()=>!0}):jsx("div",{className:"json_editor",children:jsx(C,{value:t instanceof Set?"Set "+JSON.stringify([...t]):t instanceof Map?"Map "+JSON.stringify([...t]):Object.getPrototypeOf(t).constructor.name+" "+JSON.stringify(t),disabled:!0})})},Et=({token:e})=>e.type==="readonly_selector"?jsx(oi,{token:e}):jsx(ni,{token:e});var At=selectorFamily({key:"\u{1F441}\u200D\u{1F5E8} State Type",get:e=>({get:t})=>{let n;try{n=t(e);}catch(o){return "error"}return n===void 0?"undefined":q(n)?me(n).type:Object.getPrototypeOf(n).constructor.name}}),si=({node:e,isOpenState:t,typeState:n})=>{var p,l;let[o,r]=useIO(t),s=useO(e),i=useO(n),a=!!vt.refine(s);return jsxs(Fragment,{children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:o&&!a,setIsOpen:r,disabled:a}),jsxs("label",{onClick:()=>console.log(e,getState(e)),onKeyUp:()=>console.log(e,getState(e)),children:[jsx("h2",{children:(l=(p=e.family)==null?void 0:p.subKey)!=null?l:e.key}),jsxs("span",{className:"type detail",children:["(",i,")"]})]}),a?jsx(Et,{token:e}):null]}),o&&!a?jsx("main",{children:jsx(Et,{token:e})}):null]})},ii=({node:e,isOpenState:t})=>{let[n,o]=useIO(t);return Object.entries(e.familyMembers).forEach(([r,s])=>{V(r),At(s);}),jsxs(Fragment,{children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:n,setIsOpen:o}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsx("span",{className:"type detail",children:" (family)"})]})]}),n?Object.entries(e.familyMembers).map(([r,s])=>jsx(zo,{node:s,isOpenState:V(s.key),typeState:At(s)},r)):null]})},zo=({node:e,isOpenState:t,typeState:n})=>e.key.startsWith("\u{1F441}\u200D\u{1F5E8}")?null:jsx("section",{className:"node state",children:"type"in e?jsx(si,{node:e,isOpenState:t,typeState:n}):jsx(ii,{node:e,isOpenState:t})}),Jt=({tokenIndex:e})=>{let t=useO(e);return jsx("article",{className:"index state_index",children:Object.entries(t).filter(([n])=>!n.startsWith("\u{1F441}\u200D\u{1F5E8}")).sort().map(([n,o])=>jsx(zo,{node:o,isOpenState:V(o.key),typeState:At(o)},n))})};var ai=({atomUpdate:e})=>jsxs("article",{className:"node atom_update",onClick:()=>console.log(e),onKeyUp:()=>console.log(e),children:[jsxs("span",{className:"detail",children:[e.key,": "]}),jsx("span",{children:jsx("span",{className:"summary",children:Xo.diff(e.oldValue,e.newValue).summary})})]},e.key),pi=({serialNumber:e,transactionUpdate:t})=>jsxs("article",{className:"node transaction_update",children:[jsx("header",{children:jsx("h4",{children:e})}),jsxs("main",{children:[jsxs("section",{className:"transaction_params",children:[jsx("span",{className:"detail",children:"params: "}),t.params.map((n,o)=>jsxs("article",{className:"node transaction_param",onClick:()=>console.log(t),onKeyUp:()=>console.log(t),children:[jsxs("span",{className:"detail",children:[ce(n),": "]}),jsx("span",{className:"summary",children:typeof n=="object"&&n!==null&&"type"in n&&"target"in n?jsx(Fragment,{children:JSON.stringify(n.type)}):jsx(Fragment,{children:JSON.stringify(n)})})]},"param"+o))]}),jsxs("section",{className:"node transaction_output",children:[jsx("span",{className:"detail",children:"output: "}),jsx("span",{className:"detail",children:ce(t.output)}),t.output?jsxs("span",{className:"summary",children:[": ",JSON.stringify(t.output)]}):null]}),jsxs("section",{className:"transaction_impact",children:[jsx("span",{className:"detail",children:"impact: "}),t.atomUpdates.filter(n=>!n.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((n,o)=>jsx(U.AtomUpdate,{serialNumber:o,atomUpdate:n},`${t.key}:${o}:${n.key}`))]})]})]}),li=({timelineUpdate:e})=>jsxs("article",{className:"node timeline_update",children:[jsx("header",{children:jsxs("h4",{children:[e.timestamp,": ",e.type," (",e.key,")"]})}),jsx("main",{children:e.type==="transaction_update"?e.atomUpdates.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((t,n)=>jsx(U.AtomUpdate,{serialNumber:n,atomUpdate:t},`${e.key}:${n}:${t.key}`)):e.type==="selector_update"?e.atomUpdates.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map((t,n)=>jsx(U.AtomUpdate,{serialNumber:n,atomUpdate:t},`${e.key}:${n}:${t.key}`)):e.type==="atom_update"?jsx(U.AtomUpdate,{serialNumber:e.timestamp,atomUpdate:e}):null})]}),U={AtomUpdate:ai,TransactionUpdate:pi,TimelineUpdate:li};var Go=()=>jsx("span",{className:"you_are_here",children:"you are here"}),fi=({token:e,isOpenState:t,timelineState:n})=>{let o=useO(n),[r,s]=useIO(t);return jsxs("section",{className:"node timeline_log",children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:r,setIsOpen:s}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsxs("span",{className:"detail length",children:["(",o.at,"/",o.history.length,")"]}),jsx("span",{className:"gap"}),jsxs("nav",{children:[jsx("button",{type:"button",onClick:()=>undo(e),disabled:o.at===0,children:"undo"}),jsx("button",{type:"button",onClick:()=>redo(e),disabled:o.at===o.history.length,children:"redo"})]})]})]}),r?jsx("main",{children:o.history.map((i,a)=>jsxs(Fragment$1,{children:[a===o.at?jsx(Go,{}):null,jsx(U.TimelineUpdate,{timelineUpdate:i}),a===o.history.length-1&&o.at===o.history.length?jsx(Go,{}):null]},i.key+a+o.at))}):null]})},Qo=()=>{let e=useO(er);return jsx("article",{className:"index timeline_index",children:e.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map(t=>jsx(fi,{token:t,isOpenState:V(t.key),timelineState:tr(t.key)},t.key))})};var bi=({token:e,isOpenState:t,logState:n})=>{let o=useO(n),[r,s]=useIO(t);return jsxs("section",{className:"node transaction_log",children:[jsxs("header",{children:[jsx(X.OpenClose,{isOpen:r,setIsOpen:s}),jsxs("label",{children:[jsx("h2",{children:e.key}),jsxs("span",{className:"detail length",children:["(",o.length,")"]})]})]}),r?jsx("main",{children:o.map((i,a)=>jsx(U.TransactionUpdate,{serialNumber:a,transactionUpdate:i},i.key+a))}):null]})},or=()=>{let e=useO(rr);return jsx("article",{className:"index transaction_index",children:e.filter(t=>!t.key.startsWith("\u{1F441}\u200D\u{1F5E8}")).map(t=>jsx(bi,{token:t,isOpenState:V(t.key),logState:sr(t.key)},t.key))})};var Ed=()=>{let e=useRef(null),[t,n]=useIO(mr),[o,r]=useIO(ur),s=useO(dr),i=useRef(!1);return jsxs(Fragment,{children:[jsx(motion.span,{ref:e,className:"atom_io_devtools_zone",style:{position:"fixed",top:0,left:0,right:0,bottom:0,pointerEvents:"none"}}),jsxs(motion.main,{drag:!0,dragConstraints:e,className:"atom_io_devtools",transition:spring,style:t?{}:{backgroundColor:"#0000",borderColor:"#0000",maxHeight:28,maxWidth:33},children:[t?jsxs(Fragment,{children:[jsxs(motion.header,{children:[jsx("h1",{children:"atom.io"}),jsx("nav",{children:s.map(a=>jsx("button",{type:"button",className:a===o?"active":"",onClick:()=>r(a),disabled:a===o,children:a},a))})]}),jsx(motion.main,{children:jsx(LayoutGroup,{children:o==="atoms"?jsx(Jt,{tokenIndex:lr}):o==="selectors"?jsx(Jt,{tokenIndex:cr}):o==="transactions"?jsx(or,{}):o==="timelines"?jsx(Qo,{}):null})})]}):null,jsx("footer",{children:jsx("button",{type:"button",onMouseDown:()=>i.current=!1,onMouseMove:()=>i.current=!0,onMouseUp:()=>{i.current||n(a=>!a);},children:"\u{1F441}\u200D\u{1F5E8}"})})]})]})};var {atomIndex:lr,selectorIndex:cr,transactionIndex:rr,findTransactionLogState:sr,timelineIndex:er,findTimelineState:tr}=attachIntrospectionStates(),mr=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools Are Open",default:!0,effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools Are Open")]}),ur=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Selection",default:"atoms",effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools View")]}),dr=atom({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Options",default:["atoms","selectors","transactions","timelines"],effects:[lazyLocalStorageEffect("\u{1F441}\u200D\u{1F5E8} Devtools View Options")]}),V=atomFamily({key:"\u{1F441}\u200D\u{1F5E8} Devtools View Is Open",default:!1,effects:e=>[lazyLocalStorageEffect(e+":view-is-open")]}),vt=new le({number:e=>typeof e=="number",string:e=>typeof e=="string",boolean:e=>typeof e=="boolean",null:e=>e===null}),Oi=new le({object:v,array:e=>Array.isArray(e)}),Xo=new je(vt,Oi,{number:Gt,string:Zt,boolean:Qt,null:()=>({summary:"No Change"}),object:tt,array:en});
17
+
18
+ export { Ed as AtomIODevtools, lr as atomIndex, mr as devtoolsAreOpenState, dr as devtoolsViewOptionsState, ur as devtoolsViewSelectionState, tr as findTimelineState, sr as findTransactionLogState, V as findViewIsOpenState, Oi as jsonTreeRefinery, Xo as prettyJson, vt as primitiveRefinery, cr as selectorIndex, er as timelineIndex, rr as transactionIndex };
19
+ //# sourceMappingURL=out.js.map
4643
20
  //# sourceMappingURL=index.mjs.map