@saasquatch/component-boilerplate 1.2.3-8 → 1.2.3-9

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.
@@ -1,4 +1,4 @@
1
- import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import n from"jwt-decode";import{equal as r}from"@wry/equality";import{parse as a,print as o}from"graphql";import{useReducer as i,useCallback as s,useEffect as u,useRef as d,useState as c,useMemo as l}from"@saasquatch/universal-hooks";import m from"fast-memoize";import{Subject as f}from"rxjs";import{bufferTime as g}from"rxjs/operators";import{nanoid as p}from"nanoid";import{ClientError as h}from"graphql-request/dist/types";import{GraphQLClient as y,gql as w}from"graphql-request";import v from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function E(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function S(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}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=E();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}function A(){var e,t;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==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function $(){const e=A();return"None"===e.type||"SquatchAdmin"===e.type}function k(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function j(){var e;const t=A();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function x(){const e=A();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function R(){return function(){const e=navigator.language,t=null==e?void 0:e.split("-");return t&&1!==t.length?`${t[0]}_${t[1].toUpperCase()}`:e}()}function V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function N(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:H(),contextName:"sq:user-identity"}).start())}function O(e){if(e)try{const t=n(e),r=t.exp;let a,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),a=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,a=t.user.id);if(!a||!o)return;if(r&&Date.now()>=1e3*r)return;return{id:a,accountId:o,jwt:e}}catch(e){return}}function H(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return O(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=O(e.jwt);return t?V({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function W(e){N();const t=window.squatchUserIdentity;r(t.context,e)||(t.context=e),e&&"SquatchPortal"===A().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||localStorage.removeItem("sq:user-identity")}function U(){var e;return null==(e=J())?void 0:e.jwt}function J(){N();const t=E(),n=e(t,"sq:user-identity"),r=O(null==n?void 0:n.jwt);if(!n||r)return n;W(void 0)}var L=function(){return(L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},_=new Map,Q=new Map,T=!0,z=!1;function G(e){return e.replace(/[\s,]+/g," ").trim()}function B(e){var t,n,r,o=G(e);if(!_.has(o)){var i=a(e,{experimentalFragmentVariables:z});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");_.set(o,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}((t=i,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=G((i=e.loc).source.body.substring(i.start,i.end)),o=Q.get(t);o&&!o.has(a)?T&&console.warn("Warning: fragment with name "+t+" 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||Q.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),L(L({},t),{definitions:r}))))}return _.get(o)}function K(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){r+=t&&"Document"===t.kind?t.loc.source.body:t,r+=e[n+1]}),B(r)}var Z,X=K;(Z=K||(K={})).gql=X,Z.resetCaches=function(){_.clear(),Q.clear()},Z.disableFragmentWarnings=function(){T=!1},Z.enableExperimentalFragmentVariables=function(){z=!0},Z.disableExperimentalFragmentVariables=function(){z=!1},K.default=K;var Y=K;class ee extends y{constructor(e,t){var n;super(e,t),n=this,this.subject=new f;const r=new f;this.subject.pipe(g(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:i,unmergedQueryAddedEvents:s}=ae(e);for(const e of s)r.next(e);if(i.length)try{const e=await n.superRequest(t,a);se(e,i)}catch(e){if(e instanceof h){const{data:t,errors:n}=e.response;if(!t)return de(i,e);const r=Object.keys(t);let a=[...i];for(const t of n){let n;t.path.find((i,s,u)=>{if(r.includes(i)){const d=re(i),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const l=oe(e.response.data,n);u[s]=ne(u[s],d);const{query:m,variables:f}=n,g=V({},e.response,{errors:[t],data:l,path:u}),p=new h(g,{query:"string"!=typeof m?o(m):m,variables:f});return ue(n,p),!0}return!1})}se(t,a)}else de(i,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ie(a,e)}catch(t){ue(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t){return new Promise((n,r)=>{const a={query:e,variables:t,id:te(),resolve:n,reject:r};this.subject.next(a)})}}const te=()=>p().replace(/[-_]/g,""),ne=(e,t)=>e.replace(`_${t}`,""),re=e=>{const t=e.split("_");return t[t.length-1]},ae=e=>{const t=[],n=[],{document:r,variables:i}=e.reduce((e,r)=>{const{query:i,variables:s,id:u}=r;try{const d="string"==typeof i?a(i):i,c=d.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof i?i:o(i),m=/@/.test(l);if(c||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,u);return e=e.addN(d,[s],f,f),t.push(r),e}catch(t){return n.push(r),e}},v("BatchedQuery"));return{mergedQuery:r&&o(r),mergedVariables:i,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},oe=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=V({},t,{[ne(n,r)]:e[n]})),t),{})},ie=(e,t)=>{const{resolve:n}=t;n(e)},se=(e,t)=>{for(const n of t){const t=oe(e,n);n.resolve(t)}},ue=(e,t)=>{const{reject:n}=e;n(t)},de=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ce="sq:graphql-client",le=m(function(e,t,n){return new ee(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function me(e,t){switch(t.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:t.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:t.payload,loading:!1}}}function fe(t,n){const r=function(){const t=U(),n=j(),r=k(),a=le(n,r,t),o=E(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=i(me,n);return[a,s(async function(e){if(r)try{o({type:"loading"});const n=await r.request(t,e);o({type:"data",payload:n})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const ge={loading:!1,data:void 0,errors:void 0};function pe(e){const[t,n]=fe(e,ge);return[n,t]}let he;const ye=Y(he||(he=(e=>e)`
1
+ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import n from"jwt-decode";import{equal as r}from"@wry/equality";import{parse as a,print as o}from"graphql";import{useReducer as i,useCallback as s,useEffect as u,useRef as d,useState as c,useMemo as l}from"@saasquatch/universal-hooks";import m from"fast-memoize";import{Subject as f}from"rxjs";import{bufferTime as g}from"rxjs/operators";import{nanoid as p}from"nanoid";import{ClientError as h}from"graphql-request/dist/types";import{GraphQLClient as y,gql as w}from"graphql-request";import v from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function S(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function E(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}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=S();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}function A(){var e,t;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==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function $(){const e=A();return"None"===e.type||"SquatchAdmin"===e.type}function k(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function j(){var e;const t=A();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function x(){const e=A();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function R(){return function(){const e=navigator.language,t=null==e?void 0:e.split("-");return t&&1!==t.length?`${t[0]}_${t[1].toUpperCase()}`:e}()}function V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function N(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:H(),contextName:"sq:user-identity"}).start())}function O(e){if(e)try{const t=n(e),r=t.exp;let a,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),a=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,a=t.user.id);if(!a||!o)return;if(r&&Date.now()>=1e3*r)return;return{id:a,accountId:o,jwt:e}}catch(e){return}}function H(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return O(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=O(e.jwt);return t?V({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function W(e){N();const t=window.squatchUserIdentity;r(t.context,e)||(t.context=e),e&&"SquatchPortal"===A().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||localStorage.removeItem("sq:user-identity")}function J(){var e;return null==(e=U())?void 0:e.jwt}function U(){N();const t=S(),n=e(t,"sq:user-identity"),r=O(null==n?void 0:n.jwt);if(!n||r)return n;W(void 0)}var L=function(){return(L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},_=new Map,Q=new Map,T=!0,z=!1;function G(e){return e.replace(/[\s,]+/g," ").trim()}function B(e){var t,n,r,o=G(e);if(!_.has(o)){var i=a(e,{experimentalFragmentVariables:z});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");_.set(o,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}((t=i,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=G((i=e.loc).source.body.substring(i.start,i.end)),o=Q.get(t);o&&!o.has(a)?T&&console.warn("Warning: fragment with name "+t+" 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||Q.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),L(L({},t),{definitions:r}))))}return _.get(o)}function K(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){r+=t&&"Document"===t.kind?t.loc.source.body:t,r+=e[n+1]}),B(r)}var Z,X=K;(Z=K||(K={})).gql=X,Z.resetCaches=function(){_.clear(),Q.clear()},Z.disableFragmentWarnings=function(){T=!1},Z.enableExperimentalFragmentVariables=function(){z=!0},Z.disableExperimentalFragmentVariables=function(){z=!1},K.default=K;var Y=K;class ee extends y{constructor(e,t){var n;super(e,t),n=this,this.subject=new f;const r=new f;this.subject.pipe(g(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:i,unmergedQueryAddedEvents:s}=ae(e);for(const e of s)r.next(e);if(i.length)try{const e=await n.superRequest(t,a);se(e,i)}catch(e){if(e instanceof h){const{data:t,errors:n}=e.response;if(!t)return de(i,e);const r=Object.keys(t);let a=[...i];for(const t of n){let n;t.path.find((i,s,u)=>{if(r.includes(i)){const d=re(i),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const l=oe(e.response.data,n);u[s]=ne(u[s],d);const{query:m,variables:f}=n,g=V({},e.response,{errors:[t],data:l,path:u}),p=new h(g,{query:"string"!=typeof m?o(m):m,variables:f});return ue(n,p),!0}return!1})}se(t,a)}else de(i,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ie(a,e)}catch(t){ue(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t){return new Promise((n,r)=>{const a={query:e,variables:t,id:te(),resolve:n,reject:r};this.subject.next(a)})}}const te=()=>p().replace(/[-_]/g,""),ne=(e,t)=>e.replace(`_${t}`,""),re=e=>{const t=e.split("_");return t[t.length-1]},ae=e=>{const t=[],n=[],{document:r,variables:i}=e.reduce((e,r)=>{const{query:i,variables:s,id:u}=r;try{const d="string"==typeof i?a(i):i,c=d.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof i?i:o(i),m=/@/.test(l);if(c||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,u);return e=e.addN(d,[s],f,f),t.push(r),e}catch(t){return n.push(r),e}},v("BatchedQuery"));return{mergedQuery:r&&o(r),mergedVariables:i,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},oe=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=V({},t,{[ne(n,r)]:e[n]})),t),{})},ie=(e,t)=>{const{resolve:n}=t;n(e)},se=(e,t)=>{for(const n of t){const t=oe(e,n);n.resolve(t)}},ue=(e,t)=>{const{reject:n}=e;n(t)},de=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ce="sq:graphql-client",le=m(function(e,t,n){return new ee(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function me(e,t){switch(t.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:t.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:t.payload,loading:!1}}}function fe(t,n){const r=function(){const t=J(),n=j(),r=k(),a=le(n,r,t),o=S(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=i(me,n);return[a,s(async function(e){if(r)try{o({type:"loading"});const n=await r.request(t,e);o({type:"data",payload:n})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const ge={loading:!1,data:void 0,errors:void 0};function pe(e){const[t,n]=fe(e,ge);return[n,t]}let he;const ye=Y(he||(he=(e=>e)`
2
2
  mutation AuthenticateWithEmailAndPassword(
3
3
  $email: String!
4
4
  $password: String!
@@ -20,12 +20,14 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
20
20
  $email: String!
21
21
  $password: String!
22
22
  $formData: RSJsonNode
23
+ $urlParams: RSJsonNode
23
24
  ) {
24
25
  registerManagedIdentityWithEmailAndPassword(
25
26
  registerManagedIdentityWithEmailAndPasswordInput: {
26
27
  email: $email
27
28
  password: $password
28
29
  formData: $formData
30
+ urlParams: $urlParams
29
31
  }
30
32
  ) {
31
33
  token
@@ -42,7 +44,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
42
44
  success
43
45
  }
44
46
  }
45
- `));function qe(){const[e,{loading:t,data:n,errors:r}]=pe(Fe);return[e,{loading:t,data:n,errors:r}]}let Ee;const Se=Y(Ee||(Ee=(e=>e)`
47
+ `));function qe(){const[e,{loading:t,data:n,errors:r}]=pe(Fe);return[e,{loading:t,data:n,errors:r}]}let Se;const Ee=Y(Se||(Se=(e=>e)`
46
48
  mutation ResetPassword($oobCode: String!, $password: String!) {
47
49
  resetManagedIdentityPassword(
48
50
  resetManagedIdentityPasswordInput: {
@@ -56,7 +58,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
56
58
  sessionData
57
59
  }
58
60
  }
59
- `));function Pe(){const[e,{loading:t,data:r,errors:a}]=pe(Se);return u(()=>{if(null!=r&&r.resetManagedIdentityPassword){const{resetManagedIdentityPassword:e}=r,t=e.token,{user:a}=n(t);W({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.resetManagedIdentityPassword]),[e,{loading:t,data:r,errors:a}]}let Me;const De=Y(Me||(Me=(e=>e)`
61
+ `));function Pe(){const[e,{loading:t,data:r,errors:a}]=pe(Ee);return u(()=>{if(null!=r&&r.resetManagedIdentityPassword){const{resetManagedIdentityPassword:e}=r,t=e.token,{user:a}=n(t);W({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.resetManagedIdentityPassword]),[e,{loading:t,data:r,errors:a}]}let Me;const De=Y(Me||(Me=(e=>e)`
60
62
  mutation VerifyPasswordResetCode($oobCode: String!) {
61
63
  verifyManagedIdentityPasswordResetCode(
62
64
  verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }
@@ -72,7 +74,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
72
74
  sessionData
73
75
  }
74
76
  }
75
- `));function Re(){const e=J(),[t,{loading:n,data:r,errors:a,refetch:o}]=ke(xe);return u(()=>{if(null!=r&&r.managedIdentity){const{managedIdentity:t}=r;W(V({},e,{managedIdentity:t}))}},[null==r?void 0:r.managedIdentity]),[s(()=>t({}),[t]),{loading:n,data:r,errors:a,refetch:o}]}let Ve;const Ne=Y(Ve||(Ve=(e=>e)`
77
+ `));function Re(){const e=U(),[t,{loading:n,data:r,errors:a,refetch:o}]=ke(xe);return u(()=>{if(null!=r&&r.managedIdentity){const{managedIdentity:t}=r;W(V({},e,{managedIdentity:t}))}},[null==r?void 0:r.managedIdentity]),[s(()=>t({}),[t]),{loading:n,data:r,errors:a,refetch:o}]}let Ve;const Ne=Y(Ve||(Ve=(e=>e)`
76
78
  mutation VerifyEmail($oobCode: String!) {
77
79
  verifyManagedIdentityEmail(
78
80
  verifyManagedIdentityEmailInput: { oobCode: $oobCode }
@@ -91,7 +93,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
91
93
  success
92
94
  }
93
95
  }
94
- `));function Ue(){return pe(We)}let Je;const Le=Y(Je||(Je=(e=>e)`
96
+ `));function Je(){return pe(We)}let Ue;const Le=Y(Ue||(Ue=(e=>e)`
95
97
  mutation RequestVerificationEmail($email: String!, $urlParams: RSJsonNode) {
96
98
  requestManagedIdentityVerificationEmail(
97
99
  requestManagedIdentityVerificationEmailInput: {
@@ -106,7 +108,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
106
108
  mutation ($eventMeta: UserAnalyticsEvent!) {
107
109
  createUserAnalyticsEvent(eventMeta: $eventMeta)
108
110
  }
109
- `));function it(){const e=x(),t=J(),n=M(),[r]=pe(ot);return t?a=>{r({eventMeta:{id:t.id,accountId:t.accountId,programId:n,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:()=>{}}var st,ut=1e3,dt=60*ut,ct=60*dt,lt=24*ct,mt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\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(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*lt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ct;case"minutes":case"minute":case"mins":case"min":case"m":return n*dt;case"seconds":case"second":case"secs":case"sec":case"s":return n*ut;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=lt?ft(e,t,lt,"day"):t>=ct?ft(e,t,ct,"hour"):t>=dt?ft(e,t,dt,"minute"):t>=ut?ft(e,t,ut,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=lt?Math.round(e/lt)+"d":t>=ct?Math.round(e/ct)+"h":t>=dt?Math.round(e/dt)+"m":t>=ut?Math.round(e/ut)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ft(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}let gt,pt,ht,yt=e=>e;const wt=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.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+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.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`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.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=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=mt,t.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(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(st={exports:{}},st.exports),st.exports)("sq:useForm"),vt=w(gt||(gt=yt`
111
+ `));function it(){const e=x(),t=U(),n=M(),[r]=pe(ot);return t?a=>{r({eventMeta:{id:t.id,accountId:t.accountId,programId:n,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:()=>{}}var st,ut=1e3,dt=60*ut,ct=60*dt,lt=24*ct,mt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\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(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*lt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ct;case"minutes":case"minute":case"mins":case"min":case"m":return n*dt;case"seconds":case"second":case"secs":case"sec":case"s":return n*ut;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=lt?ft(e,t,lt,"day"):t>=ct?ft(e,t,ct,"hour"):t>=dt?ft(e,t,dt,"minute"):t>=ut?ft(e,t,ut,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=lt?Math.round(e/lt)+"d":t>=ct?Math.round(e/ct)+"h":t>=dt?Math.round(e/dt)+"m":t>=ut?Math.round(e/ut)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ft(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}let gt,pt,ht,yt=e=>e;const wt=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.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+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.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`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.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=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=mt,t.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(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(st={exports:{}},st.exports),st.exports)("sq:useForm"),vt=w(gt||(gt=yt`
110
112
  query ($key: String!) {
111
113
  form(key: $key) {
112
114
  schema
@@ -177,5 +179,5 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
177
179
  }
178
180
  }
179
181
  }
180
- `));function It(e){var t,n,r,a;const{formKey:o,formRef:s,autoSubmit:d=!1}=e,[c,{data:l,loading:m}]=ke(vt),[f,g]=pe(Ct),[p,h]=ke(bt),y={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:h,submitData:g},[w,v]=i((e,t)=>V({},e,t),y),{enabled:C,disabledMessage:b,validating:I,valid:q,error:E,formData:S}=w;async function P(e){await p({formValidationInput:{key:o,formData:e}})}return Qe(()=>{wt("submitData useEffect",g),v({submitData:g})},[g]),Qe(()=>{wt("validationData useEffect",h),v({validationData:h})},[h]),u(()=>{!m&&l&&function(){var t,n,r,a,o;v({enabled:null==l||null==(t=l.form.initialData)?void 0:t.isEnabled,disabledMessage:null==l||null==(n=l.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const i=s;if(!i)return;const u=null==l||null==(a=l.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,u):async function(e,t){const n=e.elements,r=new FormData(e);wt({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{wt({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(t,r):a.value=F.get(t,r)||""}catch(e){wt("no initialData found for key",r)}})}(i,u)}()},[m]),u(()=>{var e,t,n,r,a,i;w.validationData&&(v({validating:!1,valid:(null==(e=w.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),d&&null!=(r=w.validationData)&&null!=(a=r.data)&&null!=(i=a.validateForm)&&i.valid&&f({formSubmissionInput:{key:o,formData:S}}))},[null==(t=w.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:b,loadingForm:m,validating:I,valid:q,error:E,validationData:w.validationData,submitData:w.submitData},data:{formKey:o,schema:null==l||null==(a=l.form)?void 0:a.schema},callbacks:{getForm:c,handleSubmit:async function(e){e.preventDefault(),v({validating:!0});const t=e.target;wt("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())F.set(r,a[0],a[1]);v({formData:r}),await P(r)},validateForm:P,submitForm:async function(e){await f({formSubmissionInput:{key:o,formData:e}})},setFormState:v,getValidationErrors:function(){var e,t,n,r;const a=null==h||null==(e=h.data)||null==(t=e.validateForm)||null==(n=t.results[0])||null==(r=n.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1).startsWith(`${e}`))}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1)===e)},getSubErrorsAtPath:o,hasSubErrors:e=>{var t;return(null==(t=o(e))?void 0:t.length)>0}}},getSubmissionErrors:function(){var e;if(!w.submitData)return[];const t=null==(e=w.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,i,s;const u=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),d=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(e=>!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}).filter(({error:e})=>e);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}}))||[]}}}}export{ee as BatchedGraphQLClient,ce as GRAPHQL_CONTEXT,A as getEnvironmentSDK,$ as isDemo,le as memoizedGraphQLClient,Ze as navigation,D as setProgramId,S as setUseHostImplementation,W as setUserIdentity,j as useAppDomain,we as useAuthenticateWithEmailAndPasswordMutation,qe as useChangePasswordMutation,Xe as useCurrentPage,nt as useDebounce,rt as useDebouncedCallback,x as useEngagementMedium,It as useForm,E as useHost,ke as useLazyQuery,R as useLocale,Re as useManagedIdentityQuery,pe as useMutation,et as usePaginatedQuery,Ye as usePagination,M as useProgramId,Be as useQuery,be as useRegisterWithEmailAndPasswordMutation,Ue as useRequestPasswordResetEmailMutation,_e as useRequestVerificationEmailMutation,Pe as useResetPasswordMutation,it as useShareEvent,k as useTenantAlias,Te as useTick,U as useToken,J as useUserIdentity,Oe as useVerifyEmailMutation,Ae as useVerifyPasswordResetCodeMutation};
182
+ `));function It(e){var t,n,r,a;const{formKey:o,formRef:s,autoSubmit:d=!1}=e,[c,{data:l,loading:m}]=ke(vt),[f,g]=pe(Ct),[p,h]=ke(bt),y={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:h,submitData:g},[w,v]=i((e,t)=>V({},e,t),y),{enabled:C,disabledMessage:b,validating:I,valid:q,error:S,formData:E}=w;async function P(e){await p({formValidationInput:{key:o,formData:e}})}return Qe(()=>{wt("submitData useEffect",g),v({submitData:g})},[g]),Qe(()=>{wt("validationData useEffect",h),v({validationData:h})},[h]),u(()=>{!m&&l&&function(){var t,n,r,a,o;v({enabled:null==l||null==(t=l.form.initialData)?void 0:t.isEnabled,disabledMessage:null==l||null==(n=l.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const i=s;if(!i)return;const u=null==l||null==(a=l.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,u):async function(e,t){const n=e.elements,r=new FormData(e);wt({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{wt({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(t,r):a.value=F.get(t,r)||""}catch(e){wt("no initialData found for key",r)}})}(i,u)}()},[m]),u(()=>{var e,t,n,r,a,i;w.validationData&&(v({validating:!1,valid:(null==(e=w.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),d&&null!=(r=w.validationData)&&null!=(a=r.data)&&null!=(i=a.validateForm)&&i.valid&&f({formSubmissionInput:{key:o,formData:E}}))},[null==(t=w.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:b,loadingForm:m,validating:I,valid:q,error:S,validationData:w.validationData,submitData:w.submitData},data:{formKey:o,schema:null==l||null==(a=l.form)?void 0:a.schema},callbacks:{getForm:c,handleSubmit:async function(e){e.preventDefault(),v({validating:!0});const t=e.target;wt("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())F.set(r,a[0],a[1]);v({formData:r}),await P(r)},validateForm:P,submitForm:async function(e){await f({formSubmissionInput:{key:o,formData:e}})},setFormState:v,getValidationErrors:function(){var e,t,n,r;const a=null==h||null==(e=h.data)||null==(t=e.validateForm)||null==(n=t.results[0])||null==(r=n.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1).startsWith(`${e}`))}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1)===e)},getSubErrorsAtPath:o,hasSubErrors:e=>{var t;return(null==(t=o(e))?void 0:t.length)>0}}},getSubmissionErrors:function(){var e;if(!w.submitData)return[];const t=null==(e=w.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,i,s;const u=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),d=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(e=>!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}).filter(({error:e})=>e);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}}))||[]}}}}export{ee as BatchedGraphQLClient,ce as GRAPHQL_CONTEXT,A as getEnvironmentSDK,$ as isDemo,le as memoizedGraphQLClient,Ze as navigation,D as setProgramId,E as setUseHostImplementation,W as setUserIdentity,j as useAppDomain,we as useAuthenticateWithEmailAndPasswordMutation,qe as useChangePasswordMutation,Xe as useCurrentPage,nt as useDebounce,rt as useDebouncedCallback,x as useEngagementMedium,It as useForm,S as useHost,ke as useLazyQuery,R as useLocale,Re as useManagedIdentityQuery,pe as useMutation,et as usePaginatedQuery,Ye as usePagination,M as useProgramId,Be as useQuery,be as useRegisterWithEmailAndPasswordMutation,Je as useRequestPasswordResetEmailMutation,_e as useRequestVerificationEmailMutation,Pe as useResetPasswordMutation,it as useShareEvent,k as useTenantAlias,Te as useTick,J as useToken,U as useUserIdentity,Oe as useVerifyEmailMutation,Ae as useVerifyPasswordResetCodeMutation};
181
183
  //# sourceMappingURL=index.modern.js.map