jaxs 0.4.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jaxs.umd.cjs CHANGED
@@ -1,1153 +1 @@
1
- ;(function (m, f) {
2
- typeof exports == 'object' && typeof module < 'u'
3
- ? f(exports)
4
- : typeof define == 'function' && define.amd
5
- ? define(['exports'], f)
6
- : ((m = typeof globalThis < 'u' ? globalThis : m || self),
7
- f((m.jaxs = {})))
8
- })(this, function (m) {
9
- 'use strict'
10
- const f = (e, t) => t.createElement(e),
11
- nt = (e, t) => {
12
- for (const s in t) {
13
- if (s === '__self') continue
14
- const n = t[s].toString()
15
- s === 'value' ? (e.value = n) : e.setAttribute(s, n)
16
- }
17
- },
18
- rt = (e, t, s) => {
19
- const n = {}
20
- for (const r in t) {
21
- const o = t[r],
22
- a = (h) => s(o, h)
23
- e.addEventListener(r, a),
24
- (n[r] = { domEvent: r, busEvent: o, listener: a })
25
- }
26
- e.eventMaps = n
27
- },
28
- ot = (e, t, s, n) => {
29
- const r = f(e, n.document)
30
- return nt(r, t), rt(r, s, n.publish), r
31
- },
32
- y = 'http://www.w3.org/2000/svg',
33
- it = {
34
- animate: !0,
35
- animateMotion: !0,
36
- animateTransform: !0,
37
- circle: !0,
38
- clipPath: !0,
39
- defs: !0,
40
- desc: !0,
41
- ellipse: !0,
42
- feBlend: !0,
43
- feColorMatrix: !0,
44
- feComponentTransfer: !0,
45
- feComposite: !0,
46
- feConvolveMatrix: !0,
47
- feDiffuseLighting: !0,
48
- feDisplacementMap: !0,
49
- feDistantLight: !0,
50
- feDropShadow: !0,
51
- feFlood: !0,
52
- feFuncA: !0,
53
- feFuncB: !0,
54
- feFuncG: !0,
55
- feFuncR: !0,
56
- feGaussianBlur: !0,
57
- feImage: !0,
58
- feMerge: !0,
59
- feMergeNode: !0,
60
- feMorphology: !0,
61
- feOffset: !0,
62
- fePointLight: !0,
63
- feSpecularLighting: !0,
64
- feSpotLight: !0,
65
- feTile: !0,
66
- feTurbulence: !0,
67
- filter: !0,
68
- foreignObject: !0,
69
- g: !0,
70
- image: !0,
71
- line: !0,
72
- linearGradient: !0,
73
- marker: !0,
74
- mask: !0,
75
- metadata: !0,
76
- mpath: !0,
77
- path: !0,
78
- pattern: !0,
79
- polygon: !0,
80
- polyline: !0,
81
- radialGradient: !0,
82
- rect: !0,
83
- script: !0,
84
- set: !0,
85
- stop: !0,
86
- style: !0,
87
- svg: !0,
88
- switch: !0,
89
- symbol: !0,
90
- text: !0,
91
- textPath: !0,
92
- title: !0,
93
- tspan: !0,
94
- use: !0,
95
- view: !0,
96
- },
97
- ut = (e, t) => !!(it[e] || (e === 'a' && t === y)),
98
- at = (e, t, s) => {
99
- const n = s.createElementNS(y, e)
100
- for (const r in t)
101
- r === '__self' ||
102
- r === 'xmlns' ||
103
- n.setAttributeNS(null, r, t[r].toString())
104
- return n
105
- },
106
- ct = (e) => e.namespaceURI === y,
107
- ht = (e, t) => t.createTextNode(e)
108
- class lt {
109
- constructor(t) {
110
- this.value = t.toString()
111
- }
112
- render(t) {
113
- const s = ht(this.value, t.document)
114
- return (s.__jsx = 'TextNode'), [s]
115
- }
116
- }
117
- const dt = (e) => typeof e == 'string' || typeof e == 'number',
118
- pt = (e) => new lt(e),
119
- mt = (e) => (dt(e) ? pt(e) : e),
120
- ft = (e) => bt(e).map(mt).flat(),
121
- bt = (e) => (Array.isArray(e) ? e.flat() : e ? [e] : []),
122
- N = (e, t = {}) => e || t.children || [],
123
- vt = (e, t = '') => {
124
- const s = {},
125
- n = {}
126
- for (const r in e) {
127
- const o = e[r]
128
- if (r.match(/^on.+/i)) {
129
- const a = r.slice(2).toLowerCase()
130
- n[a] = o ? o.toString() : ''
131
- } else {
132
- if (o === !1) continue
133
- r === '__source' ? (s.__source = e.__source) : (s[r] = gt(r, o, t))
134
- }
135
- }
136
- return { attributes: s, events: n }
137
- },
138
- gt = (e, t, s = '') => (t == null ? s : t.toString()),
139
- yt = (e, t) => {
140
- const s = e || {},
141
- n = N(t, s)
142
- return (s.children = s.children || n), s
143
- },
144
- j = (e, t, s, n = []) => e.reduce(Et(t, s), n).flat(),
145
- Et = (e, t) => (s, n) =>
146
- n
147
- ? Array.isArray(n)
148
- ? j(n, e, t, s)
149
- : (n.render(e, t).forEach((r) => s.push(r)), s)
150
- : s
151
- class O {
152
- constructor(t) {
153
- this.collection = ft(t)
154
- }
155
- render(t, s) {
156
- this.parentElement = s
157
- const n = this.generateDom(t)
158
- return this.attachToParent(n), n
159
- }
160
- generateDom(t) {
161
- return j(this.collection, t, this.parentElement)
162
- }
163
- attachToParent(t) {
164
- if (this.parentElement === void 0) return
165
- const s = this.parentElement
166
- t.forEach((n) => s.appendChild(n))
167
- }
168
- }
169
- class xt {
170
- constructor(t, s) {
171
- ;(this.type = t), (this.attributes = s)
172
- }
173
- generate() {
174
- return (
175
- this.attributes.key ||
176
- this.sourceKey() ||
177
- this.createKeyFromAttributes()
178
- )
179
- }
180
- sourceKey() {
181
- if (this.attributes.__source) {
182
- const {
183
- fileName: t,
184
- lineNumber: s,
185
- columnNumber: n,
186
- } = this.attributes.__source
187
- return `${t}:${s}:${n}`
188
- }
189
- }
190
- createKeyFromAttributes() {
191
- const t = this.attributes.id ? `#${this.attributes.id}` : '',
192
- s = this.attributes.type ? `[type=${this.attributes.type}]` : '',
193
- n = this.attributes.name ? `[name=${this.attributes.name}]` : ''
194
- return `${this.type}${t}${s}${n}`
195
- }
196
- }
197
- class At {
198
- constructor(t, s, n = []) {
199
- this.type = t
200
- const { events: r, attributes: o } = vt(s)
201
- ;(this.events = r),
202
- (this.attributes = o),
203
- (this.isSvg = ut(this.type, this.attributes.xmlns)),
204
- (this.children = new O(n))
205
- }
206
- render(t) {
207
- const s = this.generateDom(t)
208
- return s ? (this.children.render(t, s), [s]) : []
209
- }
210
- generateDom(t) {
211
- return this.isSvg ? this.generateSvgDom(t) : this.generateHtmlDom(t)
212
- }
213
- generateHtmlDom(t) {
214
- const s = ot(this.type, this.attributes, this.events, t)
215
- return (s.__jsx = this.jsxKey()), s
216
- }
217
- generateSvgDom(t) {
218
- const s = at(this.type, this.attributes, t.document)
219
- return (s.__jsx = this.jsxKey()), s
220
- }
221
- jsxKey() {
222
- return new xt(this.type, this.attributes).generate()
223
- }
224
- }
225
- const k = (e, t, ...s) =>
226
- typeof e == 'string' ? new At(e, t, s) : e(yt(t, s))
227
- k.fragment = (e, t) => {
228
- const s = N(t, e)
229
- return new O(s)
230
- }
231
- class wt {
232
- constructor(t, s, n) {
233
- ;(this.template = t),
234
- (this.selector = s),
235
- (this.renderKit = n),
236
- (this.dom = [])
237
- }
238
- renderAndAttach(t) {
239
- ;(this.parentElement = this.getParentElement()),
240
- (this.dom = this.render({ ...t, parent: this.parentElement })),
241
- this.parentElement && this.attach()
242
- }
243
- render(t) {
244
- return this.template.render(t)
245
- }
246
- attach() {
247
- this.parentElement && (this.parentElement.innerHTML = ''),
248
- this.dom.forEach((t) => {
249
- this.parentElement && this.parentElement.appendChild(t)
250
- })
251
- }
252
- getParentElement() {
253
- return this.renderKit.document.querySelector(this.selector)
254
- }
255
- }
256
- const St = (e, t, s) => {
257
- const n = new wt(e, t, s)
258
- return n.renderAndAttach(s), n
259
- },
260
- M = 'go-to-href',
261
- b = 'navigation:location-change',
262
- $ = 'navigation:route-change',
263
- _t = Object.freeze(
264
- Object.defineProperty(
265
- {
266
- __proto__: null,
267
- linkNavigationEvent: M,
268
- locationChangeEvent: b,
269
- routeChangeEvent: $,
270
- },
271
- Symbol.toStringTag,
272
- { value: 'Module' },
273
- ),
274
- ),
275
- T = (e) => {
276
- e.createRecord('route', { host: '', path: '', query: {} })
277
- },
278
- F = (e) => {
279
- const t = e.closest('[href]')
280
- return (t && t.getAttribute('href')) || ''
281
- },
282
- D = (e, { publish: t, window: s }) => {
283
- s.history.pushState(null, '', e), t(b, null)
284
- },
285
- L = (e, t) => {
286
- if (!e || !e.target) return
287
- e.preventDefault()
288
- const s = F(e.target)
289
- D(s, t)
290
- },
291
- P = (e) =>
292
- e
293
- .replace(/^\?/, '')
294
- .split('&')
295
- .reduce((t, s) => {
296
- if (!s) return t
297
- const n = s.split('=')
298
- return (t[n[0]] = n[1]), t
299
- }, {}),
300
- B = (e, t) => {
301
- const { state: s, publish: n, window: r } = t,
302
- { host: o, pathname: a, search: h } = r.location,
303
- u = a,
304
- d = P(h),
305
- c = { host: o, path: u, query: d }
306
- s.store('route').update(c), n($, c)
307
- },
308
- U = (e) => {
309
- const { subscribe: t } = e
310
- t(M, L)
311
- },
312
- z = (e) => {
313
- const { publish: t, subscribe: s, state: n, window: r } = e
314
- T(n), r.addEventListener('popstate', () => t(b, null)), s(b, B)
315
- },
316
- V = (e) => {
317
- setTimeout(() => e.publish(b, null), 0)
318
- },
319
- K = (e) => {
320
- z(e), U(e), V(e)
321
- },
322
- Nt = Object.freeze(
323
- Object.defineProperty(
324
- {
325
- __proto__: null,
326
- publishLocation: V,
327
- startNavigation: K,
328
- subscribeToHistoryChange: z,
329
- subscribeToNavigation: U,
330
- },
331
- Symbol.toStringTag,
332
- { value: 'Module' },
333
- ),
334
- )
335
- class R {
336
- constructor({
337
- window: t,
338
- document: s,
339
- publish: n,
340
- subscribe: r,
341
- bus: o,
342
- state: a,
343
- renderKit: h,
344
- }) {
345
- ;(this.window = t),
346
- (this.document = s),
347
- (this.publish = n),
348
- (this.subscribe = r),
349
- (this.bus = o),
350
- (this.state = a),
351
- (this.renderKit = h),
352
- (this.roots = [])
353
- }
354
- render(t, s) {
355
- const n = St(t, s, this.renderKit)
356
- return this.roots.push(n), n
357
- }
358
- startNavigation() {
359
- K(this)
360
- }
361
- }
362
- const jt = Object.freeze(
363
- Object.defineProperty({ __proto__: null, App: R }, Symbol.toStringTag, {
364
- value: 'Module',
365
- }),
366
- )
367
- class q {
368
- constructor() {
369
- this.lookup = {}
370
- }
371
- add(t, s, n) {
372
- this.ensureArrayFor(t)
373
- const r = { listener: s, index: n, matcher: t }
374
- return this.lookup[t].push(r), () => this.remove(r)
375
- }
376
- remove(t) {
377
- this.lookup[t.matcher] &&
378
- (this.lookup[t.matcher] = this.lookup[t.matcher].reduce(
379
- (s, n) => (n !== t && s.push(n), s),
380
- [],
381
- ))
382
- }
383
- matches(t) {
384
- return this.lookup[t] || []
385
- }
386
- ensureArrayFor(t) {
387
- this.lookup[t] || (this.lookup[t] = [])
388
- }
389
- }
390
- class I {
391
- constructor() {
392
- this.lookup = []
393
- }
394
- add(t, s, n) {
395
- const r = { listener: s, index: n, matcher: t }
396
- return this.lookup.push(r), () => this.remove(r)
397
- }
398
- remove(t) {
399
- this.lookup = this.lookup.reduce((s, n) => (n !== t && s.push(n), s), [])
400
- }
401
- matches(t) {
402
- return this.lookup.filter((s) => s.matcher.test(t))
403
- }
404
- }
405
- class J {
406
- constructor() {
407
- ;(this.exactSubscriptions = new q()),
408
- (this.fuzzySubscriptions = new I()),
409
- (this.currentIndex = 0)
410
- }
411
- subscribe(t, s) {
412
- let n
413
- return (
414
- typeof t == 'string'
415
- ? (n = this.exactSubscriptions.add(t, s, this.currentIndex))
416
- : (n = this.fuzzySubscriptions.add(t, s, this.currentIndex)),
417
- (this.currentIndex += 1),
418
- n
419
- )
420
- }
421
- publish(t, s) {
422
- ;[
423
- ...this.exactSubscriptions.matches(t),
424
- ...this.fuzzySubscriptions.matches(t),
425
- ]
426
- .sort((r, o) => r.index - o.index)
427
- .forEach((r) => {
428
- r.listener(s, this.listenerOptions(t))
429
- })
430
- }
431
- addListenerOptions(t) {
432
- this.options = t
433
- }
434
- listenerOptions(t) {
435
- return { eventName: t, ...this.options, publish: this.publish.bind(this) }
436
- }
437
- }
438
- const H = () => {
439
- const e = new J()
440
- return {
441
- bus: e,
442
- publish: (n, r) => e.publish(n, r),
443
- subscribe: (n, r) => e.subscribe(n, r),
444
- }
445
- },
446
- Ot = Object.freeze(
447
- Object.defineProperty(
448
- {
449
- __proto__: null,
450
- ExactSubscriptions: q,
451
- FuzzySubscriptions: I,
452
- JaxsBus: J,
453
- createBus: H,
454
- },
455
- Symbol.toStringTag,
456
- { value: 'Module' },
457
- ),
458
- ),
459
- v = (e) => Array.isArray(e),
460
- E = (e) => e !== null && !v(e) && typeof e == 'object',
461
- kt = (e, t) => e === t,
462
- Mt = (e, t) => Object.keys(e).length === Object.keys(t).length,
463
- $t = (e, t) =>
464
- !(E(e) && E(t)) || !Mt(e, t)
465
- ? !1
466
- : Object.keys(e).every((s) => {
467
- const n = e[s],
468
- r = t[s]
469
- return x(n, r)
470
- }),
471
- Tt = (e, t) =>
472
- !(v(e) && v(t)) || e.length !== t.length
473
- ? !1
474
- : e.every((s, n) => {
475
- const r = t[n]
476
- return x(s, r)
477
- }),
478
- x = (e, t) => (E(e) ? $t(e, t) : v(e) ? Tt(e, t) : kt(e, t))
479
- class g {
480
- constructor(t) {
481
- this.store = t
482
- }
483
- update(t) {
484
- this.store.update(t)
485
- }
486
- reset() {
487
- this.store.update(this.store.initialState)
488
- }
489
- get value() {
490
- return this.store.value
491
- }
492
- addUpdaterFunction(t, s) {
493
- this.constructor.prototype[t] = (...n) => {
494
- const r = s(this.value, ...n)
495
- this.update(r)
496
- }
497
- }
498
- addUpdaterFunctions(t) {
499
- for (const s in t) this.addUpdaterFunction(s, t[s])
500
- }
501
- }
502
- class A extends g {
503
- addUpdaterFunction(t, s) {
504
- this.constructor.prototype[t] = (...n) => {
505
- const r = s(this.value, ...n)
506
- this.update(r)
507
- }
508
- }
509
- push(t) {
510
- const s = [...this.value, t]
511
- this.update(s)
512
- }
513
- pop() {
514
- const t = [...this.value],
515
- s = t.pop()
516
- return this.update(t), s
517
- }
518
- unshift(t) {
519
- const s = [t, ...this.value]
520
- this.update(s)
521
- }
522
- shift() {
523
- const t = [...this.value],
524
- s = t.shift()
525
- return this.update(t), s
526
- }
527
- addSorter(t, s) {
528
- this[t] = () => {
529
- this.sortBy(s)
530
- }
531
- }
532
- sortBy(t) {
533
- const s = [...this.value]
534
- s.sort(t), this.update(s)
535
- }
536
- insertAt(t, s) {
537
- const n = [...this.value]
538
- n.splice(t, 0, s), this.update(n)
539
- }
540
- }
541
- class w {
542
- constructor(t) {
543
- ;(this.name = t.name),
544
- (this.parent = t.parent),
545
- (this._value = t.value),
546
- (this.initialState = structuredClone(t.value)),
547
- (this.updater = new g(this))
548
- }
549
- get value() {
550
- return this._value
551
- }
552
- set value(t) {
553
- throw new Error('Cannot set value directly. Use an updater!')
554
- }
555
- update(t) {
556
- if (typeof t == 'function') {
557
- const s = this.getUpdatedValue(t)
558
- this.updateValue(s)
559
- } else this.updateValue(t)
560
- }
561
- updateValue(t) {
562
- x(this._value, t) || ((this._value = t), this.parent.notify(this.name))
563
- }
564
- getUpdatedValue(t) {
565
- return t(this.value)
566
- }
567
- addUpdaters(t) {
568
- this.updater.addUpdaterFunctions(t)
569
- }
570
- addUpdater(t, s) {
571
- this.updater.addUpdaterFunction(t, s)
572
- }
573
- addSorter(t, s) {
574
- this.updater instanceof A && this.updater.addSorter(t, s)
575
- }
576
- }
577
- class G extends g {
578
- toggle() {
579
- const t = !this.value
580
- this.update(t)
581
- }
582
- setTrue() {
583
- this.update(!0)
584
- }
585
- setFalse() {
586
- this.update(!1)
587
- }
588
- addUpdaterFunction(t, s) {
589
- this.constructor.prototype[t] = (...n) => {
590
- const r = s(this.value, ...n)
591
- this.update(r)
592
- }
593
- }
594
- }
595
- class C extends g {
596
- addUpdaterFunction(t, s) {
597
- this.constructor.prototype[t] = (...n) => {
598
- const r = s(this.value, ...n)
599
- this.update(r)
600
- }
601
- }
602
- updateAttribute(t, s) {
603
- const n = { ...this.value }
604
- ;(n[t] = s), this.update(n)
605
- }
606
- }
607
- const S = 'state'
608
- class Q {
609
- constructor(t) {
610
- ;(this.publisher = t),
611
- (this.stores = {}),
612
- (this.eventNamePrefix = S),
613
- (this.notifications = new Set()),
614
- (this.inTransaction = !1)
615
- }
616
- create(t, s) {
617
- const n = new w({ name: t, parent: this, value: s })
618
- return (this.stores[t] = n), n
619
- }
620
- createBoolean(t, s) {
621
- const n = this.create(t, s)
622
- return (n.updater = new G(n)), n
623
- }
624
- createRecord(t, s) {
625
- const n = this.create(t, s)
626
- return (n.updater = new C(n)), n
627
- }
628
- createList(t, s) {
629
- const n = this.create(t, s)
630
- return (n.updater = new A(n)), n
631
- }
632
- store(t) {
633
- return this.stores[t] || new w({ name: t, parent: this, value: void 0 })
634
- }
635
- get(t) {
636
- return this.store(t).value
637
- }
638
- getAll(t) {
639
- return t.reduce((s, n) => ((s[n] = this.get(n)), s), {})
640
- }
641
- notify(t) {
642
- this.inTransaction ? this.notifications.add(t) : this.publish(t)
643
- }
644
- update(t, s) {
645
- this.store(t).update(s)
646
- }
647
- transaction(t) {
648
- ;(this.inTransaction = !0),
649
- t(this.stores),
650
- (this.inTransaction = !1),
651
- this.publishAll()
652
- }
653
- publishAll() {
654
- this.notifications.forEach((t) => {
655
- this.publish(t)
656
- }),
657
- this.notifications.clear()
658
- }
659
- publish(t) {
660
- this.publisher(this.event(t), { state: this, store: this.store(t) })
661
- }
662
- event(t) {
663
- return `${this.eventNamePrefix}:${t}`
664
- }
665
- }
666
- const W = (e) => new Q(e),
667
- Ft = Object.freeze(
668
- Object.defineProperty(
669
- {
670
- __proto__: null,
671
- State: Q,
672
- Store: w,
673
- StoreUpdaterBoolean: G,
674
- StoreUpdaterList: A,
675
- StoreUpdaterObject: C,
676
- createState: W,
677
- eventName: S,
678
- },
679
- Symbol.toStringTag,
680
- { value: 'Module' },
681
- ),
682
- )
683
- class Dt {
684
- constructor(t) {
685
- this.setupDomEnvironment(t)
686
- }
687
- setup() {
688
- return (
689
- this.setupBus(),
690
- this.setupState(),
691
- this.addBusOptions(),
692
- this.setRenderKit(),
693
- new R({
694
- window: this.window,
695
- document: this.document,
696
- publish: this.publish,
697
- subscribe: this.subscribe,
698
- bus: this.bus,
699
- state: this.state,
700
- renderKit: this.renderKit,
701
- })
702
- )
703
- }
704
- setupDomEnvironment(t) {
705
- t.window
706
- ? ((this.window = t.window), (this.document = this.window.document))
707
- : t.document
708
- ? ((this.window = t.document.defaultView),
709
- (this.document = t.document))
710
- : ((this.window = window), (this.document = document))
711
- }
712
- setupBus() {
713
- const { publish: t, subscribe: s, bus: n } = H()
714
- ;(this.publish = t), (this.subscribe = s), (this.bus = n)
715
- }
716
- setupState() {
717
- this.state = W(this.publish)
718
- }
719
- addBusOptions() {
720
- this.bus.addListenerOptions({
721
- state: this.state,
722
- document: this.document,
723
- window: this.window,
724
- })
725
- }
726
- setRenderKit() {
727
- this.renderKit = {
728
- publish: this.publish,
729
- subscribe: this.subscribe,
730
- state: this.state,
731
- document: this.document,
732
- window: this.window,
733
- }
734
- }
735
- }
736
- const Lt = (e = {}) => {
737
- const s = new Dt(e).setup()
738
- return s.startNavigation(), s
739
- }
740
- var i = ((e) => (
741
- (e[(e.removeNode = 0)] = 'removeNode'),
742
- (e[(e.insertNode = 1)] = 'insertNode'),
743
- (e[(e.replaceNode = 2)] = 'replaceNode'),
744
- (e[(e.removeAttribute = 3)] = 'removeAttribute'),
745
- (e[(e.addAttribute = 4)] = 'addAttribute'),
746
- (e[(e.updateAttribute = 5)] = 'updateAttribute'),
747
- (e[(e.removeEvent = 6)] = 'removeEvent'),
748
- (e[(e.addEvent = 7)] = 'addEvent'),
749
- (e[(e.updateEvent = 8)] = 'updateEvent'),
750
- (e[(e.changeValue = 9)] = 'changeValue'),
751
- (e[(e.changeText = 10)] = 'changeText'),
752
- e
753
- ))(i || {})
754
- const Pt = Object.freeze(
755
- Object.defineProperty(
756
- { __proto__: null, ChangeInstructionTypes: i },
757
- Symbol.toStringTag,
758
- { value: 'Module' },
759
- ),
760
- ),
761
- Bt = (e, t) => ({ source: e, target: t, type: i.changeText, data: {} }),
762
- Ut = (e, t) => ({ source: e, target: t, type: i.replaceNode, data: {} }),
763
- zt = (e, t, s) => ({
764
- source: e,
765
- target: t,
766
- data: s,
767
- type: i.removeAttribute,
768
- }),
769
- Vt = (e, t, s) => ({ source: e, target: t, data: s, type: i.addAttribute }),
770
- Kt = (e, t, s) => ({
771
- source: e,
772
- target: t,
773
- data: s,
774
- type: i.updateAttribute,
775
- }),
776
- Rt = (e, t, s) => ({ source: e, target: t, data: s, type: i.removeEvent }),
777
- qt = (e, t, s) => ({ source: e, target: t, data: s, type: i.addEvent }),
778
- It = (e, t, s) => ({ source: e, target: t, data: s, type: i.updateEvent }),
779
- X = (e) => ({ source: e, target: e, type: i.removeNode, data: {} }),
780
- _ = (e, t) => ({ target: e, source: e, type: i.insertNode, data: t }),
781
- Jt = (e, t, s) => ({ source: e, target: t, type: i.changeValue, data: s }),
782
- Ht = (e, t) => (e.type > t.type ? 1 : e.type < t.type ? -1 : 0),
783
- Y = { index: -1 }
784
- class Gt {
785
- constructor() {
786
- this.map = {}
787
- }
788
- populate(t) {
789
- t.forEach((s, n) => {
790
- const r = s.__jsx
791
- r &&
792
- ((this.map[r] = this.map[r] || []),
793
- this.map[r].push({ element: s, index: n }))
794
- })
795
- }
796
- pullMatch(t) {
797
- const s = t && t.__jsx
798
- return !s || !(this.map[s] && this.map[s].length)
799
- ? Y
800
- : this.map[s].shift()
801
- }
802
- clear(t) {
803
- const s = t && t.__jsx
804
- if (!(s && this.map[s] && this.map[s].length)) return
805
- const n = this.map[s]
806
- this.map[s] = n.reduce((r, o) => (o.element !== t && r.push(o), r), [])
807
- }
808
- check(t) {
809
- const s = t && t.__jsx
810
- return s && this.map[s] ? this.map[s].length > 0 : !1
811
- }
812
- remaining() {
813
- return Object.values(this.map).flat()
814
- }
815
- }
816
- const Z = (e) => {
817
- const t = new Gt()
818
- return t.populate(e), t
819
- },
820
- tt = (e, t, s = !1) => {
821
- const n = [],
822
- r = e.attributes,
823
- o = r.length,
824
- a = t.attributes,
825
- h = a.length
826
- let u, d, c
827
- for (u = 0; u < o; u++) {
828
- c = null
829
- const l = r.item(u)
830
- if (l) {
831
- for (d = 0; d < h; d++) {
832
- const p = a.item(d)
833
- if (p && l.name == p.name) {
834
- c = p
835
- break
836
- }
837
- }
838
- c
839
- ? l.value !== c.value &&
840
- n.push(Kt(e, t, { name: l.name, value: c.value, isSvg: s }))
841
- : n.push(zt(e, t, { name: l.name, isSvg: s }))
842
- }
843
- }
844
- for (u = 0; u < h; u++) {
845
- c = null
846
- const l = a.item(u)
847
- if (l) {
848
- for (d = 0; d < o; d++) {
849
- const p = r.item(d)
850
- if (p && p.name == l.name) {
851
- c = p
852
- break
853
- }
854
- }
855
- c || n.push(Vt(e, t, { name: l.name, value: l.value, isSvg: s }))
856
- }
857
- }
858
- return n
859
- },
860
- Ct = (e, t) => {
861
- const s = [],
862
- n = e.eventMaps,
863
- r = t.eventMaps,
864
- o = Object.keys(n),
865
- a = Object.keys(r)
866
- return (
867
- o.forEach((h) => {
868
- const u = n[h],
869
- d = r[h]
870
- d
871
- ? d.busEvent !== u.busEvent &&
872
- s.push(
873
- It(e, t, {
874
- name: h,
875
- targetValue: d.listener,
876
- sourceValue: u.listener,
877
- }),
878
- )
879
- : s.push(Rt(e, t, { name: u.domEvent, value: u.listener }))
880
- }),
881
- a.forEach((h) => {
882
- const u = n[h],
883
- d = r[h]
884
- u || s.push(qt(e, t, { name: d.domEvent, value: d.listener }))
885
- }),
886
- s
887
- )
888
- },
889
- Qt = (e) => e.tagName !== 'INPUT',
890
- Wt = (e, t) => e.value === t.value,
891
- Xt = (e, t) => {
892
- if (Qt(e) || Wt(e, t)) return []
893
- const s = e,
894
- n = t
895
- return [Jt(s, n, { name: 'value', value: n.value })]
896
- },
897
- Yt = (e, t) => {
898
- const s = tt(e, t),
899
- n = Ct(e, t),
900
- r = Xt(e, t)
901
- return s.concat(n).concat(r)
902
- },
903
- Zt = (e, t) => tt(e, t, !0),
904
- te = (e, t) => (e.textContent !== t.textContent ? [Bt(e, t)] : []),
905
- ee = (e, t, s) => {
906
- let n = []
907
- if (e.nodeType === 1 && ct(e)) {
908
- const r = e,
909
- o = t,
910
- a = Zt(r, o),
911
- h = s(r.childNodes, o.childNodes, r)
912
- n = a.concat(h)
913
- } else if (e.nodeType === 1) {
914
- const r = e,
915
- o = t,
916
- a = Yt(r, o),
917
- h = s(r.childNodes, o.childNodes, r)
918
- n = a.concat(h)
919
- } else e.nodeType === 3 && (n = te(e, t))
920
- return n
921
- },
922
- et = (e, t, s) => {
923
- const n = [],
924
- r = se(e, t),
925
- o = Z(e),
926
- a = Z(t),
927
- h = []
928
- let u = 0
929
- for (; u < r; u++) {
930
- const c = e[u],
931
- l = t[u]
932
- if (l && a.check(l)) {
933
- const p = o.pullMatch(l)
934
- a.clear(l),
935
- p.element
936
- ? (p.index !== u && n.push(_(p.element, { parent: s, index: u })),
937
- h.push({ source: p.element, target: l }))
938
- : c
939
- ? a.check(c)
940
- ? n.push(_(l, { parent: s, index: u }))
941
- : (o.clear(c), n.push(Ut(c, l)))
942
- : n.push(_(l, { parent: s, index: u }))
943
- } else c && o.pullMatch(c).element && n.push(X(c))
944
- }
945
- o.remaining().forEach(({ element: c }) => {
946
- n.push(X(c))
947
- })
948
- const d = h.reduce(
949
- (c, { source: l, target: p }) => c.concat(ee(l, p, et)),
950
- [],
951
- )
952
- return n.concat(d).sort(Ht)
953
- },
954
- se = (e, t) => {
955
- const s = e.length,
956
- n = t.length
957
- return s > n ? s : n
958
- },
959
- ne = (e, t, s) => {
960
- const n = et(e, t, s)
961
- return (
962
- n.forEach((r) => {
963
- re(r)
964
- }),
965
- n
966
- )
967
- },
968
- re = (e) => {
969
- ;(be[e.type] || oe)(e)
970
- },
971
- oe = (e) => {},
972
- ie = (e) => {
973
- const { source: t, target: s } = e
974
- t.nodeValue = s.textContent
975
- },
976
- ue = (e) => {
977
- const { source: t } = e
978
- t.remove()
979
- },
980
- ae = (e) => {
981
- const { target: t, data: s } = e,
982
- { parent: n, index: r } = s,
983
- o = n.childNodes[r]
984
- o ? o && o !== t && n.insertBefore(t, o) : n.appendChild(t)
985
- },
986
- ce = (e) => {
987
- const { source: t, target: s } = e
988
- t.replaceWith(s)
989
- },
990
- he = (e) => {
991
- const { source: t, data: s } = e,
992
- { name: n, isSvg: r } = s
993
- r ? t.removeAttributeNS(null, n) : t.removeAttribute(n)
994
- },
995
- st = (e) => {
996
- const { source: t, data: s } = e,
997
- { name: n, value: r, isSvg: o } = s
998
- o ? t.setAttributeNS(null, n, r) : t.setAttribute(n, r)
999
- },
1000
- le = (e) => {
1001
- st(e)
1002
- },
1003
- de = (e) => {
1004
- const t = e.data,
1005
- s = e.source,
1006
- { name: n, value: r } = t
1007
- s.removeEventListener(n, r)
1008
- },
1009
- pe = (e) => {
1010
- const t = e.data,
1011
- s = e.source,
1012
- { name: n, value: r } = t
1013
- s.addEventListener(n, r)
1014
- },
1015
- me = (e) => {
1016
- const t = e.data,
1017
- s = e.source,
1018
- { name: n, sourceValue: r, targetValue: o } = t
1019
- s.removeEventListener(n, r), s.addEventListener(n, o)
1020
- },
1021
- fe = (e) => {
1022
- const t = e.data,
1023
- s = e.source,
1024
- { value: n } = t
1025
- s.value = n
1026
- },
1027
- be = {
1028
- [i.changeText]: ie,
1029
- [i.removeNode]: ue,
1030
- [i.insertNode]: ae,
1031
- [i.replaceNode]: ce,
1032
- [i.removeAttribute]: he,
1033
- [i.addAttribute]: st,
1034
- [i.updateAttribute]: le,
1035
- [i.removeEvent]: de,
1036
- [i.addEvent]: pe,
1037
- [i.updateEvent]: me,
1038
- [i.changeValue]: fe,
1039
- },
1040
- ve = (e, t, s) => {
1041
- const n = [...t]
1042
- return (
1043
- e.forEach((r) => {
1044
- ge(r, n, s)
1045
- }),
1046
- n
1047
- )
1048
- },
1049
- ge = (e, t, s) => {
1050
- const n = Ae[e.type]
1051
- n && n(e, t, s)
1052
- },
1053
- ye = (e, t) => {
1054
- const { source: s } = e,
1055
- n = t.indexOf(s)
1056
- n >= 0 && t.splice(n, 1)
1057
- },
1058
- Ee = (e, t, s) => {
1059
- const { target: n } = e,
1060
- r = e.data,
1061
- { index: o, parent: a } = r
1062
- s === a && t.splice(o, 0, n)
1063
- },
1064
- xe = (e, t) => {
1065
- const { target: s, source: n } = e,
1066
- r = t.indexOf(n)
1067
- r >= 0 && (t[r] = s)
1068
- },
1069
- Ae = { [i.removeNode]: ye, [i.insertNode]: Ee, [i.replaceNode]: xe }
1070
- class we {
1071
- constructor({
1072
- Template: t,
1073
- subscriptions: s,
1074
- attributes: n,
1075
- viewModel: r,
1076
- }) {
1077
- ;(this.Template = t),
1078
- (this.viewModel = r),
1079
- (this.attributes = n),
1080
- (this.subscriptions = s),
1081
- (this.dom = []),
1082
- (this.parentElement = null)
1083
- }
1084
- render(t) {
1085
- return (
1086
- (this.parentElement = t.parent),
1087
- (this.renderKit = t),
1088
- this.subscribeForRerender(),
1089
- (this.dom = this.generateDom(t)),
1090
- this.dom
1091
- )
1092
- }
1093
- generateDom(t) {
1094
- const s = {
1095
- ...this.attributes,
1096
- ...this.viewModel(t.state.getAll(this.subscriptions)),
1097
- },
1098
- n = this.Template(s)
1099
- return n ? n.render(t) : []
1100
- }
1101
- rerender() {
1102
- if (!this.parentElement && this.dom[0]) {
1103
- const n = this.dom[0].parentElement
1104
- this.parentElement = n
1105
- }
1106
- const t = this.generateDom(this.renderKit),
1107
- s = ne(this.dom, t, this.parentElement)
1108
- this.dom = ve(s, this.dom, this.parentElement)
1109
- }
1110
- subscribeForRerender() {
1111
- const { subscribe: t } = this.renderKit
1112
- this.subscriptions.forEach((s) => {
1113
- t(this.eventName(s), () => this.rerender())
1114
- })
1115
- }
1116
- eventName(t) {
1117
- return `${S}:${t}`
1118
- }
1119
- }
1120
- const Se = (e) => e,
1121
- _e = ({ Template: e, viewModel: t, subscriptions: s }) => (
1122
- (s = s || []),
1123
- (t = t || Se),
1124
- (n) =>
1125
- new we({ Template: e, viewModel: t, subscriptions: s, attributes: n })
1126
- ),
1127
- Ne = Object.freeze(
1128
- Object.defineProperty(
1129
- {
1130
- __proto__: null,
1131
- createRouteState: T,
1132
- events: _t,
1133
- extractQueryParams: P,
1134
- findHref: F,
1135
- navigate: D,
1136
- onLinkClick: L,
1137
- onLocationChange: B,
1138
- start: Nt,
1139
- },
1140
- Symbol.toStringTag,
1141
- { value: 'Module' },
1142
- ),
1143
- )
1144
- ;(m.JaxsTypes = Pt),
1145
- (m.appBuilding = jt),
1146
- (m.bind = _e),
1147
- (m.createApp = Lt),
1148
- (m.jsx = k),
1149
- (m.messageBus = Ot),
1150
- (m.navigation = Ne),
1151
- (m.state = Ft),
1152
- Object.defineProperty(m, Symbol.toStringTag, { value: 'Module' })
1153
- })
1
+ (function(p,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(p=typeof globalThis<"u"?globalThis:p||self,f(p.jaxs={}))})(this,function(p){"use strict";const f=(e,t)=>t.createElement(e),ot=(e,t)=>{for(const s in t){if(s==="__self")continue;const n=t[s].toString();if(s==="value"){const r=e;r.value!==n&&(r.value=n)}else e.setAttribute(s,n)}},it=(e,t,s)=>{const n={};for(const r in t){const o=t[r],a=l=>s(o,l);e.addEventListener(r,a),n[r]={domEvent:r,busEvent:o,listener:a}}e.eventMaps=n},ut=(e,t,s,n)=>{const r=f(e,n.document);return ot(r,t),it(r,s,n.publish),r},g="http://www.w3.org/2000/svg",at={animate:!0,animateMotion:!0,animateTransform:!0,circle:!0,clipPath:!0,defs:!0,desc:!0,ellipse:!0,feBlend:!0,feColorMatrix:!0,feComponentTransfer:!0,feComposite:!0,feConvolveMatrix:!0,feDiffuseLighting:!0,feDisplacementMap:!0,feDistantLight:!0,feDropShadow:!0,feFlood:!0,feFuncA:!0,feFuncB:!0,feFuncG:!0,feFuncR:!0,feGaussianBlur:!0,feImage:!0,feMerge:!0,feMergeNode:!0,feMorphology:!0,feOffset:!0,fePointLight:!0,feSpecularLighting:!0,feSpotLight:!0,feTile:!0,feTurbulence:!0,filter:!0,foreignObject:!0,g:!0,image:!0,line:!0,linearGradient:!0,marker:!0,mask:!0,metadata:!0,mpath:!0,path:!0,pattern:!0,polygon:!0,polyline:!0,radialGradient:!0,rect:!0,script:!0,set:!0,stop:!0,style:!0,svg:!0,switch:!0,symbol:!0,text:!0,textPath:!0,title:!0,tspan:!0,use:!0,view:!0},ct=(e,t)=>!!(at[e]||e==="a"&&t===g),lt=(e,t,s)=>{const n=s.createElementNS(g,e);for(const r in t)r==="__self"||r==="xmlns"||n.setAttributeNS(null,r,t[r].toString());return n},ht=e=>e.namespaceURI===g,dt=(e,t)=>t.createTextNode(e);class pt{constructor(t){this.value=t.toString()}render(t){const s=dt(this.value,t.document);return s.__jsx="TextNode",[s]}}const mt=e=>typeof e=="string"||typeof e=="number",ft=e=>new pt(e),bt=e=>mt(e)?ft(e):e,vt=e=>gt(e).map(bt).flat(),gt=e=>Array.isArray(e)?e.flat():e?[e]:[],S=(e,t={})=>e||t.children||[],yt=(e,t="")=>{const s={},n={};for(const r in e){const o=e[r];if(r.match(/^on.+/i)){const a=r.slice(2).toLowerCase();n[a]=o?o.toString():""}else{if(o===!1)continue;r==="__source"?s.__source=e.__source:s[r]=Et(r,o,t)}}return{attributes:s,events:n}},Et=(e,t,s="")=>t==null?s:t.toString(),xt=(e,t)=>{const s=e||{},n=S(t,s);return s.children=s.children||n,s},N=(e,t,s,n=[])=>e.reduce(At(t,s),n).flat(),At=(e,t)=>(s,n)=>n?Array.isArray(n)?N(n,e,t,s):(n.render(e,t).forEach(r=>s.push(r)),s):s;class j{constructor(t){this.collection=vt(t)}render(t,s){this.parentElement=s;const n=this.generateDom(t);return this.attachToParent(n),n}generateDom(t){return N(this.collection,t,this.parentElement)}attachToParent(t){if(this.parentElement===void 0)return;const s=this.parentElement;t.forEach(n=>s.appendChild(n))}}class _t{constructor(t,s){this.type=t,this.attributes=s}generate(){return this.attributes.key||this.sourceKey()||this.createKeyFromAttributes()}sourceKey(){if(this.attributes.__source){const{fileName:t,lineNumber:s,columnNumber:n}=this.attributes.__source;return`${t}:${s}:${n}`}}createKeyFromAttributes(){const t=this.attributes.id?`#${this.attributes.id}`:"",s=this.attributes.type?`[type=${this.attributes.type}]`:"",n=this.attributes.name?`[name=${this.attributes.name}]`:"";return`${this.type}${t}${s}${n}`}}class wt{constructor(t,s,n=[]){this.type=t;const{events:r,attributes:o}=yt(s);this.events=r,this.attributes=o,this.isSvg=ct(this.type,this.attributes.xmlns),this.children=new j(n)}render(t){const s=this.generateDom(t);return s?(this.children.render(t,s),[s]):[]}generateDom(t){return this.isSvg?this.generateSvgDom(t):this.generateHtmlDom(t)}generateHtmlDom(t){const s=ut(this.type,this.attributes,this.events,t);return s.__jsx=this.jsxKey(),s}generateSvgDom(t){const s=lt(this.type,this.attributes,t.document);return s.__jsx=this.jsxKey(),s}jsxKey(){return new _t(this.type,this.attributes).generate()}}const O=(e,t,...s)=>typeof e=="string"?new wt(e,t,s):e(xt(t,s));O.fragment=(e,t)=>{const s=S(t,e);return new j(s)};class St{constructor(t,s,n){this.template=t,this.selector=s,this.renderKit=n,this.dom=[]}renderAndAttach(t){this.parentElement=this.getParentElement(),this.dom=this.render({...t,parent:this.parentElement}),this.parentElement&&this.attach()}render(t){return this.template.render(t)}attach(){this.parentElement&&(this.parentElement.innerHTML=""),this.dom.forEach(t=>{this.parentElement&&this.parentElement.appendChild(t)})}getParentElement(){return this.renderKit.document.querySelector(this.selector)}}const Nt=(e,t,s)=>{const n=new St(e,t,s);return n.renderAndAttach(s),n},M="go-to-href",b="navigation:location-change",T="navigation:route-change",jt=Object.freeze(Object.defineProperty({__proto__:null,linkNavigationEvent:M,locationChangeEvent:b,routeChangeEvent:T},Symbol.toStringTag,{value:"Module"})),k=e=>{e.createRecord("route",{host:"",path:"",query:{}})},$=e=>{const t=e.closest("[href]");return t&&t.getAttribute("href")||""},P=(e,{publish:t,window:s})=>{s.history.pushState(null,"",e),t(b,null)},D=(e,t)=>{if(!e||!e.target)return;e.preventDefault();const s=$(e.target);P(s,t)},L=e=>e.replace(/^\?/,"").split("&").reduce((t,s)=>{if(!s)return t;const n=s.split("=");return t[n[0]]=n[1],t},{}),F=(e,t)=>{const{state:s,publish:n,window:r}=t,{host:o,pathname:a,search:l}=r.location,u=a,d=L(l),c={host:o,path:u,query:d};s.store("route").update(c),n(T,c)},B=e=>{const{subscribe:t}=e;t(M,D)},z=e=>{const{publish:t,subscribe:s,state:n,window:r}=e;k(n),r.addEventListener("popstate",()=>t(b,null)),s(b,F)},V=e=>{setTimeout(()=>e.publish(b,null),0)},K=e=>{z(e),B(e),V(e)},Ot=Object.freeze(Object.defineProperty({__proto__:null,publishLocation:V,startNavigation:K,subscribeToHistoryChange:z,subscribeToNavigation:B},Symbol.toStringTag,{value:"Module"}));class R{constructor({window:t,document:s,publish:n,subscribe:r,bus:o,state:a,renderKit:l}){this.window=t,this.document=s,this.publish=n,this.subscribe=r,this.bus=o,this.state=a,this.renderKit=l,this.roots=[]}render(t,s){const n=Nt(t,s,this.renderKit);return this.roots.push(n),n}startNavigation(){K(this)}}const Mt=Object.freeze(Object.defineProperty({__proto__:null,App:R},Symbol.toStringTag,{value:"Module"}));class U{constructor(){this.lookup={}}add(t,s,n){this.ensureArrayFor(t);const r={listener:s,index:n,matcher:t};return this.lookup[t].push(r),()=>this.remove(r)}remove(t){this.lookup[t.matcher]&&(this.lookup[t.matcher]=this.lookup[t.matcher].reduce((s,n)=>(n!==t&&s.push(n),s),[]))}matches(t){return this.lookup[t]||[]}ensureArrayFor(t){this.lookup[t]||(this.lookup[t]=[])}}class q{constructor(){this.lookup=[]}add(t,s,n){const r={listener:s,index:n,matcher:t};return this.lookup.push(r),()=>this.remove(r)}remove(t){this.lookup=this.lookup.reduce((s,n)=>(n!==t&&s.push(n),s),[])}matches(t){return this.lookup.filter(s=>s.matcher.test(t))}}class I{constructor(){this.exactSubscriptions=new U,this.fuzzySubscriptions=new q,this.currentIndex=0}subscribe(t,s){let n;return typeof t=="string"?n=this.exactSubscriptions.add(t,s,this.currentIndex):n=this.fuzzySubscriptions.add(t,s,this.currentIndex),this.currentIndex+=1,n}publish(t,s){[...this.exactSubscriptions.matches(t),...this.fuzzySubscriptions.matches(t)].sort((r,o)=>r.index-o.index).forEach(r=>{r.listener(s,this.listenerOptions(t))})}addListenerOptions(t){this.options=t}listenerOptions(t){return{eventName:t,...this.options,publish:this.publish.bind(this)}}}const J=()=>{const e=new I;return{bus:e,publish:(n,r)=>e.publish(n,r),subscribe:(n,r)=>e.subscribe(n,r)}},Tt=Object.freeze(Object.defineProperty({__proto__:null,ExactSubscriptions:U,FuzzySubscriptions:q,JaxsBus:I,createBus:J},Symbol.toStringTag,{value:"Module"})),v=e=>Array.isArray(e),y=e=>e!==null&&!v(e)&&typeof e=="object",kt=(e,t)=>e===t,$t=(e,t)=>Object.keys(e).length===Object.keys(t).length,Pt=(e,t)=>!(y(e)&&y(t))||!$t(e,t)?!1:Object.keys(e).every(s=>{const n=e[s],r=t[s];return E(n,r)}),Dt=(e,t)=>!(v(e)&&v(t))||e.length!==t.length?!1:e.every((s,n)=>{const r=t[n];return E(s,r)}),E=(e,t)=>y(e)?Pt(e,t):v(e)?Dt(e,t):kt(e,t);class x{constructor(t){this.name=t.name,this.parent=t.parent,this._value=t.value,this.initialValue=structuredClone(t.value)}get value(){return this._value}set value(t){throw new Error("Cannot set value directly. Use an updater!")}reset(){this._value=this.initialValue}update(t){if(typeof t=="function"){const s=this.getUpdatedValue(t);this.updateValue(s)}else this.updateValue(t)}updateValue(t){E(this._value,t)||(this._value=t,this.parent.notify(this.name))}getUpdatedValue(t){return t(this.value)}}class A{constructor(t){this.store=t}update(t){this.store.update(t)}reset(){this.store.update(this.store.initialValue)}get value(){return this.store.value}}class H extends A{toggle(){const t=!this.value;this.update(t)}setTrue(){this.update(!0)}setFalse(){this.update(!1)}}const Lt=e=>new H(e);class G extends A{push(t){const s=[...this.value,t];this.update(s)}pop(){const t=[...this.value],s=t.pop();return this.update(t),s}unshift(t){const s=[t,...this.value];this.update(s)}shift(){const t=[...this.value],s=t.shift();return this.update(t),s}addSorter(t,s){this[t]=()=>{this.sortBy(s)}}sortBy(t){const s=[...this.value];s.sort(t),this.update(s)}insertAt(t,s){const n=[...this.value];n.splice(t,0,s),this.update(n)}remove(t){const s=this.value.reduce((n,r)=>(r!==t&&n.push(r),n),[]);this.update(s)}removeBy(t){const s=this.value.reduce((n,r)=>(t(r)||n.push(r),n),[]);this.update(s)}}const Ft=e=>new G(e);class C extends A{updateAttribute(t,s){const n={...this.value};n[t]=s,this.update(n)}resetAttribute(t){const s={...this.value},n=this.store.initialValue[t];s[t]=n,this.update(s)}}const Bt={object:e=>new C(e),list:Ft,boolean:Lt},_="state";class Q{constructor(t){this.publisher=t,this.stores={},this.eventNamePrefix=_,this.notifications=new Set,this.inTransaction=!1}create(t,s){const n=new x({name:t,parent:this,value:s});return this.stores[t]=n,n}createBoolean(t,s){const n=this.create(t,s);return n.updater=new H(n),n}createRecord(t,s){const n=this.create(t,s);return n.updater=new C(n),n}createList(t,s){const n=this.create(t,s);return n.updater=new G(n),n}store(t){return this.stores[t]||new x({name:t,parent:this,value:void 0})}get(t){return this.store(t).value}getAll(t){return t.reduce((s,n)=>(s[n]=this.get(n),s),{})}notify(t){this.inTransaction?this.notifications.add(t):this.publish(t)}update(t,s){this.store(t).update(s)}transaction(t){this.inTransaction=!0,t(this.stores),this.inTransaction=!1,this.publishAll()}publishAll(){this.notifications.forEach(t=>{this.publish(t)}),this.notifications.clear()}publish(t){this.publisher(this.event(t),{state:this,store:this.store(t)})}event(t){return`${this.eventNamePrefix}:${t}`}}const W=e=>new Q(e),zt=Object.freeze(Object.defineProperty({__proto__:null,State:Q,Store:x,createState:W,eventName:_,updaters:Bt},Symbol.toStringTag,{value:"Module"}));class Vt{constructor(t){this.setupDomEnvironment(t)}setup(){return this.setupBus(),this.setupState(),this.addBusOptions(),this.setRenderKit(),new R({window:this.window,document:this.document,publish:this.publish,subscribe:this.subscribe,bus:this.bus,state:this.state,renderKit:this.renderKit})}setupDomEnvironment(t){t.window?(this.window=t.window,this.document=this.window.document):t.document?(this.window=t.document.defaultView,this.document=t.document):(this.window=window,this.document=document)}setupBus(){const{publish:t,subscribe:s,bus:n}=J();this.publish=t,this.subscribe=s,this.bus=n}setupState(){this.state=W(this.publish)}addBusOptions(){this.bus.addListenerOptions({state:this.state,document:this.document,window:this.window})}setRenderKit(){this.renderKit={publish:this.publish,subscribe:this.subscribe,state:this.state,document:this.document,window:this.window}}}const Kt=(e={})=>{const s=new Vt(e).setup();return s.startNavigation(),s};var i=(e=>(e[e.removeNode=0]="removeNode",e[e.insertNode=1]="insertNode",e[e.replaceNode=2]="replaceNode",e[e.removeAttribute=3]="removeAttribute",e[e.addAttribute=4]="addAttribute",e[e.updateAttribute=5]="updateAttribute",e[e.removeEvent=6]="removeEvent",e[e.addEvent=7]="addEvent",e[e.updateEvent=8]="updateEvent",e[e.changeValue=9]="changeValue",e[e.changeText=10]="changeText",e))(i||{});const Rt=Object.freeze(Object.defineProperty({__proto__:null,ChangeInstructionTypes:i},Symbol.toStringTag,{value:"Module"})),Ut=(e,t)=>({source:e,target:t,type:i.changeText,data:{}}),qt=(e,t)=>({source:e,target:t,type:i.replaceNode,data:{}}),It=(e,t,s)=>({source:e,target:t,data:s,type:i.removeAttribute}),Jt=(e,t,s)=>({source:e,target:t,data:s,type:i.addAttribute}),Ht=(e,t,s)=>({source:e,target:t,data:s,type:i.updateAttribute}),Gt=(e,t,s)=>({source:e,target:t,data:s,type:i.removeEvent}),Ct=(e,t,s)=>({source:e,target:t,data:s,type:i.addEvent}),Qt=(e,t,s)=>({source:e,target:t,data:s,type:i.updateEvent}),X=e=>({source:e,target:e,type:i.removeNode,data:{}}),w=(e,t)=>({target:e,source:e,type:i.insertNode,data:t}),Wt=(e,t,s)=>({source:e,target:t,type:i.changeValue,data:s}),Xt=(e,t)=>e.type>t.type?1:e.type<t.type?-1:0,Y={index:-1};class Yt{constructor(){this.map={}}populate(t){t.forEach((s,n)=>{const r=s.__jsx;r&&(this.map[r]=this.map[r]||[],this.map[r].push({element:s,index:n}))})}pullMatch(t){const s=t&&t.__jsx;return!s||!(this.map[s]&&this.map[s].length)?Y:this.map[s].shift()}clear(t){const s=t&&t.__jsx;if(!(s&&this.map[s]&&this.map[s].length))return;const n=this.map[s];this.map[s]=n.reduce((r,o)=>(o.element!==t&&r.push(o),r),[])}check(t){const s=t&&t.__jsx;return s&&this.map[s]?this.map[s].length>0:!1}remaining(){return Object.values(this.map).flat()}}const Z=e=>{const t=new Yt;return t.populate(e),t},tt=(e,t,s=!1)=>{const n=[],r=e.attributes,o=r.length,a=t.attributes,l=a.length;let u,d,c;for(u=0;u<o;u++){c=null;const h=r.item(u);if(h){for(d=0;d<l;d++){const m=a.item(d);if(m&&h.name==m.name){c=m;break}}c?h.value!==c.value&&n.push(Ht(e,t,{name:h.name,value:c.value,isSvg:s})):n.push(It(e,t,{name:h.name,isSvg:s}))}}for(u=0;u<l;u++){c=null;const h=a.item(u);if(h){for(d=0;d<o;d++){const m=r.item(d);if(m&&m.name==h.name){c=m;break}}c||n.push(Jt(e,t,{name:h.name,value:h.value,isSvg:s}))}}return n},Zt=(e,t)=>{const s=[],n=e.eventMaps,r=t.eventMaps,o=Object.keys(n),a=Object.keys(r);return o.forEach(l=>{const u=n[l],d=r[l];d?d.busEvent!==u.busEvent&&s.push(Qt(e,t,{name:l,targetValue:d.listener,sourceValue:u.listener})):s.push(Gt(e,t,{name:u.domEvent,value:u.listener}))}),a.forEach(l=>{const u=n[l],d=r[l];u||s.push(Ct(e,t,{name:d.domEvent,value:d.listener}))}),s},te=e=>e.tagName!=="INPUT",ee=(e,t)=>e.value===t.value,se=(e,t)=>{if(te(e)||ee(e,t))return[];const s=e,n=t;return[Wt(s,n,{name:"value",value:n.value})]},ne=(e,t)=>{const s=tt(e,t),n=Zt(e,t),r=se(e,t);return s.concat(n).concat(r)},re=(e,t)=>tt(e,t,!0),oe=(e,t)=>e.textContent!==t.textContent?[Ut(e,t)]:[],ie=(e,t,s)=>{let n=[];if(e.nodeType===1&&ht(e)){const r=e,o=t,a=re(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else if(e.nodeType===1){const r=e,o=t,a=ne(r,o),l=s(r.childNodes,o.childNodes,r);n=a.concat(l)}else e.nodeType===3&&(n=oe(e,t));return n},et=(e,t,s)=>{const n=[],r=ue(e,t),o=Z(e),a=Z(t),l=[];let u=0;for(;u<r;u++){const c=e[u],h=t[u];if(h&&a.check(h)){const m=o.pullMatch(h);a.clear(h),m.element?(m.index!==u&&n.push(w(m.element,{parent:s,index:u})),l.push({source:m.element,target:h})):c?a.check(c)?n.push(w(h,{parent:s,index:u})):(o.clear(c),n.push(qt(c,h))):n.push(w(h,{parent:s,index:u}))}else c&&o.pullMatch(c).element&&n.push(X(c))}o.remaining().forEach(({element:c})=>{n.push(X(c))});const d=l.reduce((c,{source:h,target:m})=>c.concat(ie(h,m,et)),[]);return n.concat(d).sort(Xt)},ue=(e,t)=>{const s=e.length,n=t.length;return s>n?s:n},ae=(e,t,s)=>{const n=et(e,t,s);return n.forEach(r=>{ce(r)}),n},ce=e=>{(xe[e.type]||le)(e)},le=e=>{},he=e=>{const{source:t,target:s}=e;t.nodeValue=s.textContent},de=e=>{const{source:t}=e;t.remove()},pe=e=>{const{target:t,data:s}=e,{parent:n,index:r}=s,o=n.childNodes[r];o?o&&o!==t&&n.insertBefore(t,o):n.appendChild(t)},me=e=>{const{source:t,target:s}=e;t.replaceWith(s)},fe=e=>{const{source:t,data:s}=e,{name:n,isSvg:r}=s;r?t.removeAttributeNS(null,n):t.removeAttribute(n)},st=e=>{const{source:t,data:s}=e,{name:n,value:r,isSvg:o}=s;o?t.setAttributeNS(null,n,r):t.setAttribute(n,r)},be=e=>{st(e)},ve=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.removeEventListener(n,r)},ge=e=>{const t=e.data,s=e.source,{name:n,value:r}=t;s.addEventListener(n,r)},ye=e=>{const t=e.data,s=e.source,{name:n,sourceValue:r,targetValue:o}=t;s.removeEventListener(n,r),s.addEventListener(n,o)},Ee=e=>{const t=e.data,s=e.source,{value:n}=t;s.value=n},xe={[i.changeText]:he,[i.removeNode]:de,[i.insertNode]:pe,[i.replaceNode]:me,[i.removeAttribute]:fe,[i.addAttribute]:st,[i.updateAttribute]:be,[i.removeEvent]:ve,[i.addEvent]:ge,[i.updateEvent]:ye,[i.changeValue]:Ee},Ae=(e,t,s)=>{const n=[...t];return e.forEach(r=>{_e(r,n,s)}),n},_e=(e,t,s)=>{const n=je[e.type];n&&n(e,t,s)},we=(e,t)=>{const{source:s}=e,n=t.indexOf(s);n>=0&&t.splice(n,1)},Se=(e,t,s)=>{const{target:n}=e,r=e.data,{index:o,parent:a}=r;s===a&&t.splice(o,0,n)},Ne=(e,t)=>{const{target:s,source:n}=e,r=t.indexOf(n);r>=0&&(t[r]=s)},je={[i.removeNode]:we,[i.insertNode]:Se,[i.replaceNode]:Ne};class Oe{constructor({Template:t,subscriptions:s,attributes:n,viewModel:r}){this.Template=t,this.viewModel=r,this.attributes=n,this.subscriptions=s,this.dom=[],this.parentElement=null}render(t){return this.parentElement=t.parent,this.renderKit=t,this.subscribeForRerender(),this.dom=this.generateDom(t),this.dom}generateDom(t){const s={...this.attributes,...this.viewModel(t.state.getAll(this.subscriptions))},n=this.Template(s);return n?n.render(t):[]}rerender(){if(!this.parentElement&&this.dom[0]){const n=this.dom[0].parentElement;this.parentElement=n}const t=this.generateDom(this.renderKit),s=ae(this.dom,t,this.parentElement);this.dom=Ae(s,this.dom,this.parentElement)}subscribeForRerender(){const{subscribe:t}=this.renderKit;this.subscriptions.forEach(s=>{t(this.eventName(s),()=>this.rerender())})}eventName(t){return`${_}:${t}`}}const Me=e=>e,nt=({Template:e,viewModel:t,subscriptions:s})=>(s=s||[],t=t||Me,n=>new Oe({Template:e,viewModel:t,subscriptions:s,attributes:n})),Te=Object.freeze(Object.defineProperty({__proto__:null,createRouteState:k,events:jt,extractQueryParams:L,findHref:$,navigate:P,onLinkClick:D,onLocationChange:F,start:Ot},Symbol.toStringTag,{value:"Module"})),ke=e=>({path:t})=>t===e,$e=()=>!0,rt=e=>({route:t})=>{const s=e.find(n=>n.match(t));return s&&s.Partial},Pe=Object.freeze(Object.defineProperty({__proto__:null,buildRouter:rt,catchAll:$e,exactPathMatch:ke},Symbol.toStringTag,{value:"Module"})),De=()=>({render:(e,t)=>[]}),Le=e=>{const t=rt(e);return nt({Template:({route:n})=>(t({route:n})||De)(),subscriptions:["route"]})};p.JaxsTypes=Rt,p.appBuilding=Mt,p.bind=nt,p.createApp=Kt,p.jsx=O,p.messageBus=Tt,p.navigation=Te,p.routedView=Le,p.routing=Pe,p.state=zt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});