@codeleap/portals 6.3.0 → 7.0.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.
Files changed (41) hide show
  1. package/dist/factors/alert.d.ts +44 -0
  2. package/dist/factors/alert.d.ts.map +1 -0
  3. package/dist/factors/bottomSheet.d.ts +61 -0
  4. package/dist/factors/bottomSheet.d.ts.map +1 -0
  5. package/dist/factors/drawer.d.ts +32 -0
  6. package/dist/factors/drawer.d.ts.map +1 -0
  7. package/dist/factors/modal.d.ts +32 -0
  8. package/dist/factors/modal.d.ts.map +1 -0
  9. package/dist/globals.d.ts +19 -0
  10. package/dist/globals.d.ts.map +1 -0
  11. package/dist/index.d.ts +13 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/lib/Portal.d.ts +121 -0
  14. package/dist/lib/Portal.d.ts.map +1 -0
  15. package/dist/lib/PortalRegistry.d.ts +59 -0
  16. package/dist/lib/PortalRegistry.d.ts.map +1 -0
  17. package/dist/lib/PortalRequest.d.ts +44 -0
  18. package/dist/lib/PortalRequest.d.ts.map +1 -0
  19. package/dist/lib/PortalState.d.ts +83 -0
  20. package/dist/lib/PortalState.d.ts.map +1 -0
  21. package/dist/types/index.d.ts +2 -0
  22. package/dist/types/index.d.ts.map +1 -0
  23. package/dist/types/misc.d.ts +7 -0
  24. package/dist/types/misc.d.ts.map +1 -0
  25. package/dist/types/portal.d.ts +40 -0
  26. package/dist/types/portal.d.ts.map +1 -0
  27. package/dist/utils.d.ts +12 -0
  28. package/dist/utils.d.ts.map +1 -0
  29. package/package.json +25 -11
  30. package/src/factors/alert.ts +20 -60
  31. package/src/factors/bottomSheet.ts +20 -3
  32. package/src/factors/drawer.ts +11 -1
  33. package/src/factors/modal.ts +11 -1
  34. package/src/globals.ts +6 -0
  35. package/src/lib/Portal.tsx +62 -14
  36. package/src/lib/PortalRequest.ts +5 -5
  37. package/src/lib/PortalState.ts +64 -25
  38. package/src/types/misc.ts +2 -0
  39. package/src/types/portal.ts +11 -5
  40. package/src/utils.ts +9 -0
  41. package/package.json.bak +0 -32
@@ -0,0 +1,44 @@
1
+ import { AnyFunction } from '@codeleap/types';
2
+ import { Modal } from './modal';
3
+ /** Discriminant for alert categories used to control icon/style in the wrapper component. */
4
+ export type AlertType = 'info' | 'error' | 'warn' | 'ask' | 'custom';
5
+ /** A single button option rendered inside an alert dialog. */
6
+ export type AlertOption = {
7
+ text: string;
8
+ onPress?: AnyFunction;
9
+ style?: 'destructive' | 'outline' | 'cancel' | 'default' | 'minimal';
10
+ };
11
+ /** Configuration options for displaying an alert dialog. */
12
+ export type AlertOptions = {
13
+ title?: string;
14
+ body?: string;
15
+ options?: AlertOption[];
16
+ onDismiss?: AnyFunction;
17
+ type?: AlertType;
18
+ };
19
+ /**
20
+ * Alert utility for displaying typed alert modals (info, error, warn, ask, custom).
21
+ * Provides convenient methods for common alert scenarios.
22
+ */
23
+ export declare class Alert {
24
+ /**
25
+ * Returns the Modal instance used to display alerts.
26
+ * Must be implemented by the consuming app before calling any alert method.
27
+ * @throws Error if not implemented
28
+ */
29
+ static openAlert(): Modal<AlertOptions>;
30
+ private trigger;
31
+ /** Opens an alert with 'ask' type. */
32
+ ask(args: AlertOptions): void;
33
+ /** Opens an alert with 'error' type. */
34
+ error(args: AlertOptions): void;
35
+ /** Opens an alert with 'warn' type. */
36
+ warn(args: AlertOptions): void;
37
+ /** Opens an alert with 'info' type. */
38
+ info(args: AlertOptions): void;
39
+ /** Opens a custom alert with user-defined options and type. */
40
+ custom<T>(options: Partial<AlertOptions> & T): void;
41
+ }
42
+ /** Global alert instance for showing alerts throughout the app. */
43
+ export declare const alert: Alert;
44
+ //# sourceMappingURL=alert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../src/factors/alert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,6FAA6F;AAC7F,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAEpE,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;CACrE,CAAA;AAED,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,WAAW,EAAE,CAAA;IACvB,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,qBAAa,KAAK;IAEhB;;;;OAIG;IACH,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,YAAY,CAAC;IAIvC,OAAO,CAAC,OAAO;IAIf,sCAAsC;IACtC,GAAG,CAAC,IAAI,EAAE,YAAY;IAItB,wCAAwC;IACxC,KAAK,CAAC,IAAI,EAAE,YAAY;IAIxB,uCAAuC;IACvC,IAAI,CAAC,IAAI,EAAE,YAAY;IAIvB,uCAAuC;IACvC,IAAI,CAAC,IAAI,EAAE,YAAY;IAIvB,+DAA+D;IAC/D,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC;CAG7C;AAED,mEAAmE;AACnE,eAAO,MAAM,KAAK,OAAc,CAAA"}
@@ -0,0 +1,61 @@
1
+ import { Portal } from '../lib/Portal';
2
+ import { PortalConstructorParam, PortalConfig, PortalWrapperProps } from '../types';
3
+ import { BottomSheetRef, BottomSheetWrapperProps } from '../globals';
4
+ import { Keyof } from '@codeleap/types';
5
+ import { ReactElement } from 'react';
6
+ /**
7
+ * Bottom sheet portal for bottom-sliding panels.
8
+ * Extends Portal with bottom sheet-specific wrapper, configuration and ref methods.
9
+ *
10
+ * @template Params - Custom bottom sheet parameters
11
+ * @template Result - Type of result returned by request
12
+ * @template Metadata - Additional configuration metadata
13
+ */
14
+ export declare class BottomSheet<Params = {}, Result = {}, Metadata = {}> extends Portal<Params, Result, Metadata, BottomSheetRef, BottomSheetWrapperProps> {
15
+ displayName: string;
16
+ /** Wrapper component used to render bottom sheet UI. Must be assigned by the consuming app. */
17
+ static WrapperComponent: (props: PortalWrapperProps<BottomSheetWrapperProps, BottomSheetRef>) => ReactElement | null;
18
+ /** Default transition duration in milliseconds for bottom sheet open/close animations. */
19
+ static DEFAULT_TRANSITION_DURATION: number;
20
+ /** @inheritdoc */
21
+ protected get defaultTransitionDuration(): number;
22
+ /** @inheritdoc */
23
+ protected get wrapperComponent(): any;
24
+ /** Closes all open BottomSheet instances. */
25
+ static closeAll(): Promise<void>;
26
+ /** Name of the ref method to call imperatively when opening the sheet (set by the consuming app). */
27
+ static openKeyMethod: Keyof<BottomSheetRef>;
28
+ /** Name of the ref method to call imperatively when closing the sheet (set by the consuming app). */
29
+ static closeKeyMethod: Keyof<BottomSheetRef>;
30
+ /** Returns default config: `rendersWhenHidden=true` and `resetParamsOnClose=false`. */
31
+ protected getDefaultConfig(): Partial<PortalConfig<Params, Metadata>>;
32
+ /** Calls the native open method on the ref via `openKeyMethod`, if configured. */
33
+ protected openBottomSheet(): void;
34
+ /** Calls the native close method on the ref via `closeKeyMethod`, if configured. */
35
+ protected closeBottomSheet(): void;
36
+ /** @inheritdoc — also triggers the native open animation via `openBottomSheet()`. */
37
+ protected handleOpen(): void;
38
+ /** @inheritdoc — also triggers the native close animation via `closeBottomSheet()`. */
39
+ protected handleClose(): void;
40
+ /**
41
+ * Registers a callback to be called when bottom sheet opens.
42
+ * Overrides parent to ensure native open method is called.
43
+ * @param callback - Function to execute on open
44
+ * @returns The bottom sheet instance for chaining
45
+ */
46
+ onOpen(callback: (portal: Portal<Params, Result, Metadata, BottomSheetRef, BottomSheetWrapperProps>) => void): this;
47
+ /**
48
+ * Registers a callback to be called when bottom sheet closes.
49
+ * Overrides parent to ensure native close method is called.
50
+ * @param callback - Function to execute on close
51
+ * @returns The bottom sheet instance for chaining
52
+ */
53
+ onClose(callback: (portal: Portal<Params, Result, Metadata, BottomSheetRef, BottomSheetWrapperProps>) => void): this;
54
+ }
55
+ /**
56
+ * Factory function to create a new BottomSheet instance.
57
+ * @param idOrConfig - BottomSheet ID or configuration object
58
+ * @returns New BottomSheet instance
59
+ */
60
+ export declare function bottomSheet<Params = {}, Result = {}, Metadata = {}>(idOrConfig?: PortalConstructorParam<Params, Metadata>): BottomSheet<Params, Result, Metadata>;
61
+ //# sourceMappingURL=bottomSheet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bottomSheet.d.ts","sourceRoot":"","sources":["../../src/factors/bottomSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC;;;;;;;GAOG;AACH,qBAAa,WAAW,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAuB,CAAC;IACjJ,WAAW,SAAgB;IAE3B,+FAA+F;IAC/F,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,uBAAuB,EAAE,cAAc,CA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';
4
+ import { PortalConstructorParam, PortalWrapperProps } from '../types';
5
+ /**
6
+ * Drawer portal for side-sliding panels.
7
+ * Extends Portal with drawer-specific wrapper and configuration.
8
+ *
9
+ * @template Params - Custom drawer parameters
10
+ * @template Result - Type of result returned by request
11
+ * @template Metadata - Additional configuration metadata
12
+ */
13
+ export declare class Drawer<Params = {}, Result = {}, Metadata = {}> extends Portal<Params, Result, Metadata, DrawerRef, DrawerWrapperProps> {
14
+ displayName: string;
15
+ /** Wrapper component used to render drawer UI. Must be assigned by the consuming app. */
16
+ static WrapperComponent: (props: PortalWrapperProps<DrawerWrapperProps, DrawerRef>) => ReactElement | null;
17
+ /** Default transition duration in milliseconds for drawer open/close animations. */
18
+ static DEFAULT_TRANSITION_DURATION: number;
19
+ /** @inheritdoc */
20
+ protected get defaultTransitionDuration(): number;
21
+ /** @inheritdoc */
22
+ protected get wrapperComponent(): any;
23
+ /** Closes all open Drawer instances. */
24
+ static closeAll(): Promise<void>;
25
+ }
26
+ /**
27
+ * Factory function to create a new Drawer instance.
28
+ * @param idOrConfig - Drawer ID or configuration object
29
+ * @returns New Drawer instance
30
+ */
31
+ export declare function drawer<Params = {}, Result = {}, Metadata = {}>(idOrConfig?: PortalConstructorParam<Params, Metadata>): Drawer<Params, Result, Metadata>;
32
+ //# sourceMappingURL=drawer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/factors/drawer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAErE;;;;;;;GAOG;AACH,qBAAa,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,CAAC;IAClI,WAAW,SAAW;IAEtB,yFAAyF;IACzF,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,kBAAkB,EAAE,SAAS,CAAC,KAAK,YAAY,GAAG,IAAI,CAAa;IAEvH,oFAAoF;IACpF,MAAM,CAAC,2BAA2B,SAAM;IAExC,kBAAkB;IAClB,SAAS,KAAK,yBAAyB,WAEtC;IAED,kBAAkB;IAClB,SAAS,KAAK,gBAAgB,IAAI,GAAG,CAEpC;IAED,wCAAwC;WAC3B,QAAQ;CAItB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,oCAEpH"}
@@ -0,0 +1,32 @@
1
+ import { ReactElement } from 'react';
2
+ import { ModalRef, ModalWrapperProps } from '../globals';
3
+ import { Portal } from '../lib/Portal';
4
+ import { PortalConstructorParam, PortalWrapperProps } from '../types';
5
+ /**
6
+ * Modal portal for centered overlay dialogs.
7
+ * Extends Portal with modal-specific wrapper and configuration.
8
+ *
9
+ * @template Params - Custom modal parameters
10
+ * @template Result - Type of result returned by request
11
+ * @template Metadata - Additional configuration metadata
12
+ */
13
+ export declare class Modal<Params = {}, Result = {}, Metadata = {}> extends Portal<Params, Result, Metadata, ModalRef, ModalWrapperProps> {
14
+ displayName: string;
15
+ /** Wrapper component used to render modal UI. Must be assigned by the consuming app. */
16
+ static WrapperComponent: (props: PortalWrapperProps<ModalWrapperProps, ModalRef>) => ReactElement | null;
17
+ /** Default transition duration in milliseconds for modal open/close animations. */
18
+ static DEFAULT_TRANSITION_DURATION: number;
19
+ /** @inheritdoc */
20
+ protected get defaultTransitionDuration(): number;
21
+ /** @inheritdoc */
22
+ protected get wrapperComponent(): any;
23
+ /** Closes all open Modal instances. */
24
+ static closeAll(): Promise<void>;
25
+ }
26
+ /**
27
+ * Factory function to create a new Modal instance.
28
+ * @param idOrConfig - Modal ID or configuration object
29
+ * @returns New Modal instance
30
+ */
31
+ export declare function modal<Params = {}, Result = {}, Metadata = {}>(idOrConfig?: PortalConstructorParam<Params, Metadata>): Modal<Params, Result, Metadata>;
32
+ //# sourceMappingURL=modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/factors/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAErE;;;;;;;GAOG;AACH,qBAAa,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,CAAE,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,CAAC;IAC/H,WAAW,SAAU;IAErB,wFAAwF;IACxF,MAAM,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,KAAK,YAAY,GAAG,IAAI,CAAa;IAErH,mFAAmF;IACnF,MAAM,CAAC,2BAA2B,SAAM;IAExC,kBAAkB;IAClB,SAAS,KAAK,yBAAyB,WAEtC;IAED,kBAAkB;IAClB,SAAS,KAAK,gBAAgB,IAAI,GAAG,CAEpC;IAED,uCAAuC;WAC1B,QAAQ;CAItB;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,mCAEnH"}
@@ -0,0 +1,19 @@
1
+ /** Props for the bottom sheet wrapper component. Extend this interface in the consuming app. */
2
+ export interface BottomSheetWrapperProps {
3
+ }
4
+ /** Ref type for the bottom sheet component. Extend this interface to expose imperative methods. */
5
+ export interface BottomSheetRef {
6
+ }
7
+ /** Props for the modal wrapper component. Extend this interface in the consuming app. */
8
+ export interface ModalWrapperProps {
9
+ }
10
+ /** Ref type for the modal component. Extend this interface to expose imperative methods. */
11
+ export interface ModalRef {
12
+ }
13
+ /** Props for the drawer wrapper component. Extend this interface in the consuming app. */
14
+ export interface DrawerWrapperProps {
15
+ }
16
+ /** Ref type for the drawer component. Extend this interface to expose imperative methods. */
17
+ export interface DrawerRef {
18
+ }
19
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,MAAM,WAAW,uBAAuB;CAAG;AAE3C,mGAAmG;AACnG,MAAM,WAAW,cAAc;CAAG;AAElC,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;CAAG;AAErC,4FAA4F;AAC5F,MAAM,WAAW,QAAQ;CAAG;AAE5B,0FAA0F;AAC1F,MAAM,WAAW,kBAAkB;CAAG;AAEtC,6FAA6F;AAC7F,MAAM,WAAW,SAAS;CAAG"}
@@ -0,0 +1,13 @@
1
+ export * from './lib/Portal';
2
+ export * from './lib/PortalRegistry';
3
+ export * from './lib/PortalState';
4
+ export * from './lib/PortalRequest';
5
+ export * from './types/misc';
6
+ export * from './types/portal';
7
+ export * from './utils';
8
+ export * from './factors/alert';
9
+ export * from './factors/modal';
10
+ export * from './factors/bottomSheet';
11
+ export * from './factors/drawer';
12
+ export * from './globals';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA;AAEvB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,WAAW,CAAA"}
@@ -0,0 +1,121 @@
1
+ import React, { JSX } from 'react';
2
+ import { atom } from 'nanostores';
3
+ import { AnyRecord } from '@codeleap/types';
4
+ import { PortalConfig, PortalConstructorParam, RenderPortalContent } from '../types';
5
+ import { PortalRegistry } from './PortalRegistry';
6
+ import { PortalState } from './PortalState';
7
+ import { PortalRequest } from './PortalRequest';
8
+ type IAtom<T> = ReturnType<typeof atom<T>>;
9
+ /**
10
+ * Nanostores atom holding the IDs of all currently registered portals in creation order.
11
+ * Drives `GlobalOutlet` re-renders when portals are added or removed (including ephemeral ones).
12
+ * Read-only outside of portal lifecycle code — mutate only via `Portal` constructor/`onVisibilityChanged`.
13
+ */
14
+ export declare const registeredIds: import("nanostores").PreinitializedWritableAtom<string[]> & object;
15
+ /**
16
+ * Base class for creating portals (modal, drawer, bottom sheet, etc).
17
+ * Manages state, visibility, params and lifecycle of floating components.
18
+ *
19
+ * @template Params - Custom portal parameters
20
+ * @template Result - Type of result returned by request
21
+ * @template Metadata - Additional configuration metadata
22
+ * @template RefType - Type of wrapper component ref
23
+ * @template WrapperProps - Props for wrapper component
24
+ */
25
+ export declare class Portal<Params = {}, Result = {}, Metadata = {}, RefType = any, WrapperProps = AnyRecord> extends PortalState<Params> {
26
+ displayName: string;
27
+ id: string;
28
+ RenderContent: RenderPortalContent<Params, Result, RefType>;
29
+ ref?: React.RefObject<RefType | null>;
30
+ requestHandler: PortalRequest<Params, Result>;
31
+ _config: PortalConfig<Params, Metadata>;
32
+ _wrapperProps: IAtom<WrapperProps>;
33
+ _lazyWrapperProps: (params: Params) => WrapperProps;
34
+ static registry: PortalRegistry<Portal<any, any, any, any, AnyRecord>>;
35
+ static generateId: () => string;
36
+ protected getDefaultConfig(): Partial<PortalConfig<Params, Metadata>>;
37
+ protected get registry(): PortalRegistry<any>;
38
+ protected get idGenerator(): () => string;
39
+ protected get defaultTransitionDuration(): number | null;
40
+ protected get wrapperComponent(): any;
41
+ /**
42
+ * Sets the render function for portal content.
43
+ * @param render - Function that renders the portal content
44
+ * @returns The portal instance for chaining
45
+ */
46
+ content(render: RenderPortalContent<Params, Result, RefType>): this;
47
+ /** Gets the resolve handler for the pending request. */
48
+ get resolve(): ((result: Result | undefined) => void) | undefined;
49
+ /** Gets the reject handler for the pending request. */
50
+ get reject(): ((reason: unknown) => void) | undefined;
51
+ private onVisibilityChanged;
52
+ /** Gets the z-index position of the portal in the registry stack. */
53
+ get stackIndex(): number;
54
+ /**
55
+ * Creates a new portal instance.
56
+ * @param idOrConfig - Portal ID string or configuration object with optional id field
57
+ */
58
+ constructor(idOrConfig?: PortalConstructorParam<Params, Metadata>);
59
+ /**
60
+ * Registers a callback to be called when portal closes.
61
+ * @param callback - Function to execute on close
62
+ * @returns The portal instance for chaining
63
+ */
64
+ onClose(callback: (portal: Portal<Params, Result, Metadata, RefType, WrapperProps>) => void): this;
65
+ /**
66
+ * Registers a callback to be called when portal opens.
67
+ * @param callback - Function to execute on open
68
+ * @returns The portal instance for chaining
69
+ */
70
+ onOpen(callback: (portal: Portal<Params, Result, Metadata, RefType, WrapperProps>) => void): this;
71
+ /**
72
+ * Sets wrapper component props. Can be static or a function based on params.
73
+ * @param props - Props object or function that returns props
74
+ * @returns The portal instance for chaining
75
+ */
76
+ props(props: WrapperProps | ((params: Params) => WrapperProps)): this;
77
+ /**
78
+ * React hook to update wrapper props with dependency tracking.
79
+ * @param props - Props to merge with existing wrapper props
80
+ * @param deps - Dependency array for effect
81
+ */
82
+ useProps(props: WrapperProps, deps?: React.DependencyList): void;
83
+ /**
84
+ * React hook to access portal state (visibility and params).
85
+ * @returns Object with visible and params state
86
+ */
87
+ useState(): {
88
+ visible: boolean;
89
+ params: Params;
90
+ };
91
+ /** Whether there is a pending request awaiting resolution. */
92
+ get hasPendingRequest(): boolean;
93
+ /**
94
+ * Renders the portal component. Use this as a React component.
95
+ * @param props - Combined params and wrapper props
96
+ * @returns JSX element with portal content wrapped in wrapper component
97
+ */
98
+ Component(props?: Params & {
99
+ portalProps?: WrapperProps;
100
+ }): JSX.Element | null;
101
+ /**
102
+ * Creates a request promise that resolves when portal is closed with result.
103
+ * @param params - Parameters to pass to the portal
104
+ * @param force - Force new request even if one is pending
105
+ * @returns Promise that resolves with portal result
106
+ */
107
+ request(params?: Params, force?: boolean): Promise<Result | undefined>;
108
+ /**
109
+ * Resets all registered portals to their closed initial state.
110
+ * Useful in test afterEach hooks to prevent state leaking between tests.
111
+ */
112
+ static resetAll(): void;
113
+ /**
114
+ * Global outlet component that renders all non-independent portals.
115
+ * Place this once in your app root.
116
+ * @returns JSX element rendering all registered portals
117
+ */
118
+ static GlobalOutlet(): JSX.Element;
119
+ }
120
+ export {};
121
+ //# sourceMappingURL=Portal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../src/lib/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAA;AAGvD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OA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+ * Registry for managing portal instances and their stacking order.
3
+ * Maintains a registry of portals by ID and tracks their z-index stack.
4
+ *
5
+ * @template T - Type of portal instances to manage
6
+ */
7
+ export declare class PortalRegistry<T> {
8
+ private registry;
9
+ private stack;
10
+ /**
11
+ * Registers a portal instance with an ID.
12
+ * @param id - Unique identifier for the portal
13
+ * @param instance - Portal instance to register
14
+ */
15
+ register(id: string, instance: T): void;
16
+ /**
17
+ * Unregisters a portal and removes it from the stack.
18
+ * @param id - Portal ID to unregister
19
+ */
20
+ unregister(id: string): void;
21
+ /**
22
+ * Retrieves a portal instance by ID.
23
+ * @param id - Portal ID to retrieve
24
+ * @returns Portal instance or undefined
25
+ */
26
+ getInstance(id: string): T;
27
+ /**
28
+ * Adds a portal ID to the top of the stack.
29
+ * @param id - Portal ID to push
30
+ */
31
+ push(id: string): void;
32
+ /**
33
+ * Removes a portal ID from the stack and all portals above it.
34
+ * @param id - Portal ID to remove
35
+ */
36
+ remove(id: string): void;
37
+ /**
38
+ * Gets the stack index (z-index position) of a portal.
39
+ * @param id - Portal ID to find
40
+ * @returns Stack index or -1 if not found
41
+ */
42
+ getStackIndex(id: string): number;
43
+ /**
44
+ * Retrieves all registered portal instances.
45
+ * @returns Array of all portal instances
46
+ */
47
+ getAll(): T[];
48
+ /**
49
+ * Filters portal instances by predicate function.
50
+ * @param predicate - Function to test each instance
51
+ * @returns Filtered array of portal instances
52
+ */
53
+ filter(predicate: (instance: T) => boolean): T[];
54
+ /**
55
+ * Clears all portals from registry and stack.
56
+ */
57
+ clear(): void;
58
+ }
59
+ //# sourceMappingURL=PortalRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalRegistry.d.ts","sourceRoot":"","sources":["../../src/lib/PortalRegistry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAwB;IAExC,OAAO,CAAC,KAAK,CAAe;IAE5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAIhC;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM;IAKrB;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC;IAI1B;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM;IAIf;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM;IAOjB;;;;OAIG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAIjC;;;OAGG;IACH,MAAM,IAAI,CAAC,EAAE;IAIb;;;;OAIG;IACH,MAAM,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,EAAE;IAIhD;;OAEG;IACH,KAAK;CAIN"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Handles promise-based portal requests with resolve/reject semantics.
3
+ * Manages the async flow of opening a portal and waiting for a result.
4
+ *
5
+ * @template Params - Parameters for opening the portal
6
+ * @template Result - Type of result returned when request resolves
7
+ */
8
+ export declare class PortalRequest<Params = {}, Result = {}> {
9
+ resolve?: (result: Result | undefined) => void;
10
+ reject?: (reason: unknown) => void;
11
+ private onOpen;
12
+ private onClose;
13
+ /**
14
+ * Creates a portal request handler.
15
+ * @param onOpen - Function to call when opening portal
16
+ * @param onClose - Function to call when closing portal
17
+ */
18
+ constructor(onOpen: (params?: Params) => Promise<void>, onClose: () => Promise<void>);
19
+ /**
20
+ * Checks if there's a pending request waiting for resolution.
21
+ * @returns True if request is pending
22
+ */
23
+ get hasPendingRequest(): boolean;
24
+ /**
25
+ * Creates a new request promise that opens the portal and waits for result.
26
+ * @param params - Parameters to pass when opening portal
27
+ * @param force - Force new request even if one is pending
28
+ * @returns Promise that resolves with portal result
29
+ */
30
+ request(params?: Params, force?: boolean): Promise<Result | undefined>;
31
+ /**
32
+ * Clears the current request resolve/reject handlers.
33
+ */
34
+ clearRequest(): void;
35
+ /**
36
+ * Gets the current request handlers for resolve and reject.
37
+ * @returns Object with resolve and reject functions
38
+ */
39
+ getRequestHandlers(): {
40
+ resolve: ((result: Result | undefined) => void) | undefined;
41
+ reject: ((reason: unknown) => void) | undefined;
42
+ };
43
+ }
44
+ //# sourceMappingURL=PortalRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalRequest.d.ts","sourceRoot":"","sources":["../../src/lib/PortalRequest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,aAAa,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE;IACjD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAA;IAE9C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;IAElC,OAAO,CAAC,MAAM,CAAoC;IAElD,OAAO,CAAC,OAAO,CAAqB;IAEpC;;;;OAIG;gBAED,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC1C,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAM9B;;;OAGG;IACH,IAAI,iBAAiB,YAEpB;IAED;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,MAAM,GAAC,SAAS,CAAC;IAyBlE;;OAEG;IACH,YAAY;IAKZ;;;OAGG;IACH,kBAAkB;2BAxEC,MAAM,GAAG,SAAS,KAAK,IAAI;0BAE5B,OAAO,KAAK,IAAI;;CA4EnC"}
@@ -0,0 +1,83 @@
1
+ import { atom } from 'nanostores';
2
+ type IAtom<T> = ReturnType<typeof atom<T>>;
3
+ /** Configuration for initializing portal state: initial params, visibility, reset behavior, and transition timing. */
4
+ export type PortalStateConfig<Params> = {
5
+ initialParams?: Params | (() => Promise<Params>);
6
+ startsOpen?: boolean | (() => Promise<boolean>);
7
+ resetParamsOnClose?: boolean;
8
+ transitionDuration?: number;
9
+ };
10
+ /**
11
+ * Manages portal visibility and parameter state with nanostores.
12
+ * Handles opening, closing, toggling and parameter updates.
13
+ *
14
+ * @template Params - Type of parameters managed by the state
15
+ */
16
+ export declare class PortalState<Params = {}> {
17
+ /** Nanostores atom managing portal visibility state. */
18
+ visible: IAtom<boolean>;
19
+ /** Nanostores atom managing portal parameters. */
20
+ params: IAtom<Params>;
21
+ /** Initial parameter values used when resetting. */
22
+ _initialParams: Params;
23
+ private config;
24
+ /**
25
+ * Asserts the portal state has been initialized and returns the initialized stores.
26
+ * @throws Error if `initializeState()` has not been called yet
27
+ */
28
+ assertInitialized(): {
29
+ visible: import("nanostores").PreinitializedWritableAtom<boolean> & object;
30
+ params: import("nanostores").PreinitializedWritableAtom<Params> & object;
31
+ config: PortalStateConfig<Params>;
32
+ initialParams: Params & ({} | null);
33
+ };
34
+ /**
35
+ * Initializes the portal state with configuration.
36
+ * @param config - Configuration for initial state, visibility and params
37
+ */
38
+ initializeState(config: PortalStateConfig<Params>): void;
39
+ /** Gets the current visibility state. */
40
+ get isVisible(): boolean;
41
+ /** Gets the current parameter values. */
42
+ get currentParams(): Params;
43
+ private awaitTransition;
44
+ /** Lifecycle hook called after the portal opens. Override in subclasses to run custom logic. */
45
+ protected handleOpen(): void;
46
+ /**
47
+ * Opens the portal with optional parameters.
48
+ * @param params - Parameters to merge with current params
49
+ */
50
+ open(params?: Params): Promise<void>;
51
+ /** Lifecycle hook called after the portal closes. Override in subclasses to run custom logic. */
52
+ protected handleClose(): void;
53
+ /**
54
+ * Closes the portal and optionally resets parameters.
55
+ */
56
+ close(): Promise<void>;
57
+ /**
58
+ * Toggles portal visibility (opens if closed, closes if open).
59
+ */
60
+ toggle(): Promise<void>;
61
+ /**
62
+ * Updates portal parameters by merging with current params.
63
+ * @param next - Partial params or updater function
64
+ */
65
+ setParams(next: Partial<Params> | ((prev: Params) => Partial<Params>)): void;
66
+ /**
67
+ * Resets parameters to initial values.
68
+ */
69
+ resetParams(): void;
70
+ /**
71
+ * Gets current parameter values.
72
+ * @returns Current params object
73
+ */
74
+ getParams(): Params;
75
+ /**
76
+ * Subscribes to visibility changes.
77
+ * @param callback - Function called when visibility changes
78
+ * @returns Unsubscribe function
79
+ */
80
+ subscribe(callback: (visible: boolean, wasVisible?: boolean) => void): () => void;
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=PortalState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalState.d.ts","sourceRoot":"","sources":["../../src/lib/PortalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,YAAY,CAAA;AAIhD,KAAK,KAAK,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAU1C,sHAAsH;AACtH,MAAM,MAAM,iBAAiB,CAAC,MAAM,IAAI;IACtC,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAChD,UAAU,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/C,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED;;;;;GAKG;AACH,qBAAa,WAAW,CAAC,MAAM,GAAG,EAAE;IAClC,wDAAwD;IACxD,OAAO,EAAG,KAAK,CAAC,OAAO,CAAC,CAAA;IAExB,kDAAkD;IAClD,MAAM,EAAG,KAAK,CAAC,MAAM,CAAC,CAAA;IAEtB,oDAAoD;IACpD,cAAc,EAAG,MAAM,CAAA;IAEvB,OAAO,CAAC,MAAM,CAA4B;IAE1C;;;OAGG;IACH,iBAAiB;;;;;;IAYjB;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC;IAyBjD,yCAAyC;IACzC,IAAI,SAAS,YAGZ;IAED,yCAAyC;IACzC,IAAI,aAAa,WAGhB;IAED,OAAO,CAAC,eAAe;IAKvB,gGAAgG;IAChG,SAAS,CAAC,UAAU;IAEpB;;;OAGG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM;IAqB1B,iGAAiG;IACjG,SAAS,CAAC,WAAW;IAErB;;OAEG;IACG,KAAK;IAoBX;;OAEG;IACH,MAAM;IAUN;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAYrE;;OAEG;IACH,WAAW;IAKX;;;OAGG;IACH,SAAS;IAKT;;;;OAIG;IACH,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,OAAO,KAAK,IAAI;CAIrE"}
@@ -0,0 +1,2 @@
1
+ export * from './portal';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { AnyFunction } from '@codeleap/types';
2
+ /** Extracts all but the first element of a tuple type. */
3
+ type AllButFirst<T extends any[]> = T extends [infer _, ...infer Rest] ? Rest : [];
4
+ /** Produces a version of function `T` whose first parameter excludes type `E`. */
5
+ export type ExcludeFromParam<T extends AnyFunction, E = any> = (p?: Exclude<Parameters<T>[0], E>, ...args: AllButFirst<Parameters<T>>) => ReturnType<T>;
6
+ export {};
7
+ //# sourceMappingURL=misc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/types/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,0DAA0D;AAC1D,KAAK,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,CAAC,GAAG,IAAI,GAAG,EAAE,CAAA;AAElF,kFAAkF;AAClF,MAAM,MAAM,gBAAgB,CAC1B,CAAC,SAAS,WAAW,EACrB,CAAC,GAAG,GAAG,IACL,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,40 @@
1
+ import { Ref } from 'react';
2
+ /** Props injected into portal content: visibility flag, lifecycle methods, and the portal's current params. */
3
+ export type PortalParams<P = {}, Result = {}> = {
4
+ visible: boolean;
5
+ toggle: () => void | Promise<void>;
6
+ close: () => void | Promise<void>;
7
+ open: (params?: P) => void | Promise<void>;
8
+ setParams: (next: Partial<P> | ((prev: P) => Partial<P>)) => void;
9
+ request?: {
10
+ resolve?: (result: Result) => void;
11
+ reject?: (reason: unknown) => void;
12
+ };
13
+ } & P;
14
+ /** Function that renders portal content, receiving params and an optional ref. */
15
+ export type RenderPortalContent<Params = {}, Result = {}, RefType = any> = (props: PortalParams<Params, Result>, ref?: React.RefObject<RefType>) => React.ReactElement;
16
+ /** Configuration options for portal initialization and runtime behavior. */
17
+ export type PortalConfig<P, M = {}> = {
18
+ initialParams?: P | (() => Promise<P>);
19
+ startsOpen?: boolean | (() => Promise<boolean>);
20
+ independent?: boolean;
21
+ rendersWhenHidden?: boolean;
22
+ metadata?: M;
23
+ transitionDuration?: number;
24
+ resetParamsOnClose?: boolean;
25
+ ephemeral?: boolean;
26
+ };
27
+ /** Constructor parameter — either a portal ID string or a config object with an optional `id` field. */
28
+ export type PortalConstructorParam<Params = {}, Metadata = {}> = (Partial<PortalConfig<Params, Metadata>> & {
29
+ id?: string;
30
+ }) | string;
31
+ /** Props passed to the wrapper component (modal/drawer/sheet) including lifecycle handlers and z-index. */
32
+ export type PortalWrapperProps<P, R> = P & {
33
+ close: () => void;
34
+ open: () => void;
35
+ toggle: () => void;
36
+ zIndex: number;
37
+ visible: boolean;
38
+ ref: Ref<R>;
39
+ };
40
+ //# sourceMappingURL=portal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../src/types/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAE3B,+GAA+G;AAC/G,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI;IAC9C,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClC,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IACjE,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;QAClC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;KACnC,CAAA;CACF,GAAG,CAAC,CAAA;AAEL,kFAAkF;AAClF,MAAM,MAAM,mBAAmB,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,OAAO,GAAG,GAAG,IAAI,CACzE,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,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