rx-tiny-flux 1.0.32 → 1.0.34

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/Readme.md CHANGED
@@ -194,10 +194,6 @@ counterSubscription.unsubscribe();
194
194
 
195
195
  For developers using the `ZML` library on the ZeppOS platform, `rx-tiny-flux` offers an optional plugin that seamlessly integrates the store with the `BaseApp` and `BasePage` component lifecycle.
196
196
 
197
- **Disclaimer:** This library is currently intended to run inside ZeppOS. It uses ZeppOS-only modules (like `@zos/fs` and `@zos/ble/TransferFile`) for large action transfers, so bundlers outside the ZeppOS environment may warn about unresolved dependencies.
198
-
199
- **Promise:** A future release will provide a ZeppOS-safe optional build (lazy-loading the `@zos/*` modules) so non-ZeppOS environments can consume the library without these warnings.
200
-
201
197
  This plugin injects `dispatch` and `subscribe` methods into your component's instance. Most importantly, the `subscribe` method is lifecycle-aware: it automatically tracks all subscriptions and unsubscribes from them when the component's `onDestroy` hook is called, preventing common memory leaks.
202
198
 
203
199
  #### How to Use
@@ -352,8 +348,6 @@ const showSuccessToastEffect = createEffect(actions$ => actions$.pipe(
352
348
 
353
349
  ```
354
350
 
355
- For large payloads that exceed the `messaging.call` limits, use `propagateLargeAction()` instead of `propagateAction()`. It persists the action on disk, transfers it using the TransferFile API, and dispatches it on the other side. Ensure the `storePlugin` is registered on both the App and Side Service contexts so the receiver can read and dispatch the file.
356
-
357
351
  #### Accessing State within Effects using `withLatestFromStore`
358
352
 
359
353
  A common requirement for effects is to access the current state to make decisions. For example, an effect might need the current user's ID to fetch data. The `withLatestFromStore` operator is designed for this purpose, especially in ZeppOS where the `store` instance isn't readily available when defining effects.
@@ -1,6 +1,3 @@
1
- import TransferFile from '@zos/ble/TransferFile';
2
- import * as fs from '@zos/fs';
3
-
4
1
  /******************************************************************************
5
2
  Copyright (c) Microsoft Corporation.
6
3
 
@@ -2398,6 +2395,72 @@ function createSelector(...args) {
2398
2395
 
2399
2396
  const LARGE_ACTION_MESSAGE_KEY = '__rxTinyFluxLargeAction';
2400
2397
  const TRANSFER_STATE_KEY = '_rxTinyFluxTransferState';
2398
+ let cachedTransferFileInstance;
2399
+ let cachedFsModule;
2400
+
2401
+ const tryResolveModule = (moduleName) => {
2402
+ const loader = typeof __$$RQR$$__ === 'function'
2403
+ ? __$$RQR$$__
2404
+ : (typeof require === 'function' ? require : null);
2405
+
2406
+ if (!loader) {
2407
+ return null;
2408
+ }
2409
+
2410
+ try {
2411
+ return loader(moduleName);
2412
+ } catch (error) {
2413
+ return null;
2414
+ }
2415
+ };
2416
+
2417
+ const resolveTransferFileInstance = () => {
2418
+ if (cachedTransferFileInstance !== undefined) {
2419
+ return cachedTransferFileInstance;
2420
+ }
2421
+
2422
+ const isSideServiceContext = typeof messaging !== 'undefined';
2423
+
2424
+ if (isSideServiceContext) {
2425
+ if (typeof transferFile !== 'undefined' && typeof transferFile.getInbox === 'function') {
2426
+ cachedTransferFileInstance = transferFile;
2427
+ return cachedTransferFileInstance;
2428
+ }
2429
+ }
2430
+
2431
+ if (isSideServiceContext && typeof globalThis !== 'undefined') {
2432
+ if (globalThis.transferFile && typeof globalThis.transferFile.getInbox === 'function') {
2433
+ cachedTransferFileInstance = globalThis.transferFile;
2434
+ return cachedTransferFileInstance;
2435
+ }
2436
+ }
2437
+
2438
+ if (!isSideServiceContext) {
2439
+ const module = tryResolveModule('@zos/ble/TransferFile');
2440
+ const TransferFileCtor = module && (module.default || module.TransferFile || module);
2441
+ if (TransferFileCtor) {
2442
+ cachedTransferFileInstance = new TransferFileCtor();
2443
+ return cachedTransferFileInstance;
2444
+ }
2445
+ }
2446
+
2447
+ cachedTransferFileInstance = null;
2448
+ return cachedTransferFileInstance;
2449
+ };
2450
+
2451
+ const resolveFsModule = () => {
2452
+ if (cachedFsModule !== undefined) {
2453
+ return cachedFsModule;
2454
+ }
2455
+
2456
+ if (typeof globalThis !== 'undefined' && globalThis.fs) {
2457
+ cachedFsModule = globalThis.fs;
2458
+ return cachedFsModule;
2459
+ }
2460
+
2461
+ cachedFsModule = tryResolveModule('@zos/fs') || null;
2462
+ return cachedFsModule;
2463
+ };
2401
2464
 
2402
2465
  const logDebug = (context, message) => {
2403
2466
  if (context && typeof context.debug === 'function') {
@@ -2425,7 +2488,17 @@ const getTransferState = (context) => {
2425
2488
  }
2426
2489
 
2427
2490
  try {
2428
- const transferFile = new TransferFile();
2491
+ const transferFile = resolveTransferFileInstance();
2492
+ if (!transferFile) {
2493
+ logError(context, '[rx-tiny-flux] TransferFile is not available.');
2494
+ return null;
2495
+ }
2496
+
2497
+ if (typeof transferFile.getInbox !== 'function' || typeof transferFile.getOutbox !== 'function') {
2498
+ logError(context, '[rx-tiny-flux] TransferFile is missing inbox/outbox accessors.');
2499
+ return null;
2500
+ }
2501
+
2429
2502
  const state = {
2430
2503
  transferFile,
2431
2504
  inbox: transferFile.getInbox(),
@@ -2433,6 +2506,10 @@ const getTransferState = (context) => {
2433
2506
  inboxListenerAttached: false,
2434
2507
  expectedFiles: new Set(),
2435
2508
  };
2509
+ logDebug(
2510
+ context,
2511
+ `[rx-tiny-flux] TransferFile initialized. inbox=${Boolean(state.inbox)} outbox=${Boolean(state.outbox)}`
2512
+ );
2436
2513
  context[TRANSFER_STATE_KEY] = state;
2437
2514
  return state;
2438
2515
  } catch (error) {
@@ -2477,7 +2554,8 @@ const decodeToString = (data) => {
2477
2554
  };
2478
2555
 
2479
2556
  const writeActionFile = (context, filePath, action) => {
2480
- if (typeof fs.writeFileSync !== 'function') {
2557
+ const fs = resolveFsModule();
2558
+ if (!fs || typeof fs.writeFileSync !== 'function') {
2481
2559
  throw new Error('[rx-tiny-flux] writeFileSync is not available in @zos/fs.');
2482
2560
  }
2483
2561
  fs.writeFileSync(filePath, JSON.stringify(action));
@@ -2485,7 +2563,8 @@ const writeActionFile = (context, filePath, action) => {
2485
2563
  };
2486
2564
 
2487
2565
  const readActionFile = (context, filePath) => {
2488
- if (typeof fs.readFileSync !== 'function') {
2566
+ const fs = resolveFsModule();
2567
+ if (!fs || typeof fs.readFileSync !== 'function') {
2489
2568
  throw new Error('[rx-tiny-flux] readFileSync is not available in @zos/fs.');
2490
2569
  }
2491
2570
  const raw = fs.readFileSync(filePath);
@@ -2498,6 +2577,11 @@ const removeFile = (context, filePath) => {
2498
2577
  return;
2499
2578
  }
2500
2579
 
2580
+ const fs = resolveFsModule();
2581
+ if (!fs) {
2582
+ return;
2583
+ }
2584
+
2501
2585
  try {
2502
2586
  if (typeof fs.unlinkSync === 'function') {
2503
2587
  fs.unlinkSync(filePath);
@@ -2604,21 +2688,29 @@ const handleLargeActionMessage = (context, message) => {
2604
2688
  }
2605
2689
  }
2606
2690
 
2607
- logDebug(context, '[rx-tiny-flux] Received large action header message.');
2691
+ logDebug(
2692
+ context,
2693
+ `[rx-tiny-flux] Received large action header message. transferId=${payload.transferId || 'unknown'} fileName=${payload.fileName || 'unknown'} actionType=${payload.actionType || 'unknown'}`
2694
+ );
2608
2695
  return true;
2609
2696
  };
2610
2697
 
2611
2698
  const setupLargeActionReceiver = (context) => {
2612
2699
  const state = getTransferState(context);
2613
2700
  if (!state || state.inboxListenerAttached) {
2701
+ if (!state) {
2702
+ logDebug(context, '[rx-tiny-flux] Skipping large action receiver setup: no TransferFile state.');
2703
+ }
2614
2704
  return;
2615
2705
  }
2616
2706
 
2617
2707
  state.inboxListenerAttached = true;
2708
+ logDebug(context, '[rx-tiny-flux] Large action receiver attached to inbox.');
2618
2709
 
2619
2710
  state.inbox.on('NEWFILE', () => {
2620
2711
  const fileObject = state.inbox.getNextFile();
2621
2712
  if (!fileObject) {
2713
+ logDebug(context, '[rx-tiny-flux] Inbox NEWFILE fired but no file object was returned.');
2622
2714
  return;
2623
2715
  }
2624
2716
 
@@ -2628,11 +2720,17 @@ const setupLargeActionReceiver = (context) => {
2628
2720
  const isExpected = filePath && state.expectedFiles.has(filePath);
2629
2721
  const isLargeAction = Boolean(metaPayload) || isExpected;
2630
2722
 
2723
+ logDebug(
2724
+ context,
2725
+ `[rx-tiny-flux] Inbox NEWFILE received. filePath=${filePath || 'unknown'} expected=${Boolean(isExpected)} hasMeta=${Boolean(metaPayload)}`
2726
+ );
2727
+
2631
2728
  if (filePath && isExpected) {
2632
2729
  state.expectedFiles.delete(filePath);
2633
2730
  }
2634
2731
 
2635
2732
  if (!isLargeAction) {
2733
+ logDebug(context, '[rx-tiny-flux] Ignoring inbox file: not a large action.');
2636
2734
  return;
2637
2735
  }
2638
2736
 
@@ -2653,6 +2751,7 @@ const setupLargeActionReceiver = (context) => {
2653
2751
  if (typeof fileObject.on === 'function') {
2654
2752
  fileObject.on('change', (event) => {
2655
2753
  const readyState = event && event.data && event.data.readyState;
2754
+ logDebug(context, `[rx-tiny-flux] Inbox file change event. readyState=${readyState || 'unknown'}`);
2656
2755
  if (readyState === 'transferred') {
2657
2756
  handleTransferred();
2658
2757
  } else if (readyState === 'error') {
@@ -2662,6 +2761,7 @@ const setupLargeActionReceiver = (context) => {
2662
2761
  }
2663
2762
 
2664
2763
  if (fileObject.readyState === 'transferred') {
2764
+ logDebug(context, '[rx-tiny-flux] Inbox file already transferred.');
2665
2765
  handleTransferred();
2666
2766
  }
2667
2767
  });
@@ -2677,6 +2777,7 @@ const enqueueLargeActionTransfer = (action, context) => {
2677
2777
  return false;
2678
2778
  }
2679
2779
 
2780
+ logDebug(context, `[rx-tiny-flux] Enqueueing large action transfer. type=${action && action.type ? action.type : 'unknown'}`);
2680
2781
  const transferId = createTransferId();
2681
2782
  const fileName = buildFileName(transferId);
2682
2783
  const payload = {
@@ -2693,12 +2794,16 @@ const enqueueLargeActionTransfer = (action, context) => {
2693
2794
  }
2694
2795
 
2695
2796
  if (typeof context.call === 'function') {
2797
+ logDebug(context, `[rx-tiny-flux] Sending large action header via messaging.call. transferId=${transferId}`);
2696
2798
  context.call({ [LARGE_ACTION_MESSAGE_KEY]: payload });
2799
+ } else {
2800
+ logDebug(context, '[rx-tiny-flux] messaging.call is not available for large action header.');
2697
2801
  }
2698
2802
 
2699
2803
  let fileObject;
2700
2804
  try {
2701
2805
  fileObject = state.outbox.enqueueFile(fileName, { [LARGE_ACTION_MESSAGE_KEY]: payload });
2806
+ logDebug(context, `[rx-tiny-flux] Enqueued file for transfer. fileName=${fileName}`);
2702
2807
  } catch (error) {
2703
2808
  logError(context, '[rx-tiny-flux] Failed to enqueue file for transfer.', error);
2704
2809
  removeFile(context, fileName);
@@ -2708,6 +2813,7 @@ const enqueueLargeActionTransfer = (action, context) => {
2708
2813
  if (fileObject && typeof fileObject.on === 'function') {
2709
2814
  fileObject.on('change', (event) => {
2710
2815
  const readyState = event && event.data && event.data.readyState;
2816
+ logDebug(context, `[rx-tiny-flux] Outbox file change event. readyState=${readyState || 'unknown'}`);
2711
2817
  if (readyState === 'transferred' || readyState === 'error') {
2712
2818
  removeFile(context, fileName);
2713
2819
  }
@@ -1 +1 @@
1
- import t from"@zos/ble/TransferFile";import*as n from"@zos/fs";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};function r(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function o(t,n,e,r){return new(e||(e=Promise))(function(o,i){function u(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(u,c)}s((r=r.apply(t,n||[])).next())})}function i(t,n){var e,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(s){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function u(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function c(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function s(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function l(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=e.apply(t,n||[]),i=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,l)}}),r[Symbol.asyncIterator]=function(){return this},r;function u(t,n){o[t]&&(r[t]=function(n){return new Promise(function(e,r){i.push([t,n,e,r])>1||c(t,n)})},n&&(r[t]=n(r[t])))}function c(t,n){try{(e=o[t](n)).value instanceof a?Promise.resolve(e.value.v).then(s,l):f(i[0][2],e)}catch(t){f(i[0][3],t)}var e}function s(t){c("next",t)}function l(t){c("throw",t)}function f(t,n){t(n),i.shift(),i.length&&c(i[0][0],i[0][1])}}function f(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,e=t[Symbol.asyncIterator];return e?e.call(t):(t=u(t),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise(function(r,o){(function(t,n,e,r){Promise.resolve(r).then(function(n){t({value:n,done:e})},n)})(r,o,(n=t[e](n)).done,n.value)})}}}function h(t){return"function"==typeof t}function p(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var d=p(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function b(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var y=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,e,r,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=u(i),l=a.next();!l.done;l=a.next()){l.value.remove(this)}}catch(n){t={error:n}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var f=this.initialTeardown;if(h(f))try{f()}catch(t){o=t instanceof d?t.errors:[t]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var b=u(p),y=b.next();!y.done;y=b.next()){var v=y.value;try{m(v)}catch(t){o=null!=o?o:[],t instanceof d?o=s(s([],c(o)),c(t.errors)):o.push(t)}}}catch(t){e={error:t}}finally{try{y&&!y.done&&(r=b.return)&&r.call(b)}finally{if(e)throw e.error}}}if(o)throw new d(o)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)m(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(e=this._finalizers)&&void 0!==e?e:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&b(n,t)},t.prototype.remove=function(n){var e=this._finalizers;e&&b(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),v=y.EMPTY;function x(t){return t instanceof y||t&&"closed"in t&&h(t.remove)&&h(t.add)&&h(t.unsubscribe)}function m(t){h(t)?t():t.unsubscribe()}var g={Promise:void 0},w=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,s([t,n],c(e)))};function _(t){w(function(){throw t})}function S(){}function A(t){t()}var E=function(t){function n(n){var e=t.call(this)||this;return e.isStopped=!1,n?(e.destination=n,x(n)&&n.add(e)):e.destination=F,e}return r(n,t),n.create=function(t,n,e){return new P(t,n,e)},n.prototype.next=function(t){this.isStopped||this._next(t)},n.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},n.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},n.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},n.prototype._next=function(t){this.destination.next(t)},n.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},n.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},n}(y),O=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){I(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){I(t)}else I(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){I(t)}},t}(),P=function(t){function n(n,e,r){var o,i=t.call(this)||this;return o=h(n)||!n?{next:null!=n?n:void 0,error:null!=e?e:void 0,complete:null!=r?r:void 0}:n,i.destination=new O(o),i}return r(n,t),n}(E);function I(t){_(t)}var F={closed:!0,next:S,error:function(t){throw t},complete:S},T="function"==typeof Symbol&&Symbol.observable||"@@observable";function C(t){return t}function $(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return z(t)}function z(t){return 0===t.length?C:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)}}var j=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(t,n,e){var r,o=this,i=(r=t)&&r instanceof E||function(t){return t&&h(t.next)&&h(t.error)&&h(t.complete)}(r)&&x(r)?t:new P(t,n,e);return A(function(){var t=o,n=t.operator,e=t.source;i.add(n?n.call(i,e):e?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var e=this;return new(n=k(n))(function(n,r){var o=new P({next:function(n){try{t(n)}catch(t){r(t),o.unsubscribe()}},error:r,complete:n});e.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[T]=function(){return this},t.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return z(t)(this)},t.prototype.toPromise=function(t){var n=this;return new(t=k(t))(function(t,e){var r;n.subscribe(function(t){return r=t},function(t){return e(t)},function(){return t(r)})})},t.create=function(n){return new t(n)},t}();function k(t){var n;return null!==(n=null!=t?t:g.Promise)&&void 0!==n?n:Promise}function N(t){return function(n){if(function(t){return h(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function D(t,n,e,r,o){return new B(t,n,e,r,o)}var B=function(t){function n(n,e,r,o,i,u){var c=t.call(this,n)||this;return c.onFinalize=i,c.shouldUnsubscribe=u,c._next=e?function(t){try{e(t)}catch(t){n.error(t)}}:t.prototype._next,c._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=r?function(){try{r()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,c}return r(n,t),n.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var e=this.closed;t.prototype.unsubscribe.call(this),!e&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},n}(E),M=p(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),L=function(t){function n(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r(n,t),n.prototype.lift=function(t){var n=new R(this,this);return n.operator=t,n},n.prototype._throwIfClosed=function(){if(this.closed)throw new M},n.prototype.next=function(t){var n=this;A(function(){var e,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=u(n.currentObservers),i=o.next();!i.done;i=o.next()){i.value.next(t)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}}})},n.prototype.error=function(t){var n=this;A(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var e=n.observers;e.length;)e.shift().error(t)}})},n.prototype.complete=function(){var t=this;A(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},n.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(n.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),n.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},n.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},n.prototype._innerSubscribe=function(t){var n=this,e=this,r=e.hasError,o=e.isStopped,i=e.observers;return r||o?v:(this.currentObservers=null,i.push(t),new y(function(){n.currentObservers=null,b(i,t)}))},n.prototype._checkFinalizedStatuses=function(t){var n=this,e=n.hasError,r=n.thrownError,o=n.isStopped;e?t.error(r):o&&t.complete()},n.prototype.asObservable=function(){var t=new j;return t.source=this,t},n.create=function(t,n){return new R(t,n)},n}(j),R=function(t){function n(n,e){var r=t.call(this)||this;return r.destination=n,r.source=e,r}return r(n,t),n.prototype.next=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===e||e.call(n,t)},n.prototype.error=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===e||e.call(n,t)},n.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},n.prototype._subscribe=function(t){var n,e;return null!==(e=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==e?e:v},n}(L),U=function(t){function n(n){var e=t.call(this)||this;return e._value=n,e}return r(n,t),Object.defineProperty(n.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),n.prototype._subscribe=function(n){var e=t.prototype._subscribe.call(this,n);return!e.closed&&n.next(this._value),e},n.prototype.getValue=function(){var t=this,n=t.hasError,e=t.thrownError,r=t._value;if(n)throw e;return this._throwIfClosed(),r},n.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},n}(L),W={now:function(){return(W.delegate||Date).now()},delegate:void 0},V=function(t){function n(n,e,r){void 0===n&&(n=1/0),void 0===e&&(e=1/0),void 0===r&&(r=W);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=e,o._timestampProvider=r,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=e===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,e),o}return r(n,t),n.prototype.next=function(n){var e=this,r=e.isStopped,o=e._buffer,i=e._infiniteTimeWindow,u=e._timestampProvider,c=e._windowTime;r||(o.push(n),!i&&o.push(u.now()+c)),this._trimBuffer(),t.prototype.next.call(this,n)},n.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),e=this._infiniteTimeWindow,r=this._buffer.slice(),o=0;o<r.length&&!t.closed;o+=e?1:2)t.next(r[o]);return this._checkFinalizedStatuses(t),n},n.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,e=t._timestampProvider,r=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<r.length&&r.splice(0,r.length-i),!o){for(var u=e.now(),c=0,s=1;s<r.length&&r[s]<=u;s+=2)c=s;c&&r.splice(0,c+1)}},n}(L),q=function(t){function n(n,e){return t.call(this)||this}return r(n,t),n.prototype.schedule=function(t,n){return this},n}(y),J=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,s([t,n],c(e)))},Y=function(t){return clearInterval(t)},Z=function(t){function n(n,e){var r=t.call(this,n,e)||this;return r.scheduler=n,r.work=e,r.pending=!1,r}return r(n,t),n.prototype.schedule=function(t,n){var e;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,n)),this.pending=!0,this.delay=n,this.id=null!==(e=this.id)&&void 0!==e?e:this.requestAsyncId(o,this.id,n),this},n.prototype.requestAsyncId=function(t,n,e){return void 0===e&&(e=0),J(t.flush.bind(t,this),e)},n.prototype.recycleAsyncId=function(t,n,e){if(void 0===e&&(e=0),null!=e&&this.delay===e&&!1===this.pending)return n;null!=n&&Y(n)},n.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var e=this._execute(t,n);if(e)return e;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},n.prototype._execute=function(t,n){var e,r=!1;try{this.work(t)}catch(t){r=!0,e=t||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),e},n.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,e=this.scheduler,r=e.actions;this.work=this.state=this.scheduler=null,this.pending=!1,b(r,this),null!=n&&(this.id=this.recycleAsyncId(e,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},n}(q),G=function(){function t(n,e){void 0===e&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(t,n,e){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(e,n)},t.now=W.now,t}(),K=new(function(t){function n(n,e){void 0===e&&(e=G.now);var r=t.call(this,n,e)||this;return r.actions=[],r._active=!1,r}return r(n,t),n.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var e;this._active=!0;do{if(e=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,e){for(;t=n.shift();)t.unsubscribe();throw e}}},n}(G))(Z),H=K,Q=new j(function(t){return t.complete()});function X(t){return t&&h(t.schedule)}function tt(t){return t[t.length-1]}function nt(t){return X(tt(t))?t.pop():void 0}var et=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function rt(t){return h(null==t?void 0:t.then)}function ot(t){return h(t[T])}function it(t){return Symbol.asyncIterator&&h(null==t?void 0:t[Symbol.asyncIterator])}function ut(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var ct="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function st(t){return h(null==t?void 0:t[ct])}function at(t){return l(this,arguments,function(){var n,e,r;return i(this,function(o){switch(o.label){case 0:n=t.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,a(n.read())];case 3:return e=o.sent(),r=e.value,e.done?[4,a(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,a(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function lt(t){return h(null==t?void 0:t.getReader)}function ft(t){if(t instanceof j)return t;if(null!=t){if(ot(t))return o=t,new j(function(t){var n=o[T]();if(h(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(et(t))return r=t,new j(function(t){for(var n=0;n<r.length&&!t.closed;n++)t.next(r[n]);t.complete()});if(rt(t))return e=t,new j(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(it(t))return ht(t);if(st(t))return n=t,new j(function(t){var e,r;try{for(var o=u(n),i=o.next();!i.done;i=o.next()){var c=i.value;if(t.next(c),t.closed)return}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t.complete()});if(lt(t))return ht(at(t))}var n,e,r,o;throw ut(t)}function ht(t){return new j(function(n){(function(t,n){var e,r,u,c;return o(this,void 0,void 0,function(){var o,s;return i(this,function(i){switch(i.label){case 0:i.trys.push([0,5,6,11]),e=f(t),i.label=1;case 1:return[4,e.next()];case 2:if((r=i.sent()).done)return[3,4];if(o=r.value,n.next(o),n.closed)return[2];i.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=i.sent(),u={error:s},[3,11];case 6:return i.trys.push([6,,9,10]),r&&!r.done&&(c=e.return)?[4,c.call(e)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function pt(t,n,e,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var i=n.schedule(function(){e(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function dt(t,n){return void 0===n&&(n=0),N(function(e,r){e.subscribe(D(r,function(e){return pt(r,t,function(){return r.next(e)},n)},function(){return pt(r,t,function(){return r.complete()},n)},function(e){return pt(r,t,function(){return r.error(e)},n)}))})}function bt(t,n){return void 0===n&&(n=0),N(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function yt(t,n){if(!t)throw new Error("Iterable cannot be null");return new j(function(e){pt(e,n,function(){var r=t[Symbol.asyncIterator]();pt(e,n,function(){r.next().then(function(t){t.done?e.complete():e.next(t.value)})},0,!0)})})}function vt(t,n){if(null!=t){if(ot(t))return function(t,n){return ft(t).pipe(bt(n),dt(n))}(t,n);if(et(t))return function(t,n){return new j(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}(t,n);if(rt(t))return function(t,n){return ft(t).pipe(bt(n),dt(n))}(t,n);if(it(t))return yt(t,n);if(st(t))return function(t,n){return new j(function(e){var r;return pt(e,n,function(){r=t[ct](),pt(e,n,function(){var t,n,o;try{n=(t=r.next()).value,o=t.done}catch(t){return void e.error(t)}o?e.complete():e.next(n)},0,!0)}),function(){return h(null==r?void 0:r.return)&&r.return()}})}(t,n);if(lt(t))return function(t,n){return yt(at(t),n)}(t,n)}throw ut(t)}function xt(t,n){return n?vt(t,n):ft(t)}function mt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return xt(t,nt(t))}function gt(t,n){return N(function(e,r){var o=0;e.subscribe(D(r,function(e){r.next(t.call(n,e,o++))}))})}function wt(t,n,e){return void 0===e&&(e=1/0),h(n)?wt(function(e,r){return gt(function(t,o){return n(e,t,r,o)})(ft(t(e,r)))},e):("number"==typeof n&&(e=n),N(function(n,r){return function(t,n,e,r,o,i,u){var c=[],s=0,a=0,l=!1,f=function(){!l||c.length||s||n.complete()},h=function(t){s++;var o=!1;ft(e(t,a++)).subscribe(D(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{s--;for(var t=function(){var t=c.shift();u||h(t)};c.length&&s<r;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(D(n,function(t){return s<r?h(t):c.push(t)},function(){l=!0,f()})),function(){}}(n,r,t,e)}))}function _t(){return wt(C,1)}function St(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return _t()(xt(t,nt(t)))}function At(t){return new j(function(n){ft(t()).subscribe(n)})}function Et(t,n,e){void 0===t&&(t=0),void 0===e&&(e=H);var r=-1;return null!=n&&(X(n)?e=n:r=n),new j(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-e.now():t;i<0&&(i=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=r?this.schedule(void 0,r):n.complete())},i)})}function Ot(t,n){return N(function(e,r){var o=0;e.subscribe(D(r,function(e){return t.call(n,e,o++)&&r.next(e)}))})}function Pt(t,n){return N(function(e,r){var o=[];ft(t).subscribe(D(r,function(t){var e=[];o.push(e);var i=new y;i.add(ft(n(t)).subscribe(D(r,function(){b(o,e),r.next(e),i.unsubscribe()},S)))},S)),e.subscribe(D(r,function(t){var n,e;try{for(var r=u(o),i=r.next();!i.done;i=r.next()){i.value.push(t)}}catch(t){n={error:t}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(n)throw n.error}}},function(){for(;o.length>0;)r.next(o.shift());r.complete()}))})}function It(t){return N(function(n,e){var r,o=null,i=!1;o=n.subscribe(D(e,void 0,void 0,function(u){r=ft(t(u,It(t)(n))),o?(o.unsubscribe(),o=null,r.subscribe(e)):i=!0})),i&&(o.unsubscribe(),o=null,r.subscribe(e))})}function Ft(t,n){return h(n)?wt(t,n,1):wt(t,1)}function Tt(t,n){return void 0===n&&(n=K),N(function(e,r){var o=null,i=null,u=null,c=function(){if(o){o.unsubscribe(),o=null;var t=i;i=null,r.next(t)}};function s(){var e=u+t,i=n.now();if(i<e)return o=this.schedule(void 0,e-i),void r.add(o);c()}e.subscribe(D(r,function(e){i=e,u=n.now(),o||(o=n.schedule(s,t),r.add(o))},function(){c(),r.complete()},void 0,function(){i=o=null}))})}function Ct(t){return t<=0?function(){return Q}:N(function(n,e){var r=0;n.subscribe(D(e,function(n){++r<=t&&(e.next(n),t<=r&&e.complete())}))})}function $t(t,n){return wt(function(n,e){return ft(t(n,e)).pipe(Ct(1),function(t){return gt(function(){return t})}(n))})}function zt(t,n){void 0===n&&(n=K);var e=Et(t,n);return $t(function(){return e})}function jt(t,n){return t===n}function kt(t,n){return n?function(e){return e.pipe(kt(function(e,r){return ft(t(e,r)).pipe(gt(function(t,o){return n(e,t,r,o)}))}))}:N(function(n,e){var r=0,o=null,i=!1;n.subscribe(D(e,function(n){o||(o=D(e,void 0,function(){o=null,i&&e.complete()}),ft(t(n,r++)).subscribe(o))},function(){i=!0,!o&&e.complete()}))})}function Nt(t,n){return N(function(t,n,e,r,o){return function(r,i){var u=e,c=n,s=0;r.subscribe(D(i,function(n){var e=s++;c=u?t(c,n,e):(u=!0,n),i.next(c)},o))}}(t,n,arguments.length>=2))}function Dt(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(!0!==n){if(!1!==n){var o=new P({next:function(){o.unsubscribe(),t()}});return ft(n.apply(void 0,s([],c(e)))).subscribe(o)}}else t()}function Bt(t,n,e){var r;return r=t,function(t){void 0===t&&(t={});var n=t.connector,e=void 0===n?function(){return new L}:n,r=t.resetOnError,o=void 0===r||r,i=t.resetOnComplete,u=void 0===i||i,c=t.resetOnRefCountZero,s=void 0===c||c;return function(t){var n,r,i,c=0,a=!1,l=!1,f=function(){null==r||r.unsubscribe(),r=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return N(function(t,d){c++,l||a||f();var b=i=null!=i?i:e();d.add(function(){0!==--c||l||a||(r=Dt(p,s))}),b.subscribe(d),!n&&c>0&&(n=new P({next:function(t){return b.next(t)},error:function(t){l=!0,f(),r=Dt(h,o,t),b.error(t)},complete:function(){a=!0,f(),r=Dt(h,u),b.complete()}}),ft(t).subscribe(n))})(t)}}({connector:function(){return new V(r,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Mt(t,n){return N(function(e,r){var o=null,i=0,u=!1,c=function(){return u&&!o&&r.complete()};e.subscribe(D(r,function(e){null==o||o.unsubscribe();var u=0,s=i++;ft(t(e,s)).subscribe(o=D(r,function(t){return r.next(n?n(e,t,s,u++):t)},function(){o=null,c()}))},function(){u=!0,c()}))})}function Lt(t,n,e){var r=h(t)||n||e?{next:t,error:n,complete:e}:t;return r?N(function(t,n){var e;null===(e=r.subscribe)||void 0===e||e.call(r);var o=!0;t.subscribe(D(n,function(t){var e;null===(e=r.next)||void 0===e||e.call(r,t),n.next(t)},function(){var t;o=!1,null===(t=r.complete)||void 0===t||t.call(r),n.complete()},function(t){var e;o=!1,null===(e=r.error)||void 0===e||e.call(r,t),n.error(t)},function(){var t,n;o&&(null===(t=r.unsubscribe)||void 0===t||t.call(r)),null===(n=r.finalize)||void 0===n||n.call(r)}))}):C}function Rt(t,n,e){void 0===n&&(n=K);var r=Et(t,n);return function(t,n){return N(function(e,r){var o=null!=n?n:{},i=o.leading,u=void 0===i||i,c=o.trailing,s=void 0!==c&&c,a=!1,l=null,f=null,h=!1,p=function(){null==f||f.unsubscribe(),f=null,s&&(y(),h&&r.complete())},d=function(){f=null,h&&r.complete()},b=function(n){return f=ft(t(n)).subscribe(D(r,p,d))},y=function(){if(a){a=!1;var t=l;l=null,r.next(t),!h&&b(t)}};e.subscribe(D(r,function(t){a=!0,l=t,(!f||f.closed)&&(u?y():b(t))},function(){h=!0,(!(s&&a&&f)||f.closed)&&r.complete()}))})}(function(){return r},e)}function Ut(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e,r=h(tt(e=t))?e.pop():void 0;return N(function(n,e){for(var o=t.length,i=new Array(o),u=t.map(function(){return!1}),a=!1,l=function(n){ft(t[n]).subscribe(D(e,function(t){i[n]=t,a||u[n]||(u[n]=!0,(a=u.every(C))&&(u=null))},S))},f=0;f<o;f++)l(f);n.subscribe(D(e,function(t){if(a){var n=s([t],c(i));e.next(r?r.apply(void 0,s([],c(n))):n)}}))})}class Wt{_state$;_actions$=new L;get actions$(){return this._actions$.asObservable()}_reducers=[];_context=null;constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new U(n);const e=this._actions$.pipe(Nt((t,n)=>{let e={...t},r=!1;return this._reducers.forEach(({path:o,reducerFn:i})=>{const u=t[o],c=i(u,n);u!==c&&(e[o]=c,r=!0)}),r?e:t},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=nt(t);return N(function(n,r){(e?St(t,n,e):St(t,n)).subscribe(r)})}(t),Bt(1));e.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n={...this._state$.getValue()};let e=!1;t.forEach(({path:t,initialState:r})=>{void 0===n[t]&&(n[t]=r,e=!0)}),e&&this._state$.next(n)}setContext(t){this._context=t}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0};let e=t(this._actions$);n.dispatch?e.pipe(gt(t=>this._context&&!t.context?{...t,context:this._context}:t)).subscribe(t=>this.dispatch(t)):e.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(gt(n=>t(n)),(void 0===e&&(e=C),n=null!=n?n:jt,N(function(t,r){var o,i=!0;t.subscribe(D(r,function(t){var u=e(t);!i&&n(o,u)||(i=!1,o=u,r.next(t))}))})));var n,e}}function Vt(t){const n=n=>({type:t,...n});return n.type=t,n}function qt(){}function Jt(...t){const n=t.pop(),e=t,r=e.includes(qt);if(r&&e.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:e.map(t=>t.type),reducerFn:n,isCatchAll:r}}function Yt(t,n,...e){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const r=e.filter(t=>!t.isCatchAll),o=e.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,e)=>{for(const n of r)if(n.types.includes(e.type))return n.reducerFn(t,e);return o?o.reducerFn(t,e):t}}}function Zt(...t){const n=t.map(t=>t.type);return Ot(t=>n.includes(t.type))}function Gt(t,n={dispatch:!0}){if("function"!=typeof t)throw new Error("Effect must be a function.");return Object.defineProperty(t,"_rxEffect",{value:{dispatch:!1!==n.dispatch},enumerable:!1}),t}function Kt(t,n){return e=>{const r=e[t];return n?n(r):r}}function Ht(...t){const n=t.pop(),e=t;let r,o,i=!1;return t=>{const u=e.map(n=>n(t));return i&&function(t,n){if(!n||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}(u,o)||(o=u,r=n(...u),i=!0),r}}const Qt="__rxTinyFluxLargeAction",Xt="_rxTinyFluxTransferState",tn=(t,n)=>{t&&"function"==typeof t.debug?t.debug(n):"undefined"!=typeof console&&"function"==typeof console.debug&&console.debug(n)},nn=(t,n,e)=>{"undefined"!=typeof console&&"function"==typeof console.error?console.error(n,e):"undefined"!=typeof console&&"function"==typeof console.log&&console.log(n,e)},en=n=>{if(!n)return null;if(n[Xt])return n[Xt];try{const e=new t,r={transferFile:e,inbox:e.getInbox(),outbox:e.getOutbox(),inboxListenerAttached:!1,expectedFiles:new Set};return n[Xt]=r,r}catch(t){return nn(0,"[rx-tiny-flux] Failed to initialize TransferFile.",t),null}},rn=(t,e)=>{if("function"!=typeof n.readFileSync)throw new Error("[rx-tiny-flux] readFileSync is not available in @zos/fs.");const r=(t=>{if("string"==typeof t)return t;if(!t)return"";if("undefined"!=typeof TextDecoder)try{return new TextDecoder("utf-8").decode(t)}catch(t){tn(null,`[rx-tiny-flux] TextDecoder failed: ${t?.message||t}`)}let n=t;t instanceof ArrayBuffer?n=new Uint8Array(t):ArrayBuffer.isView(t)&&(n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e})(n.readFileSync(e));return JSON.parse(r)},on=(t,e)=>{if(e)try{"function"==typeof n.unlinkSync?n.unlinkSync(e):"function"==typeof n.rmSync?n.rmSync(e):"function"==typeof n.removeSync&&n.removeSync(e)}catch(n){tn(t,`[rx-tiny-flux] Failed to remove file ${e}.`)}},un=(t,n)=>{if(!n)return!1;const e=n[Qt]||(n.type===Qt?n:null);if(!e)return!1;const r=en(t);if(r){const t=e.fileName||n.fileName;t&&r.expectedFiles.add(t)}return tn(t,"[rx-tiny-flux] Received large action header message."),!0},cn=t=>{const n=en(t);n&&!n.inboxListenerAttached&&(n.inboxListenerAttached=!0,n.inbox.on("NEWFILE",()=>{const e=n.inbox.getNextFile();if(!e)return;const r=(t=>t?t.meta?t.meta:t.metadata?t.metadata:t.metaData?t.metaData:"function"==typeof t.getMetaData?t.getMetaData():"function"==typeof t.getMetadata?t.getMetadata():null:null)(e),o=r&&r[Qt],i=((t,n)=>t?t.filePath?t.filePath:t.path?t.path:t.fullPath?t.fullPath:t.fileName?t.fileName:"function"==typeof t.getFilePath?t.getFilePath():n:n)(e,o&&o.fileName),u=i&&n.expectedFiles.has(i),c=Boolean(o)||u;if(i&&u&&n.expectedFiles.delete(i),!c)return;const s=()=>{i?((t,n)=>{try{const e=rn(0,n);e&&"string"==typeof e.type?"function"==typeof t.dispatch?t.dispatch(e):nn(0,"[rx-tiny-flux] Dispatch is not available for large action."):tn(t,"[rx-tiny-flux] Ignored large action without a valid type.")}catch(t){nn(0,`[rx-tiny-flux] Failed to read large action from ${n}.`,t)}finally{on(t,n)}})(t,i):nn(0,"[rx-tiny-flux] Incoming large action has no file path.")};"function"==typeof e.on&&e.on("change",n=>{const e=n&&n.data&&n.data.readyState;"transferred"===e?s():"error"===e&&i&&on(t,i)}),"transferred"===e.readyState&&s()}))},sn=(t,e)=>{if(!e)return!1;const r=en(e);if(!r)return!1;const o=`${Date.now()}-${Math.random().toString(16).slice(2)}`,i=(t=>`data://rx-tiny-flux-action-${t}.json`)(o),u={transferId:o,fileName:i,actionType:t&&t.type};try{((t,e,r)=>{if("function"!=typeof n.writeFileSync)throw new Error("[rx-tiny-flux] writeFileSync is not available in @zos/fs.");n.writeFileSync(e,JSON.stringify(r)),tn(t,`[rx-tiny-flux] Stored large action at ${e}.`)})(e,i,t)}catch(t){return nn(0,"[rx-tiny-flux] Failed to store large action on disk.",t),!1}let c;"function"==typeof e.call&&e.call({[Qt]:u});try{c=r.outbox.enqueueFile(i,{[Qt]:u})}catch(t){return nn(0,"[rx-tiny-flux] Failed to enqueue file for transfer.",t),on(e,i),!1}return c&&"function"==typeof c.on&&c.on("change",t=>{const n=t&&t.data&&t.data.readyState;"transferred"!==n&&"error"!==n||on(e,i)}),!0};function an(t,n){return{onCreate(){n?(n.setContext(this),this.debug("Attach the store and a dispatch method to the App instance."),this._store=n,this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},this.onAction=t=>{un(this,t)||(t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from App.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on App.onAction."))},this.messaging.onCall(this.onAction),cn(this),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){let t;const e="undefined"!=typeof messaging;if(e)n?(n.setContext(this),t=n,this.onAction=t=>{un(this,t)||(t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from SideService.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on SideService.onAction."))}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.");else{const n=getApp();n&&n._store?t=n._store:console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.onAction=()=>{}}if(!t)return this.onAction=()=>console.error("[rx-tiny-flux] OnAction failed: store not initialized."),this.messaging.onCall(this.onAction),this.dispatch=()=>console.error("[rx-tiny-flux] Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("[rx-tiny-flux] Subscribe failed: store not initialized."));this._store=t,this.messaging.onCall(this.onAction),this.debug(`Attaching store methods to the ${e?"SideService":"Page"} instance.`),this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},e&&cn(this),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,o=this._store.select(t),i=(r.length>0?o.pipe(...r):o).subscribe(e);return this._subscriptions.push(i),i},e||(this.listen=(t,n)=>{const e=(Array.isArray(t)?t:[t]).map(t=>"function"==typeof t?t.type:t);if(e.some(t=>"string"!=typeof t))throw new Error("[rx-tiny-flux] listen: actionTypes must be strings or action creators with a `type` property.");this._subscriptions||(this._subscriptions=[]);const r=this._store.actions$.pipe(Ot(t=>e.includes(t.type))).subscribe(n);this._subscriptions.push(r)})},onDestroy(){this.messaging.offOnCall(this.onAction),this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const ln=(...t)=>n=>n.pipe(Lt(t=>{if(!t.context||!t.context._store||!t.context._store._state$)throw new Error("[rx-tiny-flux] `withLatestFromStore` could not find a valid store on `action.context._store`. Ensure the `storePlugin` is correctly configured.")}),gt(n=>{const e=n.context._store._state$.getValue();return[n,...t.map(t=>t(e))]})),fn=()=>Ot(()=>"undefined"!=typeof messaging),hn=()=>Ot(()=>"undefined"==typeof messaging),pn=()=>Lt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation action '${t.type}' through messaging.call(action).`);const{context:n,...e}=t;t.context.call(e)}else console.debug(`No context: Action '${t.type}' not propagated through messaging.call(action).`)}),dn=()=>Lt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation large action '${t.type}' through TransferFile.`);const{context:n,...e}=t;sn(e,t.context)}else console.debug(`No context: Action '${t.type}' not propagated through TransferFile.`)});export{Q as EMPTY,j as Observable,Wt as Store,qt as anyAction,Pt as bufferToggle,It as catchError,Ft as concatMap,Vt as createAction,Gt as createEffect,Kt as createFeatureSelector,Yt as createReducer,Ht as createSelector,Tt as debounceTime,At as defer,zt as delay,kt as exhaustMap,Ot as filter,xt as from,hn as isApp,fn as isSideService,gt as map,wt as mergeMap,mt as of,Zt as ofType,Jt as on,$ as pipe,pn as propagateAction,dn as propagateLargeAction,Nt as scan,an as storePlugin,Mt as switchMap,Ct as take,Lt as tap,Rt as throttleTime,Et as timer,Ut as withLatestFrom,ln as withLatestFromStore};
1
+ var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};function n(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function e(t,n,e,r){return new(e||(e=Promise))(function(i,o){function u(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(u,s)}c((r=r.apply(t,n||[])).next())})}function r(t,n){var e,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=s(0),u.throw=s(1),u.return=s(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function s(s){return function(c){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(o=0)),o;)try{if(e=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=n.call(t,o)}catch(t){s=[6,t],r=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function i(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return u}function u(t,n,e){if(e||2===arguments.length)for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function s(t){return this instanceof s?(this.v=t,this):new s(t)}function c(t,n,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=e.apply(t,n||[]),o=[];return r=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,l)}}),r[Symbol.asyncIterator]=function(){return this},r;function u(t,n){i[t]&&(r[t]=function(n){return new Promise(function(e,r){o.push([t,n,e,r])>1||c(t,n)})},n&&(r[t]=n(r[t])))}function c(t,n){try{(e=i[t](n)).value instanceof s?Promise.resolve(e.value.v).then(a,l):f(o[0][2],e)}catch(t){f(o[0][3],t)}var e}function a(t){c("next",t)}function l(t){c("throw",t)}function f(t,n){t(n),o.shift(),o.length&&c(o[0][0],o[0][1])}}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,e=t[Symbol.asyncIterator];return e?e.call(t):(t=i(t),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(e){n[e]=t[e]&&function(n){return new Promise(function(r,i){(function(t,n,e,r){Promise.resolve(r).then(function(n){t({value:n,done:e})},n)})(r,i,(n=t[e](n)).done,n.value)})}}}function l(t){return"function"==typeof t}function f(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var h=f(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function p(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var d=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,e,r,s;if(!this.closed){this.closed=!0;var c=this._parentage;if(c)if(this._parentage=null,Array.isArray(c))try{for(var a=i(c),f=a.next();!f.done;f=a.next()){f.value.remove(this)}}catch(n){t={error:n}}finally{try{f&&!f.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else c.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(t){s=t instanceof h?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var y=i(d),b=y.next();!b.done;b=y.next()){var x=b.value;try{v(x)}catch(t){s=null!=s?s:[],t instanceof h?s=u(u([],o(s)),o(t.errors)):s.push(t)}}}catch(t){e={error:t}}finally{try{b&&!b.done&&(r=y.return)&&r.call(y)}finally{if(e)throw e.error}}}if(s)throw new h(s)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)v(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(e=this._finalizers)&&void 0!==e?e:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&p(n,t)},t.prototype.remove=function(n){var e=this._finalizers;e&&p(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),y=d.EMPTY;function b(t){return t instanceof d||t&&"closed"in t&&l(t.remove)&&l(t.add)&&l(t.unsubscribe)}function v(t){l(t)?t():t.unsubscribe()}var x={Promise:void 0},g=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,u([t,n],o(e)))};function m(t){g(function(){throw t})}function w(){}function _(t){t()}var S=function(t){function e(n){var e=t.call(this)||this;return e.isStopped=!1,n?(e.destination=n,b(n)&&n.add(e)):e.destination=F,e}return n(e,t),e.create=function(t,n,e){return new E(t,n,e)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(d),A=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){I(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){I(t)}else I(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){I(t)}},t}(),E=function(t){function e(n,e,r){var i,o=t.call(this)||this;return i=l(n)||!n?{next:null!=n?n:void 0,error:null!=e?e:void 0,complete:null!=r?r:void 0}:n,o.destination=new A(i),o}return n(e,t),e}(S);function I(t){m(t)}var F={closed:!0,next:w,error:function(t){throw t},complete:w},T="function"==typeof Symbol&&Symbol.observable||"@@observable";function $(t){return t}function O(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return P(t)}function P(t){return 0===t.length?$:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)}}var C=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var e=new t;return e.source=this,e.operator=n,e},t.prototype.subscribe=function(t,n,e){var r,i=this,o=(r=t)&&r instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(r)&&b(r)?t:new E(t,n,e);return _(function(){var t=i,n=t.operator,e=t.source;o.add(n?n.call(o,e):e?i._subscribe(o):i._trySubscribe(o))}),o},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var e=this;return new(n=k(n))(function(n,r){var i=new E({next:function(n){try{t(n)}catch(t){r(t),i.unsubscribe()}},error:r,complete:n});e.subscribe(i)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[T]=function(){return this},t.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return P(t)(this)},t.prototype.toPromise=function(t){var n=this;return new(t=k(t))(function(t,e){var r;n.subscribe(function(t){return r=t},function(t){return e(t)},function(){return t(r)})})},t.create=function(n){return new t(n)},t}();function k(t){var n;return null!==(n=null!=t?t:x.Promise)&&void 0!==n?n:Promise}function z(t){return function(n){if(function(t){return l(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function N(t,n,e,r,i){return new j(t,n,e,r,i)}var j=function(t){function e(n,e,r,i,o,u){var s=t.call(this,n)||this;return s.onFinalize=o,s.shouldUnsubscribe=u,s._next=e?function(t){try{e(t)}catch(t){n.error(t)}}:t.prototype._next,s._error=i?function(t){try{i(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=r?function(){try{r()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,s}return n(e,t),e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var e=this.closed;t.prototype.unsubscribe.call(this),!e&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},e}(S),D=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),B=function(t){function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return n(e,t),e.prototype.lift=function(t){var n=new R(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new D},e.prototype.next=function(t){var n=this;_(function(){var e,r;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=i(n.currentObservers),u=o.next();!u.done;u=o.next()){u.value.next(t)}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}}})},e.prototype.error=function(t){var n=this;_(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var e=n.observers;e.length;)e.shift().error(t)}})},e.prototype.complete=function(){var t=this;_(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,e=this,r=e.hasError,i=e.isStopped,o=e.observers;return r||i?y:(this.currentObservers=null,o.push(t),new d(function(){n.currentObservers=null,p(o,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,e=n.hasError,r=n.thrownError,i=n.isStopped;e?t.error(r):i&&t.complete()},e.prototype.asObservable=function(){var t=new C;return t.source=this,t},e.create=function(t,n){return new R(t,n)},e}(C),R=function(t){function e(n,e){var r=t.call(this)||this;return r.destination=n,r.source=e,r}return n(e,t),e.prototype.next=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===e||e.call(n,t)},e.prototype.error=function(t){var n,e;null===(e=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===e||e.call(n,t)},e.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},e.prototype._subscribe=function(t){var n,e;return null!==(e=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==e?e:y},e}(B),L=function(t){function e(n){var e=t.call(this)||this;return e._value=n,e}return n(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var e=t.prototype._subscribe.call(this,n);return!e.closed&&n.next(this._value),e},e.prototype.getValue=function(){var t=this,n=t.hasError,e=t.thrownError,r=t._value;if(n)throw e;return this._throwIfClosed(),r},e.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},e}(B),M={now:function(){return(M.delegate||Date).now()},delegate:void 0},q=function(t){function e(n,e,r){void 0===n&&(n=1/0),void 0===e&&(e=1/0),void 0===r&&(r=M);var i=t.call(this)||this;return i._bufferSize=n,i._windowTime=e,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=e===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,e),i}return n(e,t),e.prototype.next=function(n){var e=this,r=e.isStopped,i=e._buffer,o=e._infiniteTimeWindow,u=e._timestampProvider,s=e._windowTime;r||(i.push(n),!o&&i.push(u.now()+s)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),e=this._infiniteTimeWindow,r=this._buffer.slice(),i=0;i<r.length&&!t.closed;i+=e?1:2)t.next(r[i]);return this._checkFinalizedStatuses(t),n},e.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,e=t._timestampProvider,r=t._buffer,i=t._infiniteTimeWindow,o=(i?1:2)*n;if(n<1/0&&o<r.length&&r.splice(0,r.length-o),!i){for(var u=e.now(),s=0,c=1;c<r.length&&r[c]<=u;c+=2)s=c;s&&r.splice(0,s+1)}},e}(B),U=function(t){function e(n,e){return t.call(this)||this}return n(e,t),e.prototype.schedule=function(t,n){return this},e}(d),W=function(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,u([t,n],o(e)))},V=function(t){return clearInterval(t)},J=function(t){function e(n,e){var r=t.call(this,n,e)||this;return r.scheduler=n,r.work=e,r.pending=!1,r}return n(e,t),e.prototype.schedule=function(t,n){var e;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var r=this.id,i=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(i,r,n)),this.pending=!0,this.delay=n,this.id=null!==(e=this.id)&&void 0!==e?e:this.requestAsyncId(i,this.id,n),this},e.prototype.requestAsyncId=function(t,n,e){return void 0===e&&(e=0),W(t.flush.bind(t,this),e)},e.prototype.recycleAsyncId=function(t,n,e){if(void 0===e&&(e=0),null!=e&&this.delay===e&&!1===this.pending)return n;null!=n&&V(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var e=this._execute(t,n);if(e)return e;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var e,r=!1;try{this.work(t)}catch(t){r=!0,e=t||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),e},e.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,e=this.scheduler,r=e.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(r,this),null!=n&&(this.id=this.recycleAsyncId(e,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},e}(U),Y=function(){function t(n,e){void 0===e&&(e=t.now),this.schedulerActionCtor=n,this.now=e}return t.prototype.schedule=function(t,n,e){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(e,n)},t.now=M.now,t}(),Q=new(function(t){function e(n,e){void 0===e&&(e=Y.now);var r=t.call(this,n,e)||this;return r.actions=[],r._active=!1,r}return n(e,t),e.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var e;this._active=!0;do{if(e=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,e){for(;t=n.shift();)t.unsubscribe();throw e}}},e}(Y))(J),Z=Q,G=new C(function(t){return t.complete()});function K(t){return t&&l(t.schedule)}function H(t){return t[t.length-1]}function X(t){return K(H(t))?t.pop():void 0}var tt=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function nt(t){return l(null==t?void 0:t.then)}function et(t){return l(t[T])}function rt(t){return Symbol.asyncIterator&&l(null==t?void 0:t[Symbol.asyncIterator])}function it(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var ot="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ut(t){return l(null==t?void 0:t[ot])}function st(t){return c(this,arguments,function(){var n,e,i;return r(this,function(r){switch(r.label){case 0:n=t.getReader(),r.label=1;case 1:r.trys.push([1,,9,10]),r.label=2;case 2:return[4,s(n.read())];case 3:return e=r.sent(),i=e.value,e.done?[4,s(void 0)]:[3,5];case 4:return[2,r.sent()];case 5:return[4,s(i)];case 6:return[4,r.sent()];case 7:return r.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ct(t){return l(null==t?void 0:t.getReader)}function at(t){if(t instanceof C)return t;if(null!=t){if(et(t))return o=t,new C(function(t){var n=o[T]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(tt(t))return r=t,new C(function(t){for(var n=0;n<r.length&&!t.closed;n++)t.next(r[n]);t.complete()});if(nt(t))return e=t,new C(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,m)});if(rt(t))return lt(t);if(ut(t))return n=t,new C(function(t){var e,r;try{for(var o=i(n),u=o.next();!u.done;u=o.next()){var s=u.value;if(t.next(s),t.closed)return}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t.complete()});if(ct(t))return lt(st(t))}var n,e,r,o;throw it(t)}function lt(t){return new C(function(n){(function(t,n){var i,o,u,s;return e(this,void 0,void 0,function(){var e,c;return r(this,function(r){switch(r.label){case 0:r.trys.push([0,5,6,11]),i=a(t),r.label=1;case 1:return[4,i.next()];case 2:if((o=r.sent()).done)return[3,4];if(e=o.value,n.next(e),n.closed)return[2];r.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=r.sent(),u={error:c},[3,11];case 6:return r.trys.push([6,,9,10]),o&&!o.done&&(s=i.return)?[4,s.call(i)]:[3,8];case 7:r.sent(),r.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function ft(t,n,e,r,i){void 0===r&&(r=0),void 0===i&&(i=!1);var o=n.schedule(function(){e(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}function ht(t,n){return void 0===n&&(n=0),z(function(e,r){e.subscribe(N(r,function(e){return ft(r,t,function(){return r.next(e)},n)},function(){return ft(r,t,function(){return r.complete()},n)},function(e){return ft(r,t,function(){return r.error(e)},n)}))})}function pt(t,n){return void 0===n&&(n=0),z(function(e,r){r.add(t.schedule(function(){return e.subscribe(r)},n))})}function dt(t,n){if(!t)throw new Error("Iterable cannot be null");return new C(function(e){ft(e,n,function(){var r=t[Symbol.asyncIterator]();ft(e,n,function(){r.next().then(function(t){t.done?e.complete():e.next(t.value)})},0,!0)})})}function yt(t,n){if(null!=t){if(et(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(tt(t))return function(t,n){return new C(function(e){var r=0;return n.schedule(function(){r===t.length?e.complete():(e.next(t[r++]),e.closed||this.schedule())})})}(t,n);if(nt(t))return function(t,n){return at(t).pipe(pt(n),ht(n))}(t,n);if(rt(t))return dt(t,n);if(ut(t))return function(t,n){return new C(function(e){var r;return ft(e,n,function(){r=t[ot](),ft(e,n,function(){var t,n,i;try{n=(t=r.next()).value,i=t.done}catch(t){return void e.error(t)}i?e.complete():e.next(n)},0,!0)}),function(){return l(null==r?void 0:r.return)&&r.return()}})}(t,n);if(ct(t))return function(t,n){return dt(st(t),n)}(t,n)}throw it(t)}function bt(t,n){return n?yt(t,n):at(t)}function vt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return bt(t,X(t))}function xt(t,n){return z(function(e,r){var i=0;e.subscribe(N(r,function(e){r.next(t.call(n,e,i++))}))})}function gt(t,n,e){return void 0===e&&(e=1/0),l(n)?gt(function(e,r){return xt(function(t,i){return n(e,t,r,i)})(at(t(e,r)))},e):("number"==typeof n&&(e=n),z(function(n,r){return function(t,n,e,r,i,o,u){var s=[],c=0,a=0,l=!1,f=function(){!l||s.length||c||n.complete()},h=function(t){c++;var i=!1;at(e(t,a++)).subscribe(N(n,function(t){n.next(t)},function(){i=!0},void 0,function(){if(i)try{c--;for(var t=function(){var t=s.shift();u||h(t)};s.length&&c<r;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(N(n,function(t){return c<r?h(t):s.push(t)},function(){l=!0,f()})),function(){}}(n,r,t,e)}))}function mt(){return gt($,1)}function wt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return mt()(bt(t,X(t)))}function _t(t){return new C(function(n){at(t()).subscribe(n)})}function St(t,n,e){void 0===t&&(t=0),void 0===e&&(e=Z);var r=-1;return null!=n&&(K(n)?e=n:r=n),new C(function(n){var i,o=(i=t)instanceof Date&&!isNaN(i)?+t-e.now():t;o<0&&(o=0);var u=0;return e.schedule(function(){n.closed||(n.next(u++),0<=r?this.schedule(void 0,r):n.complete())},o)})}function At(t,n){return z(function(e,r){var i=0;e.subscribe(N(r,function(e){return t.call(n,e,i++)&&r.next(e)}))})}function Et(t,n){return z(function(e,r){var o=[];at(t).subscribe(N(r,function(t){var e=[];o.push(e);var i=new d;i.add(at(n(t)).subscribe(N(r,function(){p(o,e),r.next(e),i.unsubscribe()},w)))},w)),e.subscribe(N(r,function(t){var n,e;try{for(var r=i(o),u=r.next();!u.done;u=r.next()){u.value.push(t)}}catch(t){n={error:t}}finally{try{u&&!u.done&&(e=r.return)&&e.call(r)}finally{if(n)throw n.error}}},function(){for(;o.length>0;)r.next(o.shift());r.complete()}))})}function It(t){return z(function(n,e){var r,i=null,o=!1;i=n.subscribe(N(e,void 0,void 0,function(u){r=at(t(u,It(t)(n))),i?(i.unsubscribe(),i=null,r.subscribe(e)):o=!0})),o&&(i.unsubscribe(),i=null,r.subscribe(e))})}function Ft(t,n){return l(n)?gt(t,n,1):gt(t,1)}function Tt(t,n){return void 0===n&&(n=Q),z(function(e,r){var i=null,o=null,u=null,s=function(){if(i){i.unsubscribe(),i=null;var t=o;o=null,r.next(t)}};function c(){var e=u+t,o=n.now();if(o<e)return i=this.schedule(void 0,e-o),void r.add(i);s()}e.subscribe(N(r,function(e){o=e,u=n.now(),i||(i=n.schedule(c,t),r.add(i))},function(){s(),r.complete()},void 0,function(){o=i=null}))})}function $t(t){return t<=0?function(){return G}:z(function(n,e){var r=0;n.subscribe(N(e,function(n){++r<=t&&(e.next(n),t<=r&&e.complete())}))})}function Ot(t,n){return gt(function(n,e){return at(t(n,e)).pipe($t(1),function(t){return xt(function(){return t})}(n))})}function Pt(t,n){void 0===n&&(n=Q);var e=St(t,n);return Ot(function(){return e})}function Ct(t,n){return t===n}function kt(t,n){return n?function(e){return e.pipe(kt(function(e,r){return at(t(e,r)).pipe(xt(function(t,i){return n(e,t,r,i)}))}))}:z(function(n,e){var r=0,i=null,o=!1;n.subscribe(N(e,function(n){i||(i=N(e,void 0,function(){i=null,o&&e.complete()}),at(t(n,r++)).subscribe(i))},function(){o=!0,!i&&e.complete()}))})}function zt(t,n){return z(function(t,n,e,r,i){return function(r,o){var u=e,s=n,c=0;r.subscribe(N(o,function(n){var e=c++;s=u?t(s,n,e):(u=!0,n),o.next(s)},i))}}(t,n,arguments.length>=2))}function Nt(t,n){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];if(!0!==n){if(!1!==n){var i=new E({next:function(){i.unsubscribe(),t()}});return at(n.apply(void 0,u([],o(e)))).subscribe(i)}}else t()}function jt(t,n,e){var r;return r=t,function(t){void 0===t&&(t={});var n=t.connector,e=void 0===n?function(){return new B}:n,r=t.resetOnError,i=void 0===r||r,o=t.resetOnComplete,u=void 0===o||o,s=t.resetOnRefCountZero,c=void 0===s||s;return function(t){var n,r,o,s=0,a=!1,l=!1,f=function(){null==r||r.unsubscribe(),r=void 0},h=function(){f(),n=o=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return z(function(t,d){s++,l||a||f();var y=o=null!=o?o:e();d.add(function(){0!==--s||l||a||(r=Nt(p,c))}),y.subscribe(d),!n&&s>0&&(n=new E({next:function(t){return y.next(t)},error:function(t){l=!0,f(),r=Nt(h,i,t),y.error(t)},complete:function(){a=!0,f(),r=Nt(h,u),y.complete()}}),at(t).subscribe(n))})(t)}}({connector:function(){return new q(r,n,e)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function Dt(t,n){return z(function(e,r){var i=null,o=0,u=!1,s=function(){return u&&!i&&r.complete()};e.subscribe(N(r,function(e){null==i||i.unsubscribe();var u=0,c=o++;at(t(e,c)).subscribe(i=N(r,function(t){return r.next(n?n(e,t,c,u++):t)},function(){i=null,s()}))},function(){u=!0,s()}))})}function Bt(t,n,e){var r=l(t)||n||e?{next:t,error:n,complete:e}:t;return r?z(function(t,n){var e;null===(e=r.subscribe)||void 0===e||e.call(r);var i=!0;t.subscribe(N(n,function(t){var e;null===(e=r.next)||void 0===e||e.call(r,t),n.next(t)},function(){var t;i=!1,null===(t=r.complete)||void 0===t||t.call(r),n.complete()},function(t){var e;i=!1,null===(e=r.error)||void 0===e||e.call(r,t),n.error(t)},function(){var t,n;i&&(null===(t=r.unsubscribe)||void 0===t||t.call(r)),null===(n=r.finalize)||void 0===n||n.call(r)}))}):$}function Rt(t,n,e){void 0===n&&(n=Q);var r=St(t,n);return function(t,n){return z(function(e,r){var i=null!=n?n:{},o=i.leading,u=void 0===o||o,s=i.trailing,c=void 0!==s&&s,a=!1,l=null,f=null,h=!1,p=function(){null==f||f.unsubscribe(),f=null,c&&(b(),h&&r.complete())},d=function(){f=null,h&&r.complete()},y=function(n){return f=at(t(n)).subscribe(N(r,p,d))},b=function(){if(a){a=!1;var t=l;l=null,r.next(t),!h&&y(t)}};e.subscribe(N(r,function(t){a=!0,l=t,(!f||f.closed)&&(u?b():y(t))},function(){h=!0,(!(c&&a&&f)||f.closed)&&r.complete()}))})}(function(){return r},e)}function Lt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e,r=l(H(e=t))?e.pop():void 0;return z(function(n,e){for(var i=t.length,s=new Array(i),c=t.map(function(){return!1}),a=!1,l=function(n){at(t[n]).subscribe(N(e,function(t){s[n]=t,a||c[n]||(c[n]=!0,(a=c.every($))&&(c=null))},w))},f=0;f<i;f++)l(f);n.subscribe(N(e,function(t){if(a){var n=u([t],o(s));e.next(r?r.apply(void 0,u([],o(n))):n)}}))})}class Mt{_state$;_actions$=new B;get actions$(){return this._actions$.asObservable()}_reducers=[];_context=null;constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new L(n);const e=this._actions$.pipe(zt((t,n)=>{let e={...t},r=!1;return this._reducers.forEach(({path:i,reducerFn:o})=>{const u=t[i],s=o(u,n);u!==s&&(e[i]=s,r=!0)}),r?e:t},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=X(t);return z(function(n,r){(e?wt(t,n,e):wt(t,n)).subscribe(r)})}(t),jt(1));e.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n={...this._state$.getValue()};let e=!1;t.forEach(({path:t,initialState:r})=>{void 0===n[t]&&(n[t]=r,e=!0)}),e&&this._state$.next(n)}setContext(t){this._context=t}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0};let e=t(this._actions$);n.dispatch?e.pipe(xt(t=>this._context&&!t.context?{...t,context:this._context}:t)).subscribe(t=>this.dispatch(t)):e.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(xt(n=>t(n)),(void 0===e&&(e=$),n=null!=n?n:Ct,z(function(t,r){var i,o=!0;t.subscribe(N(r,function(t){var u=e(t);!o&&n(i,u)||(o=!1,i=u,r.next(t))}))})));var n,e}}function qt(t){const n=n=>({type:t,...n});return n.type=t,n}function Ut(){}function Wt(...t){const n=t.pop(),e=t,r=e.includes(Ut);if(r&&e.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:e.map(t=>t.type),reducerFn:n,isCatchAll:r}}function Vt(t,n,...e){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const r=e.filter(t=>!t.isCatchAll),i=e.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,e)=>{for(const n of r)if(n.types.includes(e.type))return n.reducerFn(t,e);return i?i.reducerFn(t,e):t}}}function Jt(...t){const n=t.map(t=>t.type);return At(t=>n.includes(t.type))}function Yt(t,n={dispatch:!0}){if("function"!=typeof t)throw new Error("Effect must be a function.");return Object.defineProperty(t,"_rxEffect",{value:{dispatch:!1!==n.dispatch},enumerable:!1}),t}function Qt(t,n){return e=>{const r=e[t];return n?n(r):r}}function Zt(...t){const n=t.pop(),e=t;let r,i,o=!1;return t=>{const u=e.map(n=>n(t));return o&&function(t,n){if(!n||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}(u,i)||(i=u,r=n(...u),o=!0),r}}const Gt="__rxTinyFluxLargeAction",Kt="_rxTinyFluxTransferState";let Ht,Xt;const tn=t=>{const n="function"==typeof __$$RQR$$__?__$$RQR$$__:"function"==typeof require?require:null;if(!n)return null;try{return n(t)}catch(t){return null}},nn=()=>{if(void 0!==Ht)return Ht;const t="undefined"!=typeof messaging;if(t&&"undefined"!=typeof transferFile&&"function"==typeof transferFile.getInbox)return Ht=transferFile,Ht;if(t&&"undefined"!=typeof globalThis&&globalThis.transferFile&&"function"==typeof globalThis.transferFile.getInbox)return Ht=globalThis.transferFile,Ht;if(!t){const t=tn("@zos/ble/TransferFile"),n=t&&(t.default||t.TransferFile||t);if(n)return Ht=new n,Ht}return Ht=null,Ht},en=()=>void 0!==Xt?Xt:"undefined"!=typeof globalThis&&globalThis.fs?(Xt=globalThis.fs,Xt):(Xt=tn("@zos/fs")||null,Xt),rn=(t,n)=>{t&&"function"==typeof t.debug?t.debug(n):"undefined"!=typeof console&&"function"==typeof console.debug&&console.debug(n)},on=(t,n,e)=>{"undefined"!=typeof console&&"function"==typeof console.error?console.error(n,e):"undefined"!=typeof console&&"function"==typeof console.log&&console.log(n,e)},un=t=>{if(!t)return null;if(t[Kt])return t[Kt];try{const n=nn();if(!n)return on(0,"[rx-tiny-flux] TransferFile is not available."),null;if("function"!=typeof n.getInbox||"function"!=typeof n.getOutbox)return on(0,"[rx-tiny-flux] TransferFile is missing inbox/outbox accessors."),null;const e={transferFile:n,inbox:n.getInbox(),outbox:n.getOutbox(),inboxListenerAttached:!1,expectedFiles:new Set};return rn(t,`[rx-tiny-flux] TransferFile initialized. inbox=${Boolean(e.inbox)} outbox=${Boolean(e.outbox)}`),t[Kt]=e,e}catch(t){return on(0,"[rx-tiny-flux] Failed to initialize TransferFile.",t),null}},sn=(t,n)=>{const e=en();if(!e||"function"!=typeof e.readFileSync)throw new Error("[rx-tiny-flux] readFileSync is not available in @zos/fs.");const r=(t=>{if("string"==typeof t)return t;if(!t)return"";if("undefined"!=typeof TextDecoder)try{return new TextDecoder("utf-8").decode(t)}catch(t){rn(null,`[rx-tiny-flux] TextDecoder failed: ${t?.message||t}`)}let n=t;t instanceof ArrayBuffer?n=new Uint8Array(t):ArrayBuffer.isView(t)&&(n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength));let e="";for(let t=0;t<n.length;t+=1)e+=String.fromCharCode(n[t]);return e})(e.readFileSync(n));return JSON.parse(r)},cn=(t,n)=>{if(!n)return;const e=en();if(e)try{"function"==typeof e.unlinkSync?e.unlinkSync(n):"function"==typeof e.rmSync?e.rmSync(n):"function"==typeof e.removeSync&&e.removeSync(n)}catch(e){rn(t,`[rx-tiny-flux] Failed to remove file ${n}.`)}},an=(t,n)=>{if(!n)return!1;const e=n[Gt]||(n.type===Gt?n:null);if(!e)return!1;const r=un(t);if(r){const t=e.fileName||n.fileName;t&&r.expectedFiles.add(t)}return rn(t,`[rx-tiny-flux] Received large action header message. transferId=${e.transferId||"unknown"} fileName=${e.fileName||"unknown"} actionType=${e.actionType||"unknown"}`),!0},ln=t=>{const n=un(t);n&&!n.inboxListenerAttached?(n.inboxListenerAttached=!0,rn(t,"[rx-tiny-flux] Large action receiver attached to inbox."),n.inbox.on("NEWFILE",()=>{const e=n.inbox.getNextFile();if(!e)return void rn(t,"[rx-tiny-flux] Inbox NEWFILE fired but no file object was returned.");const r=(t=>t?t.meta?t.meta:t.metadata?t.metadata:t.metaData?t.metaData:"function"==typeof t.getMetaData?t.getMetaData():"function"==typeof t.getMetadata?t.getMetadata():null:null)(e),i=r&&r[Gt],o=((t,n)=>t?t.filePath?t.filePath:t.path?t.path:t.fullPath?t.fullPath:t.fileName?t.fileName:"function"==typeof t.getFilePath?t.getFilePath():n:n)(e,i&&i.fileName),u=o&&n.expectedFiles.has(o),s=Boolean(i)||u;if(rn(t,`[rx-tiny-flux] Inbox NEWFILE received. filePath=${o||"unknown"} expected=${Boolean(u)} hasMeta=${Boolean(i)}`),o&&u&&n.expectedFiles.delete(o),!s)return void rn(t,"[rx-tiny-flux] Ignoring inbox file: not a large action.");const c=()=>{o?((t,n)=>{try{const e=sn(0,n);e&&"string"==typeof e.type?"function"==typeof t.dispatch?t.dispatch(e):on(0,"[rx-tiny-flux] Dispatch is not available for large action."):rn(t,"[rx-tiny-flux] Ignored large action without a valid type.")}catch(t){on(0,`[rx-tiny-flux] Failed to read large action from ${n}.`,t)}finally{cn(t,n)}})(t,o):on(0,"[rx-tiny-flux] Incoming large action has no file path.")};"function"==typeof e.on&&e.on("change",n=>{const e=n&&n.data&&n.data.readyState;rn(t,`[rx-tiny-flux] Inbox file change event. readyState=${e||"unknown"}`),"transferred"===e?c():"error"===e&&o&&cn(t,o)}),"transferred"===e.readyState&&(rn(t,"[rx-tiny-flux] Inbox file already transferred."),c())})):n||rn(t,"[rx-tiny-flux] Skipping large action receiver setup: no TransferFile state.")},fn=(t,n)=>{if(!n)return!1;const e=un(n);if(!e)return!1;rn(n,`[rx-tiny-flux] Enqueueing large action transfer. type=${t&&t.type?t.type:"unknown"}`);const r=`${Date.now()}-${Math.random().toString(16).slice(2)}`,i=(t=>`data://rx-tiny-flux-action-${t}.json`)(r),o={transferId:r,fileName:i,actionType:t&&t.type};try{((t,n,e)=>{const r=en();if(!r||"function"!=typeof r.writeFileSync)throw new Error("[rx-tiny-flux] writeFileSync is not available in @zos/fs.");r.writeFileSync(n,JSON.stringify(e)),rn(t,`[rx-tiny-flux] Stored large action at ${n}.`)})(n,i,t)}catch(t){return on(0,"[rx-tiny-flux] Failed to store large action on disk.",t),!1}let u;"function"==typeof n.call?(rn(n,`[rx-tiny-flux] Sending large action header via messaging.call. transferId=${r}`),n.call({[Gt]:o})):rn(n,"[rx-tiny-flux] messaging.call is not available for large action header.");try{u=e.outbox.enqueueFile(i,{[Gt]:o}),rn(n,`[rx-tiny-flux] Enqueued file for transfer. fileName=${i}`)}catch(t){return on(0,"[rx-tiny-flux] Failed to enqueue file for transfer.",t),cn(n,i),!1}return u&&"function"==typeof u.on&&u.on("change",t=>{const e=t&&t.data&&t.data.readyState;rn(n,`[rx-tiny-flux] Outbox file change event. readyState=${e||"unknown"}`),"transferred"!==e&&"error"!==e||cn(n,i)}),!0};function hn(t,n){return{onCreate(){n?(n.setContext(this),this.debug("Attach the store and a dispatch method to the App instance."),this._store=n,this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},this.onAction=t=>{an(this,t)||(t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from App.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on App.onAction."))},this.messaging.onCall(this.onAction),ln(this),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,i=this._store.select(t),o=(r.length>0?i.pipe(...r):i).subscribe(e);return this._subscriptions.push(o),o}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseApp.use(storePlugin, store)`.")},onInit(){let t;const e="undefined"!=typeof messaging;if(e)n?(n.setContext(this),t=n,this.onAction=t=>{an(this,t)||(t&&"string"==typeof t.type?(this.debug(`Dispatching action ${t.type} from SideService.onAction.`),this.dispatch(t)):this.debug("Not an Action, discarding the message on SideService.onAction."))}):console.error("[rx-tiny-flux] StorePlugin Error: A store instance must be provided to `BaseSideService.use(storePlugin, store)`.");else{const n=getApp();n&&n._store?t=n._store:console.error("[rx-tiny-flux] Store not found on global App object. Ensure the plugin is registered on BaseApp."),this.onAction=()=>{}}if(!t)return this.onAction=()=>console.error("[rx-tiny-flux] OnAction failed: store not initialized."),this.messaging.onCall(this.onAction),this.dispatch=()=>console.error("[rx-tiny-flux] Dispatch failed: store not initialized."),void(this.subscribe=()=>console.error("[rx-tiny-flux] Subscribe failed: store not initialized."));this._store=t,this.messaging.onCall(this.onAction),this.debug(`Attaching store methods to the ${e?"SideService":"Page"} instance.`),this.dispatch=t=>{setTimeout(()=>{const n={...t,context:this};this._store.dispatch(n)},50)},e&&ln(this),this.subscribe=(t,...n)=>{this._subscriptions||(this._subscriptions=[]);const e=n.pop(),r=n,i=this._store.select(t),o=(r.length>0?i.pipe(...r):i).subscribe(e);return this._subscriptions.push(o),o},e||(this.listen=(t,n)=>{const e=(Array.isArray(t)?t:[t]).map(t=>"function"==typeof t?t.type:t);if(e.some(t=>"string"!=typeof t))throw new Error("[rx-tiny-flux] listen: actionTypes must be strings or action creators with a `type` property.");this._subscriptions||(this._subscriptions=[]);const r=this._store.actions$.pipe(At(t=>e.includes(t.type))).subscribe(n);this._subscriptions.push(r)})},onDestroy(){this.messaging.offOnCall(this.onAction),this._subscriptions&&this._subscriptions.length>0&&(this._subscriptions.forEach(t=>t.unsubscribe()),this._subscriptions=[])}}}const pn=(...t)=>n=>n.pipe(Bt(t=>{if(!t.context||!t.context._store||!t.context._store._state$)throw new Error("[rx-tiny-flux] `withLatestFromStore` could not find a valid store on `action.context._store`. Ensure the `storePlugin` is correctly configured.")}),xt(n=>{const e=n.context._store._state$.getValue();return[n,...t.map(t=>t(e))]})),dn=()=>At(()=>"undefined"!=typeof messaging),yn=()=>At(()=>"undefined"==typeof messaging),bn=()=>Bt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation action '${t.type}' through messaging.call(action).`);const{context:n,...e}=t;t.context.call(e)}else console.debug(`No context: Action '${t.type}' not propagated through messaging.call(action).`)}),vn=()=>Bt(t=>{if(t.context&&"function"==typeof t.context.call){t.context.debug(`Propagation large action '${t.type}' through TransferFile.`);const{context:n,...e}=t;fn(e,t.context)}else console.debug(`No context: Action '${t.type}' not propagated through TransferFile.`)});export{G as EMPTY,C as Observable,Mt as Store,Ut as anyAction,Et as bufferToggle,It as catchError,Ft as concatMap,qt as createAction,Yt as createEffect,Qt as createFeatureSelector,Vt as createReducer,Zt as createSelector,Tt as debounceTime,_t as defer,Pt as delay,kt as exhaustMap,At as filter,bt as from,yn as isApp,dn as isSideService,xt as map,gt as mergeMap,vt as of,Jt as ofType,Wt as on,O as pipe,bn as propagateAction,vn as propagateLargeAction,zt as scan,hn as storePlugin,Dt as switchMap,$t as take,Bt as tap,Rt as throttleTime,St as timer,Lt as withLatestFrom,pn as withLatestFromStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rx-tiny-flux",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "A lightweight, minimalist state management library for pure JavaScript projects, inspired by NgRx and Redux, and built with RxJS.",
5
5
  "author": "Bernardo Baumblatt <baumblatt@gmail.com>",
6
6
  "license": "MIT",