@saasquatch/component-boilerplate 1.6.0 → 1.6.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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +16 -16
- 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 +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgramContext as n,PROGRAM_CONTEXT_NAME as r,lazilyStartUserContext as a,USER_CONTEXT_NAME as o,userIdentityFromJwt as s,isDemo as i,setUserIdentity as d,getTenantAlias as c,getAppDomain as
|
|
1
|
+
import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgramContext as n,PROGRAM_CONTEXT_NAME as r,lazilyStartUserContext as a,USER_CONTEXT_NAME as o,userIdentityFromJwt as s,isDemo as i,setUserIdentity as d,getTenantAlias as c,getAppDomain as u,getEngagementMedium as l,getEnvironment as m,history as f}from"@saasquatch/component-environment";export{getEnvironmentSDK,isDemo,setProgramId,setUserIdentity}from"@saasquatch/component-environment";import{useDomContext as g}from"@saasquatch/dom-context-hooks";import{parse as p,print as h}from"graphql";import y from"jwt-decode";import{useReducer as v,useCallback as C,useState as w,useEffect as b,useMemo as I,useRef as F}from"@saasquatch/universal-hooks";import E from"fast-memoize";import{Subject as P}from"rxjs";import{bufferTime as $}from"rxjs/operators";import{nanoid as D}from"nanoid";import{ClientError as M}from"graphql-request/dist/types";import{GraphQLClient as S,gql as k}from"graphql-request";import A from"graphql-combine-query";import{equal as q}from"@wry/equality";import R from"debounce";import j from"jsonpointer";const V={current:void 0};function x(){if(void 0===V.current)throw new Error("no implementation of useHost provided");return V.current()}function W(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");V.current=e}function N(){e();const n=x();return g(n,t)}function O(){n();const e=x();return g(e,r)}function H(){var e,t;return null==(e=L())||null==(t=e.managedIdentity)?void 0:t.sessionData}function U(){var e;return null==(e=L())?void 0:e.jwt}function L(){a();const e=x(),t=g(e,o),n=s(null==t?void 0:t.jwt);if(i()||!t||n)return t;d(void 0)}const _=c,T=u,J=l;var Q=function(){return(Q=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)},z=new Map,G=new Map,B=!0,K=!1;function Z(e){return e.replace(/[\s,]+/g," ").trim()}function X(e){var t,n,r,a=Z(e);if(!z.has(a)){var o=p(e,{experimentalFragmentVariables:K});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");z.set(a,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=o,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=Z((s=e.loc).source.body.substring(s.start,s.end)),o=G.get(t);o&&!o.has(a)?B&&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||G.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var s}),Q(Q({},t),{definitions:r}))))}return z.get(a)}function Y(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]}),X(r)}var ee,te=Y;(ee=Y||(Y={})).gql=te,ee.resetCaches=function(){z.clear(),G.clear()},ee.disableFragmentWarnings=function(){B=!1},ee.enableExperimentalFragmentVariables=function(){K=!0},ee.disableExperimentalFragmentVariables=function(){K=!1},Y.default=Y;var ne=Y;function re(){return(re=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)}class ae extends S{constructor(e,t){var n;super(e,t),n=this,this.subject=new P;const r=new P;this.subject.pipe($(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:o,unmergedQueryAddedEvents:s}=de(e);for(const e of s)r.next(e);if(o.length)try{const e=await n.superRequest(t,a);le(e,o)}catch(e){if(e instanceof M){const{data:t,errors:n}=e.response;if(!t)return fe(o,e);const r=Object.keys(t);let a=[...o];for(const t of n){let n;t.path.find((o,s,i)=>{if(r.includes(o)){const d=ie(o),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const u=ce(e.response.data,n);i[s]=se(i[s],d);const{query:l,variables:m}=n,f=re({},e.response,{errors:[t],data:u,path:i}),g=new M(f,{query:"string"!=typeof l?h(l):l,variables:m});return me(n,g),!0}return!1})}le(t,a)}else fe(o,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ue(a,e)}catch(t){me(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:oe(),resolve:n,reject:r};this.subject.next(a)})}}const oe=()=>D().replace(/[-_]/g,""),se=(e,t)=>e.replace(`_${t}`,""),ie=e=>{const t=e.split("_");return t[t.length-1]},de=e=>{const t=[],n=[],{document:r,variables:a}=e.reduce((e,r)=>{const{query:a,variables:o,id:s}=r;try{const i="string"==typeof a?p(a):a,d=i.definitions.find(e=>"FragmentDefinition"===e.kind),c="string"==typeof a?a:h(a),u=/@/.test(c);if(d||u)return n.push(r),e;const l=e=>((e,t)=>`${e}_${t}`)(e,s);return e=e.addN(i,[o],l,l),t.push(r),e}catch(t){return n.push(r),e}},A("BatchedQuery"));return{mergedQuery:r&&h(r),mergedVariables:a,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},ce=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=re({},t,{[se(n,r)]:e[n]})),t),{})},ue=(e,t)=>{const{resolve:n}=t;n(e)},le=(e,t)=>{for(const n of t){const t=ce(e,n);n.resolve(t)}},me=(e,t)=>{const{reject:n}=e;n(t)},fe=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ge="sq:graphql-client",pe=E(function(e,t,n){return new ae(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function he(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 ye(e,t){const n=function(){const e=U(),t=T(),n=_(),r=pe(t,n,e),a=x(),o=g(a,"sq:graphql-client",{attempts:0});return null!=o?o:r}(),[r,a]=v(he,t);return[r,C(async function(t,r=!1){if(!n){const e=new Error("No GraphQL client found");return a({type:"errors",payload:e}),e}try{r||a({type:"loading"});const o=await n.request(e,t);return a({type:"data",payload:o}),o}catch(e){return a({type:"errors",payload:e}),e}},[n,e,a])]}const ve={loading:!1,data:void 0,errors:void 0};function Ce(e){const[t,n]=ye(e,ve);return[n,t]}let we;const be=ne(we||(we=(e=>e)`
|
|
2
2
|
mutation AuthenticateWithEmailAndPassword(
|
|
3
3
|
$email: String!
|
|
4
4
|
$password: String!
|
|
@@ -15,7 +15,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
15
15
|
sessionData
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
`));function
|
|
18
|
+
`));function Ie(){const[e,{loading:t,data:n,errors:r}]=Ce(be);return[async t=>{const n=await e(t);if(!(n instanceof Error)&&n.authenticateManagedIdentityWithEmailAndPassword){const e=n.authenticateManagedIdentityWithEmailAndPassword.token,{user:t}=y(e);d({jwt:e,id:t.id,accountId:t.accountId,managedIdentity:{email:n.authenticateManagedIdentityWithEmailAndPassword.email,emailVerified:n.authenticateManagedIdentityWithEmailAndPassword.emailVerified,sessionData:n.authenticateManagedIdentityWithEmailAndPassword.sessionData}})}return n},{loading:t,data:n,errors:r}]}let Fe;const Ee=ne(Fe||(Fe=(e=>e)`
|
|
19
19
|
mutation RegisterWithEmailAndPassword(
|
|
20
20
|
$email: String!
|
|
21
21
|
$password: String!
|
|
@@ -36,7 +36,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
36
36
|
sessionData
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
`));function
|
|
39
|
+
`));function Pe(){const[e,{loading:t,data:n,errors:r}]=Ce(Ee);return[async t=>{const n=await e(t);if(!(n instanceof Error)&&n.registerManagedIdentityWithEmailAndPassword){const e=n.registerManagedIdentityWithEmailAndPassword.token,{user:t}=y(e);d({jwt:e,id:t.id,accountId:t.accountId,managedIdentity:{email:n.registerManagedIdentityWithEmailAndPassword.email,emailVerified:n.registerManagedIdentityWithEmailAndPassword.emailVerified,sessionData:n.registerManagedIdentityWithEmailAndPassword.sessionData}})}return n},{loading:t,data:n,errors:r}]}let $e;const De=ne($e||($e=(e=>e)`
|
|
40
40
|
mutation RegisterViaRegistrationForm($key: String!, $formData: RSJsonNode!) {
|
|
41
41
|
submitForm(formSubmissionInput: { key: $key, formData: $formData }) {
|
|
42
42
|
results {
|
|
@@ -58,7 +58,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
`));function
|
|
61
|
+
`));function Me(){const[e,{loading:t,data:n,errors:r}]=Ce(De),[a,o]=w(null);return[async t=>{var n,r,a,s;o(null);const i=await e(t);if(i instanceof Error)return i;const c=null==(n=i.submitForm)||null==(r=n.results)?void 0:r.find(e=>{var t;return"identity"===(null==e||null==(t=e.formHandler)?void 0:t.namespace)});if(c&&null!=(a=c.result)&&null!=(s=a.results)&&s.length){const e=c.result.results[0];if(e.success){const t=e.data.token,{user:n}=y(t);d({jwt:t,id:n.id,accountId:n.accountId,managedIdentity:{email:e.data.email,emailVerified:e.data.emailVerified,sessionData:e.data.sessionData}})}else o(e.message)}return i},{loading:t,data:n,errors:r,formError:a}]}let Se;const ke=ne(Se||(Se=(e=>e)`
|
|
62
62
|
mutation ChangePassword($password: String!) {
|
|
63
63
|
changeManagedIdentityPassword(
|
|
64
64
|
changeManagedIdentityPasswordInput: { password: $password }
|
|
@@ -66,7 +66,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
66
66
|
success
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
`));function
|
|
69
|
+
`));function Ae(){const[e,{loading:t,data:n,errors:r}]=Ce(ke);return[e,{loading:t,data:n,errors:r}]}let qe;const Re=ne(qe||(qe=(e=>e)`
|
|
70
70
|
mutation ResetPassword($oobCode: String!, $password: String!) {
|
|
71
71
|
resetManagedIdentityPassword(
|
|
72
72
|
resetManagedIdentityPasswordInput: {
|
|
@@ -80,7 +80,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
80
80
|
sessionData
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
`));function
|
|
83
|
+
`));function je(){const[e,{loading:t,data:n,errors:r}]=Ce(Re);return[async t=>{const n=await e(t);if(!(n instanceof Error)&&n.resetManagedIdentityPassword){const e=n.resetManagedIdentityPassword.token,{user:t}=y(e);d({jwt:e,id:t.id,accountId:t.accountId,managedIdentity:{email:n.resetManagedIdentityPassword.email,emailVerified:n.resetManagedIdentityPassword.emailVerified,sessionData:n.resetManagedIdentityPassword.sessionData}})}return n},{loading:t,data:n,errors:r}]}let Ve;const xe=ne(Ve||(Ve=(e=>e)`
|
|
84
84
|
mutation VerifyPasswordResetCode($oobCode: String!) {
|
|
85
85
|
verifyManagedIdentityPasswordResetCode(
|
|
86
86
|
verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }
|
|
@@ -88,7 +88,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
88
88
|
success
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
`));function
|
|
91
|
+
`));function We(){return Ce(xe)}function Ne(){const e=x();return{refresh:C(()=>{e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}}function Oe({skip:e=!1,update:t,variables:n}){b(()=>{const r=r=>{!e&&t(n,!0)};return document.addEventListener("sq:refresh",r),()=>document.removeEventListener("sq:refresh",r)},function(e){const t=F(e),n=F(0);return q(e,t.current)||(t.current=e,n.current+=1),I(()=>t.current,[n.current])}([n,t,e]))}const He={loading:!1,data:void 0,errors:void 0},Ue=Symbol();function Le(e){const[t,n]=ye(e,He),r=F(Ue);Oe({skip:r.current===Ue,update:n,variables:r.current});const a=C(e=>(r.current=e,n(e)),[n]);return[n,re({},t,{refetch:a})]}let _e;const Te=ne(_e||(_e=(e=>e)`
|
|
92
92
|
query ManagedIdentitySession {
|
|
93
93
|
managedIdentitySession {
|
|
94
94
|
email
|
|
@@ -96,7 +96,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
96
96
|
sessionData
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
`));function
|
|
99
|
+
`));function Je(){const e=L(),[t,{loading:n,data:r,errors:a,refetch:o}]=Le(Te),s=t=>{t instanceof Error||!t.managedIdentitySession||d(re({},e,{managedIdentity:t.managedIdentitySession}))};return[async()=>{const e=await t({});return s(e),e},{loading:n,data:r,errors:a,refetch:async()=>{const e=await o();return s(e),e}}]}let Qe;const ze=ne(Qe||(Qe=(e=>e)`
|
|
100
100
|
mutation VerifyEmail($oobCode: String!) {
|
|
101
101
|
verifyManagedIdentityEmail(
|
|
102
102
|
verifyManagedIdentityEmailInput: { oobCode: $oobCode }
|
|
@@ -104,7 +104,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
104
104
|
success
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
`));function
|
|
107
|
+
`));function Ge(){const[e]=Je(),[t,{loading:n,data:r,errors:a}]=Ce(ze);return[async n=>{const r=await t(n);return r instanceof Error||!r.verifyManagedIdentityEmail.success||await e(),r},{loading:n,data:r,errors:a}]}let Be;const Ke=ne(Be||(Be=(e=>e)`
|
|
108
108
|
mutation RequestPasswordResetEmail(
|
|
109
109
|
$email: String!
|
|
110
110
|
$urlParams: RSJsonNode
|
|
@@ -120,7 +120,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
120
120
|
success
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
`));function
|
|
123
|
+
`));function Ze(){return Ce(Ke)}let Xe;const Ye=ne(Xe||(Xe=(e=>e)`
|
|
124
124
|
mutation RequestVerificationEmail(
|
|
125
125
|
$email: String!
|
|
126
126
|
$urlParams: RSJsonNode
|
|
@@ -136,7 +136,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
136
136
|
success
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
`));function
|
|
139
|
+
`));function et(){return Ce(Ye)}let tt;const nt=ne(tt||(tt=(e=>e)`
|
|
140
140
|
mutation authenticateManagedIdentityWithInstantAccess(
|
|
141
141
|
$email: String!
|
|
142
142
|
$firstName: String
|
|
@@ -161,11 +161,11 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
161
161
|
token
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
`));function
|
|
164
|
+
`));function rt(){const e=O(),t=m(),[n,{loading:r,data:a,errors:o}]=Ce(nt);return[async r=>{const a=await n(r);if(!(a instanceof Error)&&a.authenticateManagedIdentityWithInstantAccess){if("APPROVED"!==await async function(e,t){try{var n;const r=await fetch(`${u()}/api/v1/${c()}/graphql`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({query:"\n query checkReferralFraudStatus($programId: ID) {\n viewer {\n ... on User {\n id\n instantAccessRewards(filter: { programId_eq: $programId }) {\n data {\n id\n pendingReasons\n cancelledReason\n }\n }\n }\n }\n }\n",variables:{programId:e}})});if(!r.ok)throw new Error("Failed to fetch locale");const a=await r.json();if(a.errors)throw new Error(JSON.stringify(a.errors,null,2));const o=(null==(n=a.data.viewer.instantAccessRewards)?void 0:n.data)||[];return o.some(e=>"SUSPECTED_FRAUD"===e.cancelledReason)?"DENIED":o.some(e=>{var t;return null==(t=e.pendingReasons)?void 0:t.includes("SUSPECTED_FRAUD")})?"PENDING_REVIEW":"APPROVED"}catch(e){return void console.error(e)}}(e,a.authenticateManagedIdentityWithInstantAccess.token))throw{name:"fraud_error",message:"Referral flagged as fraud."};{const e=a.authenticateManagedIdentityWithInstantAccess.email;if(d({jwt:a.authenticateManagedIdentityWithInstantAccess.token,id:e,accountId:e}),"SquatchJS2"===t){const t=new CustomEvent("sq:user-registration",{bubbles:!0,detail:{userId:e,accountId:e}});document.dispatchEvent(t)}}}return a},{loading:r,data:a,errors:o}]}function at(e,t){const n=F();return n.current&&q(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function ot(){return v(e=>e+1,0)}function st(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&st(t)}return Object.freeze(e)}const it={loading:!0,data:void 0,errors:void 0};function dt(e,t,n){const[r,a]=ye(e,it),[o,s]=ot();return at(()=>{!n&&a(t)},[e,t,a,o,n]),Oe({skip:n,update:a,variables:t}),st(re({},r,{refetch:s}))}function ct(){const[,e]=ot();return b(()=>f.listen(()=>{e()}),[]),f.location}const ut=f;function lt(e){const[t,n]=w({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,s=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=s(r,e),i=o(e,a);n(re({},t,{limit:e,offset:i}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>re({},e,{offset:t}))},calculatePagination:function(e,t){const n=s(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),i=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:i,pageProgress:`${i} of ${t}`}}}}function mt(e,t,n,r={},a=!1){var o;const{limit:s,offset:i,setLimit:d,setCurrentPage:c,calculatePagination:u}=lt(n),l=re({limit:s,offset:i},r),{loading:m,errors:f,data:g,refetch:p}=dt(e,l,a),h=t(g),{currentPage:y,pageCount:v,pageProgress:C}=u((null==h||null==(o=h.data)?void 0:o.length)||0,(null==h?void 0:h.totalCount)||0);return{envelope:h,states:{errors:f,loading:m,limit:s,currentPage:y,pageCount:v,pageProgress:C},callbacks:{refetch:p,setLimit:d,setCurrentPage:c}}}function ft(e,t){return e===t}function gt(e,t,n){const r=n&&n.equalityFn||ft,[a,o]=w(e),s=pt(C(e=>o(e),[]),t,n),i=F(e);return b(()=>{r(i.current,e)||(s.callback(e),i.current=e)},[e,s,r]),[a,{cancel:s.cancel,flush:s.flush}]}function pt(e,t=0,n={leading:!1}){const r=I(()=>R(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let ht;const yt=k(ht||(ht=(e=>e)`
|
|
165
165
|
mutation ($eventMeta: UserAnalyticsEvent!) {
|
|
166
166
|
createUserAnalyticsEvent(eventMeta: $eventMeta)
|
|
167
167
|
}
|
|
168
|
-
`));function
|
|
168
|
+
`));function vt(){const e=J(),t=L(),n=O(),[r]=Ce(yt);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 Ct,wt=1e3,bt=60*wt,It=60*bt,Ft=24*It,Et=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*Ft;case"hours":case"hour":case"hrs":case"hr":case"h":return n*It;case"minutes":case"minute":case"mins":case"min":case"m":return n*bt;case"seconds":case"second":case"secs":case"sec":case"s":return n*wt;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>=Ft?Pt(e,t,Ft,"day"):t>=It?Pt(e,t,It,"hour"):t>=bt?Pt(e,t,bt,"minute"):t>=wt?Pt(e,t,wt,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=Ft?Math.round(e/Ft)+"d":t>=It?Math.round(e/It)+"h":t>=bt?Math.round(e/bt)+"m":t>=wt?Math.round(e/wt)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Pt(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}let $t,Dt,Mt,St=e=>e;const kt=(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 s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";s++;const o=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[s]),e.splice(s,1),s--),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=Et,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}}}(Ct={exports:{}},Ct.exports),Ct.exports)("sq:useForm"),At=k($t||($t=St`
|
|
169
169
|
query ($key: String!) {
|
|
170
170
|
form(key: $key) {
|
|
171
171
|
schema
|
|
@@ -176,7 +176,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
`)),
|
|
179
|
+
`)),qt=k(Dt||(Dt=St`
|
|
180
180
|
mutation ($formSubmissionInput: FormSubmissionInput!) {
|
|
181
181
|
submitForm(formSubmissionInput: $formSubmissionInput) {
|
|
182
182
|
success
|
|
@@ -206,7 +206,7 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
`)),
|
|
209
|
+
`)),Rt=k(Mt||(Mt=St`
|
|
210
210
|
query ($formValidationInput: FormValidationInput!) {
|
|
211
211
|
validateForm(formValidationInput: $formValidationInput) {
|
|
212
212
|
valid
|
|
@@ -236,5 +236,5 @@ import{lazilyStartLocaleContext as e,LOCALE_CONTEXT_NAME as t,lazilyStartProgram
|
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
`));function
|
|
239
|
+
`));function jt(e){var t,n,r,a;const{formKey:o,formRef:s,autoSubmit:i=!1}=e,[d,{data:c,loading:u}]=Le(At),[l,m]=Ce(qt),[f,g]=Le(Rt),p={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:g,submitData:m},[h,y]=v((e,t)=>re({},e,t),p),{enabled:C,disabledMessage:w,validating:I,valid:F,error:E,formData:P}=h;async function $(e){await f({formValidationInput:{key:o,formData:e}})}return at(()=>{kt("submitData useEffect",m),y({submitData:m})},[m]),at(()=>{kt("validationData useEffect",g),y({validationData:g})},[g]),b(()=>{!u&&c&&function(){var t,n,r,a,o;y({enabled:null==c||null==(t=c.form.initialData)?void 0:t.isEnabled,disabledMessage:null==c||null==(n=c.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const i=s;if(!i)return;const d=null==c||null==(a=c.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,d):async function(e,t){const n=e.elements,r=new FormData(e);kt({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{kt({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=j.get(t,r):a.value=j.get(t,r)||""}catch(e){kt("no initialData found for key",r)}})}(i,d)}()},[u]),b(()=>{var e,t,n,r,a,s;h.validationData&&(y({validating:!1,valid:(null==(e=h.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),i&&null!=(r=h.validationData)&&null!=(a=r.data)&&null!=(s=a.validateForm)&&s.valid&&l({formSubmissionInput:{key:o,formData:P}}))},[null==(t=h.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:w,loadingForm:u,validating:I,valid:F,error:E,validationData:h.validationData,submitData:h.submitData},data:{formKey:o,schema:null==c||null==(a=c.form)?void 0:a.schema},callbacks:{getForm:d,handleSubmit:async function(e){e.preventDefault(),y({validating:!0});const t=e.target;kt("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())j.set(r,a[0],a[1]);y({formData:r}),await $(r)},validateForm:$,submitForm:async function(e){await l({formSubmissionInput:{key:o,formData:e}})},setFormState:y,getValidationErrors:function(){var e,t,n,r;const a=null==g||null==(e=g.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(!h.submitData)return[];const t=null==(e=h.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,s,i;const d=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),c=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==(s=o.integration)?void 0:s.name,formHandler:null==(i=e.formHandler)?void 0:i.name,messages:d,errors:c}}))||[]}}}}export{ae as BatchedGraphQLClient,ge as GRAPHQL_CONTEXT,pe as memoizedGraphQLClient,ut as navigation,W as setUseHostImplementation,T as useAppDomain,rt as useAuthenticateManagedIdentityWithInstantAccess,Ie as useAuthenticateWithEmailAndPasswordMutation,Ae as useChangePasswordMutation,ct as useCurrentPage,gt as useDebounce,pt as useDebouncedCallback,J as useEngagementMedium,jt as useForm,x as useHost,Le as useLazyQuery,N as useLocale,Je as useManagedIdentitySessionQuery,Ce as useMutation,mt as usePaginatedQuery,lt as usePagination,O as useProgramId,dt as useQuery,Ne as useRefreshDispatcher,Me as useRegisterViaRegistrationFormMutation,Pe as useRegisterWithEmailAndPasswordMutation,Ze as useRequestPasswordResetEmailMutation,et as useRequestVerificationEmailMutation,je as useResetPasswordMutation,H as useSessionData,vt as useShareEvent,_ as useTenantAlias,ot as useTick,U as useToken,L as useUserIdentity,Ge as useVerifyEmailMutation,We as useVerifyPasswordResetCodeMutation};
|
|
240
240
|
//# sourceMappingURL=index.modern.js.map
|