@saasquatch/component-boilerplate 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as n}from"dom-context";import{useReducer as t,useCallback as r,useEffect as a,useMemo as o,useRef as i,useState as s}from"@saasquatch/universal-hooks";import{GraphQLClient as u,gql as c}from"graphql-request";import d from"jwt-decode";import{equal as l}from"@wry/equality";import{parse as f,print as m}from"graphql";import v from"fast-memoize";import{Subject as g}from"rxjs";import{bufferTime as p}from"rxjs/operators";import{nanoid as h}from"nanoid";import{ClientError as y}from"graphql-request/dist/types";import w from"graphql-combine-query";import{createMemoryHistory as b,createBrowserHistory as C}from"history";import I from"debounce";import F from"jsonpointer";var q={current:void 0};function P(){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 E(){var e;window.squatchProgramId||(window.squatchProgramId=new n({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){E();var n=P();return e(n,"sq:program-id")}function A(e){E(),window.squatchProgramId.context=e}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 k(e,n){return(k=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function j(e,n){return n||(n=e.slice(0)),e.raw=n,e}function $(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 x(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 $(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)?$(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=function(){return(R=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)},V=new Map,O=new Map,N=!0,H=!1;function L(e){return e.replace(/[\s,]+/g," ").trim()}function W(e){var n,t,r,a=L(e);if(!V.has(a)){var o=f(e,{experimentalFragmentVariables:H});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");V.set(a,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=o,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=L((i=e.loc).source.body.substring(i.start,i.end)),o=O.get(n);o&&!o.has(a)?N&&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||O.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),R(R({},n),{definitions:r}))))}return V.get(a)}function U(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]}),W(r)}var J,_=U;(J=U||(U={})).gql=_,J.resetCaches=function(){V.clear(),O.clear()},J.disableFragmentWarnings=function(){N=!1},J.enableExperimentalFragmentVariables=function(){H=!0},J.disableExperimentalFragmentVariables=function(){H=!1},U.default=U;var Q=U,T=1e3,z=60*T,G=60*z,B=24*G,K=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*B;case"hours":case"hour":case"hrs":case"hr":case"h":return t*G;case"minutes":case"minute":case"mins":case"min":case"m":return t*z;case"seconds":case"second":case"secs":case"sec":case"s":return t*T;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>=B?Z(e,n,B,"day"):n>=G?Z(e,n,G,"hour"):n>=z?Z(e,n,z,"minute"):n>=T?Z(e,n,T,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=B?Math.round(e/B)+"d":n>=G?Math.round(e/G)+"h":n>=z?Math.round(e/z)+"m":n>=T?Math.round(e/T)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Z(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var X,Y=(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=K,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}}}(X={exports:{}},X.exports),X.exports),ee=Y("sq:user-identity");function ne(){window.squatchUserIdentity||(window.squatchUserIdentity=new n({element:document.documentElement,initialState:re(),contextName:"sq:user-identity"}).start())}function te(e){if(e)try{var n,t,r=d(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 re(){var e=kn();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 te(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=te(r.jwt);return a?D({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function ae(e){ne();var n=window.squatchUserIdentity;l(n.context,e)||(Dn(void 0),n.context=e),e&&"SquatchPortal"===kn().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(ee("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function oe(){var e;return null==(e=ie())?void 0:e.jwt}function ie(){ne();var n=P(),t=e(n,"sq:user-identity"),r=te(null==t?void 0:t.jwt);return t&&!r?(ae(void 0),void Dn(void 0)):t}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 g;var a=new g;return r.subject.pipe(p(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=fe(e),o=t.mergedQuery,i=t.mergedVariables,s=t.mergedQueryAddedEvents,u=x(t.unmergedQueryAddedEvents);!(n=u()).done;)a.next(n.value);return s.length?Promise.resolve(se(function(){return Promise.resolve(r.superRequest(o,i)).then(function(e){ge(e,s)})},function(e){if(e instanceof y){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:he(s,e)};for(var a,o=Object.keys(t),i=[].concat(s),u=function(){var n=a.value,t=void 0;n.path.find(function(r,a,s){if(o.includes(r)){var u=le(r),c=i.findIndex(function(e){return e.id===u});if(-1===c)return!1;o.splice(a,1),t=i.splice(c,1)[0];var d=me(e.response.data,t);s[a]=de(s[a],u);var l=t.query,f=t.variables,v=D({},e.response,{errors:[n],data:d,path:s}),g=new y(v,{query:"string"!=typeof l?m(l):l,variables:f});return pe(t,g),!0}return!1})},c=x(r);!(a=c()).done;)u();ge(t,i)}();if("object"==typeof n)return n.v}else he(s,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),a.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){pe(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,k(n,t);var a=r.prototype;return a.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},a.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}(u),ce=function(){return h().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 a=r.query,o=r.variables,i=r.id;try{var s="string"==typeof a?f(a):a,u=s.definitions.find(function(e){return"FragmentDefinition"===e.kind}),c="string"==typeof a?a:m(a),d=/@/.test(c);if(u||d)return t.push(r),e;var l=function(e){return function(e,n){return e+"_"+n}(e,i)};return e=e.addN(s,[o],l,l),n.push(r),e}catch(n){return t.push(r),e}},w("BatchedQuery")),a=r.document,o=r.variables;return{mergedQuery:a&&m(a),mergedVariables:o,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)},ge=function(e,n){for(var t,r=x(n);!(t=r()).done;){var a=t.value,o=me(e,a);a.resolve(o)}},pe=function(e,n){(0,e.reject)(n)},he=function(e,n){for(var t,r=x(e);!(t=r()).done;)(0,t.value.reject)(n)},ye="sq:graphql-client",we=v(function(e,n,t){return new ue(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function be(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,a){var o,i,s,u,c,d,l=(o=oe(),i=xn(),s=$n(),u=we(i,s,o),c=P(),null!=(d=e(c,"sq:graphql-client",{attempts:0}))?d:u),f=t(be,a),m=f[1];return[f[0],r(function(e,t){void 0===t&&(t=!1);try{if(!l)return m({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var r=function(r,a){try{var o=(t||m({type:"loading"}),Promise.resolve(l.request(n,e)).then(function(e){m({type:"data",payload:e})}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){m({type:"errors",payload:e})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[l,n,m])]}var Ie,Fe={loading:!1,data:void 0,errors:void 0};function qe(e){var n=Ce(e,Fe);return[n[1],n[0]]}var Pe,Se=Q(Ie||(Ie=j(["\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"])));function Ee(){var e=qe(Se),n=e[0],t=e[1],r=t.loading,o=t.data,i=t.errors;return a(function(){if(null!=o&&o.authenticateManagedIdentityWithEmailAndPassword){var e=o.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=d(n).user;ae({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:o,errors:i}]}var Me,Ae=Q(Pe||(Pe=j(["\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"])));function De(){var e=qe(Ae),n=e[0],t=e[1],r=t.loading,o=t.data,i=t.errors;return a(function(){if(null!=o&&o.registerManagedIdentityWithEmailAndPassword){var e=o.registerManagedIdentityWithEmailAndPassword,n=e.token,t=d(n).user;ae({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.registerManagedIdentityWithEmailAndPassword]),[n,{loading:r,data:o,errors:i}]}var ke,je=Q(Me||(Me=j(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"])));function $e(){var e=qe(je),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]}var xe,Re=Q(ke||(ke=j(["\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"])));function Ve(){var e=qe(Re),n=e[0],t=e[1],r=t.loading,o=t.data,i=t.errors;return a(function(){if(null!=o&&o.resetManagedIdentityPassword){var e=o.resetManagedIdentityPassword,n=e.token,t=d(n).user;ae({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.resetManagedIdentityPassword]),[n,{loading:r,data:o,errors:i}]}var Oe=Q(xe||(xe=j(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function Ne(){return qe(Oe)}function He(){var e=P();return{refresh:r(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}}function Le(e){var n=e.skip,t=void 0!==n&&n,r=e.update,s=e.variables;a(function(){var e=function(e){!t&&r(s,!0)};return document.addEventListener("sq:refresh",e),function(){return document.removeEventListener("sq:refresh",e)}},function(e){var n=i(e),t=i(0);return l(e,n.current)||(n.current=e,t.current+=1),o(function(){return n.current},[t.current])}([s,r,t]))}var We,Ue={loading:!1,data:void 0,errors:void 0},Je=Symbol();function _e(e){var n=Ce(e,Ue),t=n[0],r=n[1],a=i(Je);return Le({skip:a.current===Je,update:r,variables:a.current}),[r,D({},t,{refetch:function(e){a.current=e,r(e)}})]}var Qe,Te=Q(We||(We=j(["\n query ManagedIdentity {\n managedIdentity {\n email\n emailVerified\n sessionData\n }\n }\n"])));function ze(){var e=ie(),n=_e(Te),t=n[0],o=n[1],i=o.loading,s=o.data,u=o.errors,c=o.refetch;return a(function(){null!=s&&s.managedIdentity&&ae(D({},e,{managedIdentity:s.managedIdentity}))},[null==s?void 0:s.managedIdentity]),[r(function(){return t({})},[t]),{loading:i,data:s,errors:u,refetch:c}]}var Ge,Be=Q(Qe||(Qe=j(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function Ke(){var e,n=ze()[0],t=qe(Be),r=t[0],o=t[1],i=o.loading,s=o.data,u=o.errors;return a(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}]}var Ze,Xe=Q(Ge||(Ge=j(["\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"])));function Ye(){return qe(Xe)}var en=Q(Ze||(Ze=j(["\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 nn(){return qe(en)}function tn(e,n){var t=i();return t.current&&l(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function rn(){return t(function(e){return e+1},0)}function an(e){for(var n,t=x(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&an(r)}return Object.freeze(e)}var on={loading:!0,data:void 0,errors:void 0};function sn(e,n,t){var r=Ce(e,on),a=r[0],o=r[1],i=rn(),s=i[1];return tn(function(){!t&&o(n)},[e,n,o,i[0],t]),Le({skip:t,update:o,variables:n}),an(D({},a,{refetch:s}))}function un(){return window.squatchHistory=window.squatchHistory||function(){switch(kn().type){case"SquatchPortal":return C();default:return b()}}(),window.squatchHistory}var cn,dn={createHref:function(){var e;return(e=un()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=un()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=un()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=un()).go.apply(e,[].slice.call(arguments))},back:function(){return un().back()},forward:function(){var e;return(e=un()).forward.apply(e,[].slice.call(arguments))}};function ln(){var e=rn()[1];return a(function(){return un().listen(function(){e()})},[]),un().location}function fn(e){var n=s({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=t.offset,o=t.limit,i=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:o,setLimit:function(e){var n=u(a,e),o=i(e,n);r(D({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=i(e,o);r(function(e){return D({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,o),r=function(e,n){return Math.ceil(e/n)||0}(n,o),i=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:i,pageProgress:i+" of "+n}}}}function mn(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=fn(t),s=i.limit,u=i.setLimit,c=i.setCurrentPage,d=i.calculatePagination,l=sn(e,D({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,v=l.refetch,g=n(l.data),p=d((null==g||null==(o=g.data)?void 0:o.length)||0,(null==g?void 0:g.totalCount)||0);return{envelope:g,states:{errors:m,loading:f,limit:s,currentPage:p.currentPage,pageCount:p.pageCount,pageProgress:p.pageProgress},callbacks:{refetch:v,setLimit:u,setCurrentPage:c}}}function vn(e,n){return e===n}function gn(e,n,t){var o=t&&t.equalityFn||vn,u=s(e),c=u[0],d=u[1],l=pn(r(function(e){return d(e)},[]),n,t),f=i(e);return a(function(){o(f.current,e)||(l.callback(e),f.current=e)},[e,l,o]),[c,{cancel:l.cancel,flush:l.flush}]}function pn(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=o(function(){return I(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var hn,yn,wn,bn=c(cn||(cn=j(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));function Cn(){var e=Rn(),n=ie(),t=M(),r=qe(bn)[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(){}}var In,Fn=Y("sq:useForm"),qn=c(hn||(hn=j(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),Pn=c(yn||(yn=j(["\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"]))),Sn=c(wn||(wn=j(["\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"])));function En(e){var n,r,o,i,s=function(e){try{return Promise.resolve(C({formValidationInput:{key:u,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},u=e.formKey,c=e.formRef,d=e.autoSubmit,l=void 0!==d&&d,f=_e(qn),m=f[0],v=f[1],g=v.data,p=v.loading,h=qe(Pn),y=h[0],w=h[1],b=_e(Sn),C=b[0],I=b[1],q=t(function(e,n){return D({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:I,submitData:w}),P=q[0],S=q[1],E=P.enabled,M=P.disabledMessage,A=P.validating,k=P.valid,j=P.error,$=P.formData;return tn(function(){Fn("submitData useEffect",w),S({submitData:w})},[w]),tn(function(){Fn("validationData useEffect",I),S({validationData:I})},[I]),a(function(){!p&&g&&function(){var n,t,r,a,o;S({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=c;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);Fn({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){Fn({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(n,r):a.value=F.get(n,r)||""}catch(e){Fn("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[p]),a(function(){var e,n,t,r,a,o;P.validationData&&(S({validating:!1,valid:(null==(e=P.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),l&&null!=(r=P.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&y({formSubmissionInput:{key:u,formData:$}}))},[null==(n=P.validationData)||null==(r=n.data)||null==(o=r.validateForm)?void 0:o.valid]),{states:{enabled:E,disabledMessage:M,loadingForm:p,validating:A,valid:k,error:j,validationData:P.validationData,submitData:P.submitData},data:{formKey:u,schema:null==g||null==(i=g.form)?void 0:i.schema},callbacks:{getForm:m,handleSubmit:function(e){try{e.preventDefault(),S({validating:!0});var n=e.target;Fn("submit form",n);for(var t,r=new FormData(n),a={},o=x(r.entries());!(t=o()).done;){var i=t.value;F.set(a,i[0],i[1])}return S({formData:a}),Promise.resolve(s(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:s,submitForm:function(e){try{return Promise.resolve(y({formSubmissionInput:{key:u,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:S,getValidationErrors:function(){var e,n,t,r,a=null==I||null==(e=I.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}}))||[]}}}}var Mn=c(In||(In=j(["\n query {\n viewer {\n ... on User {\n locale\n }\n }\n }\n"])));function An(){!function(){var e,t=window.squatchLocale,r=ie();a(function(){if(!r&&t)return t.context=void 0;s({})},[r]);var o,i=_e(Mn),s=i[0],u=i[1].data,c=null==u||null==(e=u.viewer)?void 0:e.locale;t?c!==t.context&&(t.context=c):window.squatchLocale=new n({element:document.documentElement,initialState:c||(null==(o=window.widgetIdent)?void 0:o.locale)||void 0,contextName:"sq:locale"}).start()}();var t=P();return e(t,"sq:locale")}function Dn(e){var n=window.squatchLocale;n&&(n.context=e)}function kn(){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 jn(){var e=kn();return"None"===e.type||"SquatchAdmin"===e.type}function $n(){var e=kn();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function xn(){var e,n=kn();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 Rn(){var e=kn();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}export{ue as BatchedGraphQLClient,ye as GRAPHQL_CONTEXT,kn as getEnvironmentSDK,jn as isDemo,we as memoizedGraphQLClient,dn as navigation,A as setProgramId,S as setUseHostImplementation,ae as setUserIdentity,xn as useAppDomain,Ee as useAuthenticateWithEmailAndPasswordMutation,$e as useChangePasswordMutation,ln as useCurrentPage,gn as useDebounce,pn as useDebouncedCallback,Rn as useEngagementMedium,En as useForm,P as useHost,_e as useLazyQuery,An as useLocale,ze as useManagedIdentityQuery,qe as useMutation,mn as usePaginatedQuery,fn as usePagination,M as useProgramId,sn as useQuery,He as useRefreshDispatcher,De as useRegisterWithEmailAndPasswordMutation,Ye as useRequestPasswordResetEmailMutation,nn as useRequestVerificationEmailMutation,Ve as useResetPasswordMutation,Cn as useShareEvent,$n as useTenantAlias,rn as useTick,oe as useToken,ie as useUserIdentity,Ke as useVerifyEmailMutation,Ne as useVerifyPasswordResetCodeMutation};
1
+ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as n}from"dom-context";import{useEffect as t,useReducer as r,useCallback as a,useMemo as o,useRef as i,useState as s}from"@saasquatch/universal-hooks";import{gql as u,GraphQLClient as c}from"graphql-request";import d from"jwt-decode";import{equal as l}from"@wry/equality";import{parse as f,print as m}from"graphql";import v from"fast-memoize";import{Subject as g}from"rxjs";import{bufferTime as p}from"rxjs/operators";import{nanoid as h}from"nanoid";import{ClientError as y}from"graphql-request/dist/types";import w from"graphql-combine-query";import{createMemoryHistory as b,createBrowserHistory as C}from"history";import I from"debounce";import F from"jsonpointer";var q,S={current:void 0};function P(){if(void 0===S.current)throw new Error("no implementation of useHost provided");return S.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");S.current=e}function M(){var e;window.squatchProgramId||(window.squatchProgramId=new n({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function A(){M();var n=P();return e(n,"sq:program-id")}function D(e){M(),window.squatchProgramId.context=e}function k(){return(k=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 j(e,n){return(j=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function $(e,n){return n||(n=e.slice(0)),e.raw=n,e}function x(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 R(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 x(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)?x(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 V=u(q||(q=$(["\n query {\n viewer {\n ... on User {\n locale\n }\n }\n }\n"])));function O(){!function(){var e,r=window.squatchLocale,a=ae();t(function(){if(!a&&r)return r.context=void 0;s({})},[a]);var o,i=Ye(V),s=i[0],u=i[1].data,c=null==u||null==(e=u.viewer)?void 0:e.locale;r?c!==r.context&&(r.context=c):window.squatchLocale=new n({element:document.documentElement,initialState:c||(null==(o=window.widgetIdent)?void 0:o.locale)||void 0,contextName:"sq:locale"}).start()}();var r=P();return e(r,"sq:locale")}function N(e){var n=window.squatchLocale;n&&(n.context=e)}function H(){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 L(){var e=H();return"None"===e.type||"SquatchAdmin"===e.type}function W(){var e=H();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function U(){var e,n=H();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 J(){var e=H();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}var _=1e3,Q=60*_,T=60*Q,z=24*T,G=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*z;case"hours":case"hour":case"hrs":case"hr":case"h":return t*T;case"minutes":case"minute":case"mins":case"min":case"m":return t*Q;case"seconds":case"second":case"secs":case"sec":case"s":return t*_;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>=z?B(e,n,z,"day"):n>=T?B(e,n,T,"hour"):n>=Q?B(e,n,Q,"minute"):n>=_?B(e,n,_,"second"):e+" ms"}(e):function(e){var n=Math.abs(e);return n>=z?Math.round(e/z)+"d":n>=T?Math.round(e/T)+"h":n>=Q?Math.round(e/Q)+"m":n>=_?Math.round(e/_)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function B(e,n,t,r){var a=n>=1.5*t;return Math.round(e/t)+" "+r+(a?"s":"")}var K,Z=(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=G,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}}}(K={exports:{}},K.exports),K.exports),X=Z("sq:user-identity");function Y(){window.squatchUserIdentity||(window.squatchUserIdentity=new n({element:document.documentElement,initialState:ne(),contextName:"sq:user-identity"}).start())}function ee(e){if(e)try{var n,t,r=d(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 ne(){var e=H();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 ee(n.get("jwt"));var t=localStorage.getItem("sq:user-identity");if(!t)return;try{var r=JSON.parse(t),a=ee(r.jwt);return a?k({},r,a):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function te(e){Y();var n=window.squatchUserIdentity;l(n.context,e)||(N(void 0),n.context=e),e&&"SquatchPortal"===H().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(X("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function re(){var e;return null==(e=ae())?void 0:e.jwt}function ae(){Y();var n=P(),t=e(n,"sq:user-identity"),r=ee(null==t?void 0:t.jwt);return t&&!r?(te(void 0),void N(void 0)):t}var oe=function(){return(oe=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)},ie=new Map,se=new Map,ue=!0,ce=!1;function de(e){return e.replace(/[\s,]+/g," ").trim()}function le(e){var n,t,r,a=de(e);if(!ie.has(a)){var o=f(e,{experimentalFragmentVariables:ce});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");ie.set(a,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=o,t=new Set,r=[],n.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var n=e.name.value,a=de((i=e.loc).source.body.substring(i.start,i.end)),o=se.get(n);o&&!o.has(a)?ue&&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||se.set(n,o=new Set),o.add(a),t.has(a)||(t.add(a),r.push(e))}else r.push(e);var i}),oe(oe({},n),{definitions:r}))))}return ie.get(a)}function fe(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]}),le(r)}var me,ve=fe;(me=fe||(fe={})).gql=ve,me.resetCaches=function(){ie.clear(),se.clear()},me.disableFragmentWarnings=function(){ue=!1},me.enableExperimentalFragmentVariables=function(){ce=!0},me.disableExperimentalFragmentVariables=function(){ce=!1},fe.default=fe;var ge=fe;function pe(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var he=function(e){var n,t;function r(n,t){var r;(r=e.call(this,n,t)||this).subject=new g;var a=new g;return r.subject.pipe(p(200,void 0,10)).subscribe(function(e){try{if(!e.length)return Promise.resolve();for(var n,t=Ce(e),o=t.mergedQuery,i=t.mergedVariables,s=t.mergedQueryAddedEvents,u=R(t.unmergedQueryAddedEvents);!(n=u()).done;)a.next(n.value);return s.length?Promise.resolve(pe(function(){return Promise.resolve(r.superRequest(o,i)).then(function(e){qe(e,s)})},function(e){if(e instanceof y){var n=function(){var n=e.response,t=n.data,r=n.errors;if(!t)return{v:Pe(s,e)};for(var a,o=Object.keys(t),i=[].concat(s),u=function(){var n=a.value,t=void 0;n.path.find(function(r,a,s){if(o.includes(r)){var u=be(r),c=i.findIndex(function(e){return e.id===u});if(-1===c)return!1;o.splice(a,1),t=i.splice(c,1)[0];var d=Ie(e.response.data,t);s[a]=we(s[a],u);var l=t.query,f=t.variables,v=k({},e.response,{errors:[n],data:d,path:s}),g=new y(v,{query:"string"!=typeof l?m(l):l,variables:f});return Se(t,g),!0}return!1})},c=R(r);!(a=c()).done;)u();qe(t,i)}();if("object"==typeof n)return n.v}else Pe(s,e)})):Promise.resolve()}catch(e){return Promise.reject(e)}}),a.subscribe(function(e){try{var n=pe(function(){return Promise.resolve(r.superRequest(e.query,e.variables)).then(function(n){Fe(n,e)})},function(n){Se(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,j(n,t);var a=r.prototype;return a.superRequest=function(n,t){return e.prototype.request.call(this,n,t)},a.request=function(e,n){var t=this;return new Promise(function(r,a){var o={query:e,variables:n,id:ye(),resolve:r,reject:a};t.subject.next(o)})},r}(c),ye=function(){return h().replace(/[-_]/g,"")},we=function(e,n){return e.replace("_"+n,"")},be=function(e){var n=e.split("_");return n[n.length-1]},Ce=function(e){var n=[],t=[],r=e.reduce(function(e,r){var a=r.query,o=r.variables,i=r.id;try{var s="string"==typeof a?f(a):a,u=s.definitions.find(function(e){return"FragmentDefinition"===e.kind}),c="string"==typeof a?a:m(a),d=/@/.test(c);if(u||d)return t.push(r),e;var l=function(e){return function(e,n){return e+"_"+n}(e,i)};return e=e.addN(s,[o],l,l),n.push(r),e}catch(n){return t.push(r),e}},w("BatchedQuery")),a=r.document,o=r.variables;return{mergedQuery:a&&m(a),mergedVariables:o,mergedQueryAddedEvents:n,unmergedQueryAddedEvents:t}},Ie=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=k({},n,((a={})[we(t,r)]=e[t],a))),n},{})},Fe=function(e,n){(0,n.resolve)(e)},qe=function(e,n){for(var t,r=R(n);!(t=r()).done;){var a=t.value,o=Ie(e,a);a.resolve(o)}},Se=function(e,n){(0,e.reject)(n)},Pe=function(e,n){for(var t,r=R(e);!(t=r()).done;)(0,t.value.reject)(n)},Ee="sq:graphql-client",Me=v(function(e,n,t){return new he(e+"/api/v1/"+n+"/graphql",{headers:{Authorization:"Bearer "+(t||"")}})});function Ae(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 De(n,t){var o,i,s,u,c,d,l=(o=re(),i=U(),s=W(),u=Me(i,s,o),c=P(),null!=(d=e(c,"sq:graphql-client",{attempts:0}))?d:u),f=r(Ae,t),m=f[1];return[f[0],a(function(e,t){void 0===t&&(t=!1);try{if(!l)return m({type:"errors",payload:new Error("No GraphQL client found")}),Promise.resolve();var r=function(r,a){try{var o=(t||m({type:"loading"}),Promise.resolve(l.request(n,e)).then(function(e){m({type:"data",payload:e})}))}catch(e){return a(e)}return o&&o.then?o.then(void 0,a):o}(0,function(e){m({type:"errors",payload:e})});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},[l,n,m])]}var ke,je={loading:!1,data:void 0,errors:void 0};function $e(e){var n=De(e,je);return[n[1],n[0]]}var xe,Re=ge(ke||(ke=$(["\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"])));function Ve(){var e=$e(Re),n=e[0],r=e[1],a=r.loading,o=r.data,i=r.errors;return t(function(){if(null!=o&&o.authenticateManagedIdentityWithEmailAndPassword){var e=o.authenticateManagedIdentityWithEmailAndPassword,n=e.token,t=d(n).user;te({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.authenticateManagedIdentityWithEmailAndPassword]),[n,{loading:a,data:o,errors:i}]}var Oe,Ne=ge(xe||(xe=$(["\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"])));function He(){var e=$e(Ne),n=e[0],r=e[1],a=r.loading,o=r.data,i=r.errors;return t(function(){if(null!=o&&o.registerManagedIdentityWithEmailAndPassword){var e=o.registerManagedIdentityWithEmailAndPassword,n=e.token,t=d(n).user;te({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.registerManagedIdentityWithEmailAndPassword]),[n,{loading:a,data:o,errors:i}]}var Le,We=ge(Oe||(Oe=$(["\n mutation ChangePassword($password: String!) {\n changeManagedIdentityPassword(\n changeManagedIdentityPasswordInput: { password: $password }\n ) {\n success\n }\n }\n"])));function Ue(){var e=$e(We),n=e[1];return[e[0],{loading:n.loading,data:n.data,errors:n.errors}]}var Je,_e=ge(Le||(Le=$(["\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"])));function Qe(){var e=$e(_e),n=e[0],r=e[1],a=r.loading,o=r.data,i=r.errors;return t(function(){if(null!=o&&o.resetManagedIdentityPassword){var e=o.resetManagedIdentityPassword,n=e.token,t=d(n).user;te({jwt:n,id:t.id,accountId:t.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==o?void 0:o.resetManagedIdentityPassword]),[n,{loading:a,data:o,errors:i}]}var Te=ge(Je||(Je=$(["\n mutation VerifyPasswordResetCode($oobCode: String!) {\n verifyManagedIdentityPasswordResetCode(\n verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function ze(){return $e(Te)}function Ge(){var e=P();return{refresh:a(function(){e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}}function Be(e){var n=e.skip,r=void 0!==n&&n,a=e.update,s=e.variables;t(function(){var e=function(e){!r&&a(s,!0)};return document.addEventListener("sq:refresh",e),function(){return document.removeEventListener("sq:refresh",e)}},function(e){var n=i(e),t=i(0);return l(e,n.current)||(n.current=e,t.current+=1),o(function(){return n.current},[t.current])}([s,a,r]))}var Ke,Ze={loading:!1,data:void 0,errors:void 0},Xe=Symbol();function Ye(e){var n=De(e,Ze),t=n[0],r=n[1],a=i(Xe);return Be({skip:a.current===Xe,update:r,variables:a.current}),[r,k({},t,{refetch:function(e){a.current=e,r(e)}})]}var en,nn=ge(Ke||(Ke=$(["\n query ManagedIdentitySession {\n managedIdentitySession {\n email\n emailVerified\n sessionData\n }\n }\n"])));function tn(){var e=ae(),n=Ye(nn),r=n[0],o=n[1],i=o.loading,s=o.data,u=o.errors,c=o.refetch;return t(function(){null!=s&&s.managedIdentitySession&&te(k({},e,{managedIdentity:s.managedIdentitySession}))},[null==s?void 0:s.managedIdentitySession]),[a(function(){return r({})},[r]),{loading:i,data:s,errors:u,refetch:c}]}var rn,an=ge(en||(en=$(["\n mutation VerifyEmail($oobCode: String!) {\n verifyManagedIdentityEmail(\n verifyManagedIdentityEmailInput: { oobCode: $oobCode }\n ) {\n success\n }\n }\n"])));function on(){var e,n=tn()[0],r=$e(an),a=r[0],o=r[1],i=o.loading,s=o.data,u=o.errors;return t(function(){var e;null!=s&&null!=(e=s.verifyManagedIdentityEmail)&&e.success&&n()},[null==s||null==(e=s.verifyManagedIdentityEmail)?void 0:e.success]),[a,{loading:i,data:s,errors:u}]}var sn,un=ge(rn||(rn=$(["\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"])));function cn(){return $e(un)}var dn=ge(sn||(sn=$(["\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 ln(){return $e(dn)}function fn(e,n){var t=i();return t.current&&l(n,t.current.key)||(t.current={key:n,value:e()}),t.current.value}function mn(){return r(function(e){return e+1},0)}function vn(e){for(var n,t=R(Object.getOwnPropertyNames(e));!(n=t()).done;){var r=e[n.value];r&&"object"==typeof r&&vn(r)}return Object.freeze(e)}var gn={loading:!0,data:void 0,errors:void 0};function pn(e,n,t){var r=De(e,gn),a=r[0],o=r[1],i=mn(),s=i[1];return fn(function(){!t&&o(n)},[e,n,o,i[0],t]),Be({skip:t,update:o,variables:n}),vn(k({},a,{refetch:s}))}function hn(){return window.squatchHistory=window.squatchHistory||function(){switch(H().type){case"SquatchPortal":return C();default:return b()}}(),window.squatchHistory}var yn,wn={createHref:function(){var e;return(e=hn()).createHref.apply(e,[].slice.call(arguments))},push:function(){var e;return(e=hn()).push.apply(e,[].slice.call(arguments))},replace:function(){var e;return(e=hn()).replace.apply(e,[].slice.call(arguments))},go:function(){var e;return(e=hn()).go.apply(e,[].slice.call(arguments))},back:function(){return hn().back()},forward:function(){var e;return(e=hn()).forward.apply(e,[].slice.call(arguments))}};function bn(){var e=mn()[1];return t(function(){return hn().listen(function(){e()})},[]),hn().location}function Cn(e){var n=s({limit:e.limit,offset:e.offset}),t=n[0],r=n[1],a=t.offset,o=t.limit,i=function(e,n){return e*n},u=function(e,n){return Math.ceil(e/n)||0};return{limit:o,setLimit:function(e){var n=u(a,e),o=i(e,n);r(k({},t,{limit:e,offset:o}))},offset:a,setCurrentPage:function(e){var n=i(e,o);r(function(e){return k({},e,{offset:n})})},calculatePagination:function(e,n){var t=u(a,o),r=function(e,n){return Math.ceil(e/n)||0}(n,o),i=0===e?"0":e>1?a+1+"-"+(a+e):""+(a+1);return{currentPage:t,pageCount:r,rangeOnPage:i,pageProgress:i+" of "+n}}}}function In(e,n,t,r,a){var o;void 0===r&&(r={}),void 0===a&&(a=!1);var i=Cn(t),s=i.limit,u=i.setLimit,c=i.setCurrentPage,d=i.calculatePagination,l=pn(e,k({limit:s,offset:i.offset},r),a),f=l.loading,m=l.errors,v=l.refetch,g=n(l.data),p=d((null==g||null==(o=g.data)?void 0:o.length)||0,(null==g?void 0:g.totalCount)||0);return{envelope:g,states:{errors:m,loading:f,limit:s,currentPage:p.currentPage,pageCount:p.pageCount,pageProgress:p.pageProgress},callbacks:{refetch:v,setLimit:u,setCurrentPage:c}}}function Fn(e,n){return e===n}function qn(e,n,r){var o=r&&r.equalityFn||Fn,u=s(e),c=u[0],d=u[1],l=Sn(a(function(e){return d(e)},[]),n,r),f=i(e);return t(function(){o(f.current,e)||(l.callback(e),f.current=e)},[e,l,o]),[c,{cancel:l.cancel,flush:l.flush}]}function Sn(e,n,t){void 0===n&&(n=0),void 0===t&&(t={leading:!1});var r=o(function(){return I(e,n,t.leading)},[e,n,t.leading]);return{flush:r.flush,cancel:r.clear,callback:r}}var Pn,En,Mn,An=u(yn||(yn=$(["\n mutation ($eventMeta: UserAnalyticsEvent!) {\n createUserAnalyticsEvent(eventMeta: $eventMeta)\n }\n"])));function Dn(){var e=J(),n=ae(),t=A(),r=$e(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(){}}var kn=Z("sq:useForm"),jn=u(Pn||(Pn=$(["\n query ($key: String!) {\n form(key: $key) {\n schema\n initialData {\n initialData\n isEnabled\n isEnabledErrorMessage\n }\n }\n }\n"]))),$n=u(En||(En=$(["\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"]))),xn=u(Mn||(Mn=$(["\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"])));function Rn(e){var n,a,o,i,s=function(e){try{return Promise.resolve(C({formValidationInput:{key:u,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},u=e.formKey,c=e.formRef,d=e.autoSubmit,l=void 0!==d&&d,f=Ye(jn),m=f[0],v=f[1],g=v.data,p=v.loading,h=$e($n),y=h[0],w=h[1],b=Ye(xn),C=b[0],I=b[1],q=r(function(e,n){return k({},e,n)},{enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:I,submitData:w}),S=q[0],P=q[1],E=S.enabled,M=S.disabledMessage,A=S.validating,D=S.valid,j=S.error,$=S.formData;return fn(function(){kn("submitData useEffect",w),P({submitData:w})},[w]),fn(function(){kn("validationData useEffect",I),P({validationData:I})},[I]),t(function(){!p&&g&&function(){var n,t,r,a,o;P({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=c;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);kn({htmlForm:e,formContent:r}),null==r||r.forEach(function(e,r){kn({value:e,key:r,inputs:t});var a=t.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(n,r):a.value=F.get(n,r)||""}catch(e){kn("no initialData found for key",r)}}),Promise.resolve()}catch(e){return Promise.reject(e)}}(i,s)}}()},[p]),t(function(){var e,n,t,r,a,o;S.validationData&&(P({validating:!1,valid:(null==(e=S.validationData)||null==(n=e.data)||null==(t=n.validateForm)?void 0:t.valid)||!1}),l&&null!=(r=S.validationData)&&null!=(a=r.data)&&null!=(o=a.validateForm)&&o.valid&&y({formSubmissionInput:{key:u,formData:$}}))},[null==(n=S.validationData)||null==(a=n.data)||null==(o=a.validateForm)?void 0:o.valid]),{states:{enabled:E,disabledMessage:M,loadingForm:p,validating:A,valid:D,error:j,validationData:S.validationData,submitData:S.submitData},data:{formKey:u,schema:null==g||null==(i=g.form)?void 0:i.schema},callbacks:{getForm:m,handleSubmit:function(e){try{e.preventDefault(),P({validating:!0});var n=e.target;kn("submit form",n);for(var t,r=new FormData(n),a={},o=R(r.entries());!(t=o()).done;){var i=t.value;F.set(a,i[0],i[1])}return P({formData:a}),Promise.resolve(s(a)).then(function(){})}catch(e){return Promise.reject(e)}},validateForm:s,submitForm:function(e){try{return Promise.resolve(y({formSubmissionInput:{key:u,formData:e}})).then(function(){})}catch(e){return Promise.reject(e)}},setFormState:P,getValidationErrors:function(){var e,n,t,r,a=null==I||null==(e=I.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(!S.submitData)return[];var n=null==(e=S.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}}))||[]}}}}export{he as BatchedGraphQLClient,Ee as GRAPHQL_CONTEXT,H as getEnvironmentSDK,L as isDemo,Me as memoizedGraphQLClient,wn as navigation,D as setProgramId,E as setUseHostImplementation,te as setUserIdentity,U as useAppDomain,Ve as useAuthenticateWithEmailAndPasswordMutation,Ue as useChangePasswordMutation,bn as useCurrentPage,qn as useDebounce,Sn as useDebouncedCallback,J as useEngagementMedium,Rn as useForm,P as useHost,Ye as useLazyQuery,O as useLocale,tn as useManagedIdentitySessionQuery,$e as useMutation,In as usePaginatedQuery,Cn as usePagination,A as useProgramId,pn as useQuery,Ge as useRefreshDispatcher,He as useRegisterWithEmailAndPasswordMutation,cn as useRequestPasswordResetEmailMutation,ln as useRequestVerificationEmailMutation,Qe as useResetPasswordMutation,Dn as useShareEvent,W as useTenantAlias,mn as useTick,re as useToken,ae as useUserIdentity,on as useVerifyEmailMutation,ze as useVerifyPasswordResetCodeMutation};
2
2
  //# sourceMappingURL=index.module.js.map