@saasquatch/component-boilerplate 1.2.3-8 → 1.3.1-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import n from"jwt-decode";import{equal as r}from"@wry/equality";import{parse as a,print as o}from"graphql";import{useReducer as i,useCallback as s,useEffect as u,useRef as d,useState as c,useMemo as l}from"@saasquatch/universal-hooks";import m from"fast-memoize";import{Subject as f}from"rxjs";import{bufferTime as g}from"rxjs/operators";import{nanoid as p}from"nanoid";import{ClientError as h}from"graphql-request/dist/types";import{GraphQLClient as y,gql as w}from"graphql-request";import v from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function E(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function S(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=E();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}function A(){var e,t;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function $(){const e=A();return"None"===e.type||"SquatchAdmin"===e.type}function k(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function j(){var e;const t=A();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function x(){const e=A();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}function R(){return function(){const e=navigator.language,t=null==e?void 0:e.split("-");return t&&1!==t.length?`${t[0]}_${t[1].toUpperCase()}`:e}()}function V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function N(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:H(),contextName:"sq:user-identity"}).start())}function O(e){if(e)try{const t=n(e),r=t.exp;let a,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),a=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,a=t.user.id);if(!a||!o)return;if(r&&Date.now()>=1e3*r)return;return{id:a,accountId:o,jwt:e}}catch(e){return}}function H(){const e=A();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return O(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=O(e.jwt);return t?V({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function W(e){N();const t=window.squatchUserIdentity;r(t.context,e)||(t.context=e),e&&"SquatchPortal"===A().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||localStorage.removeItem("sq:user-identity")}function U(){var e;return null==(e=J())?void 0:e.jwt}function J(){N();const t=E(),n=e(t,"sq:user-identity"),r=O(null==n?void 0:n.jwt);if(!n||r)return n;W(void 0)}var L=function(){return(L=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)},_=new Map,Q=new Map,T=!0,z=!1;function G(e){return e.replace(/[\s,]+/g," ").trim()}function B(e){var t,n,r,o=G(e);if(!_.has(o)){var i=a(e,{experimentalFragmentVariables:z});if(!i||"Document"!==i.kind)throw new Error("Not a valid GraphQL document.");_.set(o,function(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&"object"==typeof r&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}((t=i,n=new Set,r=[],t.definitions.forEach(function(e){if("FragmentDefinition"===e.kind){var t=e.name.value,a=G((i=e.loc).source.body.substring(i.start,i.end)),o=Q.get(t);o&&!o.has(a)?T&&console.warn("Warning: fragment with name "+t+" already exists.\ngraphql-tag enforces all fragment names across your application to be unique; read more about\nthis in the docs: http://dev.apollodata.com/core/fragments.html#unique-names"):o||Q.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),L(L({},t),{definitions:r}))))}return _.get(o)}function K(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];"string"==typeof e&&(e=[e]);var r=e[0];return t.forEach(function(t,n){r+=t&&"Document"===t.kind?t.loc.source.body:t,r+=e[n+1]}),B(r)}var Z,X=K;(Z=K||(K={})).gql=X,Z.resetCaches=function(){_.clear(),Q.clear()},Z.disableFragmentWarnings=function(){T=!1},Z.enableExperimentalFragmentVariables=function(){z=!0},Z.disableExperimentalFragmentVariables=function(){z=!1},K.default=K;var Y=K;class ee extends y{constructor(e,t){var n;super(e,t),n=this,this.subject=new f;const r=new f;this.subject.pipe(g(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:i,unmergedQueryAddedEvents:s}=ae(e);for(const e of s)r.next(e);if(i.length)try{const e=await n.superRequest(t,a);se(e,i)}catch(e){if(e instanceof h){const{data:t,errors:n}=e.response;if(!t)return de(i,e);const r=Object.keys(t);let a=[...i];for(const t of n){let n;t.path.find((i,s,u)=>{if(r.includes(i)){const d=re(i),c=a.findIndex(e=>e.id===d);if(-1===c)return!1;r.splice(s,1),n=a.splice(c,1)[0];const l=oe(e.response.data,n);u[s]=ne(u[s],d);const{query:m,variables:f}=n,g=V({},e.response,{errors:[t],data:l,path:u}),p=new h(g,{query:"string"!=typeof m?o(m):m,variables:f});return ue(n,p),!0}return!1})}se(t,a)}else de(i,e)}}),r.subscribe(async function(e){try{const{query:t,variables:r}=e,a=await n.superRequest(t,r);ie(a,e)}catch(t){ue(e,t)}})}superRequest(e,t){return super.request(e,t)}request(e,t){return new Promise((n,r)=>{const a={query:e,variables:t,id:te(),resolve:n,reject:r};this.subject.next(a)})}}const te=()=>p().replace(/[-_]/g,""),ne=(e,t)=>e.replace(`_${t}`,""),re=e=>{const t=e.split("_");return t[t.length-1]},ae=e=>{const t=[],n=[],{document:r,variables:i}=e.reduce((e,r)=>{const{query:i,variables:s,id:u}=r;try{const d="string"==typeof i?a(i):i,c=d.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof i?i:o(i),m=/@/.test(l);if(c||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,u);return e=e.addN(d,[s],f,f),t.push(r),e}catch(t){return n.push(r),e}},v("BatchedQuery"));return{mergedQuery:r&&o(r),mergedVariables:i,mergedQueryAddedEvents:t,unmergedQueryAddedEvents:n}},oe=(e,t)=>{if(!e)return e;const n=Object.keys(e),{id:r}=t;return n.reduce((t,n)=>(n.endsWith(r)&&(t=V({},t,{[ne(n,r)]:e[n]})),t),{})},ie=(e,t)=>{const{resolve:n}=t;n(e)},se=(e,t)=>{for(const n of t){const t=oe(e,n);n.resolve(t)}},ue=(e,t)=>{const{reject:n}=e;n(t)},de=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},ce="sq:graphql-client",le=m(function(e,t,n){return new ee(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function me(e,t){switch(t.type){case"loading":return{data:void 0,errors:void 0,loading:!0};case"data":return{data:t.payload,errors:void 0,loading:!1};case"errors":return{data:void 0,errors:t.payload,loading:!1}}}function fe(t,n){const r=function(){const t=U(),n=j(),r=k(),a=le(n,r,t),o=E(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=i(me,n);return[a,s(async function(e){if(r)try{o({type:"loading"});const n=await r.request(t,e);o({type:"data",payload:n})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const ge={loading:!1,data:void 0,errors:void 0};function pe(e){const[t,n]=fe(e,ge);return[n,t]}let he;const ye=Y(he||(he=(e=>e)`
1
+ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProvider as t}from"dom-context";import{GraphQLClient as n,gql as r}from"graphql-request";import a from"jwt-decode";import{equal as o}from"@wry/equality";import{parse as i,print as s}from"graphql";import{useReducer as c,useCallback as u,useEffect as d,useMemo as l,useRef as m,useState as f}from"@saasquatch/universal-hooks";import g from"fast-memoize";import{Subject as p}from"rxjs";import{bufferTime as h}from"rxjs/operators";import{nanoid as y}from"nanoid";import{ClientError as w}from"graphql-request/dist/types";import v from"graphql-combine-query";import{createMemoryHistory as C,createBrowserHistory as b}from"history";import I from"debounce";import F from"jsonpointer";const q={current:void 0};function S(){if(void 0===q.current)throw new Error("no implementation of useHost provided");return q.current()}function E(e){if(!e)throw new Error("Must supply an implementation");if("function"!=typeof e)throw new Error("implementation must be a function");q.current=e}function P(){var e;window.squatchProgramId||(window.squatchProgramId=new t({element:document.documentElement,initialState:(null==(e=window.widgetIdent)?void 0:e.programId)||void 0,contextName:"sq:program-id"}).start())}function M(){P();const t=S();return e(t,"sq:program-id")}function D(e){P(),window.squatchProgramId.context=e}var $=function(){return($=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)},A=new Map,k=new Map,x=!0,j=!1;function R(e){return e.replace(/[\s,]+/g," ").trim()}function V(e){var t,n,r,a=R(e);if(!A.has(a)){var o=i(e,{experimentalFragmentVariables:j});if(!o||"Document"!==o.kind)throw new Error("Not a valid GraphQL document.");A.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=R((i=e.loc).source.body.substring(i.start,i.end)),o=k.get(t);o&&!o.has(a)?x&&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||k.set(t,o=new Set),o.add(a),n.has(a)||(n.add(a),r.push(e))}else r.push(e);var i}),$($({},t),{definitions:r}))))}return A.get(a)}function N(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]}),V(r)}var O,H=N;(O=N||(N={})).gql=H,O.resetCaches=function(){A.clear(),k.clear()},O.disableFragmentWarnings=function(){x=!1},O.enableExperimentalFragmentVariables=function(){j=!0},O.disableExperimentalFragmentVariables=function(){j=!1},N.default=N;var L=N;function W(){return(W=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)}var U=1e3,J=60*U,_=60*J,Q=24*_,T=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*Q;case"hours":case"hour":case"hrs":case"hr":case"h":return n*_;case"minutes":case"minute":case"mins":case"min":case"m":return n*J;case"seconds":case"second":case"secs":case"sec":case"s":return n*U;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>=Q?z(e,t,Q,"day"):t>=_?z(e,t,_,"hour"):t>=J?z(e,t,J,"minute"):t>=U?z(e,t,U,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=Q?Math.round(e/Q)+"d":t>=_?Math.round(e/_)+"h":t>=J?Math.round(e/J)+"m":t>=U?Math.round(e/U)+"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,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}var G,B=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=T,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}}}(G={exports:{}},G.exports),G.exports);const K=B("sq:user-identity");function Z(){window.squatchUserIdentity||(window.squatchUserIdentity=new t({element:document.documentElement,initialState:Y(),contextName:"sq:user-identity"}).start())}function X(e){if(e)try{const t=a(e),n=t.exp;let r,o;if(function(e){return e.sub&&/.*:.*@.*:users/.test(e.sub)}(t)){const e=t.sub.match(/(.*):(.*)@(.*):users/);o=atob(e[1]),r=atob(e[2])}else(function(e){return e.user&&e.user.id&&e.user.accountId})(t)&&(o=t.user.accountId,r=t.user.id);if(!r||!o)return;if(n&&Date.now()>=1e3*n)return;return{id:r,accountId:o,jwt:e}}catch(e){return}}function Y(){const e=Et();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return{id:e.widgetIdent.userId,accountId:e.widgetIdent.accountId,jwt:e.widgetIdent.token};case"SquatchPortal":const t=new URLSearchParams(document.location.search);if(t.has("jwt"))return X(t.get("jwt"));const n=localStorage.getItem("sq:user-identity");if(!n)return;try{const e=JSON.parse(n),t=X(e.jwt);return t?W({},e,t):void 0}catch(e){return}case"SquatchAdmin":case"None":return}}function ee(e){Z();const t=window.squatchUserIdentity;o(t.context,e)||(t.context=e),e&&"SquatchPortal"===Et().type?localStorage.setItem("sq:user-identity",JSON.stringify(e)):e||(K("Deleting user from localStorage"),localStorage.removeItem("sq:user-identity"))}function te(){var e;return null==(e=ne())?void 0:e.jwt}function ne(){Z();const t=S(),n=e(t,"sq:user-identity"),r=X(null==n?void 0:n.jwt);if(!n||r)return n;ee(void 0)}class re extends n{constructor(e,t){var n;super(e,t),n=this,this.subject=new p;const r=new p;this.subject.pipe(h(200,void 0,10)).subscribe(async function(e){if(!e.length)return;const{mergedQuery:t,mergedVariables:a,mergedQueryAddedEvents:o,unmergedQueryAddedEvents:i}=se(e);for(const e of i)r.next(e);if(o.length)try{const e=await n.superRequest(t,a);de(e,o)}catch(e){if(e instanceof w){const{data:t,errors:n}=e.response;if(!t)return me(o,e);const r=Object.keys(t);let a=[...o];for(const t of n){let n;t.path.find((o,i,c)=>{if(r.includes(o)){const u=ie(o),d=a.findIndex(e=>e.id===u);if(-1===d)return!1;r.splice(i,1),n=a.splice(d,1)[0];const l=ce(e.response.data,n);c[i]=oe(c[i],u);const{query:m,variables:f}=n,g=W({},e.response,{errors:[t],data:l,path:c}),p=new w(g,{query:"string"!=typeof m?s(m):m,variables:f});return le(n,p),!0}return!1})}de(t,a)}else me(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){le(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:ae(),resolve:n,reject:r};this.subject.next(a)})}}const ae=()=>y().replace(/[-_]/g,""),oe=(e,t)=>e.replace(`_${t}`,""),ie=e=>{const t=e.split("_");return t[t.length-1]},se=e=>{const t=[],n=[],{document:r,variables:a}=e.reduce((e,r)=>{const{query:a,variables:o,id:c}=r;try{const u="string"==typeof a?i(a):a,d=u.definitions.find(e=>"FragmentDefinition"===e.kind),l="string"==typeof a?a:s(a),m=/@/.test(l);if(d||m)return n.push(r),e;const f=e=>((e,t)=>`${e}_${t}`)(e,c);return e=e.addN(u,[o],f,f),t.push(r),e}catch(t){return n.push(r),e}},v("BatchedQuery"));return{mergedQuery:r&&s(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=W({},t,{[oe(n,r)]:e[n]})),t),{})},ue=(e,t)=>{const{resolve:n}=t;n(e)},de=(e,t)=>{for(const n of t){const t=ce(e,n);n.resolve(t)}},le=(e,t)=>{const{reject:n}=e;n(t)},me=(e,t)=>{for(const n of e){const{reject:e}=n;e(t)}},fe="sq:graphql-client",ge=g(function(e,t,n){return new re(e+"/api/v1/"+t+"/graphql",{headers:{Authorization:`Bearer ${n||""}`}})});function pe(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 he(t,n){const r=function(){const t=te(),n=Dt(),r=Mt(),a=ge(n,r,t),o=S(),i=e(o,"sq:graphql-client",{attempts:0});return null!=i?i:a}(),[a,o]=c(pe,n);return[a,u(async function(e,n=!1){if(r)try{n||o({type:"loading"});const a=await r.request(t,e);o({type:"data",payload:a})}catch(e){o({type:"errors",payload:e})}else o({type:"errors",payload:new Error("No GraphQL client found")})},[r,t,o])]}const ye={loading:!1,data:void 0,errors:void 0};function we(e){const[t,n]=he(e,ye);return[n,t]}let ve;const Ce=L(ve||(ve=(e=>e)`
2
2
  mutation AuthenticateWithEmailAndPassword(
3
3
  $email: String!
4
4
  $password: String!
@@ -15,17 +15,19 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
15
15
  sessionData
16
16
  }
17
17
  }
18
- `));function we(){const[e,{loading:t,data:r,errors:a}]=pe(ye);return u(()=>{if(null!=r&&r.authenticateManagedIdentityWithEmailAndPassword){const{authenticateManagedIdentityWithEmailAndPassword:e}=r,t=e.token,{user:a}=n(t);W({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.authenticateManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:r,errors:a}]}let ve;const Ce=Y(ve||(ve=(e=>e)`
18
+ `));function be(){const[e,{loading:t,data:n,errors:r}]=we(Ce);return d(()=>{if(null!=n&&n.authenticateManagedIdentityWithEmailAndPassword){const{authenticateManagedIdentityWithEmailAndPassword:e}=n,t=e.token,{user:r}=a(t);ee({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==n?void 0:n.authenticateManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:n,errors:r}]}let Ie;const Fe=L(Ie||(Ie=(e=>e)`
19
19
  mutation RegisterWithEmailAndPassword(
20
20
  $email: String!
21
21
  $password: String!
22
22
  $formData: RSJsonNode
23
+ $redirectPath: String
23
24
  ) {
24
25
  registerManagedIdentityWithEmailAndPassword(
25
26
  registerManagedIdentityWithEmailAndPasswordInput: {
26
27
  email: $email
27
28
  password: $password
28
29
  formData: $formData
30
+ redirectPath: $redirectPath
29
31
  }
30
32
  ) {
31
33
  token
@@ -34,7 +36,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
34
36
  sessionData
35
37
  }
36
38
  }
37
- `));function be(){const[e,{loading:t,data:r,errors:a}]=pe(Ce);return u(()=>{if(null!=r&&r.registerManagedIdentityWithEmailAndPassword){const{registerManagedIdentityWithEmailAndPassword:e}=r,t=e.token,{user:a}=n(t);W({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.registerManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:r,errors:a}]}let Ie;const Fe=Y(Ie||(Ie=(e=>e)`
39
+ `));function qe(){const[e,{loading:t,data:n,errors:r}]=we(Fe);return d(()=>{if(null!=n&&n.registerManagedIdentityWithEmailAndPassword){const{registerManagedIdentityWithEmailAndPassword:e}=n,t=e.token,{user:r}=a(t);ee({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==n?void 0:n.registerManagedIdentityWithEmailAndPassword]),[e,{loading:t,data:n,errors:r}]}let Se;const Ee=L(Se||(Se=(e=>e)`
38
40
  mutation ChangePassword($password: String!) {
39
41
  changeManagedIdentityPassword(
40
42
  changeManagedIdentityPasswordInput: { password: $password }
@@ -42,7 +44,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
42
44
  success
43
45
  }
44
46
  }
45
- `));function qe(){const[e,{loading:t,data:n,errors:r}]=pe(Fe);return[e,{loading:t,data:n,errors:r}]}let Ee;const Se=Y(Ee||(Ee=(e=>e)`
47
+ `));function Pe(){const[e,{loading:t,data:n,errors:r}]=we(Ee);return[e,{loading:t,data:n,errors:r}]}let Me;const De=L(Me||(Me=(e=>e)`
46
48
  mutation ResetPassword($oobCode: String!, $password: String!) {
47
49
  resetManagedIdentityPassword(
48
50
  resetManagedIdentityPasswordInput: {
@@ -56,7 +58,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
56
58
  sessionData
57
59
  }
58
60
  }
59
- `));function Pe(){const[e,{loading:t,data:r,errors:a}]=pe(Se);return u(()=>{if(null!=r&&r.resetManagedIdentityPassword){const{resetManagedIdentityPassword:e}=r,t=e.token,{user:a}=n(t);W({jwt:t,id:a.id,accountId:a.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==r?void 0:r.resetManagedIdentityPassword]),[e,{loading:t,data:r,errors:a}]}let Me;const De=Y(Me||(Me=(e=>e)`
61
+ `));function $e(){const[e,{loading:t,data:n,errors:r}]=we(De);return d(()=>{if(null!=n&&n.resetManagedIdentityPassword){const{resetManagedIdentityPassword:e}=n,t=e.token,{user:r}=a(t);ee({jwt:t,id:r.id,accountId:r.accountId,managedIdentity:{email:e.email,emailVerified:e.emailVerified,sessionData:e.sessionData}})}},[null==n?void 0:n.resetManagedIdentityPassword]),[e,{loading:t,data:n,errors:r}]}let Ae;const ke=L(Ae||(Ae=(e=>e)`
60
62
  mutation VerifyPasswordResetCode($oobCode: String!) {
61
63
  verifyManagedIdentityPasswordResetCode(
62
64
  verifyManagedIdentityPasswordResetCodeInput: { oobCode: $oobCode }
@@ -64,7 +66,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
64
66
  success
65
67
  }
66
68
  }
67
- `));function Ae(){return pe(De)}const $e={loading:!1,data:void 0,errors:void 0};function ke(e){const[t,n]=fe(e,$e);return[n,V({},t,{refetch:e=>n(e)})]}let je;const xe=Y(je||(je=(e=>e)`
69
+ `));function xe(){return we(ke)}function je(){const e=S();return{refresh:u(()=>{e.dispatchEvent(new CustomEvent("sq:refresh",{bubbles:!0,composed:!0,cancelable:!0,detail:{}}))},[e])}}function Re({skip:e=!1,update:t,variables:n}){d(()=>{const r=r=>{!e&&t(n,!0)};return document.addEventListener("sq:refresh",r),()=>document.removeEventListener("sq:refresh",r)},function(e){const t=m(e),n=m(0);return o(e,t.current)||(t.current=e,n.current+=1),l(()=>t.current,[n.current])}([n,t,e]))}const Ve={loading:!1,data:void 0,errors:void 0},Ne=Symbol();function Oe(e){const[t,n]=he(e,Ve),r=m(Ne);return Re({skip:r.current===Ne,update:n,variables:r.current}),[n,W({},t,{refetch:e=>{r.current=e,n(e)}})]}let He;const Le=L(He||(He=(e=>e)`
68
70
  query ManagedIdentity {
69
71
  managedIdentity {
70
72
  email
@@ -72,7 +74,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
72
74
  sessionData
73
75
  }
74
76
  }
75
- `));function Re(){const e=J(),[t,{loading:n,data:r,errors:a,refetch:o}]=ke(xe);return u(()=>{if(null!=r&&r.managedIdentity){const{managedIdentity:t}=r;W(V({},e,{managedIdentity:t}))}},[null==r?void 0:r.managedIdentity]),[s(()=>t({}),[t]),{loading:n,data:r,errors:a,refetch:o}]}let Ve;const Ne=Y(Ve||(Ve=(e=>e)`
77
+ `));function We(){const e=ne(),[t,{loading:n,data:r,errors:a,refetch:o}]=Oe(Le);return d(()=>{if(null!=r&&r.managedIdentity){const{managedIdentity:t}=r;ee(W({},e,{managedIdentity:t}))}},[null==r?void 0:r.managedIdentity]),[u(()=>t({}),[t]),{loading:n,data:r,errors:a,refetch:o}]}let Ue;const Je=L(Ue||(Ue=(e=>e)`
76
78
  mutation VerifyEmail($oobCode: String!) {
77
79
  verifyManagedIdentityEmail(
78
80
  verifyManagedIdentityEmailInput: { oobCode: $oobCode }
@@ -80,33 +82,43 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
80
82
  success
81
83
  }
82
84
  }
83
- `));function Oe(){var e;const[t]=Re(),[n,{loading:r,data:a,errors:o}]=pe(Ne);return u(()=>{var e;null!=a&&null!=(e=a.verifyManagedIdentityEmail)&&e.success&&t()},[null==a||null==(e=a.verifyManagedIdentityEmail)?void 0:e.success]),[n,{loading:r,data:a,errors:o}]}let He;const We=Y(He||(He=(e=>e)`
84
- mutation RequestPasswordResetEmail($email: String!, $urlParams: RSJsonNode) {
85
+ `));function _e(){var e;const[t]=We(),[n,{loading:r,data:a,errors:o}]=we(Je);return d(()=>{var e;null!=a&&null!=(e=a.verifyManagedIdentityEmail)&&e.success&&t()},[null==a||null==(e=a.verifyManagedIdentityEmail)?void 0:e.success]),[n,{loading:r,data:a,errors:o}]}let Qe;const Te=L(Qe||(Qe=(e=>e)`
86
+ mutation RequestPasswordResetEmail(
87
+ $email: String!
88
+ $urlParams: RSJsonNode
89
+ $redirectPath: String
90
+ ) {
85
91
  requestManagedIdentityPasswordResetEmail(
86
92
  requestManagedIdentityPasswordResetEmailInput: {
87
93
  email: $email
88
94
  urlParams: $urlParams
95
+ redirectPath: $redirectPath
89
96
  }
90
97
  ) {
91
98
  success
92
99
  }
93
100
  }
94
- `));function Ue(){return pe(We)}let Je;const Le=Y(Je||(Je=(e=>e)`
95
- mutation RequestVerificationEmail($email: String!, $urlParams: RSJsonNode) {
101
+ `));function ze(){return we(Te)}let Ge;const Be=L(Ge||(Ge=(e=>e)`
102
+ mutation RequestVerificationEmail(
103
+ $email: String!
104
+ $urlParams: RSJsonNode
105
+ $redirectPath: String
106
+ ) {
96
107
  requestManagedIdentityVerificationEmail(
97
108
  requestManagedIdentityVerificationEmailInput: {
98
109
  email: $email
99
110
  urlParams: $urlParams
111
+ redirectPath: $redirectPath
100
112
  }
101
113
  ) {
102
114
  success
103
115
  }
104
116
  }
105
- `));function _e(){return pe(Le)}function Qe(e,t){const n=d();return n.current&&r(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function Te(){return i(e=>e+1,0)}function ze(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&ze(t)}return Object.freeze(e)}const Ge={loading:!0,data:void 0,errors:void 0};function Be(e,t,n){const[r,a]=fe(e,Ge),[o,i]=Te();return Qe(()=>{!n&&a(t)},[e,t,a,o,n]),ze(V({},r,{refetch:i}))}function Ke(){return window.squatchHistory=window.squatchHistory||function(){switch(A().type){case"SquatchPortal":return b();default:return C()}}(),window.squatchHistory}const Ze={createHref:(...e)=>Ke().createHref(...e),push:(...e)=>Ke().push(...e),replace:(...e)=>Ke().replace(...e),go:(...e)=>Ke().go(...e),back:()=>Ke().back(),forward:(...e)=>Ke().forward(...e)};function Xe(){const[,e]=Te();return u(()=>Ke().listen(()=>{e()}),[]),Ke().location}function Ye(e){const[t,n]=c({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,i=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=i(r,e),s=o(e,a);n(V({},t,{limit:e,offset:s}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>V({},e,{offset:t}))},calculatePagination:function(e,t){const n=i(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),s=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:s,pageProgress:`${s} of ${t}`}}}}function et(e,t,n,r={},a=!1){var o;const{limit:i,offset:s,setLimit:u,setCurrentPage:d,calculatePagination:c}=Ye(n),l=V({limit:i,offset:s},r),{loading:m,errors:f,data:g,refetch:p}=Be(e,l,a),h=t(g),{currentPage:y,pageCount:w,pageProgress:v}=c((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:i,currentPage:y,pageCount:w,pageProgress:v},callbacks:{refetch:p,setLimit:u,setCurrentPage:d}}}function tt(e,t){return e===t}function nt(e,t,n){const r=n&&n.equalityFn||tt,[a,o]=c(e),i=rt(s(e=>o(e),[]),t,n),l=d(e);return u(()=>{r(l.current,e)||(i.callback(e),l.current=e)},[e,i,r]),[a,{cancel:i.cancel,flush:i.flush}]}function rt(e,t=0,n={leading:!1}){const r=l(()=>I(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let at;const ot=w(at||(at=(e=>e)`
117
+ `));function Ke(){return we(Be)}function Ze(e,t){const n=m();return n.current&&o(t,n.current.key)||(n.current={key:t,value:e()}),n.current.value}function Xe(){return c(e=>e+1,0)}function Ye(e){const t=Object.getOwnPropertyNames(e);for(const n of t){const t=e[n];t&&"object"==typeof t&&Ye(t)}return Object.freeze(e)}const et={loading:!0,data:void 0,errors:void 0};function tt(e,t,n){const[r,a]=he(e,et),[o,i]=Xe();return Ze(()=>{!n&&a(t)},[e,t,a,o,n]),Re({skip:n,update:a,variables:t}),Ye(W({},r,{refetch:i}))}function nt(){return window.squatchHistory=window.squatchHistory||function(){switch(Et().type){case"SquatchPortal":return b();default:return C()}}(),window.squatchHistory}const rt={createHref:(...e)=>nt().createHref(...e),push:(...e)=>nt().push(...e),replace:(...e)=>nt().replace(...e),go:(...e)=>nt().go(...e),back:()=>nt().back(),forward:(...e)=>nt().forward(...e)};function at(){const[,e]=Xe();return d(()=>nt().listen(()=>{e()}),[]),nt().location}function ot(e){const[t,n]=f({limit:e.limit,offset:e.offset}),{offset:r,limit:a}=t,o=(e,t)=>e*t,i=(e,t)=>Math.ceil(e/t)||0;return{limit:a,setLimit:e=>{const a=i(r,e),s=o(e,a);n(W({},t,{limit:e,offset:s}))},offset:r,setCurrentPage:e=>{let t=o(e,a);n(e=>W({},e,{offset:t}))},calculatePagination:function(e,t){const n=i(r,a),o=((e,t)=>Math.ceil(e/t)||0)(t,a),s=0===e?"0":e>1?`${r+1}-${r+e}`:`${r+1}`;return{currentPage:n,pageCount:o,rangeOnPage:s,pageProgress:`${s} of ${t}`}}}}function it(e,t,n,r={},a=!1){var o;const{limit:i,offset:s,setLimit:c,setCurrentPage:u,calculatePagination:d}=ot(n),l=W({limit:i,offset:s},r),{loading:m,errors:f,data:g,refetch:p}=tt(e,l,a),h=t(g),{currentPage:y,pageCount:w,pageProgress:v}=d((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:i,currentPage:y,pageCount:w,pageProgress:v},callbacks:{refetch:p,setLimit:c,setCurrentPage:u}}}function st(e,t){return e===t}function ct(e,t,n){const r=n&&n.equalityFn||st,[a,o]=f(e),i=ut(u(e=>o(e),[]),t,n),s=m(e);return d(()=>{r(s.current,e)||(i.callback(e),s.current=e)},[e,i,r]),[a,{cancel:i.cancel,flush:i.flush}]}function ut(e,t=0,n={leading:!1}){const r=l(()=>I(e,t,n.leading),[e,t,n.leading]),{flush:a,clear:o}=r;return{flush:a,cancel:o,callback:r}}let dt;const lt=r(dt||(dt=(e=>e)`
106
118
  mutation ($eventMeta: UserAnalyticsEvent!) {
107
119
  createUserAnalyticsEvent(eventMeta: $eventMeta)
108
120
  }
109
- `));function it(){const e=x(),t=J(),n=M(),[r]=pe(ot);return t?a=>{r({eventMeta:{id:t.id,accountId:t.accountId,programId:n,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:()=>{}}var st,ut=1e3,dt=60*ut,ct=60*dt,lt=24*ct,mt=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"weeks":case"week":case"w":return 6048e5*n;case"days":case"day":case"d":return n*lt;case"hours":case"hour":case"hrs":case"hr":case"h":return n*ct;case"minutes":case"minute":case"mins":case"min":case"m":return n*dt;case"seconds":case"second":case"secs":case"sec":case"s":return n*ut;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);return t>=lt?ft(e,t,lt,"day"):t>=ct?ft(e,t,ct,"hour"):t>=dt?ft(e,t,dt,"minute"):t>=ut?ft(e,t,ut,"second"):e+" ms"}(e):function(e){var t=Math.abs(e);return t>=lt?Math.round(e/lt)+"d":t>=ct?Math.round(e/ct)+"h":t>=dt?Math.round(e/dt)+"m":t>=ut?Math.round(e/ut)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function ft(e,t,n,r){var a=t>=1.5*n;return Math.round(e/n)+" "+r+(a?"s":"")}let gt,pt,ht,yt=e=>e;const wt=(function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,a=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(a=r))}),t.splice(a,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=function(e){function t(e){let r,a=null;function o(...e){if(!o.enabled)return;const n=o,a=Number(new Date);n.diff=a-(r||a),n.prev=r,n.curr=a,r=a,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,a)=>{if("%%"===r)return"%";i++;const o=t.formatters[a];return"function"==typeof o&&(r=o.call(n,e[i]),e.splice(i,1),i--),r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=n,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===a?t.enabled(e):a,set:e=>{a=e}}),"function"==typeof t.init&&t.init(o),o}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(r),...t.skips.map(r).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),a=r.length;for(n=0;n<a;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=mt,t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(st={exports:{}},st.exports),st.exports)("sq:useForm"),vt=w(gt||(gt=yt`
121
+ `));function mt(){const e=$t(),t=ne(),n=M(),[r]=we(lt);return t?a=>{r({eventMeta:{id:t.id,accountId:t.accountId,programId:n,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:e,shareMedium:a}}})}:()=>{}}let ft,gt,pt,ht=e=>e;const yt=B("sq:useForm"),wt=r(ft||(ft=ht`
110
122
  query ($key: String!) {
111
123
  form(key: $key) {
112
124
  schema
@@ -117,7 +129,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
117
129
  }
118
130
  }
119
131
  }
120
- `)),Ct=w(pt||(pt=yt`
132
+ `)),vt=r(gt||(gt=ht`
121
133
  mutation ($formSubmissionInput: FormSubmissionInput!) {
122
134
  submitForm(formSubmissionInput: $formSubmissionInput) {
123
135
  success
@@ -147,7 +159,7 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
147
159
  }
148
160
  }
149
161
  }
150
- `)),bt=w(ht||(ht=yt`
162
+ `)),Ct=r(pt||(pt=ht`
151
163
  query ($formValidationInput: FormValidationInput!) {
152
164
  validateForm(formValidationInput: $formValidationInput) {
153
165
  valid
@@ -177,5 +189,13 @@ import{useDomContext as e}from"@saasquatch/dom-context-hooks";import{ContextProv
177
189
  }
178
190
  }
179
191
  }
180
- `));function It(e){var t,n,r,a;const{formKey:o,formRef:s,autoSubmit:d=!1}=e,[c,{data:l,loading:m}]=ke(vt),[f,g]=pe(Ct),[p,h]=ke(bt),y={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:h,submitData:g},[w,v]=i((e,t)=>V({},e,t),y),{enabled:C,disabledMessage:b,validating:I,valid:q,error:E,formData:S}=w;async function P(e){await p({formValidationInput:{key:o,formData:e}})}return Qe(()=>{wt("submitData useEffect",g),v({submitData:g})},[g]),Qe(()=>{wt("validationData useEffect",h),v({validationData:h})},[h]),u(()=>{!m&&l&&function(){var t,n,r,a,o;v({enabled:null==l||null==(t=l.form.initialData)?void 0:t.isEnabled,disabledMessage:null==l||null==(n=l.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const i=s;if(!i)return;const u=null==l||null==(a=l.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(i,u):async function(e,t){const n=e.elements,r=new FormData(e);wt({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{wt({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(t,r):a.value=F.get(t,r)||""}catch(e){wt("no initialData found for key",r)}})}(i,u)}()},[m]),u(()=>{var e,t,n,r,a,i;w.validationData&&(v({validating:!1,valid:(null==(e=w.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),d&&null!=(r=w.validationData)&&null!=(a=r.data)&&null!=(i=a.validateForm)&&i.valid&&f({formSubmissionInput:{key:o,formData:S}}))},[null==(t=w.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:b,loadingForm:m,validating:I,valid:q,error:E,validationData:w.validationData,submitData:w.submitData},data:{formKey:o,schema:null==l||null==(a=l.form)?void 0:a.schema},callbacks:{getForm:c,handleSubmit:async function(e){e.preventDefault(),v({validating:!0});const t=e.target;wt("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())F.set(r,a[0],a[1]);v({formData:r}),await P(r)},validateForm:P,submitForm:async function(e){await f({formSubmissionInput:{key:o,formData:e}})},setFormState:v,getValidationErrors:function(){var e,t,n,r;const a=null==h||null==(e=h.data)||null==(t=e.validateForm)||null==(n=t.results[0])||null==(r=n.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1).startsWith(`${e}`))}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1)===e)},getSubErrorsAtPath:o,hasSubErrors:e=>{var t;return(null==(t=o(e))?void 0:t.length)>0}}},getSubmissionErrors:function(){var e;if(!w.submitData)return[];const t=null==(e=w.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,i,s;const u=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),d=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(e=>!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}).filter(({error:e})=>e);return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:u,errors:d}}))||[]}}}}export{ee as BatchedGraphQLClient,ce as GRAPHQL_CONTEXT,A as getEnvironmentSDK,$ as isDemo,le as memoizedGraphQLClient,Ze as navigation,D as setProgramId,S as setUseHostImplementation,W as setUserIdentity,j as useAppDomain,we as useAuthenticateWithEmailAndPasswordMutation,qe as useChangePasswordMutation,Xe as useCurrentPage,nt as useDebounce,rt as useDebouncedCallback,x as useEngagementMedium,It as useForm,E as useHost,ke as useLazyQuery,R as useLocale,Re as useManagedIdentityQuery,pe as useMutation,et as usePaginatedQuery,Ye as usePagination,M as useProgramId,Be as useQuery,be as useRegisterWithEmailAndPasswordMutation,Ue as useRequestPasswordResetEmailMutation,_e as useRequestVerificationEmailMutation,Pe as useResetPasswordMutation,it as useShareEvent,k as useTenantAlias,Te as useTick,U as useToken,J as useUserIdentity,Oe as useVerifyEmailMutation,Ae as useVerifyPasswordResetCodeMutation};
192
+ `));function bt(e){var t,n,r,a;const{formKey:o,formRef:i,autoSubmit:s=!1}=e,[u,{data:l,loading:m}]=Oe(wt),[f,g]=we(vt),[p,h]=Oe(Ct),y={enabled:!1,validating:!1,valid:!0,validationMessage:"",error:"",disabledMessage:"",formData:{},validationData:h,submitData:g},[w,v]=c((e,t)=>W({},e,t),y),{enabled:C,disabledMessage:b,validating:I,valid:q,error:S,formData:E}=w;async function P(e){await p({formValidationInput:{key:o,formData:e}})}return Ze(()=>{yt("submitData useEffect",g),v({submitData:g})},[g]),Ze(()=>{yt("validationData useEffect",h),v({validationData:h})},[h]),d(()=>{!m&&l&&function(){var t,n,r,a,o;v({enabled:null==l||null==(t=l.form.initialData)?void 0:t.isEnabled,disabledMessage:null==l||null==(n=l.form)||null==(r=n.initialData)?void 0:r.isEnabledErrorMessage});const s=i;if(!s)return;const c=null==l||null==(a=l.form)||null==(o=a.initialData)?void 0:o.initialData;void 0!==e.setInitialData?e.setInitialData(s,c):async function(e,t){const n=e.elements,r=new FormData(e);yt({htmlForm:e,formContent:r}),null==r||r.forEach((e,r)=>{yt({value:e,key:r,inputs:n});const a=n.namedItem(r);try{"checkbox"==a.type?a.checked=F.get(t,r):a.value=F.get(t,r)||""}catch(e){yt("no initialData found for key",r)}})}(s,c)}()},[m]),d(()=>{var e,t,n,r,a,i;w.validationData&&(v({validating:!1,valid:(null==(e=w.validationData)||null==(t=e.data)||null==(n=t.validateForm)?void 0:n.valid)||!1}),s&&null!=(r=w.validationData)&&null!=(a=r.data)&&null!=(i=a.validateForm)&&i.valid&&f({formSubmissionInput:{key:o,formData:E}}))},[null==(t=w.validationData)||null==(n=t.data)||null==(r=n.validateForm)?void 0:r.valid]),{states:{enabled:C,disabledMessage:b,loadingForm:m,validating:I,valid:q,error:S,validationData:w.validationData,submitData:w.submitData},data:{formKey:o,schema:null==l||null==(a=l.form)?void 0:a.schema},callbacks:{getForm:u,handleSubmit:async function(e){e.preventDefault(),v({validating:!0});const t=e.target;yt("submit form",t);const n=new FormData(t);let r={};for(var a of n.entries())F.set(r,a[0],a[1]);v({formData:r}),await P(r)},validateForm:P,submitForm:async function(e){await f({formSubmissionInput:{key:o,formData:e}})},setFormState:v,getValidationErrors:function(){var e,t,n,r;const a=null==h||null==(e=h.data)||null==(t=e.validateForm)||null==(n=t.results[0])||null==(r=n.result)?void 0:r.errors;function o(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1).startsWith(`${e}`))}return{getErrorAtPath:function(e){return null==a?void 0:a.filter(t=>t.instanceLocation.substring(1)===e)},getSubErrorsAtPath:o,hasSubErrors:e=>{var t;return(null==(t=o(e))?void 0:t.length)>0}}},getSubmissionErrors:function(){var e;if(!w.submitData)return[];const t=null==(e=w.submitData.data)?void 0:e.submitForm.results;return(null==t?void 0:t.map(e=>{var t,n,r,a,o,i,s;const c=null==(t=e.result)||null==(n=t.results)?void 0:n.flatMap(e=>!e.success&&e.message).filter(e=>e),u=null==(r=e.result)||null==(a=r.results)?void 0:a.flatMap(e=>!e.success&&{error:e.error,errorType:e.errorType,errorCode:e.errorCode}).filter(({error:e})=>e);return{integration:null==(o=e.formHandler)||null==(i=o.integration)?void 0:i.name,formHandler:null==(s=e.formHandler)?void 0:s.name,messages:c,errors:u}}))||[]}}}}let It;const Ft=r(It||(It=(e=>e)`
193
+ query {
194
+ viewer {
195
+ ... on User {
196
+ locale
197
+ }
198
+ }
199
+ }
200
+ `));function qt(){!function(){var e;const n=window.squatchLocale,r=ne(),{data:a}=tt(Ft,{},!r),o=null==a||null==(e=a.viewer)?void 0:e.locale;var i;n?o&&o!==n.context&&(n.context=o):window.squatchLocale=new t({element:document.documentElement,initialState:o||(null==(i=window.widgetIdent)?void 0:i.locale)||void 0,contextName:"sq:locale"}).start()}();const n=S();return e(n,"sq:locale")}function St(e){window.squatchLocale.context=e}function Et(){var e,t;return window.SquatchAndroid?{type:"SquatchAndroid",android:window.SquatchAndroid,widgetIdent:window.widgetIdent}:window.SquatchPortal?{type:"SquatchPortal",env:window.SquatchPortal}:window.SquatchAdmin?{type:"SquatchAdmin",adminSDK:window.SquatchAdmin}:window.widgetIdent&&"demo"!==(null==(e=window.widgetIdent)?void 0:e.env)?{type:"SquatchJS2",api:null==(t=window.frameElement)?void 0:t.squatchJsApi,widgetIdent:window.widgetIdent}:{type:"None"}}function Pt(){const e=Et();return"None"===e.type||"SquatchAdmin"===e.type}function Mt(){const e=Et();switch(e.type){case"SquatchAndroid":case"SquatchJS2":return e.widgetIdent.tenantAlias;case"SquatchAdmin":case"None":return"demo";case"SquatchPortal":return e.env.tenantAlias}}function Dt(){var e;const t=Et();switch(t.type){case"SquatchAndroid":case"SquatchJS2":return t.widgetIdent.appDomain;case"SquatchPortal":return(null==(e=t.env)?void 0:e.appDomain)||"https://app.referralsaasquatch.com";case"SquatchAdmin":case"None":return"https://app.referralsaasquatch.com"}}function $t(){const e=Et();switch(e.type){case"SquatchJS2":return e.widgetIdent.engagementMedium||"EMBED";case"SquatchAndroid":case"SquatchPortal":case"SquatchAdmin":case"None":return"EMBED"}}export{re as BatchedGraphQLClient,fe as GRAPHQL_CONTEXT,Et as getEnvironmentSDK,Pt as isDemo,ge as memoizedGraphQLClient,rt as navigation,St as setLocale,D as setProgramId,E as setUseHostImplementation,ee as setUserIdentity,Dt as useAppDomain,be as useAuthenticateWithEmailAndPasswordMutation,Pe as useChangePasswordMutation,at as useCurrentPage,ct as useDebounce,ut as useDebouncedCallback,$t as useEngagementMedium,bt as useForm,S as useHost,Oe as useLazyQuery,qt as useLocale,We as useManagedIdentityQuery,we as useMutation,it as usePaginatedQuery,ot as usePagination,M as useProgramId,tt as useQuery,je as useRefreshDispatcher,qe as useRegisterWithEmailAndPasswordMutation,ze as useRequestPasswordResetEmailMutation,Ke as useRequestVerificationEmailMutation,$e as useResetPasswordMutation,mt as useShareEvent,Mt as useTenantAlias,Xe as useTick,te as useToken,ne as useUserIdentity,_e as useVerifyEmailMutation,xe as useVerifyPasswordResetCodeMutation};
181
201
  //# sourceMappingURL=index.modern.js.map