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