@trimble-oss/trimble-id-react 0.1.0-rc.1 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(m,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("@trimble-oss/trimble-id"),require("es-cookie"),require("jwt-decode"),require("react")):typeof define=="function"&&define.amd?define(["exports","@trimble-oss/trimble-id","es-cookie","jwt-decode","react"],T):(m=typeof globalThis<"u"?globalThis:m||self,T(m.ReactTID={},m.trimbleId,m.esCookie,m.jwt_decode,m.require$$0))})(this,function(m,T,L,Qe,k){"use strict";var Zt=Object.defineProperty;var qt=(m,T,L)=>T in m?Zt(m,T,{enumerable:!0,configurable:!0,writable:!0,value:L}):m[T]=L;var p=(m,T,L)=>(qt(m,typeof T!="symbol"?T+"":T,L),L);function Ze(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>a[n]})}}return t.default=a,Object.freeze(t)}const ie=Ze(L);class qe{constructor(){p(this,"generateCache",function(){const t={token:void 0,user:void 0};return{async getToken(){return t.token},async getUser(){return t.user},async storeToken(n){t.token=n},async storeUser(n){t.user=n},clear(){return t.token=void 0,t.user=void 0,Promise.resolve(void 0)}}}())}}class et{constructor(t){p(this,"localStorage");p(this,"cacheKey");this.localStorage=window.localStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=localStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);localStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.localStorage.removeItem(this.getAuthKey()),this.localStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}const ae="@TID",tt=`${ae}_AUTH_KEY`,rt=`${ae}_USER_KEY`;class nt{constructor(t){p(this,"clientId");p(this,"prefix",ae);p(this,"authSuffix",tt);p(this,"userSuffix",rt);this.clientId=t.client_id}getUserKey(){return`${this.prefix}_${this.userSuffix}_${this.clientId}`}getAuthKey(){return`${this.prefix}_${this.authSuffix}_${this.clientId}`}}class it{constructor(t){p(this,"sessionStorage");p(this,"cacheKey");this.sessionStorage=window.sessionStorage,this.cacheKey=t.cacheKey}async getToken(){const t=this.getAuthKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async getUser(){const t=this.getUserKey(),n=sessionStorage.getItem(t);return n?JSON.parse(n):void 0}async storeToken(t){const n=this.getAuthKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}async storeUser(t){const n=this.getUserKey(),o=JSON.stringify(t);sessionStorage.setItem(n,o)}getUserKey(){return this.cacheKey.getUserKey()}getAuthKey(){return this.cacheKey.getAuthKey()}clear(){return this.sessionStorage.removeItem(this.getAuthKey()),this.sessionStorage.removeItem(this.getUserKey()),Promise.resolve(void 0)}}class at{constructor(t){p(this,"persistentStore");p(this,"cacheStorage");p(this,"cacheKey");this.persistentStore=t.persistentStore,this.cacheKey=new nt({client_id:t.clientId}),this.persistentStore==="localStorage"?this.cacheStorage=new et({cacheKey:this.cacheKey}):this.persistentStore==="sessionStorage"?this.cacheStorage=new it({cacheKey:this.cacheKey}):this.cacheStorage=new qe().generateCache}async setToken(t){await this.cacheStorage.storeToken(t)}async setUser(t){await this.cacheStorage.storeUser(t)}async getUser(){return this.cacheStorage.getUser()}async getToken(){return this.cacheStorage.getToken()}async clear(){await this.cacheStorage.clear()}}const me=5*6e4,ot=["code","state"],Ee=a=>a.split("?")[0],st=a=>a.split("?")[1],_e=a=>{let t=a;if(!a.startsWith("?"))try{t=new URL(a).search}catch{}return new URLSearchParams(t)},ct=(a=window.location.href,t)=>{if(t!=null){const o=Ee(t),c=Ee(a??"");if(o!==c)return!1}const n=_e(a);for(const o of ot)if(!n.has(o))return!1;return!0},lt=a=>({id:a.sub,name:`${a.given_name} ${a.family_name}`,given_name:a.given_name,family_name:a.family_name,picture:a.picture,email:a.email,email_verified:a.email_verified,phone_number_verified:!1}),ut="@TID_COOKIE";class ft{get(t){const n=ie.get(t);if(n==null)throw new Error("Cookie not found");return JSON.parse(n)}set(t,n,o){let c={};window.location.protocol==="https:"&&(c={secure:!0,sameSite:"none"}),o!=null&&o.expires&&(c.expires=o.expires),o!=null&&o.domain&&(c.domain=o.domain),ie.set(t,JSON.stringify(n),c)}remove(t,n){const o={};n!=null&&n.domain&&(o.domain=n.domain),ie.remove(t,o)}}class dt{constructor(t){p(this,"cookieKey");p(this,"cookiesStorage");this.cookieKey=`${ut}.${t.clientId}`,this.cookiesStorage=new ft}save(t){this.cookiesStorage.set(this.cookieKey,t,{expires:1})}get(){try{return this.cookiesStorage.get(this.cookieKey)}catch{return}}clear(){this.cookiesStorage.remove(this.cookieKey)}}class Te extends Error{}class ke extends Error{}class ht extends Error{}const A="@trimble-oss/trimble-id-react",K="0.1.0-rc.1",gt={configurationEndpoint:"",clientId:"",redirectUrl:"",logoutRedirectUrl:"",scopes:[]},vt={persistentStore:"in-memory"};class Se{constructor(t){p(this,"tokenProvider");p(this,"cacheManager");p(this,"cookiesManager");p(this,"clientId");p(this,"redirectUrl");p(this,"analyticshttpclient");const{config:n=gt,persistentOptions:o=vt}=t;if(this.redirectUrl=n.redirectUrl,n.configurationEndpoint==null||n.configurationEndpoint=="")throw new Error("Configuration endpoint not defined");if(n.clientId==null||n.clientId=="")throw new Error("Consumer key is not defined");this.cookiesManager=new dt({clientId:n.clientId});const c=this.cookiesManager.get(),w=new T.OpenIdEndpointProvider(n.configurationEndpoint);let S=new T.AuthorizationCodeGrantTokenProvider(w,n.clientId,n.redirectUrl).WithScopes(n.scopes);n.logoutRedirectUrl&&(S=S.WithLogoutRedirect(n.logoutRedirectUrl)),(c==null?void 0:c.code_verifier)!=null&&(S=S.WithProofKeyForCodeExchange(c.code_verifier)),this.tokenProvider=S,this.cacheManager=new at({clientId:n.clientId,persistentStore:o.persistentStore}),this.clientId=n.clientId,this.analyticshttpclient=T.AnalyticsHttpClient,this.analyticshttpclient.sendInitEvent("TIDClient",this.clientId,A,K)}async loginWithRedirect(t){this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name,this.clientId,A,K);const{onRedirect:n}=t||{},o=T.AuthorizationCodeGrantTokenProvider.GenerateCodeVerifier();this.cookiesManager.save({code_verifier:o}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(o);const c=await this.tokenProvider.GetOAuthRedirect("state");n!=null?n(c):window.location.assign(c)}async handleCallback(t=window.location.href){const n=this.cookiesManager.get();if(n==null||(n==null?void 0:n.code_verifier)==null)throw new ht("Code verifier not available");const o=st(t),c=_e(t),w=c.get("identity_provider")??"",S=c.get("state")??"";return await this.tokenProvider.ValidateQuery(o),await this.generateToken(w),{authState:S}}async generateToken(t){var C,f;const n=await this.tokenProvider.RetrieveToken(),o=await this.tokenProvider.RetrieveRefreshToken(),c=await this.tokenProvider.RetrieveIdToken(),w=await this.tokenProvider.RetrieveTokenExpiry(),P=new Date(w).getTime(),v=(f=(C=this.tokenProvider)==null?void 0:C._scopes)==null?void 0:f.join(" ");await this.cacheManager.setToken({scope:v,state:"",session_state:"",identity_provider:t,token_type:"bearer",access_token:n,refresh_token:o,id_token:c,expires_at:P});const x=Qe(c),R=lt(x);await this.cacheManager.setUser(R),await this.reloadCodeVerifier()}async reloadCodeVerifier(){const t=await this.tokenProvider.RetrieveCodeVerifier();this.cookiesManager.save({code_verifier:t}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(t)}async getUser(){return this.analyticshttpclient.sendMethodEvent(this.getUser.name,this.clientId,A,K),await this.cacheManager.getUser()}async getAccessTokenSilently(){this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return(t==null?void 0:t.access_token)||""}async getTokens(){this.analyticshttpclient.sendMethodEvent(this.getTokens.name,this.clientId,A,K);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,"No token available",this.clientId,A,K),new ke("No token available");const n=new Date(new Date().getTime()+me);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<n.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,o.message,this.clientId,A,K),new Te(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return{access_token:(t==null?void 0:t.access_token)||"",expires_at:(t==null?void 0:t.expires_at)||0,id_token:(t==null?void 0:t.id_token)||""}}async logout(t){this.analyticshttpclient.sendMethodEvent(this.logout.name,this.clientId,A,K);const{onRedirect:n,disabledAutoRedirect:o}=t||{};this.cacheManager&&await this.cacheManager.clear(),this.cookiesManager&&this.cookiesManager.clear();const c=await this.tokenProvider.GetOAuthLogoutRedirect("state");if(n!=null)return n(c);o||window.location.assign(c)}async checkSession(){try{await this.getAccessTokenSilently()}catch{return!1}return!0}async loadUserSession(){await this.loadCacheSessionIntoSDK(),await this.checkSession()||await this.cacheManager.clear()}async loadCacheSessionIntoSDK(){const t=await this.cacheManager.getToken();if(t==null)return;const n=t.access_token,o=t.refresh_token||"",c=t.id_token,w=t.expires_at;this.tokenProvider=this.tokenProvider.WithAccessToken(n,w).WithRefreshToken(o).WithIdToken(c)}getBearerTokenHttpClient(t){return new T.BearerTokenHttpClientProvider(this.tokenProvider,t)}getRedirectUrl(){return this.redirectUrl}}const z=k.createContext(null),Re=()=>k.useContext(z)??{};var oe={exports:{}},Y={};/**
1
+ (function(p,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("@trimble-oss/trimble-id"),require("es-cookie"),require("jwt-decode"),require("react")):typeof define=="function"&&define.amd?define(["exports","@trimble-oss/trimble-id","es-cookie","jwt-decode","react"],k):(p=typeof globalThis<"u"?globalThis:p||self,k(p.ReactTID={},p.trimbleId,p.esCookie,p.jwt_decode,p.require$$0))})(this,function(p,k,L,Xe,T){"use strict";var Bt=Object.defineProperty;var Jt=(p,k,L)=>k in p?Bt(p,k,{enumerable:!0,configurable:!0,writable:!0,value:L}):p[k]=L;var I=(p,k,L)=>(Jt(p,typeof k!="symbol"?k+"":k,L),L);function Qe(i){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const a in i)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(i,a);Object.defineProperty(t,a,o.get?o:{enumerable:!0,get:()=>i[a]})}}return t.default=i,Object.freeze(t)}const re=Qe(L);class Ze{constructor(){I(this,"generateCache",function(){const t={token:void 0,user:void 0};return{async getToken(){return t.token},async getUser(){return t.user},async storeToken(a){t.token=a},async storeUser(a){t.user=a},clear(){return t.token=void 0,t.user=void 0,Promise.resolve(void 0)}}}())}}class $e{constructor(){I(this,"cacheStorage");this.cacheStorage=new Ze().generateCache}async setToken(t){await this.cacheStorage.storeToken(t)}async setUser(t){await this.cacheStorage.storeUser(t)}async getUser(){return this.cacheStorage.getUser()}async getToken(){return this.cacheStorage.getToken()}async clear(){await this.cacheStorage.clear()}}const pe=5*6e4,qe=["code","state"],ye=i=>i.split("?")[0],et=i=>i.split("?")[1],Ee=i=>{let t=i;if(!i.startsWith("?"))try{t=new URL(i).search}catch{}return new URLSearchParams(t)},tt=(i=window.location.href,t)=>{if(t!=null){const o=ye(t),u=ye(i??"");if(o!==u)return!1}const a=Ee(i);for(const o of qe)if(!a.has(o))return!1;return!0},rt=i=>({id:i.sub,name:`${i.given_name} ${i.family_name}`,given_name:i.given_name,family_name:i.family_name,picture:i.picture,email:i.email,email_verified:i.email_verified}),nt="@TID_COOKIE";class at{get(t){const a=re.get(t);if(a==null)throw new Error("Cookie not found");return JSON.parse(a)}set(t,a,o){let u={};window.location.protocol==="https:"&&(u={secure:!0,sameSite:"none"}),o!=null&&o.expires&&(u.expires=o.expires),o!=null&&o.domain&&(u.domain=o.domain),re.set(t,JSON.stringify(a),u)}remove(t,a){const o={};a!=null&&a.domain&&(o.domain=a.domain),re.remove(t,o)}}class it{constructor(t){I(this,"cookieKey");I(this,"cookiesStorage");this.cookieKey=`${nt}.${t.clientId}`,this.cookiesStorage=new at}save(t){this.cookiesStorage.set(this.cookieKey,t,{expires:1})}get(){try{return this.cookiesStorage.get(this.cookieKey)}catch{return}}clear(){this.cookiesStorage.remove(this.cookieKey)}}class me extends Error{}class _e extends Error{}class ot extends Error{}const A="@trimble-oss/trimble-id-react",D="1.0.0-rc.1",st={configurationEndpoint:"",clientId:"",redirectUrl:"",logoutRedirectUrl:"",scopes:[]};class ke{constructor(t){I(this,"tokenProvider");I(this,"cacheManager");I(this,"cookiesManager");I(this,"clientId");I(this,"redirectUrl");I(this,"analyticshttpclient");const{config:a=st}=t;if(this.redirectUrl=a.redirectUrl,a.configurationEndpoint==null||a.configurationEndpoint=="")throw new Error("Configuration endpoint not defined");if(a.clientId==null||a.clientId=="")throw new Error("Consumer key is not defined");this.cookiesManager=new it({clientId:a.clientId});const o=this.cookiesManager.get(),u=new k.OpenIdEndpointProvider(a.configurationEndpoint);let m=new k.AuthorizationCodeGrantTokenProvider(u,a.clientId,a.redirectUrl).WithScopes(a.scopes);a.logoutRedirectUrl&&(m=m.WithLogoutRedirect(a.logoutRedirectUrl)),(o==null?void 0:o.code_verifier)!=null&&(m=m.WithProofKeyForCodeExchange(o.code_verifier)),this.tokenProvider=m,this.cacheManager=new $e,this.clientId=a.clientId,this.analyticshttpclient=k.AnalyticsHttpClient,this.analyticshttpclient.sendInitEvent("TIDClient",this.clientId,A,D)}async loginWithRedirect(t){this.analyticshttpclient.sendMethodEvent(this.loginWithRedirect.name,this.clientId,A,D);const{onRedirect:a}=t||{},o=k.AuthorizationCodeGrantTokenProvider.GenerateCodeVerifier();this.cookiesManager.save({code_verifier:o}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(o);const u=await this.tokenProvider.GetOAuthRedirect("state");a!=null?a(u):window.location.assign(u)}async handleCallback(t=window.location.href){const a=this.cookiesManager.get();if(a==null||(a==null?void 0:a.code_verifier)==null)throw new ot("Code verifier not available");const o=et(t),u=Ee(t),m=u.get("identity_provider")??"",O=u.get("state")??"";return await this.tokenProvider.ValidateQuery(o),await this.generateToken(m),{authState:O}}async generateToken(t){var f,C;const a=await this.tokenProvider.RetrieveToken(),o=await this.tokenProvider.RetrieveRefreshToken(),u=await this.tokenProvider.RetrieveIdToken(),m=await this.tokenProvider.RetrieveTokenExpiry(),b=new Date(m).getTime(),y=(C=(f=this.tokenProvider)==null?void 0:f._scopes)==null?void 0:C.join(" ");await this.cacheManager.setToken({scope:y,state:"",session_state:"",identity_provider:t,token_type:"bearer",access_token:a,refresh_token:o,id_token:u,expires_at:b});const M=Xe(u),R=rt(M);await this.cacheManager.setUser(R),await this.reloadCodeVerifier()}async reloadCodeVerifier(){const t=await this.tokenProvider.RetrieveCodeVerifier();this.cookiesManager.save({code_verifier:t}),this.tokenProvider=this.tokenProvider.WithProofKeyForCodeExchange(t)}async getUser(){return this.analyticshttpclient.sendMethodEvent(this.getUser.name,this.clientId,A,D),await this.cacheManager.getUser()}async getAccessTokenSilently(){this.analyticshttpclient.sendMethodEvent(this.getAccessTokenSilently.name,this.clientId,A,D);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,"No token available",this.clientId,A,D),new _e("No token available");const a=new Date(new Date().getTime()+pe);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<a.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getAccessTokenSilently.name,o.message,this.clientId,A,D),new me(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return(t==null?void 0:t.access_token)||""}async getTokens(){this.analyticshttpclient.sendMethodEvent(this.getTokens.name,this.clientId,A,D);let t=await this.cacheManager.getToken();if(t==null)throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,"No token available",this.clientId,A,D),new _e("No token available");const a=new Date(new Date().getTime()+pe);if((t==null?void 0:t.expires_at)==null||(t==null?void 0:t.expires_at)<a.getTime()){try{await this.tokenProvider.RetrieveToken()}catch(o){throw this.analyticshttpclient.sendExceptionEvent(this.getTokens.name,o.message,this.clientId,A,D),new me(o.message)}await this.generateToken((t==null?void 0:t.identity_provider)??""),t=await this.cacheManager.getToken()}return{access_token:(t==null?void 0:t.access_token)||"",expires_at:(t==null?void 0:t.expires_at)||0,id_token:(t==null?void 0:t.id_token)||""}}async logout(t){this.analyticshttpclient.sendMethodEvent(this.logout.name,this.clientId,A,D);const{onRedirect:a,disabledAutoRedirect:o}=t||{};this.cacheManager&&await this.cacheManager.clear(),this.cookiesManager&&this.cookiesManager.clear();const u=await this.tokenProvider.GetOAuthLogoutRedirect("state");if(a!=null)return a(u);o||window.location.assign(u)}async checkSession(){try{await this.getAccessTokenSilently()}catch{return!1}return!0}async loadUserSession(){await this.loadCacheSessionIntoSDK(),await this.checkSession()||await this.cacheManager.clear()}async loadCacheSessionIntoSDK(){const t=await this.cacheManager.getToken();if(t==null)return;const a=t.access_token,o=t.refresh_token||"",u=t.id_token,m=t.expires_at;this.tokenProvider=this.tokenProvider.WithAccessToken(a,m).WithRefreshToken(o).WithIdToken(u)}getBearerTokenHttpClient(t){return new k.BearerTokenHttpClientProvider(this.tokenProvider,t)}getRedirectUrl(){return this.redirectUrl}}const z=T.createContext(null),Te=()=>T.useContext(z)??{};var ne={exports:{}},K={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var we;function yt(){if(we)return Y;we=1;var a=k,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function S(P,v,x){var R,C={},f=null,F=null;x!==void 0&&(f=""+x),v.key!==void 0&&(f=""+v.key),v.ref!==void 0&&(F=v.ref);for(R in v)o.call(v,R)&&!w.hasOwnProperty(R)&&(C[R]=v[R]);if(P&&P.defaultProps)for(R in v=P.defaultProps,v)C[R]===void 0&&(C[R]=v[R]);return{$$typeof:t,type:P,key:f,ref:F,props:C,_owner:c.current}}return Y.Fragment=n,Y.jsx=S,Y.jsxs=S,Y}var G={};/**
9
+ */var Re;function ct(){if(Re)return K;Re=1;var i=T,t=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,u=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function O(b,y,M){var R,f={},C=null,x=null;M!==void 0&&(C=""+M),y.key!==void 0&&(C=""+y.key),y.ref!==void 0&&(x=y.ref);for(R in y)o.call(y,R)&&!m.hasOwnProperty(R)&&(f[R]=y[R]);if(b&&b.defaultProps)for(R in y=b.defaultProps,y)f[R]===void 0&&(f[R]=y[R]);return{$$typeof:t,type:b,key:C,ref:x,props:f,_owner:u.current}}return K.Fragment=a,K.jsx=O,K.jsxs=O,K}var Y={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,14 +14,14 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var be;function pt(){return be||(be=1,process.env.NODE_ENV!=="production"&&function(){var a=k,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),S=Symbol.for("react.provider"),P=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),U=Symbol.iterator,H="@@iterator";function ce(e){if(e===null||typeof e!="object")return null;var r=U&&e[U]||e[H];return typeof r=="function"?r:null}var D=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(e){{for(var r=arguments.length,i=new Array(r>1?r-1:0),s=1;s<r;s++)i[s-1]=arguments[s];$("error",e,i)}}function $(e,r,i){{var s=D.ReactDebugCurrentFrame,d=s.getStackAddendum();d!==""&&(r+="%s",i=i.concat([d]));var h=i.map(function(u){return String(u)});h.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,h)}}var X=!1,Q=!1,le=!1,g=!1,O=!1,Z;Z=Symbol.for("react.module.reference");function wt(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===w||O||e===c||e===x||e===R||g||e===F||X||Q||le||typeof e=="object"&&e!==null&&(e.$$typeof===f||e.$$typeof===C||e.$$typeof===S||e.$$typeof===P||e.$$typeof===v||e.$$typeof===Z||e.getModuleId!==void 0))}function bt(e,r,i){var s=e.displayName;if(s)return s;var d=r.displayName||r.name||"";return d!==""?i+"("+d+")":i}function Pe(e){return e.displayName||"Context"}function M(e){if(e==null)return null;if(typeof e.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case n:return"Portal";case w:return"Profiler";case c:return"StrictMode";case x:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case P:var r=e;return Pe(r)+".Consumer";case S:var i=e;return Pe(i._context)+".Provider";case v:return bt(e,e.render,"ForwardRef");case C:var s=e.displayName||null;return s!==null?s:M(e.type)||"Memo";case f:{var d=e,h=d._payload,u=d._init;try{return M(u(h))}catch{return null}}}return null}var N=Object.assign,J=0,Oe,Ie,xe,Ae,Ke,Ue,De;function Me(){}Me.__reactDisabledLog=!0;function Ct(){{if(J===0){Oe=console.log,Ie=console.info,xe=console.warn,Ae=console.error,Ke=console.group,Ue=console.groupCollapsed,De=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Me,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function Pt(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},e,{value:Oe}),info:N({},e,{value:Ie}),warn:N({},e,{value:xe}),error:N({},e,{value:Ae}),group:N({},e,{value:Ke}),groupCollapsed:N({},e,{value:Ue}),groupEnd:N({},e,{value:De})})}J<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ue=D.ReactCurrentDispatcher,fe;function q(e,r,i){{if(fe===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);fe=s&&s[1]||""}return`
18
- `+fe+e}}var de=!1,ee;{var Ot=typeof WeakMap=="function"?WeakMap:Map;ee=new Ot}function je(e,r){if(!e||de)return"";{var i=ee.get(e);if(i!==void 0)return i}var s;de=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=ue.current,ue.current=null,Ct();try{if(r){var u=function(){throw Error()};if(Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(j){s=j}Reflect.construct(e,[],u)}else{try{u.call()}catch(j){s=j}e.call(u.prototype)}}else{try{throw Error()}catch(j){s=j}e()}}catch(j){if(j&&s&&typeof j.stack=="string"){for(var l=j.stack.split(`
19
- `),b=s.stack.split(`
20
- `),y=l.length-1,E=b.length-1;y>=1&&E>=0&&l[y]!==b[E];)E--;for(;y>=1&&E>=0;y--,E--)if(l[y]!==b[E]){if(y!==1||E!==1)do if(y--,E--,E<0||l[y]!==b[E]){var I=`
21
- `+l[y].replace(" at new "," at ");return e.displayName&&I.includes("<anonymous>")&&(I=I.replace("<anonymous>",e.displayName)),typeof e=="function"&&ee.set(e,I),I}while(y>=1&&E>=0);break}}}finally{de=!1,ue.current=h,Pt(),Error.prepareStackTrace=d}var V=e?e.displayName||e.name:"",Xe=V?q(V):"";return typeof e=="function"&&ee.set(e,Xe),Xe}function It(e,r,i){return je(e,!1)}function xt(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function te(e,r,i){if(e==null)return"";if(typeof e=="function")return je(e,xt(e));if(typeof e=="string")return q(e);switch(e){case x:return q("Suspense");case R:return q("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case v:return It(e.render);case C:return te(e.type,r,i);case f:{var s=e,d=s._payload,h=s._init;try{return te(h(d),r,i)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,Le={},Fe=D.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,i=te(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(i)}else Fe.setExtraStackFrame(null)}function At(e,r,i,s,d){{var h=Function.call.bind(re);for(var u in e)if(h(e,u)){var l=void 0;try{if(typeof e[u]!="function"){var b=Error((s||"React class")+": "+i+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw b.name="Invariant Violation",b}l=e[u](r,u,s,i,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){l=y}l&&!(l instanceof Error)&&(ne(d),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",i,u,typeof l),ne(null)),l instanceof Error&&!(l.message in Le)&&(Le[l.message]=!0,ne(d),_("Failed %s type: %s",i,l.message),ne(null))}}}var Kt=Array.isArray;function he(e){return Kt(e)}function Ut(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,i=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i}}function Dt(e){try{return Ne(e),!1}catch{return!0}}function Ne(e){return""+e}function We(e){if(Dt(e))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ut(e)),Ne(e)}var B=D.ReactCurrentOwner,Mt={key:!0,ref:!0,__self:!0,__source:!0},Ve,Ye,ge;ge={};function jt(e){if(re.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Lt(e){if(re.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ft(e,r){if(typeof e.ref=="string"&&B.current&&r&&B.current.stateNode!==r){var i=M(B.current.type);ge[i]||(_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',M(B.current.type),e.ref),ge[i]=!0)}}function Nt(e,r){{var i=function(){Ve||(Ve=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}}function Wt(e,r){{var i=function(){Ye||(Ye=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};i.isReactWarning=!0,Object.defineProperty(e,"ref",{get:i,configurable:!0})}}var Vt=function(e,r,i,s,d,h,u){var l={$$typeof:t,type:e,key:r,ref:i,props:u,_owner:h};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function Yt(e,r,i,s,d){{var h,u={},l=null,b=null;i!==void 0&&(We(i),l=""+i),Lt(r)&&(We(r.key),l=""+r.key),jt(r)&&(b=r.ref,Ft(r,d));for(h in r)re.call(r,h)&&!Mt.hasOwnProperty(h)&&(u[h]=r[h]);if(e&&e.defaultProps){var y=e.defaultProps;for(h in y)u[h]===void 0&&(u[h]=y[h])}if(l||b){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&Nt(u,E),b&&Wt(u,E)}return Vt(e,l,b,d,s,B.current,u)}}var ve=D.ReactCurrentOwner,Ge=D.ReactDebugCurrentFrame;function W(e){if(e){var r=e._owner,i=te(e.type,e._source,r?r.type:null);Ge.setExtraStackFrame(i)}else Ge.setExtraStackFrame(null)}var ye;ye=!1;function pe(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function Je(){{if(ve.current){var e=M(ve.current.type);if(e)return`
17
+ */var we;function lt(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){var i=T,t=Symbol.for("react.element"),a=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),u=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),b=Symbol.for("react.context"),y=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),G=Symbol.iterator,ie="@@iterator";function H(e){if(e===null||typeof e!="object")return null;var r=G&&e[G]||e[ie];return typeof r=="function"?r:null}var j=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];X("error",e,n)}}function X(e,r,n){{var s=j.ReactDebugCurrentFrame,d=s.getStackAddendum();d!==""&&(r+="%s",n=n.concat([d]));var h=n.map(function(l){return String(l)});h.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,h)}}var Q=!1,oe=!1,v=!1,S=!1,se=!1,be;be=Symbol.for("react.module.reference");function Et(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===m||se||e===u||e===M||e===R||S||e===x||Q||oe||v||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===f||e.$$typeof===O||e.$$typeof===b||e.$$typeof===y||e.$$typeof===be||e.getModuleId!==void 0))}function mt(e,r,n){var s=e.displayName;if(s)return s;var d=r.displayName||r.name||"";return d!==""?n+"("+d+")":n}function Ce(e){return e.displayName||"Context"}function U(e){if(e==null)return null;if(typeof e.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case a:return"Portal";case m:return"Profiler";case u:return"StrictMode";case M:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b:var r=e;return Ce(r)+".Consumer";case O:var n=e;return Ce(n._context)+".Provider";case y:return mt(e,e.render,"ForwardRef");case f:var s=e.displayName||null;return s!==null?s:U(e.type)||"Memo";case C:{var d=e,h=d._payload,l=d._init;try{return U(l(h))}catch{return null}}}return null}var W=Object.assign,B=0,Se,Pe,Oe,xe,Ie,Ae,De;function Me(){}Me.__reactDisabledLog=!0;function _t(){{if(B===0){Se=console.log,Pe=console.info,Oe=console.warn,xe=console.error,Ie=console.group,Ae=console.groupCollapsed,De=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Me,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}B++}}function kt(){{if(B--,B===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:Se}),info:W({},e,{value:Pe}),warn:W({},e,{value:Oe}),error:W({},e,{value:xe}),group:W({},e,{value:Ie}),groupCollapsed:W({},e,{value:Ae}),groupEnd:W({},e,{value:De})})}B<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ce=j.ReactCurrentDispatcher,le;function Z(e,r,n){{if(le===void 0)try{throw Error()}catch(d){var s=d.stack.trim().match(/\n( *(at )?)/);le=s&&s[1]||""}return`
18
+ `+le+e}}var ue=!1,$;{var Tt=typeof WeakMap=="function"?WeakMap:Map;$=new Tt}function je(e,r){if(!e||ue)return"";{var n=$.get(e);if(n!==void 0)return n}var s;ue=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var h;h=ce.current,ce.current=null,_t();try{if(r){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(F){s=F}Reflect.construct(e,[],l)}else{try{l.call()}catch(F){s=F}e.call(l.prototype)}}else{try{throw Error()}catch(F){s=F}e()}}catch(F){if(F&&s&&typeof F.stack=="string"){for(var c=F.stack.split(`
19
+ `),w=s.stack.split(`
20
+ `),g=c.length-1,E=w.length-1;g>=1&&E>=0&&c[g]!==w[E];)E--;for(;g>=1&&E>=0;g--,E--)if(c[g]!==w[E]){if(g!==1||E!==1)do if(g--,E--,E<0||c[g]!==w[E]){var P=`
21
+ `+c[g].replace(" at new "," at ");return e.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",e.displayName)),typeof e=="function"&&$.set(e,P),P}while(g>=1&&E>=0);break}}}finally{ue=!1,ce.current=h,kt(),Error.prepareStackTrace=d}var V=e?e.displayName||e.name:"",He=V?Z(V):"";return typeof e=="function"&&$.set(e,He),He}function Rt(e,r,n){return je(e,!1)}function wt(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function q(e,r,n){if(e==null)return"";if(typeof e=="function")return je(e,wt(e));if(typeof e=="string")return Z(e);switch(e){case M:return Z("Suspense");case R:return Z("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case y:return Rt(e.render);case f:return q(e.type,r,n);case C:{var s=e,d=s._payload,h=s._init;try{return q(h(d),r,n)}catch{}}}return""}var ee=Object.prototype.hasOwnProperty,Ue={},Fe=j.ReactDebugCurrentFrame;function te(e){if(e){var r=e._owner,n=q(e.type,e._source,r?r.type:null);Fe.setExtraStackFrame(n)}else Fe.setExtraStackFrame(null)}function bt(e,r,n,s,d){{var h=Function.call.bind(ee);for(var l in e)if(h(e,l)){var c=void 0;try{if(typeof e[l]!="function"){var w=Error((s||"React class")+": "+n+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}c=e[l](r,l,s,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(g){c=g}c&&!(c instanceof Error)&&(te(d),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",n,l,typeof c),te(null)),c instanceof Error&&!(c.message in Ue)&&(Ue[c.message]=!0,te(d),_("Failed %s type: %s",n,c.message),te(null))}}}var Ct=Array.isArray;function fe(e){return Ct(e)}function St(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Pt(e){try{return Le(e),!1}catch{return!0}}function Le(e){return""+e}function We(e){if(Pt(e))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",St(e)),Le(e)}var J=j.ReactCurrentOwner,Ot={key:!0,ref:!0,__self:!0,__source:!0},Ne,Ve,de;de={};function xt(e){if(ee.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function It(e){if(ee.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function At(e,r){if(typeof e.ref=="string"&&J.current&&r&&J.current.stateNode!==r){var n=U(J.current.type);de[n]||(_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',U(J.current.type),e.ref),de[n]=!0)}}function Dt(e,r){{var n=function(){Ne||(Ne=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function Mt(e,r){{var n=function(){Ve||(Ve=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var jt=function(e,r,n,s,d,h,l){var c={$$typeof:t,type:e,key:r,ref:n,props:l,_owner:h};return c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function Ut(e,r,n,s,d){{var h,l={},c=null,w=null;n!==void 0&&(We(n),c=""+n),It(r)&&(We(r.key),c=""+r.key),xt(r)&&(w=r.ref,At(r,d));for(h in r)ee.call(r,h)&&!Ot.hasOwnProperty(h)&&(l[h]=r[h]);if(e&&e.defaultProps){var g=e.defaultProps;for(h in g)l[h]===void 0&&(l[h]=g[h])}if(c||w){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;c&&Dt(l,E),w&&Mt(l,E)}return jt(e,c,w,d,s,J.current,l)}}var he=j.ReactCurrentOwner,Ke=j.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,n=q(e.type,e._source,r?r.type:null);Ke.setExtraStackFrame(n)}else Ke.setExtraStackFrame(null)}var ve;ve=!1;function ge(e){return typeof e=="object"&&e!==null&&e.$$typeof===t}function Ye(){{if(he.current){var e=U(he.current.type);if(e)return`
22
22
 
23
- Check the render method of \``+e+"`."}return""}}function Gt(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),i=e.lineNumber;return`
23
+ Check the render method of \``+e+"`."}return""}}function Ft(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return`
24
24
 
25
- Check your code at `+r+":"+i+"."}return""}}var Be={};function Jt(e){{var r=Je();if(!r){var i=typeof e=="string"?e:e.displayName||e.name;i&&(r=`
25
+ Check your code at `+r+":"+n+"."}return""}}var Ge={};function Lt(e){{var r=Ye();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
26
26
 
27
- Check the top-level render call using <`+i+">.")}return r}}function ze(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=Jt(r);if(Be[i])return;Be[i]=!0;var s="";e&&e._owner&&e._owner!==ve.current&&(s=" It was passed a child from "+M(e._owner.type)+"."),W(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,s),W(null)}}function He(e,r){{if(typeof e!="object")return;if(he(e))for(var i=0;i<e.length;i++){var s=e[i];pe(s)&&ze(s,r)}else if(pe(e))e._store&&(e._store.validated=!0);else if(e){var d=ce(e);if(typeof d=="function"&&d!==e.entries)for(var h=d.call(e),u;!(u=h.next()).done;)pe(u.value)&&ze(u.value,r)}}}function Bt(e){{var r=e.type;if(r==null||typeof r=="string")return;var i;if(typeof r=="function")i=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===v||r.$$typeof===C))i=r.propTypes;else return;if(i){var s=M(r);At(i,e.props,"prop",s,e)}else if(r.PropTypes!==void 0&&!ye){ye=!0;var d=M(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function zt(e){{for(var r=Object.keys(e.props),i=0;i<r.length;i++){var s=r[i];if(s!=="children"&&s!=="key"){W(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),W(null);break}}e.ref!==null&&(W(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),W(null))}}function $e(e,r,i,s,d,h){{var u=wt(e);if(!u){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var b=Gt(d);b?l+=b:l+=Je();var y;e===null?y="null":he(e)?y="array":e!==void 0&&e.$$typeof===t?(y="<"+(M(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,l)}var E=Yt(e,r,i,d,h);if(E==null)return E;if(u){var I=r.children;if(I!==void 0)if(s)if(he(I)){for(var V=0;V<I.length;V++)He(I[V],e);Object.freeze&&Object.freeze(I)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else He(I,e)}return e===o?zt(E):Bt(E),E}}function Ht(e,r,i){return $e(e,r,i,!0)}function $t(e,r,i){return $e(e,r,i,!1)}var Xt=$t,Qt=Ht;G.Fragment=o,G.jsx=Xt,G.jsxs=Qt}()),G}process.env.NODE_ENV==="production"?oe.exports=yt():oe.exports=pt();var se=oe.exports;const mt=(a,t)=>{switch(t.type){case"INIT":return{...a,isLoading:!1,isAuthenticated:t.user!=null,user:t.user,error:void 0};case"GET_TOKENS_COMPLETE":case"HANDLE_CALLBACK_COMPLETE":case"GET_ACCESS_TOKEN_COMPLETE":return{...a,isLoading:!1,isAuthenticated:t.user!=null,user:t.user,error:void 0};case"LOGOUT":return{...a,isAuthenticated:!1,user:void 0};case"ERROR":return{...a,isLoading:!1,error:t.error}}},Et={isLoading:!0,isAuthenticated:!1},Ce=a=>{if(a==null||Object.keys(a).length<=0)return!0;const t=Object.keys(a);for(const n of t)if(a[n]!=null&&a[n]!=="")return!1;return!0},_t=a=>{const t=Ce(a.config),n=Ce(a.persistentOptions);return!t||!n},Tt=a=>{const{children:t,configurationEndpoint:n,clientId:o,redirectUrl:c,logoutRedirectUrl:w,scopes:S,persistentStore:P,onRedirectCallback:v,checkRedirectUrlMatch:x}=a;if(k.useContext(z)!=null)throw new Error("TID Provider already defined");const C={config:{configurationEndpoint:n??"",clientId:o??"",redirectUrl:c??"",logoutRedirectUrl:w??"",scopes:S??[""]},persistentOptions:{persistentStore:P??"in-memory"}},[f]=k.useState(a.tidClient??new Se(C)),[F,U]=k.useReducer(mt,Et),H=k.useRef(!1),ce=k.useMemo(()=>x?f.getRedirectUrl():void 0,[x,f]);k.useEffect(()=>{H.current||(a.tidClient!=null&&_t({config:{configurationEndpoint:n,clientId:o,redirectUrl:c,logoutRedirectUrl:w,scopes:S},persistentOptions:{persistentStore:P}})&&console.warn("When TID client is pass as prop, any client configuration property sent directly to the TID Provider component will be ignored"),H.current=!0,(async()=>{try{let g;if(ct(void 0,ce)){const{authState:O}=await f.handleCallback();g=await f.getUser(),v!=null&&v(O)}else await f.loadUserSession(),g=await f.getUser();U({type:"INIT",user:g})}catch(g){let O=g;typeof g=="string"&&(O=new Error(g)),U({type:"ERROR",error:O})}})())},[f,v]);const D=k.useCallback(async()=>{const g=await f.getAccessTokenSilently(),O=await f.getUser();return U({type:"GET_ACCESS_TOKEN_COMPLETE",user:O}),g},[f]),_=k.useCallback(async()=>{const g=await f.getTokens(),O=await f.getUser();return U({type:"GET_TOKENS_COMPLETE",user:O}),g},[f]),$=k.useCallback(async g=>{await f.loginWithRedirect(g)},[f]),X=k.useCallback(async g=>{await f.logout(g),(g==null?void 0:g.disabledAutoRedirect)!=null&&g.disabledAutoRedirect&&U({type:"LOGOUT"})},[f]),Q=k.useCallback(async g=>{const{authState:O}=await f.handleCallback(g),Z=await f.getUser();return U({type:"HANDLE_CALLBACK_COMPLETE",user:Z}),{authState:O}},[f]),le=k.useMemo(()=>({...F,getAccessTokenSilently:D,getTokens:_,loginWithRedirect:$,handleCallback:Q,logout:X}),[F,D,_,$,Q,X]);return se.jsx(z.Provider,{value:le,children:t})},kt=Re,St=Tt,Rt=({renderComponent:a,loader:t})=>{const{isAuthenticated:n,isLoading:o,loginWithRedirect:c}=Re();return k.useEffect(()=>{!o&&!n&&(async()=>await c())()},[o,n,c]),n?a:t||se.jsx(se.Fragment,{})};m.AuthenticationGuard=Rt,m.TIDClient=Se,m.TIDContext=z,m.TIDProvider=St,m.useAuth=kt,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
27
+ Check the top-level render call using <`+n+">.")}return r}}function Be(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=Lt(r);if(Ge[n])return;Ge[n]=!0;var s="";e&&e._owner&&e._owner!==he.current&&(s=" It was passed a child from "+U(e._owner.type)+"."),N(e),_('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,s),N(null)}}function Je(e,r){{if(typeof e!="object")return;if(fe(e))for(var n=0;n<e.length;n++){var s=e[n];ge(s)&&Be(s,r)}else if(ge(e))e._store&&(e._store.validated=!0);else if(e){var d=H(e);if(typeof d=="function"&&d!==e.entries)for(var h=d.call(e),l;!(l=h.next()).done;)ge(l.value)&&Be(l.value,r)}}}function Wt(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===y||r.$$typeof===f))n=r.propTypes;else return;if(n){var s=U(r);bt(n,e.props,"prop",s,e)}else if(r.PropTypes!==void 0&&!ve){ve=!0;var d=U(r);_("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",d||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&_("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var s=r[n];if(s!=="children"&&s!=="key"){N(e),_("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),N(null);break}}e.ref!==null&&(N(e),_("Invalid attribute `ref` supplied to `React.Fragment`."),N(null))}}function ze(e,r,n,s,d,h){{var l=Et(e);if(!l){var c="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(c+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var w=Ft(d);w?c+=w:c+=Ye();var g;e===null?g="null":fe(e)?g="array":e!==void 0&&e.$$typeof===t?(g="<"+(U(e.type)||"Unknown")+" />",c=" Did you accidentally export a JSX literal instead of a component?"):g=typeof e,_("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",g,c)}var E=Ut(e,r,n,d,h);if(E==null)return E;if(l){var P=r.children;if(P!==void 0)if(s)if(fe(P)){for(var V=0;V<P.length;V++)Je(P[V],e);Object.freeze&&Object.freeze(P)}else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(P,e)}return e===o?Nt(E):Wt(E),E}}function Vt(e,r,n){return ze(e,r,n,!0)}function Kt(e,r,n){return ze(e,r,n,!1)}var Yt=Kt,Gt=Vt;Y.Fragment=o,Y.jsx=Yt,Y.jsxs=Gt}()),Y}process.env.NODE_ENV==="production"?ne.exports=ct():ne.exports=lt();var ae=ne.exports;const ut=(i,t)=>{switch(t.type){case"INIT":return{...i,isLoading:!1,isAuthenticated:t.user!=null,user:t.user,error:void 0};case"GET_TOKENS_COMPLETE":case"HANDLE_CALLBACK_COMPLETE":case"GET_ACCESS_TOKEN_COMPLETE":return{...i,isLoading:!1,isAuthenticated:t.user!=null,user:t.user,error:void 0};case"LOGOUT":return{...i,isAuthenticated:!1,user:void 0};case"ERROR":return{...i,isLoading:!1,error:t.error}}},ft={isLoading:!0,isAuthenticated:!1},dt=i=>{if(i==null||Object.keys(i).length<=0)return!0;const t=Object.keys(i);for(const a of t)if(i[a]!=null&&i[a]!=="")return!1;return!0},ht=i=>!dt(i.config),vt=i=>{const{children:t,configurationEndpoint:a,clientId:o,redirectUrl:u,logoutRedirectUrl:m,scopes:O,onRedirectCallback:b,checkRedirectUrlMatch:y}=i;if(T.useContext(z)!=null)throw new Error("TID Provider already defined");const R={config:{configurationEndpoint:a??"",clientId:o??"",redirectUrl:u??"",logoutRedirectUrl:m??"",scopes:O??[""]}},[f]=T.useState(i.tidClient??new ke(R)),[C,x]=T.useReducer(ut,ft),G=T.useRef(!1),ie=T.useMemo(()=>y?f.getRedirectUrl():void 0,[y,f]);T.useEffect(()=>{G.current||(i.tidClient!=null&&ht({config:{configurationEndpoint:a,clientId:o,redirectUrl:u,logoutRedirectUrl:m,scopes:O}})&&console.warn("When TID client is pass as prop, any client configuration property sent directly to the TID Provider component will be ignored"),G.current=!0,(async()=>{try{let v;if(tt(void 0,ie)){const{authState:S}=await f.handleCallback();v=await f.getUser(),b!=null&&b(S)}else await f.loadUserSession(),v=await f.getUser();x({type:"INIT",user:v})}catch(v){let S=v;typeof v=="string"&&(S=new Error(v)),x({type:"ERROR",error:S})}})())},[f,b]);const H=T.useCallback(async()=>{const v=await f.getAccessTokenSilently(),S=await f.getUser();return x({type:"GET_ACCESS_TOKEN_COMPLETE",user:S}),v},[f]),j=T.useCallback(async()=>{const v=await f.getTokens(),S=await f.getUser();return x({type:"GET_TOKENS_COMPLETE",user:S}),v},[f]),_=T.useCallback(async v=>{await f.loginWithRedirect(v)},[f]),X=T.useCallback(async v=>{await f.logout(v),(v==null?void 0:v.disabledAutoRedirect)!=null&&v.disabledAutoRedirect&&x({type:"LOGOUT"})},[f]),Q=T.useCallback(async v=>{const{authState:S}=await f.handleCallback(v),se=await f.getUser();return x({type:"HANDLE_CALLBACK_COMPLETE",user:se}),{authState:S}},[f]),oe=T.useMemo(()=>({...C,getAccessTokenSilently:H,getTokens:j,loginWithRedirect:_,handleCallback:Q,logout:X}),[C,H,j,_,Q,X]);return ae.jsx(z.Provider,{value:oe,children:t})},gt=Te,pt=vt,yt=({renderComponent:i,loader:t})=>{const{isAuthenticated:a,isLoading:o,loginWithRedirect:u}=Te();return T.useEffect(()=>{!o&&!a&&(async()=>await u())()},[o,a,u]),a?i:t||ae.jsx(ae.Fragment,{})};p.AuthenticationGuard=yt,p.TIDClient=ke,p.TIDContext=z,p.TIDProvider=pt,p.useAuth=gt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "name": "@trimble-oss/trimble-id-react",
4
4
  "private": false,
5
- "version": "0.1.0-rc.1",
5
+ "version": "1.0.0-rc.1",
6
6
  "homepage": "https://github.com/trimble-oss/trimble-id-sdk-docs-for-react",
7
7
  "author": "Trimble developers <developers@trimble.com>",
8
8
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "module": "./dist/trimble-id-react.es.js",
33
33
  "types": "./dist/index.d.ts",
34
34
  "dependencies": {
35
- "@trimble-oss/trimble-id": "0.0.6",
35
+ "@trimble-oss/trimble-id": "^0.0.6",
36
36
  "es-cookie": "^1.4.0",
37
37
  "husky": "^8.0.3",
38
38
  "jwt-decode": "^3.1.2"
@@ -1,46 +0,0 @@
1
- interface CacheKeyOptions {
2
- /**
3
- * Client id of the application created in trimble developer console
4
- * @type {string}
5
- */
6
- client_id: string;
7
- }
8
- /** Class representing the caching keys for storing and retrieving user and token from auth */
9
- export declare class CacheKey {
10
- /**
11
- * Client id of the application created in trimble developer console
12
- * @type {string}
13
- */
14
- private readonly clientId;
15
- /**
16
- * Prefix value of the key, by default the prefix is based on the constant PREFIX_KEY
17
- * @type {string}
18
- */
19
- private readonly prefix;
20
- /**
21
- * Suffix value use it to generate the key to store and retrieve the token, by default the prefix is based on the constant AUTH_KEY
22
- * @type {string}
23
- */
24
- private readonly authSuffix;
25
- /**
26
- * Suffix value use it to generate the key to store and retrieve the user, by default the prefix is based on the constant USER_KEY
27
- * @type {string}
28
- */
29
- private readonly userSuffix;
30
- /**
31
- * Initialized the cache key
32
- * @param {CacheKeyOptions} cacheKeyOptions - Cache key options to edit the default values
33
- */
34
- constructor(cacheKeyOptions: CacheKeyOptions);
35
- /**
36
- * Get key to store/retrieve user
37
- * @return {string} Key for the user
38
- */
39
- getUserKey(): string;
40
- /**
41
- * Get key to store/retrieve token
42
- * @return {string} Key for the token
43
- */
44
- getAuthKey(): string;
45
- }
46
- export {};
@@ -1,67 +0,0 @@
1
- import { CacheStorage, TIDAuthToken, TIDUser } from '../../interfaces';
2
- import { CacheKey } from './CacheKey';
3
- export interface LocalStorageCacheOptions {
4
- /**
5
- * The cache key represents the keys for storing and retrieving user and token from auth
6
- * @type {CacheKey}
7
- */
8
- cacheKey: CacheKey;
9
- }
10
- /**
11
- * Class representing localstorage caching
12
- * NOTE: This type storage do not expired so it will persist even if the user close the browser
13
- */
14
- export declare class LocalStorageCache implements CacheStorage {
15
- /**
16
- * Local storage from the browser
17
- * @type {Storage}
18
- */
19
- private readonly localStorage;
20
- /**
21
- * The cache key represents the keys for storing and retrieving user and token from auth
22
- * @type {CacheKey}
23
- */
24
- private readonly cacheKey;
25
- /**
26
- * Initialized configuration to store information into local storage
27
- * @param {LocalStorageCacheOptions} options - Configuration for caching in localstorage
28
- */
29
- constructor(options: LocalStorageCacheOptions);
30
- /**
31
- * Get token store in localstorage
32
- * @return {Promise<TIDAuthToken | undefined>} - Token store in localstorage
33
- */
34
- getToken(): Promise<TIDAuthToken | undefined>;
35
- /**
36
- * Get user store in localstorage
37
- * @return {Promise<TIDUser | undefined>} - User store in localstorage
38
- */
39
- getUser(): Promise<TIDUser | undefined>;
40
- /**
41
- * Store token in localstorage
42
- * @param {TIDAuthToken} token - Token that you want to store in localstorage
43
- * @return {Promise<void>} Empty promise
44
- */
45
- storeToken(authToken: TIDAuthToken): Promise<void>;
46
- /**
47
- * Store user in cache
48
- * @param {TIDUser} user - User that you want to store in localstorage
49
- * @return {Promise<void>} Empty promise
50
- */
51
- storeUser(user: TIDUser): Promise<void>;
52
- /**
53
- * Get the full key from the cachekey for the user
54
- * @return {string} - Full key to get the token from the localstorage
55
- */
56
- getUserKey(): string;
57
- /**
58
- * Get the full key from the cachekey for the token
59
- * @return {string} - Full key to get the token from the localstorage
60
- */
61
- getAuthKey(): string;
62
- /**
63
- * The clear the cache from the localstorage
64
- * @return {Promise<void>} Empty promise
65
- */
66
- clear(): Promise<void>;
67
- }
@@ -1,67 +0,0 @@
1
- import { CacheStorage, TIDAuthToken, TIDUser } from '../../interfaces';
2
- import { CacheKey } from './CacheKey';
3
- export interface SessionStorageCacheOptions {
4
- /**
5
- * The cache key represents the keys for storing and retrieving user and token from auth
6
- * @type {CacheKey}
7
- */
8
- cacheKey: CacheKey;
9
- }
10
- /**
11
- * Class representing session storage caching
12
- * NOTE: This type storage is cleared when the page session ends
13
- */
14
- export declare class SessionStorageCache implements CacheStorage {
15
- /**
16
- * Session storage from the browser
17
- * @type {Storage}
18
- */
19
- private readonly sessionStorage;
20
- /**
21
- * The cache key represents the keys for storing and retrieving user and token from auth
22
- * @type {CacheKey}
23
- */
24
- private readonly cacheKey;
25
- /**
26
- * Initialized configuration to store information into session storage
27
- * @param {SessionStorageCacheOptions} options - Configuration for caching in session storage
28
- */
29
- constructor(options: SessionStorageCacheOptions);
30
- /**
31
- * Get token store in session storage
32
- * @return {Promise<TIDAuthToken | undefined>} - Token store in session storage
33
- */
34
- getToken(): Promise<TIDAuthToken | undefined>;
35
- /**
36
- * Get user store in session storage
37
- * @return {Promise<TIDUser | undefined>} - User store in session storage
38
- */
39
- getUser(): Promise<TIDUser | undefined>;
40
- /**
41
- * Store token in session storage
42
- * @param {TIDAuthToken} authToken - Token that you want to store in session storage
43
- * @return {Promise<void>} Empty promise
44
- */
45
- storeToken(authToken: TIDAuthToken): Promise<void>;
46
- /**
47
- * Store user in cache
48
- * @param {TIDUser} user - User that you want to store in session storage
49
- * @return {Promise<void>} Empty promise
50
- */
51
- storeUser(user: TIDUser): Promise<void>;
52
- /**
53
- * Get the full key from the cachekey for the user
54
- * @return {string} - Full key to get the token from the session storage
55
- */
56
- getUserKey(): string;
57
- /**
58
- * Get the full key from the cachekey for the token
59
- * @return {string} - Full key to get the token from the session storage
60
- */
61
- getAuthKey(): string;
62
- /**
63
- * The clear the cache from the session storage
64
- * @return {Promise<void>} Empty promise
65
- */
66
- clear(): Promise<void>;
67
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Default value of the prefix key use it to store the token and the user
3
- * @type {string}
4
- */
5
- export declare const PREFIX_KEY: string;
6
- /**
7
- * Default value of the suffix key use it to store the token
8
- * @type {string}
9
- */
10
- export declare const AUTH_KEY: string;
11
- /**
12
- * Default value of the suffix key use it to store the user
13
- * @type {string}
14
- */
15
- export declare const USER_KEY: string;