@saasquatch/component-boilerplate 1.3.0 → 1.3.1-1
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/CHANGELOG.md +112 -112
- package/README.md +7 -7
- package/dist/hooks/graphql/Refresh.d.ts +11 -0
- package/dist/hooks/graphql/useBaseQuery.d.ts +1 -1
- package/dist/hooks/useDebounce.d.ts +1 -1
- package/dist/hooks/useDeepEffect.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +14 -14
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +59 -59
- package/dist/hooks/graphql/useCustomQuery.d.ts +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.3.0] - 2021-12-09
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
|
|
12
|
-
- Rare race condition causing queries to not return their data fixed
|
|
13
|
-
- User identity no longer being cleared if identity is not immediately available in context
|
|
14
|
-
|
|
15
|
-
### Added
|
|
16
|
-
|
|
17
|
-
- redirectPath is now included with registration, password reset, and verify email requests
|
|
18
|
-
|
|
19
|
-
## [1.2.2] - 2021-08-23
|
|
20
|
-
|
|
21
|
-
### Added
|
|
22
|
-
|
|
23
|
-
- Support for theme engine JWTs for determining user identity, enabling support for hybrid themes
|
|
24
|
-
|
|
25
|
-
## [1.2.1] - 2021-08-20
|
|
26
|
-
|
|
27
|
-
### Changed
|
|
28
|
-
|
|
29
|
-
- Fixed infinite loop caused by calling useToken while logged out
|
|
30
|
-
- Changed environment detection to support `widgetIdent.env = "demo"` in vanilla components
|
|
31
|
-
|
|
32
|
-
## [1.2.0] - 2021-08-04
|
|
33
|
-
|
|
34
|
-
### Added
|
|
35
|
-
|
|
36
|
-
- Portal environment now supports storing and retrieving user identity from localStorage
|
|
37
|
-
and validating JWT expiry
|
|
38
|
-
- New hooks:
|
|
39
|
-
- useAuthenticatedWithEmailAndPasswordMutation: Login a user with email and password
|
|
40
|
-
- useChangePasswordMutation: Change a user's password
|
|
41
|
-
- useManagedIdentityQuery: Query a user's managed identity
|
|
42
|
-
- useRegisterWithEmailAndPasswordMutation: Register a user with email and password
|
|
43
|
-
- useRequestPasswordResetEmailMutation: Request a password reset for an email address
|
|
44
|
-
- useRequestVerificationEmailMutation: Request an email verification for a user
|
|
45
|
-
- useResetPasswordMutation: Reset a user's password from an oobCode
|
|
46
|
-
- useVerifyEmailMutation: Verify a user's email from an oobCode
|
|
47
|
-
- useVerifyPasswordResetCodeMutation: Verify a password reset oobCode
|
|
48
|
-
|
|
49
|
-
### Changed
|
|
50
|
-
|
|
51
|
-
## [1.1.0] - 2021-05-20
|
|
52
|
-
|
|
53
|
-
### Added
|
|
54
|
-
|
|
55
|
-
- BatchedGraphQLClient - Updated client to allow queries to be batched if run in the same 200ms interval
|
|
56
|
-
- useLocale Added back due to usage in mint-components
|
|
57
|
-
|
|
58
|
-
### Changed
|
|
59
|
-
|
|
60
|
-
- useGraphQLClient - Use BatchedGraphQLClient instead of client from graphql-request
|
|
61
|
-
- useBaseQuery - Handle component unmounts with a cleanup function
|
|
62
|
-
- useForm - No longer automatically queries for the form, getForm function must be called manually from the component using the hook
|
|
63
|
-
- useQuery - New "skip" parameter based on https://www.apollographql.com/docs/react/data/queries/#skip. Also added to usePaginatedQuery
|
|
64
|
-
- Jest tests rewritten to use BatchedGraphQLClient
|
|
65
|
-
|
|
66
|
-
## [1.0.0] - 2021-04-21
|
|
67
|
-
|
|
68
|
-
### Added
|
|
69
|
-
|
|
70
|
-
- Initial release
|
|
71
|
-
- exported hooks available:
|
|
72
|
-
- identity hooks:
|
|
73
|
-
- useUserIdentity
|
|
74
|
-
setUserIdentity
|
|
75
|
-
useToken
|
|
76
|
-
- environment hooks:
|
|
77
|
-
- getEnvironmentSDK
|
|
78
|
-
useTenantAlias
|
|
79
|
-
useProgramId
|
|
80
|
-
setProgramId
|
|
81
|
-
useAppDomain
|
|
82
|
-
isDemo
|
|
83
|
-
useEngagementMedium
|
|
84
|
-
- graphql hooks:
|
|
85
|
-
- useQuery
|
|
86
|
-
useMutation
|
|
87
|
-
useLazyQuery
|
|
88
|
-
- navigation hooks
|
|
89
|
-
- navigation
|
|
90
|
-
useCurrentPage
|
|
91
|
-
- pagination hooks
|
|
92
|
-
- usePagination
|
|
93
|
-
usePaginatedQuery
|
|
94
|
-
- Generic low-level helpers
|
|
95
|
-
- useDebounce
|
|
96
|
-
useDebouncedCallback
|
|
97
|
-
useTick
|
|
98
|
-
useHost
|
|
99
|
-
setUseHostImplementation
|
|
100
|
-
- Common higher-level functionality
|
|
101
|
-
- useShareEvent
|
|
102
|
-
useForm
|
|
103
|
-
|
|
104
|
-
[unreleased]: https://github.com/saasquatch/program-tools/compare/component-boilerplate@1.3.0...HEAD
|
|
105
|
-
|
|
106
|
-
[1.3.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.3.0
|
|
107
|
-
[1.2.2]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.2
|
|
108
|
-
[1.2.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.1
|
|
109
|
-
[1.2.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.0
|
|
110
|
-
[1.1.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.1.0
|
|
111
|
-
[1.0.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.1
|
|
112
|
-
[1.0.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.0
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.3.0] - 2021-12-09
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Rare race condition causing queries to not return their data fixed
|
|
13
|
+
- User identity no longer being cleared if identity is not immediately available in context
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- redirectPath is now included with registration, password reset, and verify email requests
|
|
18
|
+
|
|
19
|
+
## [1.2.2] - 2021-08-23
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Support for theme engine JWTs for determining user identity, enabling support for hybrid themes
|
|
24
|
+
|
|
25
|
+
## [1.2.1] - 2021-08-20
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Fixed infinite loop caused by calling useToken while logged out
|
|
30
|
+
- Changed environment detection to support `widgetIdent.env = "demo"` in vanilla components
|
|
31
|
+
|
|
32
|
+
## [1.2.0] - 2021-08-04
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Portal environment now supports storing and retrieving user identity from localStorage
|
|
37
|
+
and validating JWT expiry
|
|
38
|
+
- New hooks:
|
|
39
|
+
- useAuthenticatedWithEmailAndPasswordMutation: Login a user with email and password
|
|
40
|
+
- useChangePasswordMutation: Change a user's password
|
|
41
|
+
- useManagedIdentityQuery: Query a user's managed identity
|
|
42
|
+
- useRegisterWithEmailAndPasswordMutation: Register a user with email and password
|
|
43
|
+
- useRequestPasswordResetEmailMutation: Request a password reset for an email address
|
|
44
|
+
- useRequestVerificationEmailMutation: Request an email verification for a user
|
|
45
|
+
- useResetPasswordMutation: Reset a user's password from an oobCode
|
|
46
|
+
- useVerifyEmailMutation: Verify a user's email from an oobCode
|
|
47
|
+
- useVerifyPasswordResetCodeMutation: Verify a password reset oobCode
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
## [1.1.0] - 2021-05-20
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- BatchedGraphQLClient - Updated client to allow queries to be batched if run in the same 200ms interval
|
|
56
|
+
- useLocale Added back due to usage in mint-components
|
|
57
|
+
|
|
58
|
+
### Changed
|
|
59
|
+
|
|
60
|
+
- useGraphQLClient - Use BatchedGraphQLClient instead of client from graphql-request
|
|
61
|
+
- useBaseQuery - Handle component unmounts with a cleanup function
|
|
62
|
+
- useForm - No longer automatically queries for the form, getForm function must be called manually from the component using the hook
|
|
63
|
+
- useQuery - New "skip" parameter based on https://www.apollographql.com/docs/react/data/queries/#skip. Also added to usePaginatedQuery
|
|
64
|
+
- Jest tests rewritten to use BatchedGraphQLClient
|
|
65
|
+
|
|
66
|
+
## [1.0.0] - 2021-04-21
|
|
67
|
+
|
|
68
|
+
### Added
|
|
69
|
+
|
|
70
|
+
- Initial release
|
|
71
|
+
- exported hooks available:
|
|
72
|
+
- identity hooks:
|
|
73
|
+
- useUserIdentity
|
|
74
|
+
setUserIdentity
|
|
75
|
+
useToken
|
|
76
|
+
- environment hooks:
|
|
77
|
+
- getEnvironmentSDK
|
|
78
|
+
useTenantAlias
|
|
79
|
+
useProgramId
|
|
80
|
+
setProgramId
|
|
81
|
+
useAppDomain
|
|
82
|
+
isDemo
|
|
83
|
+
useEngagementMedium
|
|
84
|
+
- graphql hooks:
|
|
85
|
+
- useQuery
|
|
86
|
+
useMutation
|
|
87
|
+
useLazyQuery
|
|
88
|
+
- navigation hooks
|
|
89
|
+
- navigation
|
|
90
|
+
useCurrentPage
|
|
91
|
+
- pagination hooks
|
|
92
|
+
- usePagination
|
|
93
|
+
usePaginatedQuery
|
|
94
|
+
- Generic low-level helpers
|
|
95
|
+
- useDebounce
|
|
96
|
+
useDebouncedCallback
|
|
97
|
+
useTick
|
|
98
|
+
useHost
|
|
99
|
+
setUseHostImplementation
|
|
100
|
+
- Common higher-level functionality
|
|
101
|
+
- useShareEvent
|
|
102
|
+
useForm
|
|
103
|
+
|
|
104
|
+
[unreleased]: https://github.com/saasquatch/program-tools/compare/component-boilerplate@1.3.0...HEAD
|
|
105
|
+
|
|
106
|
+
[1.3.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.3.0
|
|
107
|
+
[1.2.2]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.2
|
|
108
|
+
[1.2.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.1
|
|
109
|
+
[1.2.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.2.0
|
|
110
|
+
[1.1.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.1.0
|
|
111
|
+
[1.0.1]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.1
|
|
112
|
+
[1.0.0]: https://github.com/saasquatch/program-tools/releases/tag/%40saasquatch%2Fcomponent-boilerplate%401.0.0
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# SaaSquatch Component Boilerplate
|
|
2
|
-
|
|
3
|
-
This is a collection of essential universal hooks for use in building web components for the SaaSquatch platform.
|
|
4
|
-
|
|
5
|
-
## Documentation
|
|
6
|
-
|
|
7
|
-
See [index.ts](src/index.ts) for API documentation directly in Typescript.
|
|
1
|
+
# SaaSquatch Component Boilerplate
|
|
2
|
+
|
|
3
|
+
This is a collection of essential universal hooks for use in building web components for the SaaSquatch platform.
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
See [index.ts](src/index.ts) for API documentation directly in Typescript.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GqlType } from "./useBaseQuery";
|
|
2
|
+
export declare const REFRESH_EVENT_NAME = "sq:refresh";
|
|
3
|
+
export declare function useRefreshDispatcher(): {
|
|
4
|
+
refresh: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function useRefreshListener({ skip, update, variables, query, }: {
|
|
7
|
+
skip?: boolean;
|
|
8
|
+
update: (variables: unknown, skipLoading?: boolean) => unknown;
|
|
9
|
+
variables: unknown;
|
|
10
|
+
query: GqlType;
|
|
11
|
+
}): void;
|
|
@@ -43,4 +43,4 @@ export declare type GraphQlRequestError<T> = {
|
|
|
43
43
|
};
|
|
44
44
|
message?: string;
|
|
45
45
|
};
|
|
46
|
-
export declare function useBaseQuery<T = any>(query: GqlType, initialState: BaseQueryData<T>): [BaseQueryData<T>, (variables: unknown) => unknown];
|
|
46
|
+
export declare function useBaseQuery<T = any>(query: GqlType, initialState: BaseQueryData<T>): [BaseQueryData<T>, (variables: unknown, skipLoading?: boolean) => unknown];
|
|
@@ -41,7 +41,7 @@ export interface DebouncedState<T extends (...args: any[]) => ReturnType<T>> ext
|
|
|
41
41
|
* `wait` timeout. The `func` is invoked with the last arguments provided to the
|
|
42
42
|
* debounced function. Subsequent calls to the debounced function return the
|
|
43
43
|
* result of the last `func` invocation.
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
*
|
|
46
46
|
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
47
47
|
* for details over the differences between `debounce` and `throttle`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect } from "@saasquatch/universal-hooks";
|
|
2
|
+
declare type UseEffectParams = Parameters<typeof useEffect>;
|
|
3
|
+
declare type EffectCallback = UseEffectParams[0];
|
|
4
|
+
declare type DependencyList = UseEffectParams[1];
|
|
5
|
+
declare type UseEffectReturn = ReturnType<typeof useEffect>;
|
|
6
|
+
/**
|
|
7
|
+
* @param value the value to be memoized (usually a dependency list)
|
|
8
|
+
* @returns a memoized version of the value as long as it remains deeply equal
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDeepCompareMemoize<T>(value: T): T;
|
|
11
|
+
export declare function useDeepCompareEffect(callback: EffectCallback, dependencies: DependencyList): UseEffectReturn;
|
|
12
|
+
export default useDeepCompareEffect;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { useQuery } from "./hooks/graphql/useQuery";
|
|
|
16
16
|
export { useMutation } from "./hooks/graphql/useMutation";
|
|
17
17
|
export { useLazyQuery } from "./hooks/graphql/useLazyQuery";
|
|
18
18
|
export { memoizedGraphQLClient, GRAPHQL_CONTEXT, } from "./hooks/graphql/useGraphQLClient";
|
|
19
|
+
export { useRefreshDispatcher } from "./hooks/graphql/Refresh";
|
|
19
20
|
export { navigation, useCurrentPage } from "./hooks/useNavigation";
|
|
20
21
|
export { usePagination } from "./hooks/pagination/usePagination";
|
|
21
22
|
export { usePaginatedQuery } from "./hooks/pagination/usePaginatedQuery";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("@saasquatch/dom-context-hooks"),n=require("dom-context"),t=require("jwt-decode"),r=require("@wry/equality"),a=require("graphql"),o=require("@saasquatch/universal-hooks"),i=require("fast-memoize"),s=require("rxjs"),u=require("rxjs/operators"),d=require("nanoid"),c=require("graphql-request/dist/types"),l=require("graphql-request"),f=require("graphql-combine-query"),m=require("history"),g=require("debounce"),p=require("jsonpointer");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=v(t),y=v(i),w=v(f),C=v(g),b=v(p),q={current:void 0};function I(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new n.ContextProvider({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function F(){P();var n=I();return e.useDomContext(n,"sq:program-id")}function E(){var e,n;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(n=window.frameElement)?void 0:n.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function S(){var e=E();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function x(){var e,n=E();switch(n.type){case"SquatchAndroid":case"SquatchJS2":return n.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=n.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function M(){var e=E();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function D(){return(D=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function A(e,n){return(A=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function k(e,n){return n||(n=e.slice(0)),e.raw=n,e}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function $(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var R=1e3,V=60*R,O=60*V,N=24*O,H=function(e,n){n=n||{};var t=typeof e;if("string"===t&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(n){var t=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*t;case"weeks":case"week":case"w":return 6048e5*t;case"days":case"day":case"d":return t*N;case"hours":case"hour":case"hrs":case"hr":case"h":return t*O;case"minutes":case"minute":case"mins":case"min":case"m":return t*V;case"seconds":case"second":case"secs":case"sec":case"s":return t*R;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}(e);if("number"===t&&isFinite(e))return n.long?function(e){var n=Math.abs(e);return n>=N?L(e,n,N,"day"):n>=O?L(e,n,O,"hour"):n>=V?L(e,n,V,"minute"):n>=R?L(e,n,R,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=N?Math.round(e/N)+"d":n>=O?Math.round(e/O)+"h":n>=V?Math.round(e/V)+"m":n>=R?Math.round(e/R)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function L(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var W,U=(function(e,n){n.formatArgs=function(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const t="color: "+this.color;n.splice(1,0,t,"color: inherit");let r=0,a=0;n[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),n.splice(a,0,t)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),e.exports=function(e){function n(e){let r,a=null;function o(...e){if(!o.enabled)return;const t=o,a=Number(new Date);t.diff=a-(r||a),t.prev=r,t.curr=a,r=a,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=n.formatters[a];return"function"==typeof o&&(r=o.call(t,e[i]),e.splice(i,1),i--),r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return o.namespace=e,o.useColors=n.useColors(),o.color=n.selectColor(e),o.extend=t,o.destroy=n.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?n.enabled(e):a,set:e=>{a=e}}),"function"==typeof n.init&&n.init(o),o}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(t=0;t<a;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=H,n.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}(n);const{formatters:t}=e.exports;t.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(W={exports:{}},W.exports),W.exports),Q=U("sq:user-identity");function _(){window.squatchUserIdentity||(window.squatchUserIdentity=new n.ContextProvider({element:document.documentElement,initialState:J(),contextName:"sq:user-identity"}).start())}function T(e){if(e)try{var n,t,r=h.default(e),a=r.exp;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(r)){var o=r.sub.match(/(.*):(.*)@(.*):users/);t=atob(o[1]),n=atob(o[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(r)&&(t=r.user.accountId,n=r.user.id);if(!n||!t)return;if(a&&Date.now()>=1e3*a)return;return{id:n,accountId:t,jwt:e}}catch(e){return}}function J(){var e=E();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":var n=new URLSearchParams(document.location.search);if(n.has("jwt"))return T(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=T(r.jwt);return a?D({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function G(e){_();var n=window.squatchUserIdentity;r.equal(n.context,e)||(n.context=e),e&&"SquatchPortal"===E().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(Q("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function z(){var e;return null==(e=B())?void 0:e.jwt}function B(){_();var n=I(),t=e.useDomContext(n,"sq:user-identity"),r=T(null==t?void 0:t.jwt);if(!t||r)return t;G(void 0)}var K=function(){return(K=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var a in n=arguments[t])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e}).apply(this,arguments)},Z=new Map,X=new Map,Y=!0,ee=!1;function ne(e){return e.replace(/[\s,]+/g," ").trim()}function te(e){var n,t,r,o=ne(e);if(!Z.has(o)){var i=a.parse(e,{experimentalFragmentVariables:ee});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");Z.set(o,function(e){var n=new Set(e.definitions);n.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(t){var r=e[t];r&&"object"==typeof r&&n.add(r)})});var t=e.loc;return t&&(delete t.startToken,delete t.endToken),e}((n=i,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=ne((i=e.loc).source.body.substring(i.start,i.end)),o=X.get(n);o&&!o.has(a)?Y&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||X.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),K(K({},n),{definitions:r}))))}return Z.get(o)}function re(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];"string"==typeof e&&(e=[e]);var r=e[0];return n.forEach(function(n,t){r+=n&&"Document"===n.kind?n.loc.source.body:n,r+=e[t+1]}),te(r)}var ae,oe=re;(ae=re||(re={})).gql=oe,ae.resetCaches=function(){Z.clear(),X.clear()},ae.disableFragmentWarnings=function(){Y=!1},ae.enableExperimentalFragmentVariables=function(){ee=!0},ae.disableExperimentalFragmentVariables=function(){ee=!1},re.default=re;var ie=re;function se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var ue=function(e){var n,t;function r(n,t){var r;(r=e.call(this,n,t)||this).subject=new s.Subject;var o=new s.Subject;return r.subject.pipe(u.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=fe(e),i=t.mergedQuery,s=t.mergedVariables,u=t.mergedQueryAddedEvents,d=$(t.unmergedQueryAddedEvents);!(n=d()).done;)o.next(n.value);return u.length?Promise.resolve(se(function(){return Promise.resolve(r.superRequest(i,s)).then(function(e){pe(e,u)})},function(e){if(e instanceof c.ClientError){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:he(u,e)};for(var o,i=Object.keys(t),s=[].concat(u),d=function(){var n=o.value,t=void 0;n.path.find(function(r,o,u){if(i.includes(r)){var d=le(r),l=s.findIndex(function(e){return e.id===d});if(-1===l)return!1;i.splice(o,1),t=s.splice(l,1)[0];var f=me(e.response.data,t);u[o]=ce(u[o],d);var m=t.query,g=t.variables,p=D({},e.response,{errors:[n],data:f,path:u}),v=new c.ClientError(p,{query:"string"!=typeof m?a.print(m):m,variables:g});return ve(t,v),!0}return!1})},l=$(r);!(o=l()).done;)d();pe(t,s)}();if("object"==typeof n)return n.v}else he(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),o.subscribe(function(e){try{var n=se(function(){return Promise.resolve(r.superRequest(e.query,e.variables)).then(function(n){ge(n,e)})},function(n){ve(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),r}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,A(n,t);var o=r.prototype;return o.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},o.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:de(),resolve:r,reject:a};t.subject.next(o)})},r}(l.GraphQLClient),de=function(){return d.nanoid().replace(/[-_]/g,"")},ce=function(e,n){return e.replace("_"+n,"")},le=function(e){var n=e.split("_");return n[n.length-1]},fe=function(e){var n=[],t=[],r=e.reduce(function(e,r){var o=r.query,i=r.variables,s=r.id;try{var u="string"==typeof o?a.parse(o):o,d=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),c="string"==typeof o?o:a.print(o),l=/@/.test(c);if(d||l)return t.push(r),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(r),e}catch(n){return t.push(r),e}},w.default("BatchedQuery")),o=r.document,i=r.variables;return{mergedQuery:o&&a.print(o),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:t}},me=function(e,n){if(!e)return e;var t=Object.keys(e),r=n.id;return t.reduce(function(n,t){var a;return t.endsWith(r)&&(n=D({},n,((a={})[ce(t,r)]=e[t],a))),n},{})},ge=function(e,n){(0,n.resolve)(e)},pe=function(e,n){for(var t,r=$(n);!(t=r()).done;){var a=t.value,o=me(e,a);a.resolve(o)}},ve=function(e,n){(0,e.reject)(n)},he=function(e,n){for(var t,r=$(e);!(t=r()).done;)(0,t.value.reject)(n)},ye=y.default(function(e,n,t){return new ue(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function we(e,n){switch(n.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:n.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:n.payload,loading:!1}}}function Ce(n,t){var r,a,i,s,u,d,c=(r=z(),a=x(),i=S(),s=ye(a,i,r),u=I(),null!=(d=e.useDomContext(u,"sq:graphql-client",{attempts:0}))?d:s),l=o.useReducer(we,t),f=l[1];return[l[0],o.useCallback(function(e){try{if(!c)return f({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var t=function(t,r){try{var a=(f({type:"loading"}),Promise.resolve(c.request(n,e)).then(function(e){f({type:"data",payload:e})}))}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){f({type:"errors",payload:e})});return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[c,n,f])]}var be,qe={loading:!1,data:void 0,errors:void 0};function Ie(e){var n=Ce(e,qe);return[n[1],n[0]]}var Pe,Fe,Ee,Se,xe,Me=ie(be||(be=k(["\n mutation AuthenticateWithEmailAndPassword(\n $email: String!\n $password: String!\n ) {\n authenticateManagedIdentityWithEmailAndPassword(\n authenticateManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),De=ie(Pe||(Pe=k(["\n mutation RegisterWithEmailAndPassword(\n $email: String!\n $password: String!\n $formData: RSJsonNode\n $redirectPath: String\n ) {\n registerManagedIdentityWithEmailAndPassword(\n registerManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n formData: $formData\n redirectPath: $redirectPath\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),Ae=ie(Fe||(Fe=k(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),ke=ie(Ee||(Ee=k(["\n mutation ResetPassword($oobCode: String!, $password: String!) {\n resetManagedIdentityPassword(\n resetManagedIdentityPasswordInput: {\n password: $password\n oobCode: $oobCode\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),je=ie(Se||(Se=k(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),$e={loading:!1,data:void 0,errors:void 0};function Re(e){var n=Ce(e,$e),t=n[1];return[t,D({},n[0],{refetch:function(e){return t(e)}})]}var Ve,Oe=ie(xe||(xe=k(["\n query ManagedIdentity {\n managedIdentity {\n email\n emailVerified\n sessionData\n }\n }\n"])));function Ne(){var e=B(),n=Re(Oe),t=n[0],r=n[1],a=r.loading,i=r.data,s=r.errors,u=r.refetch;return o.useEffect(function(){null!=i&&i.managedIdentity&&G(D({},e,{managedIdentity:i.managedIdentity}))},[null==i?void 0:i.managedIdentity]),[o.useCallback(function(){return t({})},[t]),{loading:a,data:i,errors:s,refetch:u}]}var He,Le,We=ie(Ve||(Ve=k(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),Ue=ie(He||(He=k(["\n mutation RequestPasswordResetEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityPasswordResetEmail(\n requestManagedIdentityPasswordResetEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"]))),Qe=ie(Le||(Le=k(["\n mutation RequestVerificationEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityVerificationEmail(\n requestManagedIdentityVerificationEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"])));function _e(e,n){var t=o.useRef();return t.current&&r.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Te(){return o.useReducer(function(e){return e+1},0)}function Je(e){for(var n,t=$(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&Je(r)}return Object.freeze(e)}var Ge={loading:!0,data:void 0,errors:void 0};function ze(e,n,t){var r=Ce(e,Ge),a=r[0],o=r[1],i=Te(),s=i[1];return _e(function(){!t&&o(n)},[e,n,o,i[0],t]),Je(D({},a,{refetch:s}))}function Be(){return window.squatchHistory=window.squatchHistory||function(){switch(E().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var Ke,Ze={createHref:function(){var e;return(e=Be()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=Be()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=Be()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=Be()).go.apply(e,[].slice.call(arguments))},back:function(){return Be().back()},forward:function(){var e;return(e=Be()).forward.apply(e,[].slice.call(arguments))}};function Xe(e){var n=o.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=t.offset,i=t.limit,s=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:i,setLimit:function(e){var n=u(a,e),o=s(e,n);r(D({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=s(e,i);r(function(e){return D({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,i),r=function(e,n){return Math.ceil(e/n)||0}(n,i),o=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:o,pageProgress:o+" of "+n}}}}function Ye(e,n){return e===n}function en(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=o.useMemo(function(){return C.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var nn,tn,rn,an=l.gql(Ke||(Ke=k(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),on=U("sq:useForm"),sn=l.gql(nn||(nn=k(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),un=l.gql(tn||(tn=k(["\n mutation ($formSubmissionInput: FormSubmissionInput!) {\n submitForm(formSubmissionInput: $formSubmissionInput) {\n success\n results {\n ... on FormHandlerSubmissionResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"]))),dn=l.gql(rn||(rn=k(["\n query ($formValidationInput: FormValidationInput!) {\n validateForm(formValidationInput: $formValidationInput) {\n valid\n results {\n ... on FormHandlerValidationResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"])));exports.BatchedGraphQLClient=ue,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.getEnvironmentSDK=E,exports.isDemo=function(){var e=E();return"None"===e.type||"SquatchAdmin"===e.type},exports.memoizedGraphQLClient=ye,exports.navigation=Ze,exports.setProgramId=function(e){P(),window.squatchProgramId.context=e},exports.setUseHostImplementation=function(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e},exports.setUserIdentity=G,exports.useAppDomain=x,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var e=Ie(Me),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.authenticateManagedIdentityWithEmailAndPassword){var e=a.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useChangePasswordMutation=function(){var e=Ie(Ae),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Te()[1];return o.useEffect(function(){return Be().listen(function(){e()})},[]),Be().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||Ye,a=o.useState(e),i=a[0],s=a[1],u=en(o.useCallback(function(e){return s(e)},[]),n,t),d=o.useRef(e);return o.useEffect(function(){r(d.current,e)||(u.callback(e),d.current=e)},[e,u,r]),[i,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=en,exports.useEngagementMedium=M,exports.useForm=function(e){var n,t,r,a,i=function(e){try{return Promise.resolve(C({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,d=e.autoSubmit,c=void 0!==d&&d,l=Re(sn),f=l[0],m=l[1],g=m.data,p=m.loading,v=Ie(un),h=v[0],y=v[1],w=Re(dn),C=w[0],q=w[1],I=o.useReducer(function(e,n){return D({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:q,submitData:y}),P=I[0],F=I[1],E=P.enabled,S=P.disabledMessage,x=P.validating,M=P.valid,A=P.error,k=P.formData;return _e(function(){on("submitData useEffect",y),F({submitData:y})},[y]),_e(function(){on("validationData useEffect",q),F({validationData:q})},[q]),o.useEffect(function(){!p&&g&&function(){var n,t,r,a,o;F({enabled:null==g||null==(n=g.form.initialData)?void 0:n.isEnabled,disabledMessage:null==g||null==(t=g.form)||null==(r=t.initialData)?void 0:r.isEnabledErrorMessage});var i=u;if(i){var s=null==g||null==(a=g.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,s):function(e,n){try{var t=e.elements,r=new FormData(e);on({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){on({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=b.default.get(n,r):a.value=b.default.get(n,r)||""}catch(e){on("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[p]),o.useEffect(function(){var e,n,t,r,a,o;P.validationData&&(F({validating:!1,valid:(null==(e=P.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),c&&null!=(r=P.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&h({formSubmissionInput:{key:s,formData:k}}))},[null==(n=P.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:E,disabledMessage:S,loadingForm:p,validating:x,valid:M,error:A,validationData:P.validationData,submitData:P.submitData},data:{formKey:s,schema:null==g||null==(a=g.form)?void 0:a.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),F({validating:!0});var n=e.target;on("submit form",n);for(var t,r=new FormData(n),a={},o=$(r.entries());!(t=o()).done;){var s=t.value;b.default.set(a,s[0],s[1])}return F({formData:a}),Promise.resolve(i(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:i,submitForm:function(e){try{return Promise.resolve(h({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:F,getValidationErrors:function(){var e,n,t,r,a=null==q||null==(e=q.data)||null==(n=e.validateForm)||null==(t=n.results[0])||null==(r=t.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1).startsWith(""+e)})}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1)===e})},getSubErrorsAtPath:o,hasSubErrors:function(e){var n;return(null==(n=o(e))?void 0:n.length)>0}}},getSubmissionErrors:function(){var e;if(!P.submitData)return[];var n=null==(e=P.submitData.data)?void 0:e.submitForm.results;return(null==n?void 0:n.map(function(e){var n,t,r,a,o,i,s,u=null==(n=e.result)||null==(t=n.results)?void 0:t.flatMap(function(e){return!e.success&&e.message}).filter(function(e){return e}),d=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(function(e){return!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}}).filter(function(e){return e.error});return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:d}}))||[]}}}},exports.useHost=I,exports.useLazyQuery=Re,exports.useLocale=function(){return(n=null==(e=navigator.language)?void 0:e.split("-"))&&1!==n.length?n[0]+"_"+n[1].toUpperCase():e;var e,n},exports.useManagedIdentityQuery=Ne,exports.useMutation=Ie,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Xe(t),s=i.limit,u=i.setLimit,d=i.setCurrentPage,c=i.calculatePagination,l=ze(e,D({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,g=l.refetch,p=n(l.data),v=c((null==p||null==(o=p.data)?void 0:o.length)||0,(null==p?void 0:p.totalCount)||0);return{envelope:p,states:{errors:m,loading:f,limit:s,currentPage:v.currentPage,pageCount:v.pageCount,pageProgress:v.pageProgress},callbacks:{refetch:g,setLimit:u,setCurrentPage:d}}},exports.usePagination=Xe,exports.useProgramId=F,exports.useQuery=ze,exports.useRegisterWithEmailAndPasswordMutation=function(){var e=Ie(De),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.registerManagedIdentityWithEmailAndPassword){var e=a.registerManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.registerManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useRequestPasswordResetEmailMutation=function(){return Ie(Ue)},exports.useRequestVerificationEmailMutation=function(){return Ie(Qe)},exports.useResetPasswordMutation=function(){var e=Ie(ke),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.resetManagedIdentityPassword){var e=a.resetManagedIdentityPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.resetManagedIdentityPassword]),[n,{loading:r,data:a,errors:i}]},exports.useShareEvent=function(){var e=M(),n=B(),t=F(),r=Ie(an)[0];return n?function(a){r({eventMeta:{id:n.id,accountId:n.accountId,programId:t,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:function(){}},exports.useTenantAlias=S,exports.useTick=Te,exports.useToken=z,exports.useUserIdentity=B,exports.useVerifyEmailMutation=function(){var e,n=Ne()[0],t=Ie(We),r=t[0],a=t[1],i=a.loading,s=a.data,u=a.errors;return o.useEffect(function(){var e;null!=s&&null!=(e=s.verifyManagedIdentityEmail)&&e.success&&n()},[null==s||null==(e=s.verifyManagedIdentityEmail)?void 0:e.success]),[r,{loading:i,data:s,errors:u}]},exports.useVerifyPasswordResetCodeMutation=function(){return Ie(je)};
|
|
1
|
+
var e=require("@saasquatch/dom-context-hooks"),n=require("dom-context"),t=require("jwt-decode"),r=require("@wry/equality"),a=require("graphql"),o=require("@saasquatch/universal-hooks"),i=require("fast-memoize"),s=require("rxjs"),u=require("rxjs/operators"),c=require("nanoid"),d=require("graphql-request/dist/types"),l=require("graphql-request"),f=require("graphql-combine-query"),m=require("history"),v=require("debounce"),p=require("jsonpointer");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(t),y=g(i),w=g(f),C=g(v),b=g(p),q={current:void 0};function I(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new n.ContextProvider({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function E(){P();var n=I();return e.useDomContext(n,"sq:program-id")}function F(){var e,n;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(n=window.frameElement)?void 0:n.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function S(){var e=F();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function x(){var e,n=F();switch(n.type){case"SquatchAndroid":case"SquatchJS2":return n.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=n.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function M(){var e=F();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function D(){return(D=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function A(e,n){return(A=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function k(e,n){return n||(n=e.slice(0)),e.raw=n,e}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function $(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}var R=1e3,V=60*R,O=60*V,N=24*O,H=function(e,n){n=n||{};var t=typeof e;if("string"===t&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var n=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(n){var t=parseFloat(n[1]);switch((n[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*t;case"weeks":case"week":case"w":return 6048e5*t;case"days":case"day":case"d":return t*N;case"hours":case"hour":case"hrs":case"hr":case"h":return t*O;case"minutes":case"minute":case"mins":case"min":case"m":return t*V;case"seconds":case"second":case"secs":case"sec":case"s":return t*R;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}(e);if("number"===t&&isFinite(e))return n.long?function(e){var n=Math.abs(e);return n>=N?L(e,n,N,"day"):n>=O?L(e,n,O,"hour"):n>=V?L(e,n,V,"minute"):n>=R?L(e,n,R,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=N?Math.round(e/N)+"d":n>=O?Math.round(e/O)+"h":n>=V?Math.round(e/V)+"m":n>=R?Math.round(e/R)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function L(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var W,U=(function(e,n){n.formatArgs=function(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const t="color: "+this.color;n.splice(1,0,t,"color: inherit");let r=0,a=0;n[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),n.splice(a,0,t)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),e.exports=function(e){function n(e){let r,a=null;function o(...e){if(!o.enabled)return;const t=o,a=Number(new Date);t.diff=a-(r||a),t.prev=r,t.curr=a,r=a,e[0]=n.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=n.formatters[a];return"function"==typeof o&&(r=o.call(t,e[i]),e.splice(i,1),i--),r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return o.namespace=e,o.useColors=n.useColors(),o.color=n.selectColor(e),o.extend=t,o.destroy=n.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?n.enabled(e):a,set:e=>{a=e}}),"function"==typeof n.init&&n.init(o),o}function t(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(r),...n.skips.map(r).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(t=0;t<a;t++)r[t]&&("-"===(e=r[t].replace(/\*/g,".*?"))[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))},n.enabled=function(e){if("*"===e[e.length-1])return!0;let t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=H,n.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={},n.selectColor=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]},n.enable(n.load()),n}(n);const{formatters:t}=e.exports;t.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(W={exports:{}},W.exports),W.exports),Q=U("sq:user-identity");function _(){window.squatchUserIdentity||(window.squatchUserIdentity=new n.ContextProvider({element:document.documentElement,initialState:J(),contextName:"sq:user-identity"}).start())}function T(e){if(e)try{var n,t,r=h.default(e),a=r.exp;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(r)){var o=r.sub.match(/(.*):(.*)@(.*):users/);t=atob(o[1]),n=atob(o[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(r)&&(t=r.user.accountId,n=r.user.id);if(!n||!t)return;if(a&&Date.now()>=1e3*a)return;return{id:n,accountId:t,jwt:e}}catch(e){return}}function J(){var e=F();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":var n=new URLSearchParams(document.location.search);if(n.has("jwt"))return T(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=T(r.jwt);return a?D({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function G(e){_();var n=window.squatchUserIdentity;r.equal(n.context,e)||(n.context=e),e&&"SquatchPortal"===F().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(Q("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function z(){var e;return null==(e=B())?void 0:e.jwt}function B(){_();var n=I(),t=e.useDomContext(n,"sq:user-identity"),r=T(null==t?void 0:t.jwt);if(!t||r)return t;G(void 0)}var K=function(){return(K=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var a in n=arguments[t])Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a]);return e}).apply(this,arguments)},Z=new Map,X=new Map,Y=!0,ee=!1;function ne(e){return e.replace(/[\s,]+/g," ").trim()}function te(e){var n,t,r,o=ne(e);if(!Z.has(o)){var i=a.parse(e,{experimentalFragmentVariables:ee});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");Z.set(o,function(e){var n=new Set(e.definitions);n.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(t){var r=e[t];r&&"object"==typeof r&&n.add(r)})});var t=e.loc;return t&&(delete t.startToken,delete t.endToken),e}((n=i,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=ne((i=e.loc).source.body.substring(i.start,i.end)),o=X.get(n);o&&!o.has(a)?Y&&console.warn("Warning: fragment with name "+n+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||X.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),K(K({},n),{definitions:r}))))}return Z.get(o)}function re(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];"string"==typeof e&&(e=[e]);var r=e[0];return n.forEach(function(n,t){r+=n&&"Document"===n.kind?n.loc.source.body:n,r+=e[t+1]}),te(r)}var ae,oe=re;(ae=re||(re={})).gql=oe,ae.resetCaches=function(){Z.clear(),X.clear()},ae.disableFragmentWarnings=function(){Y=!1},ae.enableExperimentalFragmentVariables=function(){ee=!0},ae.disableExperimentalFragmentVariables=function(){ee=!1},re.default=re;var ie=re;function se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var ue=function(e){var n,t;function r(n,t){var r;(r=e.call(this,n,t)||this).subject=new s.Subject;var o=new s.Subject;return r.subject.pipe(u.bufferTime(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=fe(e),i=t.mergedQuery,s=t.mergedVariables,u=t.mergedQueryAddedEvents,c=$(t.unmergedQueryAddedEvents);!(n=c()).done;)o.next(n.value);return u.length?Promise.resolve(se(function(){return Promise.resolve(r.superRequest(i,s)).then(function(e){pe(e,u)})},function(e){if(e instanceof d.ClientError){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:he(u,e)};for(var o,i=Object.keys(t),s=[].concat(u),c=function(){var n=o.value,t=void 0;n.path.find(function(r,o,u){if(i.includes(r)){var c=le(r),l=s.findIndex(function(e){return e.id===c});if(-1===l)return!1;i.splice(o,1),t=s.splice(l,1)[0];var f=me(e.response.data,t);u[o]=de(u[o],c);var m=t.query,v=t.variables,p=D({},e.response,{errors:[n],data:f,path:u}),g=new d.ClientError(p,{query:"string"!=typeof m?a.print(m):m,variables:v});return ge(t,g),!0}return!1})},l=$(r);!(o=l()).done;)c();pe(t,s)}();if("object"==typeof n)return n.v}else he(u,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),o.subscribe(function(e){try{var n=se(function(){return Promise.resolve(r.superRequest(e.query,e.variables)).then(function(n){ve(n,e)})},function(n){ge(e,n)});return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}),r}t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,A(n,t);var o=r.prototype;return o.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},o.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:ce(),resolve:r,reject:a};t.subject.next(o)})},r}(l.GraphQLClient),ce=function(){return c.nanoid().replace(/[-_]/g,"")},de=function(e,n){return e.replace("_"+n,"")},le=function(e){var n=e.split("_");return n[n.length-1]},fe=function(e){var n=[],t=[],r=e.reduce(function(e,r){var o=r.query,i=r.variables,s=r.id;try{var u="string"==typeof o?a.parse(o):o,c=u.definitions.find(function(e){return"FragmentDefinition"===e.kind}),d="string"==typeof o?o:a.print(o),l=/@/.test(d);if(c||l)return t.push(r),e;var f=function(e){return function(e,n){return e+"_"+n}(e,s)};return e=e.addN(u,[i],f,f),n.push(r),e}catch(n){return t.push(r),e}},w.default("BatchedQuery")),o=r.document,i=r.variables;return{mergedQuery:o&&a.print(o),mergedVariables:i,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:t}},me=function(e,n){if(!e)return e;var t=Object.keys(e),r=n.id;return t.reduce(function(n,t){var a;return t.endsWith(r)&&(n=D({},n,((a={})[de(t,r)]=e[t],a))),n},{})},ve=function(e,n){(0,n.resolve)(e)},pe=function(e,n){for(var t,r=$(n);!(t=r()).done;){var a=t.value,o=me(e,a);a.resolve(o)}},ge=function(e,n){(0,e.reject)(n)},he=function(e,n){for(var t,r=$(e);!(t=r()).done;)(0,t.value.reject)(n)},ye=y.default(function(e,n,t){return new ue(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function we(e,n){switch(n.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:n.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:n.payload,loading:!1}}}function Ce(n,t){var r,a,i,s,u,c,d=(r=z(),a=x(),i=S(),s=ye(a,i,r),u=I(),null!=(c=e.useDomContext(u,"sq:graphql-client",{attempts:0}))?c:s),l=o.useReducer(we,t),f=l[1];return[l[0],o.useCallback(function(e,t){void 0===t&&(t=!1);try{if(!d)return f({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var r=function(r,a){try{var o=(t||f({type:"loading"}),Promise.resolve(d.request(n,e)).then(function(e){f({type:"data",payload:e})}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){f({type:"errors",payload:e})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[d,n,f])]}var be,qe={loading:!1,data:void 0,errors:void 0};function Ie(e){var n=Ce(e,qe);return[n[1],n[0]]}var Pe,Ee,Fe,Se,xe=ie(be||(be=k(["\n mutation AuthenticateWithEmailAndPassword(\n $email: String!\n $password: String!\n ) {\n authenticateManagedIdentityWithEmailAndPassword(\n authenticateManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),Me=ie(Pe||(Pe=k(["\n mutation RegisterWithEmailAndPassword(\n $email: String!\n $password: String!\n $formData: RSJsonNode\n $redirectPath: String\n ) {\n registerManagedIdentityWithEmailAndPassword(\n registerManagedIdentityWithEmailAndPasswordInput: {\n email: $email\n password: $password\n formData: $formData\n redirectPath: $redirectPath\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),De=ie(Ee||(Ee=k(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"]))),Ae=ie(Fe||(Fe=k(["\n mutation ResetPassword($oobCode: String!, $password: String!) {\n resetManagedIdentityPassword(\n resetManagedIdentityPasswordInput: {\n password: $password\n oobCode: $oobCode\n }\n ) {\n token\n email\n emailVerified\n sessionData\n }\n }\n"]))),ke=ie(Se||(Se=k(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function je(e){var n=e.skip,t=void 0!==n&&n,a=e.update,i=e.variables;o.useEffect(function(){var e=function(e){!t&&a(i,!0)};return document.addEventListener("sq:refresh",e),function(){return document.removeEventListener("sq:refresh",e)}},function(e){var n=o.useRef(e),t=o.useRef(0);return r.equal(e,n.current)||(n.current=e,t.current+=1),o.useMemo(function(){return n.current},[t.current])}([e.query,i,a,t]))}var $e,Re={loading:!1,data:void 0,errors:void 0},Ve=Symbol();function Oe(e){var n=Ce(e,Re),t=n[0],r=n[1],a=o.useRef(Ve);return je({skip:a.current===Ve,update:r,variables:a.current,query:e}),[r,D({},t,{refetch:function(e){a.current=e,r(e)}})]}var Ne,He=ie($e||($e=k(["\n query ManagedIdentity {\n managedIdentity {\n email\n emailVerified\n sessionData\n }\n }\n"])));function Le(){var e=B(),n=Oe(He),t=n[0],r=n[1],a=r.loading,i=r.data,s=r.errors,u=r.refetch;return o.useEffect(function(){null!=i&&i.managedIdentity&&G(D({},e,{managedIdentity:i.managedIdentity}))},[null==i?void 0:i.managedIdentity]),[o.useCallback(function(){return t({})},[t]),{loading:a,data:i,errors:s,refetch:u}]}var We,Ue,Qe=ie(Ne||(Ne=k(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"]))),_e=ie(We||(We=k(["\n mutation RequestPasswordResetEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityPasswordResetEmail(\n requestManagedIdentityPasswordResetEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"]))),Te=ie(Ue||(Ue=k(["\n mutation RequestVerificationEmail(\n $email: String!\n $urlParams: RSJsonNode\n $redirectPath: String\n ) {\n requestManagedIdentityVerificationEmail(\n requestManagedIdentityVerificationEmailInput: {\n email: $email\n urlParams: $urlParams\n redirectPath: $redirectPath\n }\n ) {\n success\n }\n }\n"])));function Je(e,n){var t=o.useRef();return t.current&&r.equal(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function Ge(){return o.useReducer(function(e){return e+1},0)}function ze(e){for(var n,t=$(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&ze(r)}return Object.freeze(e)}var Be={loading:!0,data:void 0,errors:void 0};function Ke(e,n,t){var r=Ce(e,Be),a=r[0],o=r[1],i=Ge(),s=i[1];return Je(function(){!t&&o(n)},[e,n,o,i[0],t]),je({skip:t,update:o,variables:n,query:e}),ze(D({},a,{refetch:s}))}function Ze(){return window.squatchHistory=window.squatchHistory||function(){switch(F().type){case"SquatchPortal":return m.createBrowserHistory();default:return m.createMemoryHistory()}}(),window.squatchHistory}var Xe,Ye={createHref:function(){var e;return(e=Ze()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=Ze()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=Ze()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=Ze()).go.apply(e,[].slice.call(arguments))},back:function(){return Ze().back()},forward:function(){var e;return(e=Ze()).forward.apply(e,[].slice.call(arguments))}};function en(e){var n=o.useState({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=t.offset,i=t.limit,s=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:i,setLimit:function(e){var n=u(a,e),o=s(e,n);r(D({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=s(e,i);r(function(e){return D({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,i),r=function(e,n){return Math.ceil(e/n)||0}(n,i),o=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:o,pageProgress:o+" of "+n}}}}function nn(e,n){return e===n}function tn(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=o.useMemo(function(){return C.default(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var rn,an,on,sn=l.gql(Xe||(Xe=k(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"]))),un=U("sq:useForm"),cn=l.gql(rn||(rn=k(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),dn=l.gql(an||(an=k(["\n mutation ($formSubmissionInput: FormSubmissionInput!) {\n submitForm(formSubmissionInput: $formSubmissionInput) {\n success\n results {\n ... on FormHandlerSubmissionResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"]))),ln=l.gql(on||(on=k(["\n query ($formValidationInput: FormValidationInput!) {\n validateForm(formValidationInput: $formValidationInput) {\n valid\n results {\n ... on FormHandlerValidationResult {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n result\n }\n ... on FormHandlerError {\n formHandler {\n name\n endpointUrl\n integration {\n name\n }\n }\n errorType\n error\n errorCode\n }\n }\n }\n }\n"])));exports.BatchedGraphQLClient=ue,exports.GRAPHQL_CONTEXT="sq:graphql-client",exports.getEnvironmentSDK=F,exports.isDemo=function(){var e=F();return"None"===e.type||"SquatchAdmin"===e.type},exports.memoizedGraphQLClient=ye,exports.navigation=Ye,exports.setProgramId=function(e){P(),window.squatchProgramId.context=e},exports.setUseHostImplementation=function(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e},exports.setUserIdentity=G,exports.useAppDomain=x,exports.useAuthenticateWithEmailAndPasswordMutation=function(){var e=Ie(xe),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.authenticateManagedIdentityWithEmailAndPassword){var e=a.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useChangePasswordMutation=function(){var e=Ie(De),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]},exports.useCurrentPage=function(){var e=Ge()[1];return o.useEffect(function(){return Ze().listen(function(){e()})},[]),Ze().location},exports.useDebounce=function(e,n,t){var r=t&&t.equalityFn||nn,a=o.useState(e),i=a[0],s=a[1],u=tn(o.useCallback(function(e){return s(e)},[]),n,t),c=o.useRef(e);return o.useEffect(function(){r(c.current,e)||(u.callback(e),c.current=e)},[e,u,r]),[i,{cancel:u.cancel,flush:u.flush}]},exports.useDebouncedCallback=tn,exports.useEngagementMedium=M,exports.useForm=function(e){var n,t,r,a,i=function(e){try{return Promise.resolve(C({formValidationInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},s=e.formKey,u=e.formRef,c=e.autoSubmit,d=void 0!==c&&c,l=Oe(cn),f=l[0],m=l[1],v=m.data,p=m.loading,g=Ie(dn),h=g[0],y=g[1],w=Oe(ln),C=w[0],q=w[1],I=o.useReducer(function(e,n){return D({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:q,submitData:y}),P=I[0],E=I[1],F=P.enabled,S=P.disabledMessage,x=P.validating,M=P.valid,A=P.error,k=P.formData;return Je(function(){un("submitData useEffect",y),E({submitData:y})},[y]),Je(function(){un("validationData useEffect",q),E({validationData:q})},[q]),o.useEffect(function(){!p&&v&&function(){var n,t,r,a,o;E({enabled:null==v||null==(n=v.form.initialData)?void 0:n.isEnabled,disabledMessage:null==v||null==(t=v.form)||null==(r=t.initialData)?void 0:r.isEnabledErrorMessage});var i=u;if(i){var s=null==v||null==(a=v.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,s):function(e,n){try{var t=e.elements,r=new FormData(e);un({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){un({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=b.default.get(n,r):a.value=b.default.get(n,r)||""}catch(e){un("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[p]),o.useEffect(function(){var e,n,t,r,a,o;P.validationData&&(E({validating:!1,valid:(null==(e=P.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),d&&null!=(r=P.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&h({formSubmissionInput:{key:s,formData:k}}))},[null==(n=P.validationData)||null==(t=n.data)||null==(r=t.validateForm)?void 0:r.valid]),{states:{enabled:F,disabledMessage:S,loadingForm:p,validating:x,valid:M,error:A,validationData:P.validationData,submitData:P.submitData},data:{formKey:s,schema:null==v||null==(a=v.form)?void 0:a.schema},callbacks:{getForm:f,handleSubmit:function(e){try{e.preventDefault(),E({validating:!0});var n=e.target;un("submit form",n);for(var t,r=new FormData(n),a={},o=$(r.entries());!(t=o()).done;){var s=t.value;b.default.set(a,s[0],s[1])}return E({formData:a}),Promise.resolve(i(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:i,submitForm:function(e){try{return Promise.resolve(h({formSubmissionInput:{key:s,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:E,getValidationErrors:function(){var e,n,t,r,a=null==q||null==(e=q.data)||null==(n=e.validateForm)||null==(t=n.results[0])||null==(r=t.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1).startsWith(""+e)})}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(function(n){return n.instanceLocation.substring(1)===e})},getSubErrorsAtPath:o,hasSubErrors:function(e){var n;return(null==(n=o(e))?void 0:n.length)>0}}},getSubmissionErrors:function(){var e;if(!P.submitData)return[];var n=null==(e=P.submitData.data)?void 0:e.submitForm.results;return(null==n?void 0:n.map(function(e){var n,t,r,a,o,i,s,u=null==(n=e.result)||null==(t=n.results)?void 0:t.flatMap(function(e){return!e.success&&e.message}).filter(function(e){return e}),c=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(function(e){return!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}}).filter(function(e){return e.error});return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:c}}))||[]}}}},exports.useHost=I,exports.useLazyQuery=Oe,exports.useLocale=function(){return(n=null==(e=navigator.language)?void 0:e.split("-"))&&1!==n.length?n[0]+"_"+n[1].toUpperCase():e;var e,n},exports.useManagedIdentityQuery=Le,exports.useMutation=Ie,exports.usePaginatedQuery=function(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=en(t),s=i.limit,u=i.setLimit,c=i.setCurrentPage,d=i.calculatePagination,l=Ke(e,D({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,v=l.refetch,p=n(l.data),g=d((null==p||null==(o=p.data)?void 0:o.length)||0,(null==p?void 0:p.totalCount)||0);return{envelope:p,states:{errors:m,loading:f,limit:s,currentPage:g.currentPage,pageCount:g.pageCount,pageProgress:g.pageProgress},callbacks:{refetch:v,setLimit:u,setCurrentPage:c}}},exports.usePagination=en,exports.useProgramId=E,exports.useQuery=Ke,exports.useRefreshDispatcher=function(){var e=I();return{refresh:o.useCallback(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}},exports.useRegisterWithEmailAndPasswordMutation=function(){var e=Ie(Me),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.registerManagedIdentityWithEmailAndPassword){var e=a.registerManagedIdentityWithEmailAndPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.registerManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:a,errors:i}]},exports.useRequestPasswordResetEmailMutation=function(){return Ie(_e)},exports.useRequestVerificationEmailMutation=function(){return Ie(Te)},exports.useResetPasswordMutation=function(){var e=Ie(Ae),n=e[0],t=e[1],r=t.loading,a=t.data,i=t.errors;return o.useEffect(function(){if(null!=a&&a.resetManagedIdentityPassword){var e=a.resetManagedIdentityPassword,n=e.token,t=h.default(n).user;G({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==a?void 0:a.resetManagedIdentityPassword]),[n,{loading:r,data:a,errors:i}]},exports.useShareEvent=function(){var e=M(),n=B(),t=E(),r=Ie(sn)[0];return n?function(a){r({eventMeta:{id:n.id,accountId:n.accountId,programId:t,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:function(){}},exports.useTenantAlias=S,exports.useTick=Ge,exports.useToken=z,exports.useUserIdentity=B,exports.useVerifyEmailMutation=function(){var e,n=Le()[0],t=Ie(Qe),r=t[0],a=t[1],i=a.loading,s=a.data,u=a.errors;return o.useEffect(function(){var e;null!=s&&null!=(e=s.verifyManagedIdentityEmail)&&e.success&&n()},[null==s||null==(e=s.verifyManagedIdentityEmail)?void 0:e.success]),[r,{loading:i,data:s,errors:u}]},exports.useVerifyPasswordResetCodeMutation=function(){return Ie(ke)};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|