@pontive/pontkit-core 1.7.6 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/catalog.json +1 -1
- package/custom-elements.json +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2645,8 +2645,8 @@
|
|
|
2645
2645
|
</div>
|
|
2646
2646
|
${this.hasDefaultPagination&&this.hasDefaultSelect?this._renderPagination():h}
|
|
2647
2647
|
</div>
|
|
2648
|
-
`}};ft([a({type:String})],dt.prototype,"placeholder",2);ft([a({type:Array})],dt.prototype,"dataTable",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultSelect",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultPagination",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultSearch",2);ft([a({type:Object})],dt.prototype,"checkedRows",2);ft([a({type:String})],dt.prototype,"searchTerm",2);ft([a({type:Object})],dt.prototype,"columnVisibility",2);ft([a({type:String})],dt.prototype,"sortColumn",2);ft([a({type:String})],dt.prototype,"sortDirection",2);ft([a({type:Object})],dt.prototype,"cellRenderers",2);ft([a({type:Object})],dt.prototype,"headerRenderers",2);ft([a({type:Array})],dt.prototype,"rowActions",2);ft([a({type:Array})],dt.prototype,"paginationLabels",2);ft([a({type:Number})],dt.prototype,"pageSize",2);ft([a({type:Number})],dt.prototype,"currentPage",2);ft([a({type:Array})],dt.prototype,"sortableColumns",2);ft([a({type:Array})],dt.prototype,"columnOrder",2);ft([a({type:Function})],dt.prototype,"isRowDisabled",2);dt=ft([p("pont-data-table")],dt);var H=class extends Error{constructor(t,r,o,n){super(r);E(this,"code");E(this,"details");E(this,"status");this.name="LoginflowError",this.code=t,this.details=o,this.status=n}};function Ah(e){const t=(e??"").trim();if(!t)throw new H("CONFIG_ERROR","domain is required");if(t.startsWith("/")){if(typeof location>"u")throw new H("CONFIG_ERROR",`domain "${t}" is relative to the page origin, and there is no page here`);return Dc(new URL(t,location.origin))}const r=/^https?:\/\//i.test(t)?"":`${j$(U$(t))?"http":"https"}://`;try{return Dc(new URL(`${r}${t}`))}catch{throw new H("CONFIG_ERROR",`domain "${t}" is not a hostname, an origin, or a path`)}}function Dc(e){return`${e.origin}${e.pathname}`.replace(/\/+$/,"")}function U$(e){return e.split("/")[0]}function j$(e){return/^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/i.test(e)}var ye,q$=(ye=class{constructor(){E(this,"data",new Map)}static get Instance(){return ye.instance||(ye.instance=new ye),ye.instance}get(t){return this.data.get(t)}set(t,r){this.data.set(t,r)}setConfig(t){this.data.set("config",t)}getConfig(){return this.data.get("config")}getApiBaseUrl(){return Ah(this.getConfig().domain)}apiIsSameOrigin(){if(typeof location>"u")return!1;try{return new URL(this.getApiBaseUrl()).host===location.host}catch{return!1}}remove(t){this.data.delete(t)}clear(){this.data.clear()}},E(ye,"instance"),ye),K=q$.Instance,_e,lo=(_e=class{constructor(){}static get Instance(){return _e.instance||(_e.instance=new _e),_e.instance}async request(t,r={}){const o=K.getConfig(),n=`${K.getApiBaseUrl()}${t}`,i=5e4,s=new AbortController,d=setTimeout(()=>s.abort(),i);try{const c=await fetch(n,{...r,signal:s.signal,headers:{"Content-Type":"application/json",...o.headers,...r.headers}});if(clearTimeout(d),!c.ok){const u=await c.json().catch(()=>({}));throw new H(u.code||u.error||"API_ERROR",u.message||u.error_description||`HTTP ${c.status}: ${c.statusText}`,u.details,c.status)}return await c.json()}catch(c){throw clearTimeout(d),c instanceof H?c:c instanceof Error?c.name==="AbortError"?new H("TIMEOUT","Request timeout"):new H("NETWORK_ERROR",c.message):new H("UNKNOWN_ERROR","An unknown error occurred")}}async post(t,r){return this.request(t,{credentials:"include",method:"POST",body:r?JSON.stringify(r):void 0})}async get(t){return this.request(t,{credentials:"include",method:"GET"})}async getOptional(t){const r=K.getConfig(),o=await fetch(`${K.getApiBaseUrl()}${t}`,{credentials:"include",method:"GET",headers:{...r.headers}});if(o.status===204)return null;if(!o.ok)throw new H("API_ERROR",`HTTP ${o.status}: ${o.statusText}`,void 0,o.status);return await o.json()}async postForm(t,r){return this.request(t,{credentials:"include",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(r).toString()})}},E(_e,"instance"),_e),Th="__Secure-pontive_session_state",ps="__Secure-pontive_session_probe";function z$(){return Dh(Th)?"present":V$()?"absent":"unknown"}function Oa(){if(!(typeof document>"u"||typeof location>"u"))for(const e of["",...K$(location.hostname)])Ra(Th,"",e,0)}function V$(){if(typeof document>"u"||typeof location>"u")return!1;const e=G$();try{Ra(ps,"1",e,60);const t=Dh(ps)==="1";return Ra(ps,"",e,0),t&&H$(e)}catch{return!1}}function H$(e){return e!==""||K.apiIsSameOrigin()}function G$(){let e;try{e=new URL(K.getApiBaseUrl()).hostname}catch{return""}const t=location.hostname;if(!e||!t||e.toLowerCase()===t.toLowerCase())return"";const r=t.split("."),o=e.split(".");let n=0;for(;n<r.length&&n<o.length&&r[r.length-1-n].toLowerCase()===o[o.length-1-n].toLowerCase();)n+=1;return n<2?"":o.slice(o.length-n).join(".")}function K$(e){const t=e.split("."),r=[];for(let o=1;o+2<=t.length;o+=1)r.push(t.slice(o).join("."));return r}function Ra(e,t,r,o){const n=W$()?"; Secure":"",i=r?`; Domain=${r}`:"";document.cookie=`${e}=${t}; Path=/; Max-Age=${o}; SameSite=Lax${i}${n}`}function W$(){return typeof globalThis.isSecureContext=="boolean"?globalThis.isSecureContext:location.protocol==="https:"}function Dh(e){if(typeof document>"u"||!document.cookie)return null;for(const t of document.cookie.split(";")){const r=t.indexOf("=");if(!(r<0)&&t.slice(0,r).trim()===e)return t.slice(r+1).trim()||null}return null}var Pt,St=(Pt=class{constructor(){E(this,"AUTH_SESSION_STORAGE_KEY","pontive_auth_session");E(this,"memorySession",null);E(this,"refreshTimeoutId",null);E(this,"refreshPromise",null);E(this,"refreshRetryCount",0);E(this,"refreshBlockedUntil",0);E(this,"sessionGeneration",0);E(this,"channel",null);E(this,"channelName","");E(this,"applyingBroadcast",!1);E(this,"restorePromise",null)}static get Instance(){return Pt.instance||(Pt.instance=new Pt),Pt.instance}setCurrentSession(t){this.sessionGeneration+=1,this.write(JSON.stringify(t)),this.publish({type:"session",session:t})}async withRefreshLock(t){const r=typeof navigator<"u"?navigator.locks:void 0;return r?r.request(this.channelKey("refresh"),t):t()}channelKey(t){const r=K.getConfig();return`pontive-${t}:${(r==null?void 0:r.domain)??""}:${(r==null?void 0:r.appId)??""}`}ensureChannel(){var r;if(typeof BroadcastChannel>"u")return null;const t=this.channelKey("session");return this.channel&&this.channelName===t?this.channel:((r=this.channel)==null||r.close(),this.channelName=t,this.channel=new BroadcastChannel(t),this.channel.onmessage=o=>this.receive(o.data),this.channel)}publish(t){var r;this.applyingBroadcast||(r=this.ensureChannel())==null||r.postMessage(t)}receive(t){this.applyingBroadcast=!0;try{if(t.type==="cleared"){this.clearSession();return}this.setCurrentSession(t.session),this.scheduleTokenRefresh()}finally{this.applyingBroadcast=!1}}isCurrentGeneration(t){return this.sessionGeneration===t}getCurrentSession(){const t=this.getStoredSession();return t?this.isSessionExpired(t)?(this.clearSession(),null):(this.shouldRefreshToken(t)&&this.triggerBackgroundRefresh(t),t):null}peekSession(){return this.getStoredSession()}isAuthenticated(){return this.getCurrentSession()!==null}getAuthenticatedUser(){const t=this.getCurrentSession();if(!t)return null;const r=t.id_token?this.decodeJWT(t.id_token):null;return r||(t.user??null)}cleanup(){var t;this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshPromise=null,(t=this.channel)==null||t.close(),this.channel=null,this.channelName=""}clearSession(){this.sessionGeneration+=1,this.memorySession=null,localStorage.removeItem(this.AUTH_SESSION_STORAGE_KEY),this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshRetryCount=0,this.refreshBlockedUntil=0,this.publish({type:"cleared"})}isSessionExpired(t){return!t||!t.expires_at?!0:Date.now()>=t.expires_at}cleanExpiredSession(){const t=this.getStoredSession();t&&this.isSessionExpired(t)&&this.clearSession()}getStoredSession(){const t=this.read();if(!t)return null;try{return JSON.parse(t)}catch{return this.clearSession(),null}}write(t){this.memorySession=t,localStorage.removeItem(this.AUTH_SESSION_STORAGE_KEY)}read(){return this.memorySession}decodeJWT(t){try{const o=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(o).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(n)}catch{return null}}shouldRefreshToken(t){if(!t||!t.expires_at)return!1;const r=Date.now(),o=t.expires_at,n=t.expires_in||3600,i=r+n*1e3*.2;return o<=i}scheduleTokenRefresh(){this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null);const t=this.getCurrentSession();if(!t||!t.expires_at)return;const r=Date.now(),o=t.expires_at,n=t.expires_in||3600,i=o-r-n*1e3*.2;i>0&&(this.refreshTimeoutId=setTimeout(()=>{this.triggerBackgroundRefresh(t)},i))}triggerBackgroundRefresh(t){this.refreshPromise||Date.now()<this.refreshBlockedUntil||(this.refreshPromise=this.withRefreshLock(()=>{const r=this.getStoredSession();return r&&!this.shouldRefreshToken(r)?(this.scheduleTokenRefresh(),Promise.resolve(null)):this.refreshTokens(r??t)}).then(r=>(r&&(this.setCurrentSession(r),this.refreshRetryCount=0,this.refreshBlockedUntil=0,this.scheduleTokenRefresh()),r)).catch(r=>(console.error("Background token refresh failed:",r),null)).finally(()=>{this.refreshPromise=null}))}async switchOrganization(t){if(!t)throw new H("INVALID_REQUEST","organizationId is required");return this.withRefreshLock(async()=>{const r=this.sessionGeneration,o=this.getCurrentSession(),n=await this.requestTokens(o,{organization_id:t});if(!this.isCurrentGeneration(r))throw new H("SESSION_CHANGED","the session changed while switching organization");return this.setCurrentSession(n),this.scheduleTokenRefresh(),n})}getOrganization(){const t=this.getCurrentSession(),r=t!=null&&t.access_token?this.decodeJWT(t.access_token):null,o=r==null?void 0:r.org_id;if(typeof o!="string"||o==="")return null;const n=i=>Array.isArray(i)?i.filter(s=>typeof s=="string"):[];return{id:o,roles:n(r==null?void 0:r.roles),permissions:n(r==null?void 0:r.permissions)}}async refreshTokens(t){const r=this.sessionGeneration;try{const o=await this.requestTokens(t);return this.isCurrentGeneration(r)?o:(console.warn("Token refresh returned after the session changed; discarding it"),null)}catch(o){return this.isCurrentGeneration(r)?Y$(o)?(console.error("Token refresh rejected, signing out:",Xn(o)),Oa(),this.clearSession(),null):(console.warn("Token refresh failed, keeping session and retrying:",Xn(o)),this.scheduleRefreshRetry(t),null):(console.warn("Token refresh failed after the session changed; ignoring:",Xn(o)),null)}}async fetchUserInfo(t){try{return await lo.Instance.request("/oauth2/userinfo",{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${t}`}})}catch(r){return console.debug("Could not read user info for the restored session:",Xn(r)),null}}async requestTokens(t,r={}){var i;const o={...r,grant_type:"refresh_token",client_id:(i=K.getConfig())==null?void 0:i.appId};t!=null&&t.refresh_token&&(o.refresh_token=t.refresh_token);const n=await lo.Instance.postForm("/oauth2/token",o);return{id_token:n.id_token??(t==null?void 0:t.id_token)??"",access_token:n.access_token,refresh_token:n.refresh_token??(t==null?void 0:t.refresh_token),expires_in:n.expires_in,expires_at:Date.now()+n.expires_in*1e3}}async readCurrentToken(){var r;const t=(r=K.getConfig())==null?void 0:r.appId;if(!t)return null;try{const o=await lo.Instance.getOptional(`/oauth2/session/token?client_id=${encodeURIComponent(t)}`);return!(o!=null&&o.access_token)||!(o.expires_in>0)?null:{id_token:"",access_token:o.access_token,expires_in:o.expires_in,expires_at:Date.now()+o.expires_in*1e3}}catch{return null}}async restoreSession(){const t=this.getStoredSession();return t&&!this.isSessionExpired(t)?t:z$()==="absent"?null:this.restorePromise?this.restorePromise:(this.restorePromise=this.withRefreshLock(async()=>{const r=this.getStoredSession();if(r&&!this.isSessionExpired(r))return r;try{const o=await this.readCurrentToken()??await this.requestTokens(null);return o.id_token||(o.user=await this.fetchUserInfo(o.access_token)??void 0),this.setCurrentSession(o),this.scheduleTokenRefresh(),o}catch(o){return Z$(o)&&Oa(),console.debug("No session to restore:",Xn(o)),null}}).finally(()=>{this.restorePromise=null}),this.restorePromise)}scheduleRefreshRetry(t){if(this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshRetryCount>=Pt.MAX_REFRESH_RETRIES){console.warn("Token refresh gave up after",this.refreshRetryCount,"attempts"),this.refreshRetryCount=0,this.refreshBlockedUntil=0;return}const r=Math.min(Pt.REFRESH_RETRY_BASE_MS*2**this.refreshRetryCount,Pt.MAX_REFRESH_RETRY_DELAY_MS);this.refreshRetryCount+=1,this.refreshBlockedUntil=Date.now()+r,this.refreshTimeoutId=setTimeout(()=>{this.refreshBlockedUntil=0,this.triggerBackgroundRefresh(t)},r)}},E(Pt,"MAX_REFRESH_RETRIES",5),E(Pt,"REFRESH_RETRY_BASE_MS",5e3),E(Pt,"MAX_REFRESH_RETRY_DELAY_MS",6e4),E(Pt,"instance"),Pt);function Y$(e){return!(e instanceof H)||e.status===void 0?!1:e.status===401?!0:e.status===400&&Q$.has(e.code)}var Q$=new Set(["invalid_grant","invalid_client"]);function Z$(e){return e instanceof H&&e.status!==void 0&&e.status>=400&&e.status<500}function Xn(e){return e instanceof H?`${e.code} (status ${e.status??"none"}): ${e.message}`:String(e)}var Lh=class{constructor(e=sessionStorage){E(this,"storage");E(this,"FLOW_STATE_KEY","pontive_loginflow_state");E(this,"FLOW_EXPIRY_MS",540*1e3);this.storage=e}getFlowState(){const e=this.storage.getItem(this.FLOW_STATE_KEY);if(!e)return null;try{const t=JSON.parse(e);return this.isExpired(t)?(this.clearFlowState(),null):t}catch{return this.clearFlowState(),null}}saveFlowState(e,t,r){const o=Date.now(),n=this.getFlowState(),i={flowType:e,flow_id:t,state:r.state,startedAt:(n==null?void 0:n.startedAt)||o,lastUpdatedAt:o,render_spec:r.render_spec};this.storage.setItem(this.FLOW_STATE_KEY,JSON.stringify(i))}restoreFromHistory(e){const t={flowType:e.flowType,flow_id:e.flow_id,state:e.state,startedAt:e.timestamp,lastUpdatedAt:e.timestamp,render_spec:void 0};this.storage.setItem(this.FLOW_STATE_KEY,JSON.stringify(t))}clearFlowState(){this.storage.removeItem(this.FLOW_STATE_KEY)}isExpired(e){return Date.now()-e.lastUpdatedAt>this.FLOW_EXPIRY_MS}get expiryMs(){return this.FLOW_EXPIRY_MS}},dr,Ii=(dr=class{static detect(t,r=window.location){if(dr.hasInviteToken(r))return"invitation";const o=r.pathname.toLowerCase();return t.invitationUrl&&o.includes(t.invitationUrl)?"invitation":o.includes(t.signinUrl)?"signin":o.includes(t.signupUrl)?"signup":"custom"}static hasInviteToken(t){try{return new URLSearchParams(t.search).has(dr.INVITE_TOKEN_PARAM)}catch{return!1}}},E(dr,"INVITE_TOKEN_PARAM","invite_token"),dr),Fh=class{constructor(){E(this,"listeners",new Map)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var r;(r=this.listeners.get(e))==null||r.delete(t)}emit(e,t){const r=this.listeners.get(e);r&&r.forEach(o=>{try{o(t)}catch(n){console.error(`[FlowEventBus] Error in event handler for ${e}:`,n)}})}clear(){this.listeners.clear()}clearEvent(e){this.listeners.delete(e)}},J$=class{getNavigationType(){const e=performance.getEntriesByType("navigation");if(e.length>0)return e[0].type;const t=performance.navigation;if(t)switch(t.type){case 1:return"reload";case 2:return"back_forward";default:return"navigate"}return"navigate"}},qt,X$=(qt=class{constructor(t,r,o=window.location,n,i){E(this,"httpClient",lo.Instance);E(this,"flowId");E(this,"redirectTimeoutId",null);E(this,"flowStateManager");E(this,"flowEventBus");E(this,"location");E(this,"navigationTypeDetector");E(this,"eventHandlers",new Map([["switch_to_signin",this.handleSwitchToSignin.bind(this)],["switch_to_signup",this.handleSwitchToSignup.bind(this)],["continue_here",this.handleContinueHere.bind(this)]]));E(this,"linkWatchTimer",null);E(this,"linkWatchGeneration",0);E(this,"waitingForLink",!1);const s=K.getConfig();if(!s.domain)throw new H("CONFIG_ERROR","Domain is required");if(!s.appId)throw new H("CONFIG_ERROR","App ID is required");this.flowId=t,this.location=o,this.flowStateManager=n||new Lh,this.flowEventBus=r||new Fh,this.navigationTypeDetector=i||new J$,St.Instance.cleanExpiredSession(),St.Instance.scheduleTokenRefresh()}static async init(t,r,o,n,i){const s=new qt(t,r,o,n,i),d=await s.initializeFlowInternal();return{sdk:s,flowType:d.flowType,isResumed:d.isResumed,state:d.state,render_spec:d.render_spec,auth_result:d.auth_result}}async startFlow(t,r){if(!r.app_id)throw new H("VALIDATION_ERROR","Client ID is required");const o=`/auth/v1/authflows/${t}/start`;return this.executeFlowRequest(()=>this.httpClient.post(o,r),"START_FLOW_ERROR","Failed to start flow")}async resumeFlow(t,r){const o=r?`?continue=${encodeURIComponent(r)}`:"",n=`/auth/v1/authflows/${t}/resume${o}`;return this.executeFlowRequest(()=>this.httpClient.post(n),"RESUME_FLOW_ERROR","Failed to resume flow")}async processEvent(t,r){if(!t.event)throw new H("VALIDATION_ERROR","Event type is required");const o=this.eventHandlers.get(t.event);return o?await o():await this.processServerEvent(t,r)}async executeFlowRequest(t,r,o,n){try{const i=await t();return n&&await n(i),this.processAuthResult(i.auth_result),i.redirection&&this.redirect(i.redirection),i}catch(i){throw i instanceof H?i:new H(r,o,i instanceof Error?{originalError:i.message,stack:i.stack}:i)}}async processServerEvent(t,r){let o=this.flowStateManager.getFlowState();if(!o&&(console.warn("Flow state expired, restarting flow before processing event"),await this.initializeFlowInternal(),o=this.flowStateManager.getFlowState(),!o))throw new H("FLOW_RESTART_ERROR","Failed to restart flow - no flow state after initialization");const n=o.state,i=`/auth/v1/authflows/${o.flowType}/events`,s=this.waitingForLink;this.stopWatchingForLink();let d;try{d=await this.executeFlowRequest(()=>this.httpClient.post(i,t),"PROCESS_EVENT_ERROR","Failed to process event",r)}catch(c){if(s&&qt.flowIsGone(c))return this.announceContinuedElsewhere(o.flowType,""),{state:""};throw c}if(this.watchForLink(o.flowType,d),!d.auth_result){this.flowStateManager.saveFlowState(o.flowType,o.flow_id,d);const c=this.flowStateManager.getFlowState();if(c){const u=n!==d.state;this.flowEventBus.emit("flow:updated",{flowState:c,isNewStep:u})}}return d}processAuthResult(t){if(t){const r={id_token:t.id_token,access_token:t.access_token,refresh_token:t.refresh_token,expires_in:t.expires_in,expires_at:Date.now()+t.expires_in*1e3};St.Instance.setCurrentSession(r),St.Instance.scheduleTokenRefresh(),this.flowStateManager.clearFlowState();const{onAuthenticated:o}=K.getConfig();if(o){o(r);return}console.warn("pontive: signed in, but no onAuthenticated was supplied, so the SDK cannot route the user. Supply onAuthenticated to handle the handoff.")}}async initializeFlowInternal(){const t=K.getConfig(),r=Ii.detect(t,this.location);this.validateFlowType(r);const o=this.flowStateManager.getFlowState();return this.shouldResumeFlow(o,r)?await this.resumeExistingFlow(o,r):await this.startNewFlow(r)}validateFlowType(t){if(t==="custom"&&!this.flowId)throw new H("FLOW_ID_ERROR","Flow ID is required for custom flows")}shouldResumeFlow(t,r){const n=new URLSearchParams(this.location.search).get("resume")==="true";if(!t)return n;const i=this.navigationTypeDetector.getNavigationType();if(i==="navigate"&&!n)return this.flowStateManager.clearFlowState(),console.log(`Fresh navigation detected (type: ${i}), starting new flow`),!1;if(t.flowType!==r)return this.flowStateManager.clearFlowState(),console.log(`Flow type changed from ${t.flowType} to ${r}, starting new flow, flow_id: ${this.flowId}`),!1;if(r==="custom"&&t.flow_id!==this.flowId)return this.flowStateManager.clearFlowState(),console.log(`Custom flow ID changed, starting new flow, flow_id: ${this.flowId}`),!1;const s=n?"explicit resume=true":`navigation type: ${i}`;return console.log(`Resuming existing flow (${s})`),!0}async resumeExistingFlow(t,r){try{const o=await this.resumeFlow(r,this.continueParam());if(this.watchForLink(r,o),!o.auth_result){this.flowStateManager.saveFlowState(r,(t==null?void 0:t.flow_id)??this.determineFlowId(r),o);const n=this.flowStateManager.getFlowState();n&&this.flowEventBus.emit("flow:resumed",{flowState:n})}return{flowType:r,isResumed:!0,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result}}catch(o){return this.flowStateManager.clearFlowState(),console.warn("Failed to resume flow, starting fresh:",o),await this.startNewFlow(r)}}async startNewFlow(t){const r=K.getConfig(),o=new URLSearchParams(this.location.search),n={};o.forEach((c,u)=>{n[u]=c}),r.organizationId&&!n.organization_id&&(n.organization_id=r.organizationId),console.log("metadata",n);const i=o.get("locales")||r.locales||void 0,s={app_id:r.appId,origin_url:this.location.href,signin_url:r.signinUrl,signup_url:r.signupUrl,locales:i,flow_id:this.determineFlowId(t),metadata:n},d=await this.startFlow(t,s);if(this.watchForLink(t,d),!d.auth_result){this.flowStateManager.saveFlowState(t,s.flow_id,d);const c=this.flowStateManager.getFlowState();c&&this.flowEventBus.emit("flow:started",{flowState:c})}return{flowType:t,isResumed:!1,state:d.state,render_spec:d.render_spec,auth_result:d.auth_result}}determineFlowId(t){switch(t){case"signin":return this.flowId||"signin-flow";case"signup":return this.flowId||"signup-flow";case"invitation":return this.flowId||"invitation-flow";case"custom":if(!this.flowId)throw new H("FLOW_ID_ERROR","Flow ID is required for custom flows");return this.flowId}}continueParam(){const t=new URLSearchParams(this.location.search);if(t.get("resume")==="true")return t.get("continue")??void 0}watchForLink(t,r){if(this.stopWatchingForLink(),this.waitingForLink=r.waiting_for_link===!0,!this.waitingForLink)return;const o=this.linkWatchGeneration,n=Date.now()+qt.LINK_POLL_LIMIT_MS,i=()=>{this.linkWatchTimer=setTimeout(s,qt.LINK_POLL_INTERVAL_MS)},s=async()=>{if(o!==this.linkWatchGeneration||Date.now()>n)return;if(typeof document<"u"&&document.hidden){i();return}let d;try{d=await this.httpClient.post(`/auth/v1/authflows/${t}/resume`)}catch(c){o===this.linkWatchGeneration&&qt.flowIsGone(c)&&this.announceContinuedElsewhere(t,"");return}if(o===this.linkWatchGeneration){if(d.waiting_for_link){i();return}this.announceContinuedElsewhere(t,d.state)}};i()}announceContinuedElsewhere(t,r){var o,n;this.stopWatchingForLink(),this.flowStateManager.clearFlowState(),(n=(o=K.getConfig()).onFlowStateChange)==null||n.call(o,{eventType:"flow_continued_elsewhere",flowType:t,state:r})}static flowIsGone(t){return t instanceof H&&t.status===401}stopWatchingForLink(){this.waitingForLink=!1,this.linkWatchGeneration++,this.linkWatchTimer!==null&&(clearTimeout(this.linkWatchTimer),this.linkWatchTimer=null)}async handleContinueHere(){const{continueHereUrl:t}=K.getConfig();this.flowStateManager.clearFlowState();let r=t;if(!r){const o=new URL(this.location.href);o.searchParams.delete("resume"),o.searchParams.delete("continue"),r=o.toString()}return this.redirect({url:r,redirect_delay:0}),{state:"End"}}async handleSwitchToSignin(){const t=K.getConfig();return this.redirect({url:this.withCurrentQuery(t.signinUrl),redirect_delay:0}),{state:"End"}}async handleSwitchToSignup(){const t=K.getConfig();return this.redirect({url:this.withCurrentQuery(t.signupUrl),redirect_delay:0}),{state:"End"}}withCurrentQuery(t){const r=this.location.search;return!r||r==="?"?t:t.includes("?")?`${t}&${r.slice(1)}`:`${t}${r}`}redirect(t){t.url&&(this.redirectTimeoutId!==null&&(console.log("Clearing existing redirect timeout before scheduling new redirect to:",t.url),clearTimeout(this.redirectTimeoutId),this.redirectTimeoutId=null),this.redirectTimeoutId=setTimeout(()=>{this.location.href=t.url},t.redirect_delay*1e3))}reloadPage(){setTimeout(()=>{this.location.reload()},0)}getEventBus(){return this.flowEventBus}cleanup(){this.stopWatchingForLink(),this.redirectTimeoutId&&(clearTimeout(this.redirectTimeoutId),this.redirectTimeoutId=null),this.flowEventBus.clear()}},E(qt,"LINK_POLL_INTERVAL_MS",3e3),E(qt,"LINK_POLL_LIMIT_MS",900*1e3),qt),tP=class{constructor(e){E(this,"delayMs");E(this,"timerId",null);this.delayMs=e}debounce(e){this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>{e(),this.timerId=null},this.delayMs)}cancel(){this.timerId&&(clearTimeout(this.timerId),this.timerId=null)}isPending(){return this.timerId!==null}},eP=class{pushState(e,t,r){history.pushState(e,t,r)}replaceState(e,t,r){history.replaceState(e,t,r)}get state(){return history.state}},rP=class{constructor(e,t,r=!1,o=window.location,n,i){E(this,"popstateListener",null);E(this,"pageshowListener",null);E(this,"debouncer");E(this,"isProcessing",!1);E(this,"isHandlingNavigationEvent",!1);E(this,"onFlowRestartNeeded",null);E(this,"skipHistoryTracking");E(this,"flowStateManager");E(this,"historyAdapter");E(this,"location");this.onFlowRestartNeeded=t,this.skipHistoryTracking=r,this.debouncer=new tP(200),this.location=o,this.flowStateManager=n||new Lh,this.historyAdapter=i||new eP,this.subscribeToFlowEvents(e),this.initializeListener()}subscribeToFlowEvents(e){e.on("flow:started",this.handleFlowStart.bind(this)),e.on("flow:updated",this.handleFlowUpdate.bind(this)),e.on("flow:resumed",this.handleFlowResume.bind(this))}initializeListener(){this.popstateListener=e=>{console.log("[NavigationManager] popstate event received"),this.debouncer.debounce(()=>{console.log("[NavigationManager] Debounce timeout fired, handling popstate"),this.handlePopState(e)})},this.pageshowListener=e=>{e.persisted&&(console.log("[NavigationManager] Page restored from bfcache"),this.debouncer.debounce(()=>{console.log("[NavigationManager] Handling bfcache restoration"),this.handleBfcacheRestoration()}))},window.addEventListener("popstate",this.popstateListener),window.addEventListener("pageshow",this.pageshowListener)}async handlePopState(e){if(this.isProcessing){console.log("[NavigationManager] Already processing popstate, skipping");return}console.log("[NavigationManager] Starting popstate processing"),this.isProcessing=!0,this.isHandlingNavigationEvent=!0;try{const t=e.state,r=this.flowStateManager.getFlowState(),o=K.getConfig(),n=Ii.detect(o,this.location);if(t&&this.restoreHistoryStateToSession(t),this.shouldRestartFlow(t,r,n)){await this.triggerFlowRestart();return}console.log("[NavigationManager] Valid state restored from history")}finally{this.isProcessing=!1,this.isHandlingNavigationEvent=!1}}async handleBfcacheRestoration(){if(this.isProcessing){console.log("[NavigationManager] Already processing bfcache restoration, skipping");return}console.log("[NavigationManager] Starting bfcache restoration processing"),this.isProcessing=!0,this.isHandlingNavigationEvent=!0;try{const e=this.historyAdapter.state,t=this.flowStateManager.getFlowState(),r=K.getConfig(),o=Ii.detect(r,this.location);if(e&&this.restoreHistoryStateToSession(e),this.shouldRestartFlow(e,t,o)){await this.triggerFlowRestart();return}console.log("[NavigationManager] Valid state restored from bfcache")}finally{this.isProcessing=!1,this.isHandlingNavigationEvent=!1}}restoreHistoryStateToSession(e){console.log("[NavigationManager] Restoring history state to session storage:",e),this.flowStateManager.restoreFromHistory(e)}shouldRestartFlow(e,t,r){return e&&e.flowType!==r?(console.log("[NavigationManager] Flow type changed via navigation:",e.flowType,"→",r),this.flowStateManager.clearFlowState(),!0):e?Date.now()-e.timestamp>this.flowStateManager.expiryMs?(console.log("[NavigationManager] History state expired, clearing and restarting flow"),this.flowStateManager.clearFlowState(),!0):(console.log("[NavigationManager] Valid history state restored, triggering restart to resume flow"),!0):(console.log("[NavigationManager] No history state, skipping"),!1)}async triggerFlowRestart(){this.onFlowRestartNeeded&&await this.onFlowRestartNeeded()}createHistoryState(e){return{flowType:e.flowType,flow_id:e.flow_id,state:e.state,timestamp:Date.now()}}updateBrowserHistory(e,t){if(this.skipHistoryTracking){console.log("[NavigationManager] Skipping history tracking (created from navigation)");return}const r=this.createHistoryState(e);try{t==="push"?(this.historyAdapter.pushState(r,"",this.location.href),console.log("[NavigationManager] Pushed state to history")):(this.historyAdapter.replaceState(r,"",this.location.href),console.log("[NavigationManager] Replaced state in history"))}catch(o){console.error("[NavigationManager] Failed to update history:",o)}}handleFlowStart(e){this.updateBrowserHistory(e.flowState,"replace")}handleFlowUpdate(e){const t=this.isHandlingNavigationEvent||!e.isNewStep?"replace":"push";this.updateBrowserHistory(e.flowState,t)}handleFlowResume(e){this.updateBrowserHistory(e.flowState,"replace")}destroy(){this.debouncer.cancel(),this.popstateListener&&(window.removeEventListener("popstate",this.popstateListener),this.popstateListener=null),this.pageshowListener&&(window.removeEventListener("pageshow",this.pageshowListener),this.pageshowListener=null),this.onFlowRestartNeeded=null}},Rr=new AbortController,nP=class{constructor(){E(this,"httpClient",lo.Instance);E(this,"capabilities",{webauthn:!1});E(this,"capabilitiesDetected",!1)}async detectCapabilities(){if(!this.capabilitiesDetected)try{if(typeof window.PublicKeyCredential=="function"?this.capabilities.webauthn=!0:this.capabilities.webauthn=!1,typeof PublicKeyCredential.getClientCapabilities=="function"){const e=await PublicKeyCredential.getClientCapabilities();this.capabilities={...this.capabilities,...e};return}typeof PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable=="function"&&(this.capabilities.userVerifyingPlatformAuthenticator=await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()),(PublicKeyCredential==null?void 0:PublicKeyCredential.isConditionalMediationAvailable)!==void 0&&typeof PublicKeyCredential.isConditionalMediationAvailable=="function"?this.capabilities.conditionalGet=await PublicKeyCredential.isConditionalMediationAvailable():this.capabilities.conditionalGet=!1}finally{this.capabilitiesDetected=!0}}async fetchPublicKeyCredentialRequestOptions(e,t){try{return this.httpClient.post("/auth/v1/webauthn/login/options",{conditional:t,flow_type:e})}catch(r){return console.error("error",r),null}}async fetchPublicKeyCredentialCreationOptions(e,t){try{return this.httpClient.post("/auth/v1/webauthn/register/options",{conditional:t,flow_type:e})}catch(r){return console.error("error",r),null}}async startRegistration(e,t){if(await this.detectCapabilities(),!e)return console.error("No PublicKeyCredentialCreationOptionsJSON provided"),null;Rr.abort(),Rr=new AbortController;const r=this.toPublicKeyCredentialCreationOptions(e),o={signal:Rr.signal,publicKey:r};if(t){if(!this.isConditionalCreateAvailable())return console.error("Conditional create mediation not supported in this browser"),null;o.mediation="conditional"}try{const n=await navigator.credentials.create(o);if(!n){console.error("no credential returned by authenticator");return}const{id:i,rawId:s,response:d,type:c}=n;let u;typeof d.getTransports=="function"&&(u=d.getTransports());let v;if(typeof d.getPublicKeyAlgorithm=="function")try{v=d.getPublicKeyAlgorithm()}catch(_){hs("getPublicKeyAlgorithm()",_)}let b;if(typeof d.getPublicKey=="function")try{const _=d.getPublicKey();_!==null&&(b=this.bufferToBase64URLString(_))}catch(_){hs("getPublicKey()",_)}let w;if(typeof d.getAuthenticatorData=="function")try{w=this.bufferToBase64URLString(d.getAuthenticatorData())}catch(_){hs("getAuthenticatorData()",_)}return{id:i,rawId:this.bufferToBase64URLString(s),response:{attestationObject:this.bufferToBase64URLString(d.attestationObject),clientDataJSON:this.bufferToBase64URLString(d.clientDataJSON),transports:u,publicKeyAlgorithm:v,publicKey:b,authenticatorData:w},type:c,clientExtensionResults:n.getClientExtensionResults(),authenticatorAttachment:this.toAuthenticatorAttachment(n.authenticatorAttachment)}}catch(n){const i=this.identifyAuthenticationError({error:n,options:o});return i instanceof Ir?console.error(`WebAuthn authentication failed with code: ${i.code}, message: ${i.message}`):console.error("WebAuthn authentication failed with error:",n),null}}async startAuthentication(e,t){if(await this.detectCapabilities(),!e)return console.error("No PublicKeyCredentialRequestOptionsJSON provided"),null;if(!this.isWebAuthnAvailable())return console.error("WebAuthn not supported in this browser"),null;Rr.abort(),Rr=new AbortController;const r=this.toPublicKeyCredentialRequestOptions(e),o={signal:Rr.signal,publicKey:r};if(t){if(!this.isConditionalGetAvailable())return console.error("Conditional mediation not supported in this browser"),null;o.mediation="conditional",o.publicKey&&(o.publicKey.allowCredentials=[])}try{const n=await navigator.credentials.get(o);return this.toPublicKeyCredentialJSON(n)}catch(n){const i=this.identifyAuthenticationError({error:n,options:o});return i instanceof Ir?console.error(`WebAuthn authentication failed with code: ${i.code}, message: ${i.message}`):console.error("WebAuthn authentication failed with error:",n),null}}async signalUnknownCredential(e,t){if(await this.detectCapabilities(),this.isSignalUnknownCredentialAvailable())try{await PublicKeyCredential.signalUnknownCredential({rpId:e,credentialId:t})}catch(r){console.error("Failed to signal unknown credential:",r)}else console.warn("signalUnknownCredential not supported in this browser")}async signalCurrentUserDetails(e){if(await this.detectCapabilities(),this.isSignalCurrentUserDetailsAvailable())try{await PublicKeyCredential.signalCurrentUserDetails(e)}catch(t){console.error("Failed to signal current user details:",t)}else console.warn("signalCurrentUserDetails not supported. Ask user to update manually.")}toPublicKeyCredentialDescriptor(e){const{id:t}=e;return{...e,id:this.base64URLStringToBuffer(t),type:e.type,transports:e.transports}}toAuthenticatorAttachment(e){const t=["cross-platform","platform"];if(e&&!(t.indexOf(e)<0))return e}bufferToBase64URLString(e){const t=new Uint8Array(e);let r="";for(const n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}base64URLStringToBuffer(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,o=t.padEnd(t.length+r,"="),n=atob(o),i=new ArrayBuffer(n.length),s=new Uint8Array(i);for(let d=0;d<n.length;d++)s[d]=n.charCodeAt(d);return i}toPublicKeyCredentialJSON(e){if(typeof e.toJSON=="function")return e.toJSON();const t=e.response;return{id:e.id,type:e.type,rawId:this.bufferToBase64URLString(e.rawId),authenticatorAttachment:this.toAuthenticatorAttachment(e.authenticatorAttachment),clientExtensionResults:e==null?void 0:e.getClientExtensionResults(),response:{clientDataJSON:this.bufferToBase64URLString(t.clientDataJSON),authenticatorData:this.bufferToBase64URLString(t.authenticatorData),signature:this.bufferToBase64URLString(t.signature),userHandle:t.userHandle?this.bufferToBase64URLString(t.userHandle):void 0}}}toPublicKeyCredentialCreationOptions(e){var r;if(typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const t={challenge:this.base64URLStringToBuffer(e.challenge),rp:{id:e.rp.id,name:e.rp.name},user:{displayName:e.user.displayName,id:this.base64URLStringToBuffer(e.user.id),name:e.user.name},pubKeyCredParams:e.pubKeyCredParams.map(o=>({alg:o.alg,type:o.type})),timeout:e.timeout};if(e.attestation&&(t.attestation=e.attestation),e.extensions!==void 0&&(t.extensions=e.extensions),e.authenticatorSelection){const o={};e.authenticatorSelection.authenticatorAttachment&&(o.authenticatorAttachment=e.authenticatorSelection.authenticatorAttachment),e.authenticatorSelection.requireResidentKey&&(o.requireResidentKey=e.authenticatorSelection.requireResidentKey),e.authenticatorSelection.residentKey&&(o.residentKey=e.authenticatorSelection.residentKey),e.authenticatorSelection.userVerification&&(o.userVerification=e.authenticatorSelection.userVerification),t.authenticatorSelection=o}return(r=e.excludeCredentials)!=null&&r.length&&(t.excludeCredentials=e.excludeCredentials.map(o=>this.toPublicKeyCredentialDescriptor(o))),t}toPublicKeyCredentialRequestOptions(e){var r;if(typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(e);const t={challenge:this.base64URLStringToBuffer(e.challenge)};return e.rpId!==void 0&&(t.rpId=e.rpId),e.timeout!==void 0&&(t.timeout=e.timeout),e.userVerification!==void 0&&(t.userVerification=e.userVerification),e.extensions!==void 0&&(t.extensions=e.extensions),(r=e.allowCredentials)!=null&&r.length&&(t.allowCredentials=e.allowCredentials.map(o=>this.toPublicKeyCredentialDescriptor(o))),t}identifyAuthenticationError({error:e,options:t}){const{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Ir({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new Ir({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const o=window.location.hostname;if(oP(o)){if(r.rpId!==o)return new Ir({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Ir({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new Ir({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}isPublicKeyCredentialRequestOptionsJSON(e){return typeof e=="object"&&e!==null&&"challenge"in e}isWebAuthnAvailable(){return this.capabilities.webauthn}isSignalAllAcceptedCredentialsAvailable(){return!!this.capabilities.signalAllAcceptedCredentials}isSignalCurrentUserDetailsAvailable(){return!!this.capabilities.signalCurrentUserDetails}isSignalUnknownCredentialAvailable(){return!!this.capabilities.signalUnknownCredential}isConditionalGetAvailable(){return!!this.capabilities.conditionalGet}isConditionalCreateAvailable(){return!!this.capabilities.conditionalCreate}isHybridTransportAvailable(){return!!this.capabilities.hybridTransport}destroy(){Rr.abort()}};function hs(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
|
|
2649
|
-
`,t)}var Ir=class extends Error{constructor({message:t,code:r,cause:o,name:n}){super(t);E(this,"code");this.name=n??o.name,this.code=r}};function oP(e){return e==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var we,iP=(we=class{constructor(){E(this,"configured",!1);E(this,"configuredResolve");E(this,"configuredPromise",new Promise(t=>{this.configuredResolve=t}));E(this,"loginflow",null);E(this,"navigationManager",null);E(this,"flowEventBus",null);E(this,"webauthnService",null)}static get Instance(){return we.instance||(we.instance=new we),we.instance}ensureConfigured(){if(!this.configured)throw new H("NOT_CONFIGURED","Auth.configure() must be called before using Auth methods")}ensureLoginflowInitialized(){if(!this.loginflow)throw new H("LOGINFLOW_NOT_INITIALIZED","Call Auth.startLoginflow() first")}async startLoginflowInternal(t,r=!1){this.ensureConfigured(),this.webauthnService&&(console.log("[AuthService] Cleaning up and aborting ongoing webauthn flows"),this.webauthnService.destroy(),this.webauthnService=null),this.loginflow&&(console.log("[AuthService] Cleaning up old loginflow instance"),this.loginflow.cleanup(),this.loginflow=null),this.navigationManager&&(console.log("[AuthService] Cleaning up old navigation manager instance"),this.navigationManager.destroy(),this.navigationManager=null),this.webauthnService=new nP,this.webauthnService.detectCapabilities(),this.flowEventBus=new Fh,this.navigationManager=new rP(this.flowEventBus,async()=>{console.log("[AuthService] Navigation restart triggered, restarting loginflow"),await this.startLoginflowInternal(void 0,!1)},r);const o=await X$.init(t,this.flowEventBus),n=K.getConfig();this.startPasskeyAuthentication(o.flowType,!0),this.loginflow=o.sdk;const i={flowType:o.flowType,isResumed:o.isResumed,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result};return n.onFlowStateChange&&n.onFlowStateChange({eventType:o.isResumed?"flow_resumed":"flow_started",flowType:o.flowType,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result,isResumed:o.isResumed}),i}configure(t){if(!t.domain||!t.appId)throw new H("CONFIG_ERROR","domain and appId are required");K.setConfig(t),this.configured=!0,this.configuredResolve()}whenConfigured(){return this.configuredPromise}isAuthenticated(){return this.ensureConfigured(),St.Instance.isAuthenticated()}getCurrentSession(){return this.ensureConfigured(),St.Instance.getCurrentSession()}async restoreSession(){return this.ensureConfigured(),St.Instance.restoreSession()}getAuthenticatedUser(){return this.ensureConfigured(),St.Instance.getAuthenticatedUser()}getOrganization(){return this.ensureConfigured(),St.Instance.getOrganization()}async switchOrganization(t){return this.ensureConfigured(),St.Instance.switchOrganization(t)}async startLoginflow(t){return this.startLoginflowInternal(t,!1)}async processLoginflowEvent(t){var i,s;this.ensureConfigured(),this.ensureLoginflowInitialized();const r=K.getConfig(),o=Ii.detect(r,location);if(t.event==="signin_with_passkey"&&!((i=t.data)!=null&&i.credential_request)){const d=await this.getPasskeyCredential(o,!1);if(!d||!d.cred)return console.error("no credential returned by browser"),{state:""};t.data={credential_request:d.cred}}if(t.event==="register_passkey"&&!((s=t.data)!=null&&s.conditional)){console.log("attempt to register a passkey");const d=await this.createPasskeyCredential(o,!1);if(!d)return console.error("no credential created by browser"),{state:""};t.data={credential_creation_response:d,conditional:!1}}const n=await this.loginflow.processEvent(t,async d=>{var c;if((c=d.data)!=null&&c.conditional_create_enabled){console.log("attempt to register a passkey conditionally");const u=await this.registerPasskey(o,!0);u&&(u.render_spec=void 0,d.render_spec=void 0)}});if(console.log("render spec",n.render_spec),r.onFlowStateChange){const d=sessionStorage.getItem("pontive_loginflow_state");let c="custom";if(d)try{c=JSON.parse(d).flowType}catch(u){console.error("Failed to parse flow state:",u)}r.onFlowStateChange({eventType:"flow_updated",flowType:c,state:n.state,render_spec:n.render_spec,auth_result:n.auth_result})}return n}async getPasskeyCredential(t,r){var n,i;const o=await((n=this.webauthnService)==null?void 0:n.fetchPublicKeyCredentialRequestOptions(t,r));if(!o)return console.error("failed to fetch public key request options"),null;try{return{cred:await((i=this.webauthnService)==null?void 0:i.startAuthentication(o,r)),options:o}}catch(s){return console.error("error starting authentication",s),null}}async startPasskeyAuthentication(t,r=!1){var s,d;const o=await this.getPasskeyCredential(t,r);if(!o||!o.cred){console.error("no credential found");return}const{cred:n,options:i}=o;try{((s=(await this.processLoginflowEvent({event:"signin_with_passkey",data:{credential_request:n}})).data)==null?void 0:s.error)==="CredentialNotFound"&&(i.rpId&&n.id?(d=this.webauthnService)==null||d.signalUnknownCredential(i.rpId,n.id):console.log("missing rpId or credential id for signalUnknownCredential"))}catch(c){console.error("failed to signin with passkey",c)}}async createPasskeyCredential(t,r){var o,n;try{const i=await((o=this.webauthnService)==null?void 0:o.fetchPublicKeyCredentialCreationOptions(t,r));if(!i){console.warn("no credential creation option returned by webauthn service"),console.log("skipping conditional passkey registration...");return}return(n=this.webauthnService)==null?void 0:n.startRegistration(i,r)}catch(i){console.log("error",i)}}async registerPasskey(t,r=!1){try{const o=await this.createPasskeyCredential(t,r),n=await this.processLoginflowEvent({event:"register_passkey",data:{credential_creation_response:o,conditional:r}});return console.log("passkey creation res",n),n}catch(o){console.log("error",o)}}invalidateSession(){St.Instance.clearSession()}async signOut(t){var n;this.ensureConfigured();const r=sP(St.Instance.peekSession()),o=((n=K.getConfig())==null?void 0:n.appId)??"";if(Oa(),St.Instance.clearSession(),St.Instance.cleanup(),this.loginflow&&(this.loginflow.cleanup(),this.loginflow=null),this.navigationManager&&(this.navigationManager.destroy(),this.navigationManager=null),this.flowEventBus&&(this.flowEventBus.clear(),this.flowEventBus=null),!K.apiIsSameOrigin()){window.location.assign(this.logoutUrl(r,o,t==null?void 0:t.returnTo));return}await this.endServerSession(r,o),window.location.reload()}async endServerSession(t,r){try{await fetch(`${K.getApiBaseUrl()}/oauth2/logout`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:r,...t?{logout_hint:t}:{}}).toString()})}catch(o){console.warn("Could not end the session at the authorization server:",o)}}logoutUrl(t,r,o){const n=new URLSearchParams({post_logout_redirect_uri:o??`${window.location.origin}${window.location.pathname}`,client_id:r});return t&&n.set("logout_hint",t),`${K.getApiBaseUrl()}/oauth2/logout?${n.toString()}`}},E(we,"instance"),we);function sP(e){for(const t of[e==null?void 0:e.id_token,e==null?void 0:e.access_token]){if(!t)continue;const r=St.Instance.decodeJWT(t);if(typeof(r==null?void 0:r.sid)=="string"&&r.sid)return r.sid}}var G=iP.Instance,aP=Object.defineProperty,lP=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&aP(t,r,n),n};class Ut extends f{constructor(){super(),this.shadow=!1,this.__initialAttributesCache=null}parseJsonAttribute(t){try{const r=this.getAttribute(t);return r?JSON.parse(r):{}}catch{return{}}}get sbStyle(){return this.parseJsonAttribute("pont-style")}getAttributesToExclude(){return[]}getFilteredAttributes(){const t={};return Array.from(this.attributes).forEach(r=>{this.getAttributesToExclude().includes(r.name)||(t[r.name]=r.value??"")}),t}isCustomPropertySet(t){const r=getComputedStyle(this).getPropertyValue(t).trim();return r!=="inherit"&&r.length>0}applyCustomClass(t,r,o=""){var n,i;t.some(s=>this.isCustomPropertySet(s))&&((i=(n=this.shadowRoot)==null?void 0:n.querySelector(r))==null||i.classList.add(o))}moveAttributesToElement(t,r=["id","class"]){t&&r.forEach(o=>{const n=this.getAttribute(o);n!==null&&(t.setAttribute(o,n),this.removeAttribute(o))})}removeAttributesFromHost(t=["id","class"]){t.forEach(r=>{this.hasAttribute(r)&&this.removeAttribute(r)})}captureHostAttributes(){if(this.__initialAttributesCache)return this.__initialAttributesCache;const t={};return Array.from(this.attributes).forEach(r=>{t[r.name]=r.value}),this.__initialAttributesCache=t,t}getHostClass(){return this.captureHostAttributes().class??""}removeDuplicateContent(){var i;const t=document.createTreeWalker(this,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{var d;return s.nodeType===Node.COMMENT_NODE||s.nodeType===Node.TEXT_NODE&&!((d=s.textContent)!=null&&d.trim())?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=new Map,o=[];let n;for(;n=t.nextNode();){let s;if(n.nodeType===Node.TEXT_NODE){const d=(i=n.textContent)==null?void 0:i.trim();if(!d)continue;s=`text:${d}`}else if(n instanceof HTMLElement){const d=Array.from(n.attributes).map(c=>`${c.name}=${c.value}`).sort().join(":");s=`element:${n.tagName}:${d}`}else continue;if(r.has(s)){const d=r.get(s);d!=null&&d.parentNode&&o.push(d),r.set(s,n)}else r.set(s,n)}o.forEach(s=>{var d;return(d=s.parentNode)==null?void 0:d.removeChild(s)})}moveLightDomChildrenInto(t,r){let o;r!=null&&r.length?(o=r.filter(n=>this.contains(n)&&n!==t&&!n.contains(t)),o.forEach(n=>{const i=Array.from(t.childNodes).find(s=>{var d;return(d=s.isEqualNode)==null?void 0:d.call(s,n)});i&&t.removeChild(i)})):o=Array.from(this.childNodes).filter(n=>n!==t&&!t.contains(n)&&!n.contains(t)),o.forEach(n=>t.appendChild(n))}}lP([a({type:Boolean})],Ut.prototype,"shadow");const Pr="pont:auth",Lo={showWatermark:!0},Bi="pont:branding";class dP{constructor(t){this.consumer=new ui(t,{context:Bi,subscribe:!0})}get showWatermark(){var t;return((t=this.consumer.value)==null?void 0:t.showWatermark)??Lo.showWatermark}}const kh="pont:design-mode";class Fo{constructor(t){this.host=t,this.consumer=new ui(t,{context:kh,subscribe:!0})}get active(){return this.host.hasAttribute("design-mode")?this.host.getAttribute("design-mode")!=="false":this.consumer.value??!1}}const Nh="pont:env",Mh=Symbol("renderSpecContext"),ko="pont-user-context",Bh="";function zt(...e){return Ap(ja(e))}function cP(e){return Object.entries(e).filter(([t,r])=>typeof r!="object"&&r!=null).map(([t,r])=>`${t}: ${r};`).join(" ")}function pP(e){document.documentElement.setAttribute("data-theme",e)}function hP(){const e=document.documentElement.getAttribute("data-theme");(!e||e!=="light"&&e!=="dark")&&pP("light")}function uP(e,t){return e?e.includes("{{theme}}")?e.replace("{{theme}}",t):e:""}function Ia(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const Lc="abcdefghijklmnopqrstuvwxyz0123456789",mP=6;function gP(e){let t="";for(let r=0;r<mP;r++)t+=Lc.charAt(Math.floor(Math.random()*Lc.length));return t}const _t=()=>gP();function Ui(e){const t=document.createElement("pont-toast"),r=document.createElement("pont-toast-view-port");r.part="user-profile-toast",r.setAttribute("variant","destructive"),t.dataset.state="open";const o=document.createElement("div");o.className="pont-grid pont-gap-1";const n=document.createElement("pont-toast-title");n.textContent="Uh oh! Something went wrong.";const i=document.createElement("pont-toast-description");i.textContent=e,o.appendChild(n),o.appendChild(i),r.appendChild(o),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>{t.dataset.state="open",r.dataset.state="open"},10),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},3.5*1e3)}async function fP(e,t=5e3){if(!e)return;let r;const o=new Promise(n=>{r=setTimeout(()=>n("timeout"),t)});try{await Promise.race([e.whenConfigured(),o])==="timeout"&&console.warn(`pontive: Auth.configure() has not been called after ${t}ms. Is this widget mounted inside <pont-provider>?`)}finally{clearTimeout(r)}}function vP(e){if(!(e!=null&&e.startsWith("data:image/svg+xml;base64,")))return null;try{const t=e.replace("data:image/svg+xml;base64,","");return atob(t)}catch(t){return console.error("Invalid base64 SVG:",t),null}}function bP(e){return/^https?:\/\//.test(e)||e!=null&&e.startsWith("data:image/svg+xml;base64,")?e:`data:image/svg+xml;base64,${e}`}function le(){var e;return(e=G.getCurrentSession())==null?void 0:e.access_token}function Aa(e,t=!1){if(!e&&e!==0)return"N/A";const r=typeof e=="string"?new Date(e):new Date(t?e:e*1e3);if(isNaN(r.getTime()))return"Invalid Date";const o=new Date,n=new Date(o.getFullYear(),o.getMonth(),o.getDate()),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=Math.floor((n.getTime()-i.getTime())/(1e3*60*60*24));return s===0?"Today":s===1?"Yesterday":s>1&&s<=6?r.toLocaleDateString("en-US",{weekday:"long"}):r.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Ta(e,t=!1){if(!e&&e!==0)return"N/A";const r=typeof e=="string"?new Date(e):new Date(t?e:e*1e3);return isNaN(r.getTime())?"Invalid Time":r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function ji(e){if(!e)return"";const r=(e.includes("@")?e.split("@")[0]:e).split(/[\s._-]+/).filter(Boolean);return r.length===0?"":r.length===1?r[0].slice(0,2).toUpperCase():`${r[0][0]}${r[r.length-1][0]}`.toUpperCase()}function yP(e){return e instanceof Error&&"status"in e}function qi(e,t){var r,o;return yP(e)?((o=(r=e.data)==null?void 0:r.error)==null?void 0:o.message)??e.message??t:e instanceof Error&&e.message||t}const cn={variant:"secondary",size:"default",content:"label",iconAlign:"start",label:"Continue with Passkey"},pn={variant:"outline",size:"default",content:"icon-label",iconAlign:"start",prompt:"Continue with"},hn={variant:"default",size:"default",content:"label",iconAlign:"end",label:"Submit"},_P={apple:"Apple",discord:"Discord",facebook:"Facebook",github:"GitHub",google:"Google",linkedin:"LinkedIn",meta:"Meta",microsoft:"Microsoft",x:"X"},wP={apple:U`<path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" />`,discord:U`<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" />`,facebook:U`<path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z" />`,github:U`<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />`,google:U`<path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />`,linkedin:U`<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />`,meta:U`<path d="M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z" />`,microsoft:U`<path d="M11.4 24H0V12.6h11.4V24zM24 24H12.6V12.6H24V24zM11.4 11.4H0V0h11.4v11.4zM24 11.4H12.6V0H24v11.4z" />`,x:U`<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.763l7.726-8.835L1.254 2.25H8.08l4.713 6.231 5.45-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z" />`};var $P=Object.defineProperty,PP=Object.getOwnPropertyDescriptor,Yt=(e,t,r,o)=>{for(var n=o>1?void 0:o?PP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&$P(t,r,n),n};exports.PontPasskeyButton=class extends f{constructor(){super(...arguments),this.seed=_t(),this.variant=cn.variant,this.size=cn.size,this.content=cn.content,this.iconAlign=cn.iconAlign,this._label=cn.label,this._loading=!1,this._handleClick=async()=>{if(!this.isDisabled){this._loading=!0,this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.CLICK_EVENT,{detail:{id:this.rootId,event:this.event},bubbles:!0,composed:!0}));try{if(this.event){const t=await G.processLoginflowEvent({event:this.event});this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.SUCCESS_EVENT,{detail:{id:this.rootId,event:this.event,result:t},bubbles:!0,composed:!0}))}}catch(t){const r=t instanceof Error?t.message:String(t);this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.ERROR_EVENT,{detail:{id:this.rootId,event:this.event,message:r,error:t},bubbles:!0,composed:!0}))}finally{this._loading=!1}}}}get label(){return this._label}set label(t){const r=this._label;this._label=t.length?t:cn.label,this.requestUpdate("label",r)}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontPasskeyButton.TAG}-${this.seed}`}get iconId(){return`${this.rootId}-${exports.PontPasskeyButton.ICON}`}get isLoading(){return this.loading||this._loading}get isDisabled(){return this.disabled||this.isLoading}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleClick)}_renderIcon(){const t=this.content==="icon"?"":`pont-icon-align-${this.iconAlign}`;return this.isLoading?l`
|
|
2648
|
+
`}};ft([a({type:String})],dt.prototype,"placeholder",2);ft([a({type:Array})],dt.prototype,"dataTable",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultSelect",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultPagination",2);ft([a({type:Boolean})],dt.prototype,"hasDefaultSearch",2);ft([a({type:Object})],dt.prototype,"checkedRows",2);ft([a({type:String})],dt.prototype,"searchTerm",2);ft([a({type:Object})],dt.prototype,"columnVisibility",2);ft([a({type:String})],dt.prototype,"sortColumn",2);ft([a({type:String})],dt.prototype,"sortDirection",2);ft([a({type:Object})],dt.prototype,"cellRenderers",2);ft([a({type:Object})],dt.prototype,"headerRenderers",2);ft([a({type:Array})],dt.prototype,"rowActions",2);ft([a({type:Array})],dt.prototype,"paginationLabels",2);ft([a({type:Number})],dt.prototype,"pageSize",2);ft([a({type:Number})],dt.prototype,"currentPage",2);ft([a({type:Array})],dt.prototype,"sortableColumns",2);ft([a({type:Array})],dt.prototype,"columnOrder",2);ft([a({type:Function})],dt.prototype,"isRowDisabled",2);dt=ft([p("pont-data-table")],dt);var H=class extends Error{constructor(t,r,o,n){super(r);E(this,"code");E(this,"details");E(this,"status");this.name="LoginflowError",this.code=t,this.details=o,this.status=n}};function Ah(e){const t=(e??"").trim();if(!t)throw new H("CONFIG_ERROR","domain is required");if(t.startsWith("/")){if(typeof location>"u")throw new H("CONFIG_ERROR",`domain "${t}" is relative to the page origin, and there is no page here`);return Dc(new URL(t,location.origin))}const r=/^https?:\/\//i.test(t)?"":`${j$(U$(t))?"http":"https"}://`;try{return Dc(new URL(`${r}${t}`))}catch{throw new H("CONFIG_ERROR",`domain "${t}" is not a hostname, an origin, or a path`)}}function Dc(e){return`${e.origin}${e.pathname}`.replace(/\/+$/,"")}function U$(e){return e.split("/")[0]}function j$(e){return/^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/i.test(e)}var ye,q$=(ye=class{constructor(){E(this,"data",new Map)}static get Instance(){return ye.instance||(ye.instance=new ye),ye.instance}get(t){return this.data.get(t)}set(t,r){this.data.set(t,r)}setConfig(t){this.data.set("config",t)}getConfig(){return this.data.get("config")}getApiBaseUrl(){return Ah(this.getConfig().domain)}apiIsSameOrigin(){if(typeof location>"u")return!1;try{return new URL(this.getApiBaseUrl()).host===location.host}catch{return!1}}remove(t){this.data.delete(t)}clear(){this.data.clear()}},E(ye,"instance"),ye),G=q$.Instance,_e,lo=(_e=class{constructor(){}static get Instance(){return _e.instance||(_e.instance=new _e),_e.instance}async request(t,r={}){const o=G.getConfig(),n=`${G.getApiBaseUrl()}${t}`,i=5e4,s=new AbortController,d=setTimeout(()=>s.abort(),i);try{const c=await fetch(n,{...r,signal:s.signal,headers:{"Content-Type":"application/json",...o.headers,...r.headers}});if(clearTimeout(d),!c.ok){const u=await c.json().catch(()=>({}));throw new H(u.code||u.error||"API_ERROR",u.message||u.error_description||`HTTP ${c.status}: ${c.statusText}`,u.details,c.status)}return await c.json()}catch(c){throw clearTimeout(d),c instanceof H?c:c instanceof Error?c.name==="AbortError"?new H("TIMEOUT","Request timeout"):new H("NETWORK_ERROR",c.message):new H("UNKNOWN_ERROR","An unknown error occurred")}}async post(t,r){return this.request(t,{credentials:"include",method:"POST",body:r?JSON.stringify(r):void 0})}async get(t){return this.request(t,{credentials:"include",method:"GET"})}async getOptional(t){const r=G.getConfig(),o=await fetch(`${G.getApiBaseUrl()}${t}`,{credentials:"include",method:"GET",headers:{...r.headers}});if(o.status===204)return null;if(!o.ok)throw new H("API_ERROR",`HTTP ${o.status}: ${o.statusText}`,void 0,o.status);return await o.json()}async postForm(t,r){return this.request(t,{credentials:"include",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(r).toString()})}},E(_e,"instance"),_e),Th="__Secure-pontive_session_state",ps="__Secure-pontive_session_probe";function z$(){return Dh(Th)?"present":V$()?"absent":"unknown"}function Oa(){if(!(typeof document>"u"||typeof location>"u"))for(const e of["",...K$(location.hostname)])Ra(Th,"",e,0)}function V$(){if(typeof document>"u"||typeof location>"u")return!1;const e=G$();try{Ra(ps,"1",e,60);const t=Dh(ps)==="1";return Ra(ps,"",e,0),t&&H$(e)}catch{return!1}}function H$(e){return e!==""||G.apiIsSameOrigin()}function G$(){let e;try{e=new URL(G.getApiBaseUrl()).hostname}catch{return""}const t=location.hostname;if(!e||!t||e.toLowerCase()===t.toLowerCase())return"";const r=t.split("."),o=e.split(".");let n=0;for(;n<r.length&&n<o.length&&r[r.length-1-n].toLowerCase()===o[o.length-1-n].toLowerCase();)n+=1;return n<2?"":o.slice(o.length-n).join(".")}function K$(e){const t=e.split("."),r=[];for(let o=1;o+2<=t.length;o+=1)r.push(t.slice(o).join("."));return r}function Ra(e,t,r,o){const n=W$()?"; Secure":"",i=r?`; Domain=${r}`:"";document.cookie=`${e}=${t}; Path=/; Max-Age=${o}; SameSite=Lax${i}${n}`}function W$(){return typeof globalThis.isSecureContext=="boolean"?globalThis.isSecureContext:location.protocol==="https:"}function Dh(e){if(typeof document>"u"||!document.cookie)return null;for(const t of document.cookie.split(";")){const r=t.indexOf("=");if(!(r<0)&&t.slice(0,r).trim()===e)return t.slice(r+1).trim()||null}return null}var Pt,St=(Pt=class{constructor(){E(this,"AUTH_SESSION_STORAGE_KEY","pontive_auth_session");E(this,"memorySession",null);E(this,"refreshTimeoutId",null);E(this,"refreshPromise",null);E(this,"refreshRetryCount",0);E(this,"refreshBlockedUntil",0);E(this,"sessionGeneration",0);E(this,"channel",null);E(this,"channelName","");E(this,"applyingBroadcast",!1);E(this,"restorePromise",null)}static get Instance(){return Pt.instance||(Pt.instance=new Pt),Pt.instance}setCurrentSession(t){this.sessionGeneration+=1,this.write(JSON.stringify(t)),this.publish({type:"session",session:t})}async withRefreshLock(t){const r=typeof navigator<"u"?navigator.locks:void 0;return r?r.request(this.channelKey("refresh"),t):t()}channelKey(t){const r=G.getConfig();return`pontive-${t}:${(r==null?void 0:r.domain)??""}:${(r==null?void 0:r.appId)??""}`}ensureChannel(){var r;if(typeof BroadcastChannel>"u")return null;const t=this.channelKey("session");return this.channel&&this.channelName===t?this.channel:((r=this.channel)==null||r.close(),this.channelName=t,this.channel=new BroadcastChannel(t),this.channel.onmessage=o=>this.receive(o.data),this.channel)}publish(t){var r;this.applyingBroadcast||(r=this.ensureChannel())==null||r.postMessage(t)}receive(t){this.applyingBroadcast=!0;try{if(t.type==="cleared"){this.clearSession();return}this.setCurrentSession(t.session),this.scheduleTokenRefresh()}finally{this.applyingBroadcast=!1}}isCurrentGeneration(t){return this.sessionGeneration===t}getCurrentSession(){const t=this.getStoredSession();return t?this.isSessionExpired(t)?(this.clearSession(),null):(this.shouldRefreshToken(t)&&this.triggerBackgroundRefresh(t),t):null}peekSession(){return this.getStoredSession()}isAuthenticated(){return this.getCurrentSession()!==null}getAuthenticatedUser(){const t=this.getCurrentSession();if(!t)return null;const r=t.id_token?this.decodeJWT(t.id_token):null;return r||(t.user??null)}cleanup(){var t;this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshPromise=null,(t=this.channel)==null||t.close(),this.channel=null,this.channelName=""}clearSession(){this.sessionGeneration+=1,this.memorySession=null,localStorage.removeItem(this.AUTH_SESSION_STORAGE_KEY),this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshRetryCount=0,this.refreshBlockedUntil=0,this.publish({type:"cleared"})}isSessionExpired(t){return!t||!t.expires_at?!0:Date.now()>=t.expires_at}cleanExpiredSession(){const t=this.getStoredSession();t&&this.isSessionExpired(t)&&this.clearSession()}getStoredSession(){const t=this.read();if(!t)return null;try{return JSON.parse(t)}catch{return this.clearSession(),null}}write(t){this.memorySession=t,localStorage.removeItem(this.AUTH_SESSION_STORAGE_KEY)}read(){return this.memorySession}decodeJWT(t){try{const o=t.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(o).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join(""));return JSON.parse(n)}catch{return null}}shouldRefreshToken(t){if(!t||!t.expires_at)return!1;const r=Date.now(),o=t.expires_at,n=t.expires_in||3600,i=r+n*1e3*.2;return o<=i}scheduleTokenRefresh(){this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null);const t=this.getCurrentSession();if(!t||!t.expires_at)return;const r=Date.now(),o=t.expires_at,n=t.expires_in||3600,i=o-r-n*1e3*.2;i>0&&(this.refreshTimeoutId=setTimeout(()=>{this.triggerBackgroundRefresh(t)},i))}triggerBackgroundRefresh(t){this.refreshPromise||Date.now()<this.refreshBlockedUntil||(this.refreshPromise=this.withRefreshLock(()=>{const r=this.getStoredSession();return r&&!this.shouldRefreshToken(r)?(this.scheduleTokenRefresh(),Promise.resolve(null)):this.refreshTokens(r??t)}).then(r=>(r&&(this.setCurrentSession(r),this.refreshRetryCount=0,this.refreshBlockedUntil=0,this.scheduleTokenRefresh()),r)).catch(r=>(console.error("Background token refresh failed:",r),null)).finally(()=>{this.refreshPromise=null}))}async switchOrganization(t){if(!t)throw new H("INVALID_REQUEST","organizationId is required");return this.withRefreshLock(async()=>{const r=this.sessionGeneration,o=this.getCurrentSession(),n=await this.requestTokens(o,{organization_id:t});if(!this.isCurrentGeneration(r))throw new H("SESSION_CHANGED","the session changed while switching organization");return this.setCurrentSession(n),this.scheduleTokenRefresh(),n})}getOrganization(){const t=this.getCurrentSession(),r=t!=null&&t.access_token?this.decodeJWT(t.access_token):null,o=r==null?void 0:r.org_id;if(typeof o!="string"||o==="")return null;const n=i=>Array.isArray(i)?i.filter(s=>typeof s=="string"):[];return{id:o,roles:n(r==null?void 0:r.roles),permissions:n(r==null?void 0:r.permissions)}}async refreshTokens(t){const r=this.sessionGeneration;try{const o=await this.requestTokens(t);return this.isCurrentGeneration(r)?o:(console.warn("Token refresh returned after the session changed; discarding it"),null)}catch(o){return this.isCurrentGeneration(r)?Y$(o)?(console.error("Token refresh rejected, signing out:",Xn(o)),Oa(),this.clearSession(),null):(console.warn("Token refresh failed, keeping session and retrying:",Xn(o)),this.scheduleRefreshRetry(t),null):(console.warn("Token refresh failed after the session changed; ignoring:",Xn(o)),null)}}async fetchUserInfo(t){try{return await lo.Instance.request("/oauth2/userinfo",{method:"GET",credentials:"include",headers:{Authorization:`Bearer ${t}`}})}catch(r){return console.debug("Could not read user info for the restored session:",Xn(r)),null}}async requestTokens(t,r={}){var i;const o={...r,grant_type:"refresh_token",client_id:(i=G.getConfig())==null?void 0:i.appId};t!=null&&t.refresh_token&&(o.refresh_token=t.refresh_token);const n=await lo.Instance.postForm("/oauth2/token",o);return{id_token:n.id_token??(t==null?void 0:t.id_token)??"",access_token:n.access_token,refresh_token:n.refresh_token??(t==null?void 0:t.refresh_token),expires_in:n.expires_in,expires_at:Date.now()+n.expires_in*1e3}}async readCurrentToken(){var r;const t=(r=G.getConfig())==null?void 0:r.appId;if(!t)return null;try{const o=await lo.Instance.getOptional(`/oauth2/session/token?client_id=${encodeURIComponent(t)}`);return!(o!=null&&o.access_token)||!(o.expires_in>0)?null:{id_token:"",access_token:o.access_token,expires_in:o.expires_in,expires_at:Date.now()+o.expires_in*1e3}}catch{return null}}async restoreSession(){const t=this.getStoredSession();return t&&!this.isSessionExpired(t)?t:z$()==="absent"?null:this.restorePromise?this.restorePromise:(this.restorePromise=this.withRefreshLock(async()=>{const r=this.getStoredSession();if(r&&!this.isSessionExpired(r))return r;try{const o=await this.readCurrentToken()??await this.requestTokens(null);return o.id_token||(o.user=await this.fetchUserInfo(o.access_token)??void 0),this.setCurrentSession(o),this.scheduleTokenRefresh(),o}catch(o){return Z$(o)&&Oa(),console.debug("No session to restore:",Xn(o)),null}}).finally(()=>{this.restorePromise=null}),this.restorePromise)}scheduleRefreshRetry(t){if(this.refreshTimeoutId&&(clearTimeout(this.refreshTimeoutId),this.refreshTimeoutId=null),this.refreshRetryCount>=Pt.MAX_REFRESH_RETRIES){console.warn("Token refresh gave up after",this.refreshRetryCount,"attempts"),this.refreshRetryCount=0,this.refreshBlockedUntil=0;return}const r=Math.min(Pt.REFRESH_RETRY_BASE_MS*2**this.refreshRetryCount,Pt.MAX_REFRESH_RETRY_DELAY_MS);this.refreshRetryCount+=1,this.refreshBlockedUntil=Date.now()+r,this.refreshTimeoutId=setTimeout(()=>{this.refreshBlockedUntil=0,this.triggerBackgroundRefresh(t)},r)}},E(Pt,"MAX_REFRESH_RETRIES",5),E(Pt,"REFRESH_RETRY_BASE_MS",5e3),E(Pt,"MAX_REFRESH_RETRY_DELAY_MS",6e4),E(Pt,"instance"),Pt);function Y$(e){return!(e instanceof H)||e.status===void 0?!1:e.status===401?!0:e.status===400&&Q$.has(e.code)}var Q$=new Set(["invalid_grant","invalid_client"]);function Z$(e){return e instanceof H&&e.status!==void 0&&e.status>=400&&e.status<500}function Xn(e){return e instanceof H?`${e.code} (status ${e.status??"none"}): ${e.message}`:String(e)}var Lh=class{constructor(e=sessionStorage){E(this,"storage");E(this,"FLOW_STATE_KEY","pontive_loginflow_state");E(this,"FLOW_EXPIRY_MS",540*1e3);this.storage=e}getFlowState(){const e=this.storage.getItem(this.FLOW_STATE_KEY);if(!e)return null;try{const t=JSON.parse(e);return this.isExpired(t)?(this.clearFlowState(),null):t}catch{return this.clearFlowState(),null}}saveFlowState(e,t,r){const o=Date.now(),n=this.getFlowState(),i={flowType:e,flow_id:t,state:r.state,startedAt:(n==null?void 0:n.startedAt)||o,lastUpdatedAt:o,render_spec:r.render_spec};this.storage.setItem(this.FLOW_STATE_KEY,JSON.stringify(i))}restoreFromHistory(e){const t={flowType:e.flowType,flow_id:e.flow_id,state:e.state,startedAt:e.timestamp,lastUpdatedAt:e.timestamp,render_spec:void 0};this.storage.setItem(this.FLOW_STATE_KEY,JSON.stringify(t))}clearFlowState(){this.storage.removeItem(this.FLOW_STATE_KEY)}isExpired(e){return Date.now()-e.lastUpdatedAt>this.FLOW_EXPIRY_MS}get expiryMs(){return this.FLOW_EXPIRY_MS}},dr,Ii=(dr=class{static detect(t,r=window.location){if(dr.hasInviteToken(r))return"invitation";const o=r.pathname.toLowerCase();return t.invitationUrl&&o.includes(t.invitationUrl)?"invitation":o.includes(t.signinUrl)?"signin":o.includes(t.signupUrl)?"signup":"custom"}static hasInviteToken(t){try{return new URLSearchParams(t.search).has(dr.INVITE_TOKEN_PARAM)}catch{return!1}}},E(dr,"INVITE_TOKEN_PARAM","invite_token"),dr),Fh=class{constructor(){E(this,"listeners",new Map)}on(e,t){this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t)}off(e,t){var r;(r=this.listeners.get(e))==null||r.delete(t)}emit(e,t){const r=this.listeners.get(e);r&&r.forEach(o=>{try{o(t)}catch(n){console.error(`[FlowEventBus] Error in event handler for ${e}:`,n)}})}clear(){this.listeners.clear()}clearEvent(e){this.listeners.delete(e)}},J$=class{getNavigationType(){const e=performance.getEntriesByType("navigation");if(e.length>0)return e[0].type;const t=performance.navigation;if(t)switch(t.type){case 1:return"reload";case 2:return"back_forward";default:return"navigate"}return"navigate"}},qt,X$=(qt=class{constructor(t,r,o=window.location,n,i){E(this,"httpClient",lo.Instance);E(this,"flowId");E(this,"redirectTimeoutId",null);E(this,"flowStateManager");E(this,"flowEventBus");E(this,"location");E(this,"navigationTypeDetector");E(this,"eventHandlers",new Map([["switch_to_signin",this.handleSwitchToSignin.bind(this)],["switch_to_signup",this.handleSwitchToSignup.bind(this)],["continue_here",this.handleContinueHere.bind(this)]]));E(this,"linkWatchTimer",null);E(this,"linkWatchGeneration",0);E(this,"waitingForLink",!1);const s=G.getConfig();if(!s.domain)throw new H("CONFIG_ERROR","Domain is required");if(!s.appId)throw new H("CONFIG_ERROR","App ID is required");this.flowId=t,this.location=o,this.flowStateManager=n||new Lh,this.flowEventBus=r||new Fh,this.navigationTypeDetector=i||new J$,St.Instance.cleanExpiredSession(),St.Instance.scheduleTokenRefresh()}static async init(t,r,o,n,i){const s=new qt(t,r,o,n,i),d=await s.initializeFlowInternal();return{sdk:s,flowType:d.flowType,isResumed:d.isResumed,state:d.state,render_spec:d.render_spec,auth_result:d.auth_result}}async startFlow(t,r){if(!r.app_id)throw new H("VALIDATION_ERROR","Client ID is required");const o=`/auth/v1/authflows/${t}/start`;return this.executeFlowRequest(()=>this.httpClient.post(o,r),"START_FLOW_ERROR","Failed to start flow")}async resumeFlow(t,r){const o=r?`?continue=${encodeURIComponent(r)}`:"",n=`/auth/v1/authflows/${t}/resume${o}`;return this.executeFlowRequest(()=>this.httpClient.post(n),"RESUME_FLOW_ERROR","Failed to resume flow")}async processEvent(t,r){if(!t.event)throw new H("VALIDATION_ERROR","Event type is required");const o=this.eventHandlers.get(t.event);return o?await o():await this.processServerEvent(t,r)}async executeFlowRequest(t,r,o,n){try{const i=await t();return n&&await n(i),this.processAuthResult(i.auth_result),i.redirection&&this.redirect(i.redirection),i}catch(i){throw i instanceof H?i:new H(r,o,i instanceof Error?{originalError:i.message,stack:i.stack}:i)}}async processServerEvent(t,r){let o=this.flowStateManager.getFlowState();if(!o&&(console.warn("Flow state expired, restarting flow before processing event"),await this.initializeFlowInternal(),o=this.flowStateManager.getFlowState(),!o))throw new H("FLOW_RESTART_ERROR","Failed to restart flow - no flow state after initialization");const n=o.state,i=`/auth/v1/authflows/${o.flowType}/events`,s=this.waitingForLink;this.stopWatchingForLink();let d;try{d=await this.executeFlowRequest(()=>this.httpClient.post(i,t),"PROCESS_EVENT_ERROR","Failed to process event",r)}catch(c){if(s&&qt.flowIsGone(c))return this.announceContinuedElsewhere(o.flowType,""),{state:""};throw c}if(this.watchForLink(o.flowType,d),!d.auth_result){this.flowStateManager.saveFlowState(o.flowType,o.flow_id,d);const c=this.flowStateManager.getFlowState();if(c){const u=n!==d.state;this.flowEventBus.emit("flow:updated",{flowState:c,isNewStep:u})}}return d}processAuthResult(t){if(t){const r={id_token:t.id_token,access_token:t.access_token,refresh_token:t.refresh_token,expires_in:t.expires_in,expires_at:Date.now()+t.expires_in*1e3};St.Instance.setCurrentSession(r),St.Instance.scheduleTokenRefresh(),this.flowStateManager.clearFlowState();const{onAuthenticated:o}=G.getConfig();if(o){o(r);return}console.warn("pontive: signed in, but no onAuthenticated was supplied, so the SDK cannot route the user. Supply onAuthenticated to handle the handoff.")}}async initializeFlowInternal(){const t=G.getConfig(),r=Ii.detect(t,this.location);this.validateFlowType(r);const o=this.flowStateManager.getFlowState();return this.shouldResumeFlow(o,r)?await this.resumeExistingFlow(o,r):await this.startNewFlow(r)}validateFlowType(t){if(t==="custom"&&!this.flowId)throw new H("FLOW_ID_ERROR","Flow ID is required for custom flows")}shouldResumeFlow(t,r){const n=new URLSearchParams(this.location.search).get("resume")==="true";if(!t)return n;const i=this.navigationTypeDetector.getNavigationType();if(i==="navigate"&&!n)return this.flowStateManager.clearFlowState(),console.log(`Fresh navigation detected (type: ${i}), starting new flow`),!1;if(t.flowType!==r)return this.flowStateManager.clearFlowState(),console.log(`Flow type changed from ${t.flowType} to ${r}, starting new flow, flow_id: ${this.flowId}`),!1;if(r==="custom"&&t.flow_id!==this.flowId)return this.flowStateManager.clearFlowState(),console.log(`Custom flow ID changed, starting new flow, flow_id: ${this.flowId}`),!1;const s=n?"explicit resume=true":`navigation type: ${i}`;return console.log(`Resuming existing flow (${s})`),!0}async resumeExistingFlow(t,r){try{const o=await this.resumeFlow(r,this.continueParam());if(this.watchForLink(r,o),!o.auth_result){this.flowStateManager.saveFlowState(r,(t==null?void 0:t.flow_id)??this.determineFlowId(r),o);const n=this.flowStateManager.getFlowState();n&&this.flowEventBus.emit("flow:resumed",{flowState:n})}return{flowType:r,isResumed:!0,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result}}catch(o){return this.flowStateManager.clearFlowState(),console.warn("Failed to resume flow, starting fresh:",o),await this.startNewFlow(r)}}async startNewFlow(t){const r=G.getConfig(),o=new URLSearchParams(this.location.search),n={};o.forEach((c,u)=>{n[u]=c}),r.organizationId&&!n.organization_id&&(n.organization_id=r.organizationId),console.log("metadata",n);const i=o.get("locales")||r.locales||void 0,s={app_id:r.appId,origin_url:this.location.href,signin_url:r.signinUrl,signup_url:r.signupUrl,locales:i,flow_id:this.determineFlowId(t),metadata:n,auth_base_url:G.getApiBaseUrl()},d=await this.startFlow(t,s);if(this.watchForLink(t,d),!d.auth_result){this.flowStateManager.saveFlowState(t,s.flow_id,d);const c=this.flowStateManager.getFlowState();c&&this.flowEventBus.emit("flow:started",{flowState:c})}return{flowType:t,isResumed:!1,state:d.state,render_spec:d.render_spec,auth_result:d.auth_result}}determineFlowId(t){switch(t){case"signin":return this.flowId||"signin-flow";case"signup":return this.flowId||"signup-flow";case"invitation":return this.flowId||"invitation-flow";case"custom":if(!this.flowId)throw new H("FLOW_ID_ERROR","Flow ID is required for custom flows");return this.flowId}}continueParam(){const t=new URLSearchParams(this.location.search);if(t.get("resume")==="true")return t.get("continue")??void 0}watchForLink(t,r){if(this.stopWatchingForLink(),this.waitingForLink=r.waiting_for_link===!0,!this.waitingForLink)return;const o=this.linkWatchGeneration,n=Date.now()+qt.LINK_POLL_LIMIT_MS,i=()=>{this.linkWatchTimer=setTimeout(s,qt.LINK_POLL_INTERVAL_MS)},s=async()=>{if(o!==this.linkWatchGeneration||Date.now()>n)return;if(typeof document<"u"&&document.hidden){i();return}let d;try{d=await this.httpClient.post(`/auth/v1/authflows/${t}/resume`)}catch(c){o===this.linkWatchGeneration&&qt.flowIsGone(c)&&this.announceContinuedElsewhere(t,"");return}if(o===this.linkWatchGeneration){if(d.waiting_for_link){i();return}this.announceContinuedElsewhere(t,d.state)}};i()}announceContinuedElsewhere(t,r){var o,n;this.stopWatchingForLink(),this.flowStateManager.clearFlowState(),(n=(o=G.getConfig()).onFlowStateChange)==null||n.call(o,{eventType:"flow_continued_elsewhere",flowType:t,state:r})}static flowIsGone(t){return t instanceof H&&t.status===401}stopWatchingForLink(){this.waitingForLink=!1,this.linkWatchGeneration++,this.linkWatchTimer!==null&&(clearTimeout(this.linkWatchTimer),this.linkWatchTimer=null)}async handleContinueHere(){const{continueHereUrl:t}=G.getConfig();this.flowStateManager.clearFlowState();let r=t;if(!r){const o=new URL(this.location.href);o.searchParams.delete("resume"),o.searchParams.delete("continue"),r=o.toString()}return this.redirect({url:r,redirect_delay:0}),{state:"End"}}async handleSwitchToSignin(){const t=G.getConfig();return this.redirect({url:this.withCurrentQuery(t.signinUrl),redirect_delay:0}),{state:"End"}}async handleSwitchToSignup(){const t=G.getConfig();return this.redirect({url:this.withCurrentQuery(t.signupUrl),redirect_delay:0}),{state:"End"}}withCurrentQuery(t){const r=this.location.search;return!r||r==="?"?t:t.includes("?")?`${t}&${r.slice(1)}`:`${t}${r}`}redirect(t){t.url&&(this.redirectTimeoutId!==null&&(console.log("Clearing existing redirect timeout before scheduling new redirect to:",t.url),clearTimeout(this.redirectTimeoutId),this.redirectTimeoutId=null),this.redirectTimeoutId=setTimeout(()=>{this.location.href=t.url},t.redirect_delay*1e3))}reloadPage(){setTimeout(()=>{this.location.reload()},0)}getEventBus(){return this.flowEventBus}cleanup(){this.stopWatchingForLink(),this.redirectTimeoutId&&(clearTimeout(this.redirectTimeoutId),this.redirectTimeoutId=null),this.flowEventBus.clear()}},E(qt,"LINK_POLL_INTERVAL_MS",3e3),E(qt,"LINK_POLL_LIMIT_MS",900*1e3),qt),tP=class{constructor(e){E(this,"delayMs");E(this,"timerId",null);this.delayMs=e}debounce(e){this.timerId&&clearTimeout(this.timerId),this.timerId=setTimeout(()=>{e(),this.timerId=null},this.delayMs)}cancel(){this.timerId&&(clearTimeout(this.timerId),this.timerId=null)}isPending(){return this.timerId!==null}},eP=class{pushState(e,t,r){history.pushState(e,t,r)}replaceState(e,t,r){history.replaceState(e,t,r)}get state(){return history.state}},rP=class{constructor(e,t,r=!1,o=window.location,n,i){E(this,"popstateListener",null);E(this,"pageshowListener",null);E(this,"debouncer");E(this,"isProcessing",!1);E(this,"isHandlingNavigationEvent",!1);E(this,"onFlowRestartNeeded",null);E(this,"skipHistoryTracking");E(this,"flowStateManager");E(this,"historyAdapter");E(this,"location");this.onFlowRestartNeeded=t,this.skipHistoryTracking=r,this.debouncer=new tP(200),this.location=o,this.flowStateManager=n||new Lh,this.historyAdapter=i||new eP,this.subscribeToFlowEvents(e),this.initializeListener()}subscribeToFlowEvents(e){e.on("flow:started",this.handleFlowStart.bind(this)),e.on("flow:updated",this.handleFlowUpdate.bind(this)),e.on("flow:resumed",this.handleFlowResume.bind(this))}initializeListener(){this.popstateListener=e=>{console.log("[NavigationManager] popstate event received"),this.debouncer.debounce(()=>{console.log("[NavigationManager] Debounce timeout fired, handling popstate"),this.handlePopState(e)})},this.pageshowListener=e=>{e.persisted&&(console.log("[NavigationManager] Page restored from bfcache"),this.debouncer.debounce(()=>{console.log("[NavigationManager] Handling bfcache restoration"),this.handleBfcacheRestoration()}))},window.addEventListener("popstate",this.popstateListener),window.addEventListener("pageshow",this.pageshowListener)}async handlePopState(e){if(this.isProcessing){console.log("[NavigationManager] Already processing popstate, skipping");return}console.log("[NavigationManager] Starting popstate processing"),this.isProcessing=!0,this.isHandlingNavigationEvent=!0;try{const t=e.state,r=this.flowStateManager.getFlowState(),o=G.getConfig(),n=Ii.detect(o,this.location);if(t&&this.restoreHistoryStateToSession(t),this.shouldRestartFlow(t,r,n)){await this.triggerFlowRestart();return}console.log("[NavigationManager] Valid state restored from history")}finally{this.isProcessing=!1,this.isHandlingNavigationEvent=!1}}async handleBfcacheRestoration(){if(this.isProcessing){console.log("[NavigationManager] Already processing bfcache restoration, skipping");return}console.log("[NavigationManager] Starting bfcache restoration processing"),this.isProcessing=!0,this.isHandlingNavigationEvent=!0;try{const e=this.historyAdapter.state,t=this.flowStateManager.getFlowState(),r=G.getConfig(),o=Ii.detect(r,this.location);if(e&&this.restoreHistoryStateToSession(e),this.shouldRestartFlow(e,t,o)){await this.triggerFlowRestart();return}console.log("[NavigationManager] Valid state restored from bfcache")}finally{this.isProcessing=!1,this.isHandlingNavigationEvent=!1}}restoreHistoryStateToSession(e){console.log("[NavigationManager] Restoring history state to session storage:",e),this.flowStateManager.restoreFromHistory(e)}shouldRestartFlow(e,t,r){return e&&e.flowType!==r?(console.log("[NavigationManager] Flow type changed via navigation:",e.flowType,"→",r),this.flowStateManager.clearFlowState(),!0):e?Date.now()-e.timestamp>this.flowStateManager.expiryMs?(console.log("[NavigationManager] History state expired, clearing and restarting flow"),this.flowStateManager.clearFlowState(),!0):(console.log("[NavigationManager] Valid history state restored, triggering restart to resume flow"),!0):(console.log("[NavigationManager] No history state, skipping"),!1)}async triggerFlowRestart(){this.onFlowRestartNeeded&&await this.onFlowRestartNeeded()}createHistoryState(e){return{flowType:e.flowType,flow_id:e.flow_id,state:e.state,timestamp:Date.now()}}updateBrowserHistory(e,t){if(this.skipHistoryTracking){console.log("[NavigationManager] Skipping history tracking (created from navigation)");return}const r=this.createHistoryState(e);try{t==="push"?(this.historyAdapter.pushState(r,"",this.location.href),console.log("[NavigationManager] Pushed state to history")):(this.historyAdapter.replaceState(r,"",this.location.href),console.log("[NavigationManager] Replaced state in history"))}catch(o){console.error("[NavigationManager] Failed to update history:",o)}}handleFlowStart(e){this.updateBrowserHistory(e.flowState,"replace")}handleFlowUpdate(e){const t=this.isHandlingNavigationEvent||!e.isNewStep?"replace":"push";this.updateBrowserHistory(e.flowState,t)}handleFlowResume(e){this.updateBrowserHistory(e.flowState,"replace")}destroy(){this.debouncer.cancel(),this.popstateListener&&(window.removeEventListener("popstate",this.popstateListener),this.popstateListener=null),this.pageshowListener&&(window.removeEventListener("pageshow",this.pageshowListener),this.pageshowListener=null),this.onFlowRestartNeeded=null}},Rr=new AbortController,nP=class{constructor(){E(this,"httpClient",lo.Instance);E(this,"capabilities",{webauthn:!1});E(this,"capabilitiesDetected",!1)}async detectCapabilities(){if(!this.capabilitiesDetected)try{if(typeof window.PublicKeyCredential=="function"?this.capabilities.webauthn=!0:this.capabilities.webauthn=!1,typeof PublicKeyCredential.getClientCapabilities=="function"){const e=await PublicKeyCredential.getClientCapabilities();this.capabilities={...this.capabilities,...e};return}typeof PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable=="function"&&(this.capabilities.userVerifyingPlatformAuthenticator=await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()),(PublicKeyCredential==null?void 0:PublicKeyCredential.isConditionalMediationAvailable)!==void 0&&typeof PublicKeyCredential.isConditionalMediationAvailable=="function"?this.capabilities.conditionalGet=await PublicKeyCredential.isConditionalMediationAvailable():this.capabilities.conditionalGet=!1}finally{this.capabilitiesDetected=!0}}async fetchPublicKeyCredentialRequestOptions(e,t){try{return this.httpClient.post("/auth/v1/webauthn/login/options",{conditional:t,flow_type:e})}catch(r){return console.error("error",r),null}}async fetchPublicKeyCredentialCreationOptions(e,t){try{return this.httpClient.post("/auth/v1/webauthn/register/options",{conditional:t,flow_type:e})}catch(r){return console.error("error",r),null}}async startRegistration(e,t){if(await this.detectCapabilities(),!e)return console.error("No PublicKeyCredentialCreationOptionsJSON provided"),null;Rr.abort(),Rr=new AbortController;const r=this.toPublicKeyCredentialCreationOptions(e),o={signal:Rr.signal,publicKey:r};if(t){if(!this.isConditionalCreateAvailable())return console.error("Conditional create mediation not supported in this browser"),null;o.mediation="conditional"}try{const n=await navigator.credentials.create(o);if(!n){console.error("no credential returned by authenticator");return}const{id:i,rawId:s,response:d,type:c}=n;let u;typeof d.getTransports=="function"&&(u=d.getTransports());let v;if(typeof d.getPublicKeyAlgorithm=="function")try{v=d.getPublicKeyAlgorithm()}catch(_){hs("getPublicKeyAlgorithm()",_)}let b;if(typeof d.getPublicKey=="function")try{const _=d.getPublicKey();_!==null&&(b=this.bufferToBase64URLString(_))}catch(_){hs("getPublicKey()",_)}let w;if(typeof d.getAuthenticatorData=="function")try{w=this.bufferToBase64URLString(d.getAuthenticatorData())}catch(_){hs("getAuthenticatorData()",_)}return{id:i,rawId:this.bufferToBase64URLString(s),response:{attestationObject:this.bufferToBase64URLString(d.attestationObject),clientDataJSON:this.bufferToBase64URLString(d.clientDataJSON),transports:u,publicKeyAlgorithm:v,publicKey:b,authenticatorData:w},type:c,clientExtensionResults:n.getClientExtensionResults(),authenticatorAttachment:this.toAuthenticatorAttachment(n.authenticatorAttachment)}}catch(n){const i=this.identifyAuthenticationError({error:n,options:o});return i instanceof Ir?console.error(`WebAuthn authentication failed with code: ${i.code}, message: ${i.message}`):console.error("WebAuthn authentication failed with error:",n),null}}async startAuthentication(e,t){if(await this.detectCapabilities(),!e)return console.error("No PublicKeyCredentialRequestOptionsJSON provided"),null;if(!this.isWebAuthnAvailable())return console.error("WebAuthn not supported in this browser"),null;Rr.abort(),Rr=new AbortController;const r=this.toPublicKeyCredentialRequestOptions(e),o={signal:Rr.signal,publicKey:r};if(t){if(!this.isConditionalGetAvailable())return console.error("Conditional mediation not supported in this browser"),null;o.mediation="conditional",o.publicKey&&(o.publicKey.allowCredentials=[])}try{const n=await navigator.credentials.get(o);return this.toPublicKeyCredentialJSON(n)}catch(n){const i=this.identifyAuthenticationError({error:n,options:o});return i instanceof Ir?console.error(`WebAuthn authentication failed with code: ${i.code}, message: ${i.message}`):console.error("WebAuthn authentication failed with error:",n),null}}async signalUnknownCredential(e,t){if(await this.detectCapabilities(),this.isSignalUnknownCredentialAvailable())try{await PublicKeyCredential.signalUnknownCredential({rpId:e,credentialId:t})}catch(r){console.error("Failed to signal unknown credential:",r)}else console.warn("signalUnknownCredential not supported in this browser")}async signalCurrentUserDetails(e){if(await this.detectCapabilities(),this.isSignalCurrentUserDetailsAvailable())try{await PublicKeyCredential.signalCurrentUserDetails(e)}catch(t){console.error("Failed to signal current user details:",t)}else console.warn("signalCurrentUserDetails not supported. Ask user to update manually.")}toPublicKeyCredentialDescriptor(e){const{id:t}=e;return{...e,id:this.base64URLStringToBuffer(t),type:e.type,transports:e.transports}}toAuthenticatorAttachment(e){const t=["cross-platform","platform"];if(e&&!(t.indexOf(e)<0))return e}bufferToBase64URLString(e){const t=new Uint8Array(e);let r="";for(const n of t)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}base64URLStringToBuffer(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4,o=t.padEnd(t.length+r,"="),n=atob(o),i=new ArrayBuffer(n.length),s=new Uint8Array(i);for(let d=0;d<n.length;d++)s[d]=n.charCodeAt(d);return i}toPublicKeyCredentialJSON(e){if(typeof e.toJSON=="function")return e.toJSON();const t=e.response;return{id:e.id,type:e.type,rawId:this.bufferToBase64URLString(e.rawId),authenticatorAttachment:this.toAuthenticatorAttachment(e.authenticatorAttachment),clientExtensionResults:e==null?void 0:e.getClientExtensionResults(),response:{clientDataJSON:this.bufferToBase64URLString(t.clientDataJSON),authenticatorData:this.bufferToBase64URLString(t.authenticatorData),signature:this.bufferToBase64URLString(t.signature),userHandle:t.userHandle?this.bufferToBase64URLString(t.userHandle):void 0}}}toPublicKeyCredentialCreationOptions(e){var r;if(typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const t={challenge:this.base64URLStringToBuffer(e.challenge),rp:{id:e.rp.id,name:e.rp.name},user:{displayName:e.user.displayName,id:this.base64URLStringToBuffer(e.user.id),name:e.user.name},pubKeyCredParams:e.pubKeyCredParams.map(o=>({alg:o.alg,type:o.type})),timeout:e.timeout};if(e.attestation&&(t.attestation=e.attestation),e.extensions!==void 0&&(t.extensions=e.extensions),e.authenticatorSelection){const o={};e.authenticatorSelection.authenticatorAttachment&&(o.authenticatorAttachment=e.authenticatorSelection.authenticatorAttachment),e.authenticatorSelection.requireResidentKey&&(o.requireResidentKey=e.authenticatorSelection.requireResidentKey),e.authenticatorSelection.residentKey&&(o.residentKey=e.authenticatorSelection.residentKey),e.authenticatorSelection.userVerification&&(o.userVerification=e.authenticatorSelection.userVerification),t.authenticatorSelection=o}return(r=e.excludeCredentials)!=null&&r.length&&(t.excludeCredentials=e.excludeCredentials.map(o=>this.toPublicKeyCredentialDescriptor(o))),t}toPublicKeyCredentialRequestOptions(e){var r;if(typeof PublicKeyCredential.parseRequestOptionsFromJSON=="function")return PublicKeyCredential.parseRequestOptionsFromJSON(e);const t={challenge:this.base64URLStringToBuffer(e.challenge)};return e.rpId!==void 0&&(t.rpId=e.rpId),e.timeout!==void 0&&(t.timeout=e.timeout),e.userVerification!==void 0&&(t.userVerification=e.userVerification),e.extensions!==void 0&&(t.extensions=e.extensions),(r=e.allowCredentials)!=null&&r.length&&(t.allowCredentials=e.allowCredentials.map(o=>this.toPublicKeyCredentialDescriptor(o))),t}identifyAuthenticationError({error:e,options:t}){const{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new Ir({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new Ir({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const o=window.location.hostname;if(oP(o)){if(r.rpId!==o)return new Ir({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new Ir({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new Ir({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return e}isPublicKeyCredentialRequestOptionsJSON(e){return typeof e=="object"&&e!==null&&"challenge"in e}isWebAuthnAvailable(){return this.capabilities.webauthn}isSignalAllAcceptedCredentialsAvailable(){return!!this.capabilities.signalAllAcceptedCredentials}isSignalCurrentUserDetailsAvailable(){return!!this.capabilities.signalCurrentUserDetails}isSignalUnknownCredentialAvailable(){return!!this.capabilities.signalUnknownCredential}isConditionalGetAvailable(){return!!this.capabilities.conditionalGet}isConditionalCreateAvailable(){return!!this.capabilities.conditionalCreate}isHybridTransportAvailable(){return!!this.capabilities.hybridTransport}destroy(){Rr.abort()}};function hs(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.
|
|
2649
|
+
`,t)}var Ir=class extends Error{constructor({message:t,code:r,cause:o,name:n}){super(t);E(this,"code");this.name=n??o.name,this.code=r}};function oP(e){return e==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var we,iP=(we=class{constructor(){E(this,"configured",!1);E(this,"configuredResolve");E(this,"configuredPromise",new Promise(t=>{this.configuredResolve=t}));E(this,"loginflow",null);E(this,"navigationManager",null);E(this,"flowEventBus",null);E(this,"webauthnService",null)}static get Instance(){return we.instance||(we.instance=new we),we.instance}ensureConfigured(){if(!this.configured)throw new H("NOT_CONFIGURED","Auth.configure() must be called before using Auth methods")}ensureLoginflowInitialized(){if(!this.loginflow)throw new H("LOGINFLOW_NOT_INITIALIZED","Call Auth.startLoginflow() first")}async startLoginflowInternal(t,r=!1){this.ensureConfigured(),this.webauthnService&&(console.log("[AuthService] Cleaning up and aborting ongoing webauthn flows"),this.webauthnService.destroy(),this.webauthnService=null),this.loginflow&&(console.log("[AuthService] Cleaning up old loginflow instance"),this.loginflow.cleanup(),this.loginflow=null),this.navigationManager&&(console.log("[AuthService] Cleaning up old navigation manager instance"),this.navigationManager.destroy(),this.navigationManager=null),this.webauthnService=new nP,this.webauthnService.detectCapabilities(),this.flowEventBus=new Fh,this.navigationManager=new rP(this.flowEventBus,async()=>{console.log("[AuthService] Navigation restart triggered, restarting loginflow"),await this.startLoginflowInternal(void 0,!1)},r);const o=await X$.init(t,this.flowEventBus),n=G.getConfig();this.startPasskeyAuthentication(o.flowType,!0),this.loginflow=o.sdk;const i={flowType:o.flowType,isResumed:o.isResumed,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result};return n.onFlowStateChange&&n.onFlowStateChange({eventType:o.isResumed?"flow_resumed":"flow_started",flowType:o.flowType,state:o.state,render_spec:o.render_spec,auth_result:o.auth_result,isResumed:o.isResumed}),i}configure(t){if(!t.domain||!t.appId)throw new H("CONFIG_ERROR","domain and appId are required");G.setConfig(t),this.configured=!0,this.configuredResolve()}whenConfigured(){return this.configuredPromise}isAuthenticated(){return this.ensureConfigured(),St.Instance.isAuthenticated()}getCurrentSession(){return this.ensureConfigured(),St.Instance.getCurrentSession()}async restoreSession(){return this.ensureConfigured(),St.Instance.restoreSession()}getAuthenticatedUser(){return this.ensureConfigured(),St.Instance.getAuthenticatedUser()}getOrganization(){return this.ensureConfigured(),St.Instance.getOrganization()}async switchOrganization(t){return this.ensureConfigured(),St.Instance.switchOrganization(t)}async startLoginflow(t){return this.startLoginflowInternal(t,!1)}async processLoginflowEvent(t){var i,s;this.ensureConfigured(),this.ensureLoginflowInitialized();const r=G.getConfig(),o=Ii.detect(r,location);if(t.event==="signin_with_passkey"&&!((i=t.data)!=null&&i.credential_request)){const d=await this.getPasskeyCredential(o,!1);if(!d||!d.cred)return console.error("no credential returned by browser"),{state:""};t.data={credential_request:d.cred}}if(t.event==="register_passkey"&&!((s=t.data)!=null&&s.conditional)){console.log("attempt to register a passkey");const d=await this.createPasskeyCredential(o,!1);if(!d)return console.error("no credential created by browser"),{state:""};t.data={credential_creation_response:d,conditional:!1}}const n=await this.loginflow.processEvent(t,async d=>{var c;if((c=d.data)!=null&&c.conditional_create_enabled){console.log("attempt to register a passkey conditionally");const u=await this.registerPasskey(o,!0);u&&(u.render_spec=void 0,d.render_spec=void 0)}});if(console.log("render spec",n.render_spec),r.onFlowStateChange){const d=sessionStorage.getItem("pontive_loginflow_state");let c="custom";if(d)try{c=JSON.parse(d).flowType}catch(u){console.error("Failed to parse flow state:",u)}r.onFlowStateChange({eventType:"flow_updated",flowType:c,state:n.state,render_spec:n.render_spec,auth_result:n.auth_result})}return n}async getPasskeyCredential(t,r){var n,i;const o=await((n=this.webauthnService)==null?void 0:n.fetchPublicKeyCredentialRequestOptions(t,r));if(!o)return console.error("failed to fetch public key request options"),null;try{return{cred:await((i=this.webauthnService)==null?void 0:i.startAuthentication(o,r)),options:o}}catch(s){return console.error("error starting authentication",s),null}}async startPasskeyAuthentication(t,r=!1){var s,d;const o=await this.getPasskeyCredential(t,r);if(!o||!o.cred){console.error("no credential found");return}const{cred:n,options:i}=o;try{((s=(await this.processLoginflowEvent({event:"signin_with_passkey",data:{credential_request:n}})).data)==null?void 0:s.error)==="CredentialNotFound"&&(i.rpId&&n.id?(d=this.webauthnService)==null||d.signalUnknownCredential(i.rpId,n.id):console.log("missing rpId or credential id for signalUnknownCredential"))}catch(c){console.error("failed to signin with passkey",c)}}async createPasskeyCredential(t,r){var o,n;try{const i=await((o=this.webauthnService)==null?void 0:o.fetchPublicKeyCredentialCreationOptions(t,r));if(!i){console.warn("no credential creation option returned by webauthn service"),console.log("skipping conditional passkey registration...");return}return(n=this.webauthnService)==null?void 0:n.startRegistration(i,r)}catch(i){console.log("error",i)}}async registerPasskey(t,r=!1){try{const o=await this.createPasskeyCredential(t,r),n=await this.processLoginflowEvent({event:"register_passkey",data:{credential_creation_response:o,conditional:r}});return console.log("passkey creation res",n),n}catch(o){console.log("error",o)}}invalidateSession(){St.Instance.clearSession()}async signOut(t){var n;this.ensureConfigured();const r=sP(St.Instance.peekSession()),o=((n=G.getConfig())==null?void 0:n.appId)??"";if(Oa(),St.Instance.clearSession(),St.Instance.cleanup(),this.loginflow&&(this.loginflow.cleanup(),this.loginflow=null),this.navigationManager&&(this.navigationManager.destroy(),this.navigationManager=null),this.flowEventBus&&(this.flowEventBus.clear(),this.flowEventBus=null),!G.apiIsSameOrigin()){window.location.assign(this.logoutUrl(r,o,t==null?void 0:t.returnTo));return}await this.endServerSession(r,o),window.location.reload()}async endServerSession(t,r){try{await fetch(`${G.getApiBaseUrl()}/oauth2/logout`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:r,...t?{logout_hint:t}:{}}).toString()})}catch(o){console.warn("Could not end the session at the authorization server:",o)}}logoutUrl(t,r,o){const n=new URLSearchParams({post_logout_redirect_uri:o??`${window.location.origin}${window.location.pathname}`,client_id:r});return t&&n.set("logout_hint",t),`${G.getApiBaseUrl()}/oauth2/logout?${n.toString()}`}},E(we,"instance"),we);function sP(e){for(const t of[e==null?void 0:e.id_token,e==null?void 0:e.access_token]){if(!t)continue;const r=St.Instance.decodeJWT(t);if(typeof(r==null?void 0:r.sid)=="string"&&r.sid)return r.sid}}var K=iP.Instance,aP=Object.defineProperty,lP=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&aP(t,r,n),n};class Ut extends f{constructor(){super(),this.shadow=!1,this.__initialAttributesCache=null}parseJsonAttribute(t){try{const r=this.getAttribute(t);return r?JSON.parse(r):{}}catch{return{}}}get sbStyle(){return this.parseJsonAttribute("pont-style")}getAttributesToExclude(){return[]}getFilteredAttributes(){const t={};return Array.from(this.attributes).forEach(r=>{this.getAttributesToExclude().includes(r.name)||(t[r.name]=r.value??"")}),t}isCustomPropertySet(t){const r=getComputedStyle(this).getPropertyValue(t).trim();return r!=="inherit"&&r.length>0}applyCustomClass(t,r,o=""){var n,i;t.some(s=>this.isCustomPropertySet(s))&&((i=(n=this.shadowRoot)==null?void 0:n.querySelector(r))==null||i.classList.add(o))}moveAttributesToElement(t,r=["id","class"]){t&&r.forEach(o=>{const n=this.getAttribute(o);n!==null&&(t.setAttribute(o,n),this.removeAttribute(o))})}removeAttributesFromHost(t=["id","class"]){t.forEach(r=>{this.hasAttribute(r)&&this.removeAttribute(r)})}captureHostAttributes(){if(this.__initialAttributesCache)return this.__initialAttributesCache;const t={};return Array.from(this.attributes).forEach(r=>{t[r.name]=r.value}),this.__initialAttributesCache=t,t}getHostClass(){return this.captureHostAttributes().class??""}removeDuplicateContent(){var i;const t=document.createTreeWalker(this,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{var d;return s.nodeType===Node.COMMENT_NODE||s.nodeType===Node.TEXT_NODE&&!((d=s.textContent)!=null&&d.trim())?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),r=new Map,o=[];let n;for(;n=t.nextNode();){let s;if(n.nodeType===Node.TEXT_NODE){const d=(i=n.textContent)==null?void 0:i.trim();if(!d)continue;s=`text:${d}`}else if(n instanceof HTMLElement){const d=Array.from(n.attributes).map(c=>`${c.name}=${c.value}`).sort().join(":");s=`element:${n.tagName}:${d}`}else continue;if(r.has(s)){const d=r.get(s);d!=null&&d.parentNode&&o.push(d),r.set(s,n)}else r.set(s,n)}o.forEach(s=>{var d;return(d=s.parentNode)==null?void 0:d.removeChild(s)})}moveLightDomChildrenInto(t,r){let o;r!=null&&r.length?(o=r.filter(n=>this.contains(n)&&n!==t&&!n.contains(t)),o.forEach(n=>{const i=Array.from(t.childNodes).find(s=>{var d;return(d=s.isEqualNode)==null?void 0:d.call(s,n)});i&&t.removeChild(i)})):o=Array.from(this.childNodes).filter(n=>n!==t&&!t.contains(n)&&!n.contains(t)),o.forEach(n=>t.appendChild(n))}}lP([a({type:Boolean})],Ut.prototype,"shadow");const Pr="pont:auth",Lo={showWatermark:!0},Bi="pont:branding";class dP{constructor(t){this.consumer=new ui(t,{context:Bi,subscribe:!0})}get showWatermark(){var t;return((t=this.consumer.value)==null?void 0:t.showWatermark)??Lo.showWatermark}}const kh="pont:design-mode";class Fo{constructor(t){this.host=t,this.consumer=new ui(t,{context:kh,subscribe:!0})}get active(){return this.host.hasAttribute("design-mode")?this.host.getAttribute("design-mode")!=="false":this.consumer.value??!1}}const Nh="pont:env",Mh=Symbol("renderSpecContext"),ko="pont-user-context",Bh="";function zt(...e){return Ap(ja(e))}function cP(e){return Object.entries(e).filter(([t,r])=>typeof r!="object"&&r!=null).map(([t,r])=>`${t}: ${r};`).join(" ")}function pP(e){document.documentElement.setAttribute("data-theme",e)}function hP(){const e=document.documentElement.getAttribute("data-theme");(!e||e!=="light"&&e!=="dark")&&pP("light")}function uP(e,t){return e?e.includes("{{theme}}")?e.replace("{{theme}}",t):e:""}function Ia(){return new Promise(e=>{requestAnimationFrame(()=>requestAnimationFrame(()=>e()))})}const Lc="abcdefghijklmnopqrstuvwxyz0123456789",mP=6;function gP(e){let t="";for(let r=0;r<mP;r++)t+=Lc.charAt(Math.floor(Math.random()*Lc.length));return t}const _t=()=>gP();function Ui(e){const t=document.createElement("pont-toast"),r=document.createElement("pont-toast-view-port");r.part="user-profile-toast",r.setAttribute("variant","destructive"),t.dataset.state="open";const o=document.createElement("div");o.className="pont-grid pont-gap-1";const n=document.createElement("pont-toast-title");n.textContent="Uh oh! Something went wrong.";const i=document.createElement("pont-toast-description");i.textContent=e,o.appendChild(n),o.appendChild(i),r.appendChild(o),t.appendChild(r),document.body.appendChild(t),setTimeout(()=>{t.dataset.state="open",r.dataset.state="open"},10),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t)},3.5*1e3)}async function fP(e,t=5e3){if(!e)return;let r;const o=new Promise(n=>{r=setTimeout(()=>n("timeout"),t)});try{await Promise.race([e.whenConfigured(),o])==="timeout"&&console.warn(`pontive: Auth.configure() has not been called after ${t}ms. Is this widget mounted inside <pont-provider>?`)}finally{clearTimeout(r)}}function vP(e){if(!(e!=null&&e.startsWith("data:image/svg+xml;base64,")))return null;try{const t=e.replace("data:image/svg+xml;base64,","");return atob(t)}catch(t){return console.error("Invalid base64 SVG:",t),null}}function bP(e){return/^https?:\/\//.test(e)||e!=null&&e.startsWith("data:image/svg+xml;base64,")?e:`data:image/svg+xml;base64,${e}`}function le(){var e;return(e=K.getCurrentSession())==null?void 0:e.access_token}function Aa(e,t=!1){if(!e&&e!==0)return"N/A";const r=typeof e=="string"?new Date(e):new Date(t?e:e*1e3);if(isNaN(r.getTime()))return"Invalid Date";const o=new Date,n=new Date(o.getFullYear(),o.getMonth(),o.getDate()),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()),s=Math.floor((n.getTime()-i.getTime())/(1e3*60*60*24));return s===0?"Today":s===1?"Yesterday":s>1&&s<=6?r.toLocaleDateString("en-US",{weekday:"long"}):r.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Ta(e,t=!1){if(!e&&e!==0)return"N/A";const r=typeof e=="string"?new Date(e):new Date(t?e:e*1e3);return isNaN(r.getTime())?"Invalid Time":r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function ji(e){if(!e)return"";const r=(e.includes("@")?e.split("@")[0]:e).split(/[\s._-]+/).filter(Boolean);return r.length===0?"":r.length===1?r[0].slice(0,2).toUpperCase():`${r[0][0]}${r[r.length-1][0]}`.toUpperCase()}function yP(e){return e instanceof Error&&"status"in e}function qi(e,t){var r,o;return yP(e)?((o=(r=e.data)==null?void 0:r.error)==null?void 0:o.message)??e.message??t:e instanceof Error&&e.message||t}const cn={variant:"secondary",size:"default",content:"label",iconAlign:"start",label:"Continue with Passkey"},pn={variant:"outline",size:"default",content:"icon-label",iconAlign:"start",prompt:"Continue with"},hn={variant:"default",size:"default",content:"label",iconAlign:"end",label:"Submit"},_P={apple:"Apple",discord:"Discord",facebook:"Facebook",github:"GitHub",google:"Google",linkedin:"LinkedIn",meta:"Meta",microsoft:"Microsoft",x:"X"},wP={apple:U`<path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701" />`,discord:U`<path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z" />`,facebook:U`<path d="M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z" />`,github:U`<path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />`,google:U`<path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />`,linkedin:U`<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />`,meta:U`<path d="M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z" />`,microsoft:U`<path d="M11.4 24H0V12.6h11.4V24zM24 24H12.6V12.6H24V24zM11.4 11.4H0V0h11.4v11.4zM24 11.4H12.6V0H24v11.4z" />`,x:U`<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.763l7.726-8.835L1.254 2.25H8.08l4.713 6.231 5.45-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117L17.083 19.77z" />`};var $P=Object.defineProperty,PP=Object.getOwnPropertyDescriptor,Yt=(e,t,r,o)=>{for(var n=o>1?void 0:o?PP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&$P(t,r,n),n};exports.PontPasskeyButton=class extends f{constructor(){super(...arguments),this.seed=_t(),this.variant=cn.variant,this.size=cn.size,this.content=cn.content,this.iconAlign=cn.iconAlign,this._label=cn.label,this._loading=!1,this._handleClick=async()=>{if(!this.isDisabled){this._loading=!0,this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.CLICK_EVENT,{detail:{id:this.rootId,event:this.event},bubbles:!0,composed:!0}));try{if(this.event){const t=await K.processLoginflowEvent({event:this.event});this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.SUCCESS_EVENT,{detail:{id:this.rootId,event:this.event,result:t},bubbles:!0,composed:!0}))}}catch(t){const r=t instanceof Error?t.message:String(t);this.dispatchEvent(new CustomEvent(exports.PontPasskeyButton.ERROR_EVENT,{detail:{id:this.rootId,event:this.event,message:r,error:t},bubbles:!0,composed:!0}))}finally{this._loading=!1}}}}get label(){return this._label}set label(t){const r=this._label;this._label=t.length?t:cn.label,this.requestUpdate("label",r)}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontPasskeyButton.TAG}-${this.seed}`}get iconId(){return`${this.rootId}-${exports.PontPasskeyButton.ICON}`}get isLoading(){return this.loading||this._loading}get isDisabled(){return this.disabled||this.isLoading}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleClick)}_renderIcon(){const t=this.content==="icon"?"":`pont-icon-align-${this.iconAlign}`;return this.isLoading?l`
|
|
2650
2650
|
<pont-spinner
|
|
2651
2651
|
id="${this.iconId}"
|
|
2652
2652
|
part="${exports.PontPasskeyButton.PARTS.icon}"
|
|
@@ -2687,7 +2687,7 @@
|
|
|
2687
2687
|
${this.content.includes("label")?this.label:h}
|
|
2688
2688
|
${this.iconAlign==="end"?this._renderIcon():h}
|
|
2689
2689
|
</pont-button>
|
|
2690
|
-
`}};exports.PontPasskeyButton.ROOT="passkey-button";exports.PontPasskeyButton.ICON="icon";exports.PontPasskeyButton.TAG=`${rt}-${exports.PontPasskeyButton.ROOT}`;exports.PontPasskeyButton.CLICK_EVENT=`${exports.PontPasskeyButton.TAG}:click`;exports.PontPasskeyButton.SUCCESS_EVENT=`${exports.PontPasskeyButton.TAG}:success`;exports.PontPasskeyButton.ERROR_EVENT=`${exports.PontPasskeyButton.TAG}:error`;exports.PontPasskeyButton.PARTS={root:exports.PontPasskeyButton.ROOT,icon:`${exports.PontPasskeyButton.ROOT}-${exports.PontPasskeyButton.ICON}`};Yt([a({type:String})],exports.PontPasskeyButton.prototype,"seed",2);Yt([a({type:String,attribute:"custom-id"})],exports.PontPasskeyButton.prototype,"customId",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"variant",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"size",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"content",2);Yt([a({type:String,attribute:"icon-align"})],exports.PontPasskeyButton.prototype,"iconAlign",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"label",1);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"event",2);Yt([a({type:Boolean})],exports.PontPasskeyButton.prototype,"disabled",2);Yt([a({type:Boolean})],exports.PontPasskeyButton.prototype,"loading",2);Yt([g()],exports.PontPasskeyButton.prototype,"_loading",2);exports.PontPasskeyButton=Yt([p("pont-passkey-button")],exports.PontPasskeyButton);var CP=Object.defineProperty,EP=Object.getOwnPropertyDescriptor,Lt=(e,t,r,o)=>{for(var n=o>1?void 0:o?EP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&CP(t,r,n),n};exports.PontProviderButton=class extends f{constructor(){super(...arguments),this.seed=_t(),this.design=new Fo(this),this.variant=pn.variant,this.size=pn.size,this.content=pn.content,this.iconAlign=pn.iconAlign,this._prompt=pn.prompt,this._loading=!1,this._handleClick=async()=>{if(!this.isDisabled){this._loading=!0,this.dispatchEvent(new CustomEvent(exports.PontProviderButton.CLICK_EVENT,{detail:{id:this.rootId,provider:this.provider,event:this.event},bubbles:!0,composed:!0}));try{if(this.event){const t=await
|
|
2690
|
+
`}};exports.PontPasskeyButton.ROOT="passkey-button";exports.PontPasskeyButton.ICON="icon";exports.PontPasskeyButton.TAG=`${rt}-${exports.PontPasskeyButton.ROOT}`;exports.PontPasskeyButton.CLICK_EVENT=`${exports.PontPasskeyButton.TAG}:click`;exports.PontPasskeyButton.SUCCESS_EVENT=`${exports.PontPasskeyButton.TAG}:success`;exports.PontPasskeyButton.ERROR_EVENT=`${exports.PontPasskeyButton.TAG}:error`;exports.PontPasskeyButton.PARTS={root:exports.PontPasskeyButton.ROOT,icon:`${exports.PontPasskeyButton.ROOT}-${exports.PontPasskeyButton.ICON}`};Yt([a({type:String})],exports.PontPasskeyButton.prototype,"seed",2);Yt([a({type:String,attribute:"custom-id"})],exports.PontPasskeyButton.prototype,"customId",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"variant",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"size",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"content",2);Yt([a({type:String,attribute:"icon-align"})],exports.PontPasskeyButton.prototype,"iconAlign",2);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"label",1);Yt([a({type:String})],exports.PontPasskeyButton.prototype,"event",2);Yt([a({type:Boolean})],exports.PontPasskeyButton.prototype,"disabled",2);Yt([a({type:Boolean})],exports.PontPasskeyButton.prototype,"loading",2);Yt([g()],exports.PontPasskeyButton.prototype,"_loading",2);exports.PontPasskeyButton=Yt([p("pont-passkey-button")],exports.PontPasskeyButton);var CP=Object.defineProperty,EP=Object.getOwnPropertyDescriptor,Lt=(e,t,r,o)=>{for(var n=o>1?void 0:o?EP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&CP(t,r,n),n};exports.PontProviderButton=class extends f{constructor(){super(...arguments),this.seed=_t(),this.design=new Fo(this),this.variant=pn.variant,this.size=pn.size,this.content=pn.content,this.iconAlign=pn.iconAlign,this._prompt=pn.prompt,this._loading=!1,this._handleClick=async()=>{if(!this.isDisabled){this._loading=!0,this.dispatchEvent(new CustomEvent(exports.PontProviderButton.CLICK_EVENT,{detail:{id:this.rootId,provider:this.provider,event:this.event},bubbles:!0,composed:!0}));try{if(this.event){const t=await K.processLoginflowEvent({event:this.event});this.dispatchEvent(new CustomEvent(exports.PontProviderButton.SUCCESS_EVENT,{detail:{id:this.rootId,provider:this.provider,event:this.event,result:t},bubbles:!0,composed:!0}))}}catch(t){const r=t instanceof Error?t.message:String(t);this.dispatchEvent(new CustomEvent(exports.PontProviderButton.ERROR_EVENT,{detail:{id:this.rootId,provider:this.provider,event:this.event,message:r,error:t},bubbles:!0,composed:!0}))}finally{this._loading=!1}}}}get _provider(){return!this.provider&&this.design.active?"google":this.provider}get prompt(){return this._prompt}set prompt(t){const r=this._prompt;this._prompt=t.length?t:pn.prompt,this.requestUpdate("prompt",r)}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontProviderButton.TAG}-${this.seed}`}get iconId(){return`${this.rootId}-${exports.PontProviderButton.ICON}`}get isLoading(){return this.loading||this._loading}get isDisabled(){return this.disabled||this.isLoading}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleClick)}_renderIcon(){const t=this.content==="icon"?"":`pont-icon-align-${this.iconAlign}`;return this.isLoading?l`
|
|
2691
2691
|
<pont-spinner
|
|
2692
2692
|
id="${this.iconId}"
|
|
2693
2693
|
part="${exports.PontProviderButton.PARTS.icon}"
|
|
@@ -2758,7 +2758,7 @@
|
|
|
2758
2758
|
${this.content.includes("label")?this.label:h}
|
|
2759
2759
|
${this.iconAlign==="end"?this._renderIcon():h}
|
|
2760
2760
|
</pont-button>
|
|
2761
|
-
`}};exports.PontSubmitButton.ROOT="submit-button";exports.PontSubmitButton.ICON="icon";exports.PontSubmitButton.TAG=`${rt}-${exports.PontSubmitButton.ROOT}`;exports.PontSubmitButton.CLICK_EVENT=`${exports.PontSubmitButton.TAG}:click`;exports.PontSubmitButton.PARTS={root:exports.PontSubmitButton.ROOT,icon:`${exports.PontSubmitButton.ROOT}-${exports.PontSubmitButton.ICON}`};de([a({type:String})],exports.PontSubmitButton.prototype,"seed",2);de([a({type:String,attribute:"custom-id"})],exports.PontSubmitButton.prototype,"customId",2);de([a({type:String})],exports.PontSubmitButton.prototype,"variant",2);de([a({type:String})],exports.PontSubmitButton.prototype,"size",2);de([a({type:String})],exports.PontSubmitButton.prototype,"content",2);de([a({type:String,attribute:"icon-align"})],exports.PontSubmitButton.prototype,"iconAlign",2);de([a({type:String})],exports.PontSubmitButton.prototype,"label",1);de([a({type:String})],exports.PontSubmitButton.prototype,"event",2);de([a({type:Boolean})],exports.PontSubmitButton.prototype,"disabled",2);de([a({type:Boolean})],exports.PontSubmitButton.prototype,"loading",2);exports.PontSubmitButton=de([p("pont-submit-button")],exports.PontSubmitButton);var OP=Object.defineProperty,RP=Object.getOwnPropertyDescriptor,z=(e,t,r,o)=>{for(var n=o>1?void 0:o?RP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&OP(t,r,n),n};exports.PontPasswordField=class extends f{constructor(){super(...arguments),this.seed=_t(),this._name=He.name,this._label=He.label,this.variant=He.variant,this.rules=He.rules,this.validation=He.validation,this._forgotLabel=He.forgotLabel,this._invalid=!1,this._errors=[],this._value="",this._loading=!1,this._dirty=!1,this._form=null,this._handleInput=t=>{const r=t.target,o=`${exports.PontPasswordField.INPUT_SELECTORS} input`;r.matches(o)&&(this._dirty=!0,this._value=r.value)},this._handleFormSubmit=t=>{this._validate()||t.preventDefault()},this._handleFormReset=()=>{const t=exports.PontPasswordField.INPUT_SELECTORS,r=this.querySelector(t);r&&(r.value=this.defaultValue??""),this._invalid=!1,this._errors=[],this._value="",this._dirty=!1},this._handleForgotClick=async()=>{if(this.isDisabled)return;this._loading=!0;const{rootId:t,forgotId:r,forgotEvent:o}=this;this.dispatchEvent(new CustomEvent(exports.PontPasswordField.FORGOT_CLICK_EVENT,{detail:{id:t,forgotId:r,event:o},bubbles:!0,composed:!0}));try{if(o){const n=await
|
|
2761
|
+
`}};exports.PontSubmitButton.ROOT="submit-button";exports.PontSubmitButton.ICON="icon";exports.PontSubmitButton.TAG=`${rt}-${exports.PontSubmitButton.ROOT}`;exports.PontSubmitButton.CLICK_EVENT=`${exports.PontSubmitButton.TAG}:click`;exports.PontSubmitButton.PARTS={root:exports.PontSubmitButton.ROOT,icon:`${exports.PontSubmitButton.ROOT}-${exports.PontSubmitButton.ICON}`};de([a({type:String})],exports.PontSubmitButton.prototype,"seed",2);de([a({type:String,attribute:"custom-id"})],exports.PontSubmitButton.prototype,"customId",2);de([a({type:String})],exports.PontSubmitButton.prototype,"variant",2);de([a({type:String})],exports.PontSubmitButton.prototype,"size",2);de([a({type:String})],exports.PontSubmitButton.prototype,"content",2);de([a({type:String,attribute:"icon-align"})],exports.PontSubmitButton.prototype,"iconAlign",2);de([a({type:String})],exports.PontSubmitButton.prototype,"label",1);de([a({type:String})],exports.PontSubmitButton.prototype,"event",2);de([a({type:Boolean})],exports.PontSubmitButton.prototype,"disabled",2);de([a({type:Boolean})],exports.PontSubmitButton.prototype,"loading",2);exports.PontSubmitButton=de([p("pont-submit-button")],exports.PontSubmitButton);var OP=Object.defineProperty,RP=Object.getOwnPropertyDescriptor,z=(e,t,r,o)=>{for(var n=o>1?void 0:o?RP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&OP(t,r,n),n};exports.PontPasswordField=class extends f{constructor(){super(...arguments),this.seed=_t(),this._name=He.name,this._label=He.label,this.variant=He.variant,this.rules=He.rules,this.validation=He.validation,this._forgotLabel=He.forgotLabel,this._invalid=!1,this._errors=[],this._value="",this._loading=!1,this._dirty=!1,this._form=null,this._handleInput=t=>{const r=t.target,o=`${exports.PontPasswordField.INPUT_SELECTORS} input`;r.matches(o)&&(this._dirty=!0,this._value=r.value)},this._handleFormSubmit=t=>{this._validate()||t.preventDefault()},this._handleFormReset=()=>{const t=exports.PontPasswordField.INPUT_SELECTORS,r=this.querySelector(t);r&&(r.value=this.defaultValue??""),this._invalid=!1,this._errors=[],this._value="",this._dirty=!1},this._handleForgotClick=async()=>{if(this.isDisabled)return;this._loading=!0;const{rootId:t,forgotId:r,forgotEvent:o}=this;this.dispatchEvent(new CustomEvent(exports.PontPasswordField.FORGOT_CLICK_EVENT,{detail:{id:t,forgotId:r,event:o},bubbles:!0,composed:!0}));try{if(o){const n=await K.processLoginflowEvent({event:o});this.dispatchEvent(new CustomEvent(exports.PontPasswordField.FORGOT_SUCCESS_EVENT,{detail:{id:t,forgotId:r,event:o,result:n},bubbles:!0,composed:!0}))}}catch(n){const i=n instanceof Error?n.message:String(n);this.dispatchEvent(new CustomEvent(exports.PontPasswordField.FORGOT_ERROR_EVENT,{detail:{id:t,forgotId:r,event:o,message:i,error:n},bubbles:!0,composed:!0}))}finally{this._loading=!1}}}get _defaultInputId(){return`${this.rootId}-${exports.PontPasswordField.INPUT}`}get inputId(){return this._inputId??this._defaultInputId}set inputId(t){const r=this.inputId;this._inputId=t||void 0,this.requestUpdate("inputId",r)}get name(){return this._name}set name(t){const r=this._name;this._name=t.length?t:He.name,this.requestUpdate("name",r)}get label(){return this._label}set label(t){const r=this._label;this._label=t.length?t:He.label,this.requestUpdate("label",r)}get minlength(){return this._minlength}set minlength(t){const r=this._minlength;this._minlength=t===void 0||t>0?t:void 0,this.requestUpdate("minlength",r)}get maxlength(){return this._maxlength}set maxlength(t){const r=this._maxlength;if(t===void 0||t<=0)this._maxlength=void 0;else{const{minlength:o}=this;this._maxlength=o?Math.max(t,o):t}this.requestUpdate("maxlength",r)}get _defaultRequiredError(){return Ft(this.label)}get requiredError(){return this._requiredError??this._defaultRequiredError}set requiredError(t){const r=this.requiredError;this._requiredError=t||void 0,this.requestUpdate("requiredError",r)}get _defaultMinlengthError(){return Hn(this.label,this.minlength)}get minlengthError(){return this._minlengthError??this._defaultMinlengthError}set minlengthError(t){const r=this.minlengthError;this._minlengthError=t||void 0,this.requestUpdate("minlengthError",r)}get _defaultMaxlengthError(){return Gn(this.label,this.maxlength)}get maxlengthError(){return this._maxlengthError??this._defaultMaxlengthError}set maxlengthError(t){const r=this.maxlengthError;this._maxlengthError=t||void 0,this.requestUpdate("maxlengthError",r)}get _defaultFormatError(){return Te(this.label)}get formatError(){return this._formatError??this._defaultFormatError}set formatError(t){const r=this.formatError;this._formatError=t||void 0,this.requestUpdate("formatError",r)}get forgotLabel(){return this._forgotLabel}set forgotLabel(t){const r=this._forgotLabel;this._forgotLabel=t.length?t:He.forgotLabel,this.requestUpdate("forgotLabel",r)}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontPasswordField.TAG}-${this.seed}`}get labelId(){return`${this.rootId}-${exports.PontPasswordField.LABEL}`}get markId(){return`${this.rootId}-${exports.PontPasswordField.MARK}`}get forgotId(){return`${this.rootId}-${exports.PontPasswordField.FORGOT}`}get descriptionId(){return`${this.rootId}-${exports.PontPasswordField.DESCRIPTION}`}get errorId(){return`${this.rootId}-${exports.PontPasswordField.ERROR}`}get value(){const t=this.defaultValue??"";return this._dirty?this._value:t}get isDisabled(){return this.disabled||this._loading}updated(t){if(t.has("defaultValue")&&!this._dirty){const r=exports.PontPasswordField.INPUT_SELECTORS,o=this.querySelector(r);o&&(o.value=this.defaultValue??"")}}connectedCallback(){super.connectedCallback(),this.addEventListener("input",this._handleInput),this._form=this.closest("form"),this._form!==null&&(this._form.noValidate=!0,this._form.addEventListener("submit",this._handleFormSubmit),this._form.addEventListener("reset",this._handleFormReset))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("input",this._handleInput),this._form!==null&&(this._form.removeEventListener("submit",this._handleFormSubmit),this._form.removeEventListener("reset",this._handleFormReset),this._form=null)}validate(){return this._validate()}_dispatchValidate(t,r,o){const{rootId:n,inputId:i,name:s,value:d}=this;this.dispatchEvent(new CustomEvent(exports.PontPasswordField.VALIDATE_EVENT,{detail:{id:n,inputId:i,name:s,value:d,valid:t,type:r,message:o},bubbles:!0,composed:!0}))}_onValidateSuccess(){this._invalid=!1,this._errors=[],this._dispatchValidate(!0,"success","Valid password.")}_onValidateError(t,r,o){this._invalid=!0,this._errors=o!=null&&o.length?o:[r],this._dispatchValidate(!1,t,r)}_validate(){const t=this.value;if(this.required&&!t)return this._onValidateError("required",this.requiredError),!1;if(!t||this.validation==="simple")return this._onValidateSuccess(),!0;const{minlength:r}=this;if(r&&t.length<r)return this._onValidateError("minlength",this.minlengthError),!1;const{maxlength:o}=this;if(o&&t.length>o)return this._onValidateError("maxlength",this.maxlengthError),!1;let n=!0;const i=[];for(const s of this.rules)(s.name?exports.PontPasswordField.RULE_PATTERNS[s.name]:new RegExp(s.pattern)).test(t)||(n=!1,s.error&&i.push(s.error));if(!n){const s=i.length?i.join(" "):this.formatError;return this._onValidateError("format",s,i),!1}return this._onValidateSuccess(),!0}_renderMark(){let t;if(this.mark)t="mark";else if(this.required&&this.caret)t="caret";else return h;return l`
|
|
2762
2762
|
<span
|
|
2763
2763
|
id="${this.markId}"
|
|
2764
2764
|
part="${exports.PontPasswordField.PARTS.mark}"
|
|
@@ -3144,7 +3144,7 @@
|
|
|
3144
3144
|
</pont-field-description>
|
|
3145
3145
|
`:h}
|
|
3146
3146
|
</pont-field>
|
|
3147
|
-
`}};exports.PontUsernameField.ROOT="username-field";exports.PontUsernameField.LABEL="label";exports.PontUsernameField.MARK="mark";exports.PontUsernameField.DESCRIPTION="description";exports.PontUsernameField.INPUT="input";exports.PontUsernameField.ERROR="error";exports.PontUsernameField.TAG=`${rt}-${exports.PontUsernameField.ROOT}`;exports.PontUsernameField.VALIDATE_EVENT=`${exports.PontUsernameField.TAG}:validate`;exports.PontUsernameField.PARTS={root:exports.PontUsernameField.ROOT,label:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.LABEL}`,mark:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.MARK}`,description:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.DESCRIPTION}`,input:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.INPUT}`,error:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.ERROR}`};exports.PontUsernameField.INPUT_SELECTORS=`pont-input[part="${exports.PontUsernameField.PARTS.input}"]`;et([a({type:String})],exports.PontUsernameField.prototype,"seed",2);et([a({type:String,attribute:"custom-id"})],exports.PontUsernameField.prototype,"customId",2);et([a({type:String,attribute:"input-id"})],exports.PontUsernameField.prototype,"inputId",1);et([a({type:String})],exports.PontUsernameField.prototype,"name",1);et([a({type:String,attribute:"default-value"})],exports.PontUsernameField.prototype,"defaultValue",2);et([a({type:String})],exports.PontUsernameField.prototype,"label",1);et([a({type:String})],exports.PontUsernameField.prototype,"placeholder",2);et([a({type:String})],exports.PontUsernameField.prototype,"description",2);et([a({type:String})],exports.PontUsernameField.prototype,"mark",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"caret",2);et([a({type:String})],exports.PontUsernameField.prototype,"autocomplete",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"disabled",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"required",2);et([a({type:Number})],exports.PontUsernameField.prototype,"minlength",1);et([a({type:Number})],exports.PontUsernameField.prototype,"maxlength",1);et([a({type:String})],exports.PontUsernameField.prototype,"pattern",2);et([a({type:String})],exports.PontUsernameField.prototype,"validation",2);et([a({type:String,attribute:"required-error"})],exports.PontUsernameField.prototype,"requiredError",1);et([a({type:String,attribute:"minlength-error"})],exports.PontUsernameField.prototype,"minlengthError",1);et([a({type:String,attribute:"maxlength-error"})],exports.PontUsernameField.prototype,"maxlengthError",1);et([a({type:String,attribute:"format-error"})],exports.PontUsernameField.prototype,"formatError",1);et([g()],exports.PontUsernameField.prototype,"_invalid",2);et([g()],exports.PontUsernameField.prototype,"_error",2);et([g()],exports.PontUsernameField.prototype,"_value",2);exports.PontUsernameField=et([p("pont-username-field")],exports.PontUsernameField);const us={label:"Link",service:"auth"};var zP=Object.defineProperty,VP=Object.getOwnPropertyDescriptor,De=(e,t,r,o)=>{for(var n=o>1?void 0:o?VP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&zP(t,r,n),n};exports.PontLink=class extends f{constructor(){super(...arguments),this.seed=_t(),this._label=us.label,this.service=us.service,this._loading=!1,this._handleClick=async()=>{if(this.isDisabled)return;this._loading=!0;const{rootId:t,buttonId:r,service:o,event:n}=this;this.dispatchEvent(new CustomEvent(exports.PontLink.CLICK_EVENT,{detail:{id:t,buttonId:r,service:o,event:n},bubbles:!0,composed:!0}));try{if(n&&o==="auth"){const i=await
|
|
3147
|
+
`}};exports.PontUsernameField.ROOT="username-field";exports.PontUsernameField.LABEL="label";exports.PontUsernameField.MARK="mark";exports.PontUsernameField.DESCRIPTION="description";exports.PontUsernameField.INPUT="input";exports.PontUsernameField.ERROR="error";exports.PontUsernameField.TAG=`${rt}-${exports.PontUsernameField.ROOT}`;exports.PontUsernameField.VALIDATE_EVENT=`${exports.PontUsernameField.TAG}:validate`;exports.PontUsernameField.PARTS={root:exports.PontUsernameField.ROOT,label:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.LABEL}`,mark:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.MARK}`,description:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.DESCRIPTION}`,input:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.INPUT}`,error:`${exports.PontUsernameField.ROOT}-${exports.PontUsernameField.ERROR}`};exports.PontUsernameField.INPUT_SELECTORS=`pont-input[part="${exports.PontUsernameField.PARTS.input}"]`;et([a({type:String})],exports.PontUsernameField.prototype,"seed",2);et([a({type:String,attribute:"custom-id"})],exports.PontUsernameField.prototype,"customId",2);et([a({type:String,attribute:"input-id"})],exports.PontUsernameField.prototype,"inputId",1);et([a({type:String})],exports.PontUsernameField.prototype,"name",1);et([a({type:String,attribute:"default-value"})],exports.PontUsernameField.prototype,"defaultValue",2);et([a({type:String})],exports.PontUsernameField.prototype,"label",1);et([a({type:String})],exports.PontUsernameField.prototype,"placeholder",2);et([a({type:String})],exports.PontUsernameField.prototype,"description",2);et([a({type:String})],exports.PontUsernameField.prototype,"mark",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"caret",2);et([a({type:String})],exports.PontUsernameField.prototype,"autocomplete",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"disabled",2);et([a({type:Boolean})],exports.PontUsernameField.prototype,"required",2);et([a({type:Number})],exports.PontUsernameField.prototype,"minlength",1);et([a({type:Number})],exports.PontUsernameField.prototype,"maxlength",1);et([a({type:String})],exports.PontUsernameField.prototype,"pattern",2);et([a({type:String})],exports.PontUsernameField.prototype,"validation",2);et([a({type:String,attribute:"required-error"})],exports.PontUsernameField.prototype,"requiredError",1);et([a({type:String,attribute:"minlength-error"})],exports.PontUsernameField.prototype,"minlengthError",1);et([a({type:String,attribute:"maxlength-error"})],exports.PontUsernameField.prototype,"maxlengthError",1);et([a({type:String,attribute:"format-error"})],exports.PontUsernameField.prototype,"formatError",1);et([g()],exports.PontUsernameField.prototype,"_invalid",2);et([g()],exports.PontUsernameField.prototype,"_error",2);et([g()],exports.PontUsernameField.prototype,"_value",2);exports.PontUsernameField=et([p("pont-username-field")],exports.PontUsernameField);const us={label:"Link",service:"auth"};var zP=Object.defineProperty,VP=Object.getOwnPropertyDescriptor,De=(e,t,r,o)=>{for(var n=o>1?void 0:o?VP(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&zP(t,r,n),n};exports.PontLink=class extends f{constructor(){super(...arguments),this.seed=_t(),this._label=us.label,this.service=us.service,this._loading=!1,this._handleClick=async()=>{if(this.isDisabled)return;this._loading=!0;const{rootId:t,buttonId:r,service:o,event:n}=this;this.dispatchEvent(new CustomEvent(exports.PontLink.CLICK_EVENT,{detail:{id:t,buttonId:r,service:o,event:n},bubbles:!0,composed:!0}));try{if(n&&o==="auth"){const i=await K.processLoginflowEvent({event:n});this.dispatchEvent(new CustomEvent(exports.PontLink.SUCCESS_EVENT,{detail:{id:t,buttonId:r,event:n,result:i},bubbles:!0,composed:!0}))}}catch(i){const s=i instanceof Error?i.message:String(i);this.dispatchEvent(new CustomEvent(exports.PontLink.ERROR_EVENT,{detail:{id:t,buttonId:r,event:n,message:s,error:i},bubbles:!0,composed:!0}))}finally{this._loading=!1}}}get label(){return this._label}set label(t){const r=this._label;this._label=t.length?t:us.label,this.requestUpdate("label",r)}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontLink.TAG}-${this.seed}`}get buttonId(){return`${this.rootId}-${exports.PontLink.BUTTON}`}get promptId(){return`${this.rootId}-${exports.PontLink.PROMPT}`}get isLoading(){return this.loading||this._loading}get isDisabled(){return this.disabled||this.isLoading}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleClick)}render(){var t;return l`
|
|
3148
3148
|
<div id="${this.rootId}" part="${exports.PontLink.PARTS.root}">
|
|
3149
3149
|
${(t=this.prompt)!=null&&t.length?l`
|
|
3150
3150
|
<p id="${this.promptId}" part="${exports.PontLink.PARTS.prompt}">
|
|
@@ -3241,7 +3241,7 @@
|
|
|
3241
3241
|
</svg>`}function t1(){return U`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3242
3242
|
<path d="M9.99976 7.49988V10.8332M9.99976 14.1665H10.0081M18.108 14.9999L11.4414 3.33319C11.296 3.0767 11.0852 2.86335 10.8305 2.71492C10.5757 2.56649 10.2862 2.48828 9.99136 2.48828C9.69654 2.48828 9.40699 2.56649 9.15226 2.71492C8.89753 2.86335 8.68673 3.0767 8.54136 3.33319L1.8747 14.9999C1.72777 15.2543 1.65072 15.5431 1.65137 15.837C1.65202 16.1308 1.73035 16.4192 1.8784 16.673C2.02646 16.9269 2.23899 17.137 2.49444 17.2822C2.7499 17.4274 3.0392 17.5025 3.33303 17.4999H16.6664C16.9588 17.4996 17.246 17.4223 17.4991 17.2759C17.7522 17.1295 17.9624 16.9191 18.1085 16.6658C18.2545 16.4125 18.3314 16.1252 18.3313 15.8328C18.3312 15.5404 18.2542 15.2531 18.108 14.9999Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3243
3243
|
</svg>`}function e1(){return U`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
|
|
3244
|
-
`}var r1=Object.defineProperty,n1=Object.getOwnPropertyDescriptor,No=(e,t,r,o)=>{for(var n=o>1?void 0:o?n1(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&r1(t,r,n),n};exports.PontEditIdentifier=class extends f{constructor(){super(...arguments),this.seed=_t(),this.identifier=KP.identifier,this.event="",this._handleClick=()=>{
|
|
3244
|
+
`}var r1=Object.defineProperty,n1=Object.getOwnPropertyDescriptor,No=(e,t,r,o)=>{for(var n=o>1?void 0:o?n1(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&r1(t,r,n),n};exports.PontEditIdentifier=class extends f{constructor(){super(...arguments),this.seed=_t(),this.identifier=KP.identifier,this.event="",this._handleClick=()=>{K.processLoginflowEvent({event:this.event})}}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontEditIdentifier.TAG}-${this.seed}`}get iconId(){return`${this.rootId}-${exports.PontEditIdentifier.ICON}`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleClick)}render(){return l`
|
|
3245
3245
|
<div>
|
|
3246
3246
|
<pont-typography-p>${this.identifier}</pont-typography-p>
|
|
3247
3247
|
<div class="pont-flex pont-items-center">
|
|
@@ -4570,7 +4570,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
4570
4570
|
</div>
|
|
4571
4571
|
|
|
4572
4572
|
${this.isBurger?this.renderMobileDrawer():null}
|
|
4573
|
-
`}};on([a({type:String})],_r.prototype,"orientation",2);on([a({type:String})],_r.prototype,"displayType",2);on([a({type:String})],_r.prototype,"mode",2);on([a({type:Object})],_r.prototype,"config",2);on([a({type:String})],_r.prototype,"activeTab",2);on([g()],_r.prototype,"isMenuOpen",2);_r=on([p("pont-profile-sidebar")],_r);function xl(){document.dispatchEvent(new CustomEvent("open-user-profile",{bubbles:!0,composed:!0}))}function Ol(){document.dispatchEvent(new CustomEvent("close-user-profile",{bubbles:!0,composed:!0}))}function Wh(){document.dispatchEvent(new CustomEvent("open-member-management",{bubbles:!0,composed:!0}))}function Yh(){document.dispatchEvent(new CustomEvent("close-member-management",{bubbles:!0,composed:!0}))}function Qh(e){document.dispatchEvent(new CustomEvent("pont:set-locales",{detail:{locales:e},bubbles:!0,composed:!0}))}typeof window<"u"&&(window.__pontCoreSdk||(window.__pontCoreSdk={}),window.__pontCoreSdk.openAccountSettingsModal=xl,window.__pontCoreSdk.closeAccountSettingsModal=Ol,window.__pontCoreSdk.openMemberManagementModal=Wh,window.__pontCoreSdk.closeMemberManagementModal=Yh,window.__pontCoreSdk.setLocales=Qh);var J0=Object.defineProperty,jt=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&J0(t,r,n),n};class Rt extends f{constructor(){super(),this.showAvatarMenu=!1,this.orientation=Lr.HORIZONTAL,this.mobileDisplay=Ke.REGULAR,this.mode=pr.PAGE,this.widgetsLayout=nt.ROW,this.content=null,this.isOpen=!1,this.currentBreakpoint="md",this.activeTab=ve.PROFILE,this._userLoaded=!1,this._userLoading=!1,this.userContextValue={user:null,identifier:null},this.__initialized=!1,this.account={email:"",phone:"",avatar:""},this.personal={username:"",first:"",middle:"",last:"",nickname:"",gender:"",bio:""},this.location={location:"",zoneInfo:""},this.urls={website:""},this._handleResize=()=>{this._updateBreakpoint()},this._handleCloseProfile=()=>{this.isModal&&(this.isOpen=!1)},this._handleOpenProfile=()=>{this.isModal&&(this.isOpen=!0)},this._toggleAvatarMenu=t=>{t.stopPropagation(),this.showAvatarMenu=!this.showAvatarMenu},this._handleAvatarChange=()=>{const t=document.createElement("input");t.type="file",t.accept="image/*",t.onchange=r=>{var i;const o=(i=r.target.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=()=>{this.account.avatar=n.result,this.requestUpdate()},n.readAsDataURL(o)},t.click()},this._handleAvatarRemove=()=>{this.account.avatar="https://via.placeholder.com/80",this.showAvatarMenu=!1},this._handleClickOutside=t=>{if(!this.showAvatarMenu)return;const r=t.target,o=this.querySelector("pont-account-info"),n=this.querySelector("pont-card");o!=null&&o.contains(r)||n!=null&&n.contains(r)||(this.showAvatarMenu=!1)},this._handleOpenProfile=this._handleOpenProfile.bind(this),this._handleCloseProfile=this._handleCloseProfile.bind(this),window.addEventListener("open-user-profile",this._handleOpenProfile),window.addEventListener("close-user-profile",this._handleCloseProfile)}get isModal(){return this.mode===pr.MODAL}get isVerticalOrientation(){return this.orientation===Lr.VERTICAL}get isHorizontalOrientation(){return this.orientation===Lr.HORIZONTAL}get isBurger(){return this.sidebarDisplayType===Ke.BURGER}get sidebarDisplayType(){return this.isVerticalOrientation||this.currentBreakpoint==="md"?Ke.REGULAR:Ke.BURGER}get layoutKey(){return`${this.orientation}|${this.mode}|${this.widgetsLayout}|${this.mobileDisplay}`}get containerClasses(){const t=this.isBurger||this.isVerticalOrientation;return zt(Nw,this.isModal?Bw:Mw,this.isModal?kw:Fw,t?"!pont-flex-col":"!pont-flex-row")}get contentClasses(){return zt("pont-flex-grow",this.isModal?`pont-account-settings-modal-content ${this.isHorizontalOrientation?"pont-account-settings-modal-content-horizontal":""}`:"pont-account-settings-content-md-max-height-full",this.isVerticalOrientation?"pont-account-settings-vertical-margin":"")}connectedCallback(){super.connectedCallback(),this._updateBreakpoint(),window.addEventListener("resize",this._handleResize),document.addEventListener("remove-avatar",this._handleAvatarRemove),document.addEventListener("click",this._handleClickOutside),document.addEventListener("close-user-profile",this._handleCloseProfile),document.addEventListener("open-user-profile",this._handleOpenProfile),document.addEventListener("change-avatar",this._handleAvatarChange)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize),document.removeEventListener("remove-avatar",this._handleAvatarRemove),document.removeEventListener("click",this._handleClickOutside),document.removeEventListener("close-user-profile",this._handleCloseProfile),document.removeEventListener("open-user-profile",this._handleOpenProfile),document.removeEventListener("change-avatar",this._handleAvatarChange)}updated(t){t.has("mode")&&(this.isModal?this.isOpen=!1:this.isOpen=!0),t.has("userContextValue")&&this.userContextValue.user&&this.tryRemoveFallback(),t.has("auth")&&this.loadUser()}firstUpdated(){this.__initialized||(this.__initialized=!0,this.style.width="100%",this.style.display="flex",this.style.justifyContent="center",this.style.flexDirection="column")}fillProfileData(t){var r;this.account={...this.account,avatar:t.picture||"",email:t.email||"",phone:t.phone||""},this.personal={...this.personal,bio:t.profile||"",first:t.given_name||"",last:t.family_name||"",username:t.username||"",gender:t.gender||"",middle:t.middle_name||"",nickname:t.nickname||""},this.location={...this.location,location:((r=t.address)==null?void 0:r.locality)||"",zoneInfo:t.zoneinfo||""},this.urls={...this.urls,website:t.website||""}}async loadUser(){var t,r;if(!(!((t=this.auth)!=null&&t.resolved)||!this.auth.isAuthenticated)&&!(this._userLoaded||this._userLoading)&&(this.userContextValue.identifier=((r=
|
|
4573
|
+
`}};on([a({type:String})],_r.prototype,"orientation",2);on([a({type:String})],_r.prototype,"displayType",2);on([a({type:String})],_r.prototype,"mode",2);on([a({type:Object})],_r.prototype,"config",2);on([a({type:String})],_r.prototype,"activeTab",2);on([g()],_r.prototype,"isMenuOpen",2);_r=on([p("pont-profile-sidebar")],_r);function xl(){document.dispatchEvent(new CustomEvent("open-user-profile",{bubbles:!0,composed:!0}))}function Ol(){document.dispatchEvent(new CustomEvent("close-user-profile",{bubbles:!0,composed:!0}))}function Wh(){document.dispatchEvent(new CustomEvent("open-member-management",{bubbles:!0,composed:!0}))}function Yh(){document.dispatchEvent(new CustomEvent("close-member-management",{bubbles:!0,composed:!0}))}function Qh(e){document.dispatchEvent(new CustomEvent("pont:set-locales",{detail:{locales:e},bubbles:!0,composed:!0}))}typeof window<"u"&&(window.__pontCoreSdk||(window.__pontCoreSdk={}),window.__pontCoreSdk.openAccountSettingsModal=xl,window.__pontCoreSdk.closeAccountSettingsModal=Ol,window.__pontCoreSdk.openMemberManagementModal=Wh,window.__pontCoreSdk.closeMemberManagementModal=Yh,window.__pontCoreSdk.setLocales=Qh);var J0=Object.defineProperty,jt=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&J0(t,r,n),n};class Rt extends f{constructor(){super(),this.showAvatarMenu=!1,this.orientation=Lr.HORIZONTAL,this.mobileDisplay=Ke.REGULAR,this.mode=pr.PAGE,this.widgetsLayout=nt.ROW,this.content=null,this.isOpen=!1,this.currentBreakpoint="md",this.activeTab=ve.PROFILE,this._userLoaded=!1,this._userLoading=!1,this.userContextValue={user:null,identifier:null},this.__initialized=!1,this.account={email:"",phone:"",avatar:""},this.personal={username:"",first:"",middle:"",last:"",nickname:"",gender:"",bio:""},this.location={location:"",zoneInfo:""},this.urls={website:""},this._handleResize=()=>{this._updateBreakpoint()},this._handleCloseProfile=()=>{this.isModal&&(this.isOpen=!1)},this._handleOpenProfile=()=>{this.isModal&&(this.isOpen=!0)},this._toggleAvatarMenu=t=>{t.stopPropagation(),this.showAvatarMenu=!this.showAvatarMenu},this._handleAvatarChange=()=>{const t=document.createElement("input");t.type="file",t.accept="image/*",t.onchange=r=>{var i;const o=(i=r.target.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=()=>{this.account.avatar=n.result,this.requestUpdate()},n.readAsDataURL(o)},t.click()},this._handleAvatarRemove=()=>{this.account.avatar="https://via.placeholder.com/80",this.showAvatarMenu=!1},this._handleClickOutside=t=>{if(!this.showAvatarMenu)return;const r=t.target,o=this.querySelector("pont-account-info"),n=this.querySelector("pont-card");o!=null&&o.contains(r)||n!=null&&n.contains(r)||(this.showAvatarMenu=!1)},this._handleOpenProfile=this._handleOpenProfile.bind(this),this._handleCloseProfile=this._handleCloseProfile.bind(this),window.addEventListener("open-user-profile",this._handleOpenProfile),window.addEventListener("close-user-profile",this._handleCloseProfile)}get isModal(){return this.mode===pr.MODAL}get isVerticalOrientation(){return this.orientation===Lr.VERTICAL}get isHorizontalOrientation(){return this.orientation===Lr.HORIZONTAL}get isBurger(){return this.sidebarDisplayType===Ke.BURGER}get sidebarDisplayType(){return this.isVerticalOrientation||this.currentBreakpoint==="md"?Ke.REGULAR:Ke.BURGER}get layoutKey(){return`${this.orientation}|${this.mode}|${this.widgetsLayout}|${this.mobileDisplay}`}get containerClasses(){const t=this.isBurger||this.isVerticalOrientation;return zt(Nw,this.isModal?Bw:Mw,this.isModal?kw:Fw,t?"!pont-flex-col":"!pont-flex-row")}get contentClasses(){return zt("pont-flex-grow",this.isModal?`pont-account-settings-modal-content ${this.isHorizontalOrientation?"pont-account-settings-modal-content-horizontal":""}`:"pont-account-settings-content-md-max-height-full",this.isVerticalOrientation?"pont-account-settings-vertical-margin":"")}connectedCallback(){super.connectedCallback(),this._updateBreakpoint(),window.addEventListener("resize",this._handleResize),document.addEventListener("remove-avatar",this._handleAvatarRemove),document.addEventListener("click",this._handleClickOutside),document.addEventListener("close-user-profile",this._handleCloseProfile),document.addEventListener("open-user-profile",this._handleOpenProfile),document.addEventListener("change-avatar",this._handleAvatarChange)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._handleResize),document.removeEventListener("remove-avatar",this._handleAvatarRemove),document.removeEventListener("click",this._handleClickOutside),document.removeEventListener("close-user-profile",this._handleCloseProfile),document.removeEventListener("open-user-profile",this._handleOpenProfile),document.removeEventListener("change-avatar",this._handleAvatarChange)}updated(t){t.has("mode")&&(this.isModal?this.isOpen=!1:this.isOpen=!0),t.has("userContextValue")&&this.userContextValue.user&&this.tryRemoveFallback(),t.has("auth")&&this.loadUser()}firstUpdated(){this.__initialized||(this.__initialized=!0,this.style.width="100%",this.style.display="flex",this.style.justifyContent="center",this.style.flexDirection="column")}fillProfileData(t){var r;this.account={...this.account,avatar:t.picture||"",email:t.email||"",phone:t.phone||""},this.personal={...this.personal,bio:t.profile||"",first:t.given_name||"",last:t.family_name||"",username:t.username||"",gender:t.gender||"",middle:t.middle_name||"",nickname:t.nickname||""},this.location={...this.location,location:((r=t.address)==null?void 0:r.locality)||"",zoneInfo:t.zoneinfo||""},this.urls={...this.urls,website:t.website||""}}async loadUser(){var t,r;if(!(!((t=this.auth)!=null&&t.resolved)||!this.auth.isAuthenticated)&&!(this._userLoaded||this._userLoading)&&(this.userContextValue.identifier=((r=K.getAuthenticatedUser())==null?void 0:r.email)??"",!!this.userContextValue.identifier)){this._userLoading=!0;try{this.userContextValue.user=await R0(),this.tryRemoveFallback(),this.fillProfileData(this.userContextValue.user),this._userLoaded=!0}catch(o){console.error("[pont-account-settings] Failed loading user:",o)}finally{this._userLoading=!1}}}tryRemoveFallback(){requestAnimationFrame(()=>{const r=this.querySelector('[part="fallback"]');r==null||r.remove()})}_updateBreakpoint(){const t=window.innerWidth;this.currentBreakpoint=t<yc.xs?"xs":t<yc.sm?"sm":"md"}renderWatermark(){return this.isVerticalOrientation?l`
|
|
4574
4574
|
<div class="pont-account-settings-watermark-container">
|
|
4575
4575
|
<pont-watermark custom-id="pont-watermark"></pont-watermark>
|
|
4576
4576
|
</div>
|
|
@@ -4702,7 +4702,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
4702
4702
|
${this.statisticBlock(this.generateBlockProps("pending-invites"))}
|
|
4703
4703
|
${this.statisticBlock(this.generateBlockProps("inactive-members"))}
|
|
4704
4704
|
</div>
|
|
4705
|
-
`}}customElements.define("pont-monitoring-cards",eC);var rC=Object.defineProperty,nC=Object.getOwnPropertyDescriptor,Zt=(e,t,r,o)=>{for(var n=o>1?void 0:o?nC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&rC(t,r,n),n};let Bt=class extends f{constructor(){super(...arguments),this.drawerId="pont-member-invite",this.organizationId="",this.emails=[],this.roles=[],this.availableRoles=[],this.expiryDays="7",this.customMessage="",this.errors={},this.open=!1,this.isLoading=!1,this.isLoadingRoles=!1,this._handleOpenDrawer=e=>{const t=e.detail,r=(t==null?void 0:t.id)||(t==null?void 0:t.drawer_id);r&&r!==this.drawerId||(this.open=!0,this.organizationId&&this.loadRoles())},this._handleCloseDrawer=e=>{const t=e.detail,r=(t==null?void 0:t.id)||(t==null?void 0:t.drawer_id);r&&r!==this.drawerId||(this.open=!1)},this._handleDrawerClosed=()=>{this.open=!1}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),document.addEventListener("open-sidedrawer",this._handleOpenDrawer),document.addEventListener("close-sidedrawer",this._handleCloseDrawer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("open-sidedrawer",this._handleOpenDrawer),document.removeEventListener("close-sidedrawer",this._handleCloseDrawer)}async loadRoles(){try{this.isLoadingRoles=!0;const e={resource_id:this.organizationId,resource_type:"organization"},t=await Sl(e);this.availableRoles=t.data.map(r=>({value:r.key||r.name,label:r.name,description:r.description||void 0,disabled:!1}))}catch(e){console.error("Failed to load roles:",e)}finally{this.isLoadingRoles=!1}}close(){this.open=!1,window.dispatchEvent(new CustomEvent("close-sidedrawer",{detail:{id:this.drawerId}}))}onEmailsChange(e){this.emails=e,this.errors={...this.errors,emails:void 0}}onRolesChange(e){this.roles=e,this.errors={...this.errors,roles:void 0}}handleExpiryInput(e){this.expiryDays=e.target.value}handleMessageInput(e){this.customMessage=e.target.value}async handleSend(){var r;const e={};if(this.emails.length===0&&(e.emails="Please enter at least one email address."),this.roles.length===0&&(e.roles="Please select at least one role."),Object.keys(e).length>0){this.errors=e;return}if(!this.organizationId){console.error("Organization ID is required");return}const t={emails:this.emails,roles:this.roles,invited_by:(r=
|
|
4705
|
+
`}}customElements.define("pont-monitoring-cards",eC);var rC=Object.defineProperty,nC=Object.getOwnPropertyDescriptor,Zt=(e,t,r,o)=>{for(var n=o>1?void 0:o?nC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&rC(t,r,n),n};let Bt=class extends f{constructor(){super(...arguments),this.drawerId="pont-member-invite",this.organizationId="",this.emails=[],this.roles=[],this.availableRoles=[],this.expiryDays="7",this.customMessage="",this.errors={},this.open=!1,this.isLoading=!1,this.isLoadingRoles=!1,this._handleOpenDrawer=e=>{const t=e.detail,r=(t==null?void 0:t.id)||(t==null?void 0:t.drawer_id);r&&r!==this.drawerId||(this.open=!0,this.organizationId&&this.loadRoles())},this._handleCloseDrawer=e=>{const t=e.detail,r=(t==null?void 0:t.id)||(t==null?void 0:t.drawer_id);r&&r!==this.drawerId||(this.open=!1)},this._handleDrawerClosed=()=>{this.open=!1}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),document.addEventListener("open-sidedrawer",this._handleOpenDrawer),document.addEventListener("close-sidedrawer",this._handleCloseDrawer)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("open-sidedrawer",this._handleOpenDrawer),document.removeEventListener("close-sidedrawer",this._handleCloseDrawer)}async loadRoles(){try{this.isLoadingRoles=!0;const e={resource_id:this.organizationId,resource_type:"organization"},t=await Sl(e);this.availableRoles=t.data.map(r=>({value:r.key||r.name,label:r.name,description:r.description||void 0,disabled:!1}))}catch(e){console.error("Failed to load roles:",e)}finally{this.isLoadingRoles=!1}}close(){this.open=!1,window.dispatchEvent(new CustomEvent("close-sidedrawer",{detail:{id:this.drawerId}}))}onEmailsChange(e){this.emails=e,this.errors={...this.errors,emails:void 0}}onRolesChange(e){this.roles=e,this.errors={...this.errors,roles:void 0}}handleExpiryInput(e){this.expiryDays=e.target.value}handleMessageInput(e){this.customMessage=e.target.value}async handleSend(){var r;const e={};if(this.emails.length===0&&(e.emails="Please enter at least one email address."),this.roles.length===0&&(e.roles="Please select at least one role."),Object.keys(e).length>0){this.errors=e;return}if(!this.organizationId){console.error("Organization ID is required");return}const t={emails:this.emails,roles:this.roles,invited_by:(r=K.getAuthenticatedUser())==null?void 0:r.sub,message:this.customMessage||void 0};this.isLoading=!0;try{const o=await D0(this.organizationId,t);this.emails=[],this.roles=[],this.expiryDays="7",this.customMessage="",this.errors={},window.dispatchEvent(new CustomEvent("invite-members-success",{detail:{organizationId:this.organizationId,response:o}})),this.close()}catch(o){console.error("Failed to send invites:",o),this.errors={...this.errors,emails:"Failed to send invites. Please try again."}}finally{this.isLoading=!1}}render(){return l`
|
|
4706
4706
|
<pont-sidedrawer
|
|
4707
4707
|
id=${this.drawerId}
|
|
4708
4708
|
side="right"
|
|
@@ -5546,7 +5546,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5546
5546
|
</signed-out>
|
|
5547
5547
|
</pont-provider>
|
|
5548
5548
|
`}
|
|
5549
|
-
`}};Zi([a({type:Boolean})],exports.PreviewComponent.prototype,"loading",2);Zi([a({type:Object})],exports.PreviewComponent.prototype,"renderSpec",2);Zi([a({attribute:!1})],exports.PreviewComponent.prototype,"branding",2);exports.PreviewComponent=Zi([p("pont-preview")],exports.PreviewComponent);const _C="We couldn't reach the server. Check your connection and try again.",wC="Too many attempts. Wait a moment and try again.",$C="Something went wrong on our side. Please try again.",PC="Something went wrong. Please try again.",CC="This sign-in could not be completed.",EC="The passkey request was cancelled or timed out. Please try again.",SC=409;function Jh(e){if(e instanceof DOMException&&(e.name==="NotAllowedError"||e.name==="AbortError"))return{message:EC,restartable:!1};const{status:t,code:r,message:o}=xC(e);return t===SC?{message:mp(o)??CC,restartable:!0}:t===void 0&&(r==="NETWORK_ERROR"||r==="TIMEOUT")?{message:_C,restartable:!1}:t===429?{message:wC,restartable:!1}:t!==void 0&&t>=500?{message:$C,restartable:!1}:{message:mp(o)??PC,restartable:!1}}function xC(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object")return{};const t=e;return{status:typeof t.status=="number"?t.status:void 0,code:typeof t.code=="string"?t.code:void 0,message:typeof t.message=="string"?t.message:void 0}}function mp(e){const t=e==null?void 0:e.trim();if(!t||/^HTTP \d{3}\b/.test(t)||t.includes("`"))return;const r=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?]$/.test(r)?r:`${r}.`}var OC=Object.defineProperty,Ji=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&OC(t,r,n),n};class sn extends f{constructor(){super(...arguments),this.renderSpec=null,this.branding=Lo,this.locales="",this.__flowStarted=!1,this.__initialized=!1,this.__previousLocale=null,this.restart=()=>{this.__flowStarted=!1,this.startAuthFlow()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.addEventListener(exports.PontKitLayout.RESTART_EVENT,this.restart)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(exports.PontKitLayout.RESTART_EVENT,this.restart)}firstUpdated(){this.__initialized||(this.__initialized=!0,this.__previousLocale=this.locales,this.startAuthFlow())}updated(t){if(t.has("locales")){const r=this.locales;this.__previousLocale!==r&&(this.__previousLocale=r,this.restart())}t.has("renderSpec")&&this.renderSpec&&this.tryRemoveFallback()}async startAuthFlow(){if(!this.__flowStarted){this.__flowStarted=!0,this.startError=void 0,await fP(
|
|
5549
|
+
`}};Zi([a({type:Boolean})],exports.PreviewComponent.prototype,"loading",2);Zi([a({type:Object})],exports.PreviewComponent.prototype,"renderSpec",2);Zi([a({attribute:!1})],exports.PreviewComponent.prototype,"branding",2);exports.PreviewComponent=Zi([p("pont-preview")],exports.PreviewComponent);const _C="We couldn't reach the server. Check your connection and try again.",wC="Too many attempts. Wait a moment and try again.",$C="Something went wrong on our side. Please try again.",PC="Something went wrong. Please try again.",CC="This sign-in could not be completed.",EC="The passkey request was cancelled or timed out. Please try again.",SC=409;function Jh(e){if(e instanceof DOMException&&(e.name==="NotAllowedError"||e.name==="AbortError"))return{message:EC,restartable:!1};const{status:t,code:r,message:o}=xC(e);return t===SC?{message:mp(o)??CC,restartable:!0}:t===void 0&&(r==="NETWORK_ERROR"||r==="TIMEOUT")?{message:_C,restartable:!1}:t===429?{message:wC,restartable:!1}:t!==void 0&&t>=500?{message:$C,restartable:!1}:{message:mp(o)??PC,restartable:!1}}function xC(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object")return{};const t=e;return{status:typeof t.status=="number"?t.status:void 0,code:typeof t.code=="string"?t.code:void 0,message:typeof t.message=="string"?t.message:void 0}}function mp(e){const t=e==null?void 0:e.trim();if(!t||/^HTTP \d{3}\b/.test(t)||t.includes("`"))return;const r=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?]$/.test(r)?r:`${r}.`}var OC=Object.defineProperty,Ji=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&OC(t,r,n),n};class sn extends f{constructor(){super(...arguments),this.renderSpec=null,this.branding=Lo,this.locales="",this.__flowStarted=!1,this.__initialized=!1,this.__previousLocale=null,this.restart=()=>{this.__flowStarted=!1,this.startAuthFlow()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.addEventListener(exports.PontKitLayout.RESTART_EVENT,this.restart)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(exports.PontKitLayout.RESTART_EVENT,this.restart)}firstUpdated(){this.__initialized||(this.__initialized=!0,this.__previousLocale=this.locales,this.startAuthFlow())}updated(t){if(t.has("locales")){const r=this.locales;this.__previousLocale!==r&&(this.__previousLocale=r,this.restart())}t.has("renderSpec")&&this.renderSpec&&this.tryRemoveFallback()}async startAuthFlow(){if(!this.__flowStarted){this.__flowStarted=!0,this.startError=void 0,await fP(K);try{await this.startFlow()}catch(t){console.error(`[${this.localName}] Starting the flow failed:`,t),this.startError=Jh(t).message,this.__flowStarted=!1}this.tryRemoveFallback()}}tryRemoveFallback(){requestAnimationFrame(()=>{var t;(t=this.querySelector('[part="fallback"]'))==null||t.remove()})}render(){return this.startError?l`<div part="flow-error" class="pont-flex pont-flex-col pont-gap-3">
|
|
5550
5550
|
<pont-alert status="error" description=${this.startError}></pont-alert>
|
|
5551
5551
|
<pont-button variant="outline" @click=${this.restart}>
|
|
5552
5552
|
Try again
|
|
@@ -5554,7 +5554,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5554
5554
|
</div>`:this.renderSpec?l`<pont-layout
|
|
5555
5555
|
.renderSpec=${this.renderSpec}
|
|
5556
5556
|
.branding=${this.branding}
|
|
5557
|
-
></pont-layout>`:l``}}Ji([yt({context:Mh,subscribe:!0})],sn.prototype,"renderSpec");Ji([yt({context:Bi,subscribe:!0})],sn.prototype,"branding");Ji([yt({context:Bh,subscribe:!0})],sn.prototype,"locales");Ji([g()],sn.prototype,"startError");var RC=Object.getOwnPropertyDescriptor,IC=(e,t,r,o)=>{for(var n=o>1?void 0:o?RC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(n)||n);return n};exports.PontInvitation=class extends sn{startFlow(){return
|
|
5557
|
+
></pont-layout>`:l``}}Ji([yt({context:Mh,subscribe:!0})],sn.prototype,"renderSpec");Ji([yt({context:Bi,subscribe:!0})],sn.prototype,"branding");Ji([yt({context:Bh,subscribe:!0})],sn.prototype,"locales");Ji([g()],sn.prototype,"startError");var RC=Object.getOwnPropertyDescriptor,IC=(e,t,r,o)=>{for(var n=o>1?void 0:o?RC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(n)||n);return n};exports.PontInvitation=class extends sn{startFlow(){return K.startLoginflow()}};exports.PontInvitation=IC([p("pont-invitation")],exports.PontInvitation);var AC=Object.getOwnPropertyDescriptor,TC=(e,t,r,o)=>{for(var n=o>1?void 0:o?AC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(n)||n);return n};exports.PontSignIn=class extends sn{startFlow(){return K.startLoginflow("sys_signin-flow-passkey")}};exports.PontSignIn=TC([p("pont-signin")],exports.PontSignIn);var DC=Object.getOwnPropertyDescriptor,LC=(e,t,r,o)=>{for(var n=o>1?void 0:o?DC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(n)||n);return n};exports.PontSignUp=class extends sn{startFlow(){return K.startLoginflow("sys_signup-flow")}};exports.PontSignUp=LC([p("pont-signup")],exports.PontSignUp);var FC=Object.defineProperty,Be=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&FC(t,r,n),n};class Xi extends f{constructor(){super(...arguments),this.isTrigger=!1,this.user={}}createRenderRoot(){return this}render(){const{name:t,email:r,avatar_url:o}=this.user||{};return l`
|
|
5558
5558
|
<div
|
|
5559
5559
|
class=${zt("pont-flex pont-items-center pont-gap-2 pont-w-full",this.isTrigger?"pont-py-2":"")}
|
|
5560
5560
|
>
|
|
@@ -5574,7 +5574,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5574
5574
|
>`:""}
|
|
5575
5575
|
</div>
|
|
5576
5576
|
</div>
|
|
5577
|
-
`}}Be([a({type:Boolean})],Xi.prototype,"isTrigger");Be([a({type:Object})],Xi.prototype,"user");customElements.define("pont-user-snippet",Xi);class Ue extends f{constructor(){super(...arguments),this.accountSettingsPath="",this.menuItems=[],this.user={},this.signedIn=!1,this.isLoading=!0,this._itemStates=new Map,this._subMenuOpen=new Map,this._handleAccountSettings=()=>{if(this.dispatchEvent(new CustomEvent("account-settings",{bubbles:!0,composed:!0,cancelable:!0}))){if(this.accountSettingsPath){this._navigate(this.accountSettingsPath);return}xl(),document.querySelector('pont-account-settings[mode="MODAL"]')||console.warn(`[pont-account-menu] 'Account settings' had nowhere to go: no accountSettingsPath is set, nothing cancelled the account-settings event, and no <pont-account-settings mode="MODAL"> is mounted.`)}},this._handleLogout=()=>{this.dispatchEvent(new CustomEvent("logout",{bubbles:!0,composed:!0})),
|
|
5577
|
+
`}}Be([a({type:Boolean})],Xi.prototype,"isTrigger");Be([a({type:Object})],Xi.prototype,"user");customElements.define("pont-user-snippet",Xi);class Ue extends f{constructor(){super(...arguments),this.accountSettingsPath="",this.menuItems=[],this.user={},this.signedIn=!1,this.isLoading=!0,this._itemStates=new Map,this._subMenuOpen=new Map,this._handleAccountSettings=()=>{if(this.dispatchEvent(new CustomEvent("account-settings",{bubbles:!0,composed:!0,cancelable:!0}))){if(this.accountSettingsPath){this._navigate(this.accountSettingsPath);return}xl(),document.querySelector('pont-account-settings[mode="MODAL"]')||console.warn(`[pont-account-menu] 'Account settings' had nowhere to go: no accountSettingsPath is set, nothing cancelled the account-settings event, and no <pont-account-settings mode="MODAL"> is mounted.`)}},this._handleLogout=()=>{this.dispatchEvent(new CustomEvent("logout",{bubbles:!0,composed:!0})),K.signOut()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._syncItemStates()}updated(t){t.has("auth")&&this.loadUser()}_syncItemStates(){for(const t of this.menuItems){const r=t.id??t.label;t.type==="toggle"?this._itemStates.set(r,{checked:t.checked??!1}):t.type==="select"&&(this._itemStates.set(r,{value:t.value??""}),this._subMenuOpen.set(r,!1))}}tryRemoveFallback(){requestAnimationFrame(()=>{const r=this.querySelector('[part="fallback"]');r==null||r.remove()})}async loadUser(){var t;if(!((t=this.auth)!=null&&t.resolved)){this.isLoading=!0;return}this.isLoading=!0;try{const r=this.auth.isAuthenticated;if(this.signedIn=r,r){const o=K.getAuthenticatedUser();this.user={email:o==null?void 0:o.email,name:(o==null?void 0:o.name)||`${(o==null?void 0:o.given_name)||""} ${(o==null?void 0:o.family_name)||""}`.trim(),avatar_url:o==null?void 0:o.picture}}}catch(r){console.error("[pont-account-menu] Failed to load user:",r),this.signedIn=!1}finally{this.isLoading=!1,this.tryRemoveFallback()}}_handleToggle(t,r){const o=t.id??t.label;this._itemStates.set(o,{checked:r}),this.requestUpdate(),t.onToggle&&t.onToggle(r)}_handleSelect(t,r){const o=t.id??t.label;this._itemStates.set(o,{value:r}),this.requestUpdate(),this._subMenuOpen.set(o,!1),this.requestUpdate(),t.onSelect&&t.onSelect(r)}_toggleSubMenu(t,r){for(const o of this._subMenuOpen.keys())o!==t&&this._subMenuOpen.set(o,!1);this._subMenuOpen.set(t,r),this.requestUpdate()}_renderActionItem(t){return l`
|
|
5578
5578
|
<pont-dropdown-menu-item
|
|
5579
5579
|
@click=${r=>this._handleMenuItemClick(r,t)}
|
|
5580
5580
|
data-id=${t.id||""}
|
|
@@ -5667,7 +5667,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5667
5667
|
</pont-dropdown-menu-group>
|
|
5668
5668
|
</pont-dropdown-menu-content>
|
|
5669
5669
|
</pont-dropdown-menu>
|
|
5670
|
-
`}_navigate(t){const r=new URL(t,window.location.href);r.pathname===window.location.pathname&&r.search===window.location.search||(window.location.href=t)}_handleMenuItemClick(t,r){t.stopPropagation();try{if(r&&typeof r.onClick=="function"){r.onClick(t,r),this.dispatchEvent(new CustomEvent("menu-item-click",{detail:{item:r},bubbles:!0,composed:!0}));return}if(r&&r.href){this._navigate(r.href),this.dispatchEvent(new CustomEvent("menu-item-click",{detail:{item:r},bubbles:!0,composed:!0}));return}}catch(o){console.error("[pont-account-menu] menu item click handler failed",o)}}}Be([a({type:String})],Ue.prototype,"accountSettingsPath");Be([a({attribute:!1})],Ue.prototype,"menuItems");Be([yt({context:Pr,subscribe:!0}),a({attribute:!1})],Ue.prototype,"auth");Be([g()],Ue.prototype,"user");Be([g()],Ue.prototype,"signedIn");Be([g()],Ue.prototype,"isLoading");Be([g()],Ue.prototype,"_itemStates");Be([g()],Ue.prototype,"_subMenuOpen");customElements.define("pont-account-menu",Ue);var kC=Object.defineProperty,je=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&kC(t,r,n),n};const Xo="pont-organization-changed",Xh="pont-organization-switch-failed";class Jt extends f{constructor(){super(...arguments),this.reloadOnSwitch=!1,this.emptyLabel="Select organization",this.organizations=[],this.currentId=null,this.loaded=!1,this.switching=null,this.error=null,this.onFocus=()=>this.readCurrent(),this.onChangedElsewhere=t=>{t.target!==this&&this.readCurrent()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),window.addEventListener("focus",this.onFocus),document.addEventListener(Xo,this.onChangedElsewhere)}disconnectedCallback(){window.removeEventListener("focus",this.onFocus),document.removeEventListener(Xo,this.onChangedElsewhere),super.disconnectedCallback()}updated(t){t.has("auth")&&this.load()}readCurrent(){var t;this.currentId=((t=
|
|
5670
|
+
`}_navigate(t){const r=new URL(t,window.location.href);r.pathname===window.location.pathname&&r.search===window.location.search||(window.location.href=t)}_handleMenuItemClick(t,r){t.stopPropagation();try{if(r&&typeof r.onClick=="function"){r.onClick(t,r),this.dispatchEvent(new CustomEvent("menu-item-click",{detail:{item:r},bubbles:!0,composed:!0}));return}if(r&&r.href){this._navigate(r.href),this.dispatchEvent(new CustomEvent("menu-item-click",{detail:{item:r},bubbles:!0,composed:!0}));return}}catch(o){console.error("[pont-account-menu] menu item click handler failed",o)}}}Be([a({type:String})],Ue.prototype,"accountSettingsPath");Be([a({attribute:!1})],Ue.prototype,"menuItems");Be([yt({context:Pr,subscribe:!0}),a({attribute:!1})],Ue.prototype,"auth");Be([g()],Ue.prototype,"user");Be([g()],Ue.prototype,"signedIn");Be([g()],Ue.prototype,"isLoading");Be([g()],Ue.prototype,"_itemStates");Be([g()],Ue.prototype,"_subMenuOpen");customElements.define("pont-account-menu",Ue);var kC=Object.defineProperty,je=(e,t,r,o)=>{for(var n=void 0,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=s(t,r,n)||n);return n&&kC(t,r,n),n};const Xo="pont-organization-changed",Xh="pont-organization-switch-failed";class Jt extends f{constructor(){super(...arguments),this.reloadOnSwitch=!1,this.emptyLabel="Select organization",this.organizations=[],this.currentId=null,this.loaded=!1,this.switching=null,this.error=null,this.onFocus=()=>this.readCurrent(),this.onChangedElsewhere=t=>{t.target!==this&&this.readCurrent()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),window.addEventListener("focus",this.onFocus),document.addEventListener(Xo,this.onChangedElsewhere)}disconnectedCallback(){window.removeEventListener("focus",this.onFocus),document.removeEventListener(Xo,this.onChangedElsewhere),super.disconnectedCallback()}updated(t){t.has("auth")&&this.load()}readCurrent(){var t;this.currentId=((t=K.getOrganization())==null?void 0:t.id)??null}async load(){var t;if(!((t=this.auth)!=null&&t.resolved)||!this.auth.isAuthenticated){this.organizations=[],this.loaded=!1;return}this.readCurrent();try{this.organizations=await O0()}catch(r){console.error("[pont-organization-switcher] Failed to list organizations:",r),this.organizations=[]}finally{this.loaded=!0}}async select(t){var r,o;if(!(t===this.currentId||this.switching)){this.switching=t,this.error=null;try{await K.switchOrganization(t),this.readCurrent();const n=K.getOrganization(),i={organizationId:t,roles:(n==null?void 0:n.roles)??[],permissions:(n==null?void 0:n.permissions)??[]};this.dispatchEvent(new CustomEvent(Xo,{detail:i,bubbles:!0,composed:!0})),(r=this.onOrganizationChanged)==null||r.call(this,i),this.reloadOnSwitch&&window.location.reload()}catch(n){this.error="You can't switch to that organization.",this.dispatchEvent(new CustomEvent(Xh,{detail:{organizationId:t,error:n},bubbles:!0,composed:!0})),(o=this.onSwitchFailed)==null||o.call(this,{organizationId:t,error:n})}finally{this.switching=null}}}nameOf(t){var r;return t?((r=this.organizations.find(o=>o.resource_id===t))==null?void 0:r.resource_name)||t:this.emptyLabel}render(){if(!this.loaded||this.organizations.length===0)return l``;const t=this.nameOf(this.currentId);return l`
|
|
5671
5671
|
<pont-dropdown-menu>
|
|
5672
5672
|
<pont-dropdown-menu-trigger as-child>
|
|
5673
5673
|
<pont-button part="trigger-button" variant="secondary" ?disabled=${!!this.switching}>
|
|
@@ -5703,7 +5703,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5703
5703
|
* @license
|
|
5704
5704
|
* Copyright 2020 Google LLC
|
|
5705
5705
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5706
|
-
*/const tu=Symbol.for(""),NC=e=>{if((e==null?void 0:e.r)===tu)return e==null?void 0:e._$litStatic$},MC=e=>({_$litStatic$:e,r:tu}),gp=new Map,BC=e=>(t,...r)=>{const o=r.length;let n,i;const s=[],d=[];let c,u=0,v=!1;for(;u<o;){for(c=t[u];u<o&&(i=r[u],(n=NC(i))!==void 0);)c+=n+t[++u],v=!0;u!==o&&d.push(i),s.push(c),u++}if(u===o&&s.push(t[o]),v){const b=s.join("$$lit$$");(t=gp.get(b))===void 0&&(s.raw=s,gp.set(b,t=s)),r=d}return e(t,...r)},Bs=BC(l);var UC=Object.defineProperty,jC=Object.getOwnPropertyDescriptor,bt=(e,t,r,o)=>{for(var n=o>1?void 0:o?jC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&UC(t,r,n),n};exports.PontOtp=class extends Ut{constructor(){super(...arguments),this.excludeFromForm=!1,this.required=!1,this.requiredError="Code is required.",this.incompleteError="Please enter the complete verification code.",this.variant="with_separator",this.length=6,this.timeout=300,this.dataKey="code",this.name="",this.disabled=!1,this.autoSubmit=!1,this.event="",this.resendText="",this.resendButtonText="",this.resendEvent="",this.id="otp",this._invalid=!1,this._error="",this._value="",this.handleComplete=async t=>{if(this._value=t,this.autoSubmit&&this.event){const r={};r[this.dataKey]=t;try{await
|
|
5706
|
+
*/const tu=Symbol.for(""),NC=e=>{if((e==null?void 0:e.r)===tu)return e==null?void 0:e._$litStatic$},MC=e=>({_$litStatic$:e,r:tu}),gp=new Map,BC=e=>(t,...r)=>{const o=r.length;let n,i;const s=[],d=[];let c,u=0,v=!1;for(;u<o;){for(c=t[u];u<o&&(i=r[u],(n=NC(i))!==void 0);)c+=n+t[++u],v=!0;u!==o&&d.push(i),s.push(c),u++}if(u===o&&s.push(t[o]),v){const b=s.join("$$lit$$");(t=gp.get(b))===void 0&&(s.raw=s,gp.set(b,t=s)),r=d}return e(t,...r)},Bs=BC(l);var UC=Object.defineProperty,jC=Object.getOwnPropertyDescriptor,bt=(e,t,r,o)=>{for(var n=o>1?void 0:o?jC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&UC(t,r,n),n};exports.PontOtp=class extends Ut{constructor(){super(...arguments),this.excludeFromForm=!1,this.required=!1,this.requiredError="Code is required.",this.incompleteError="Please enter the complete verification code.",this.variant="with_separator",this.length=6,this.timeout=300,this.dataKey="code",this.name="",this.disabled=!1,this.autoSubmit=!1,this.event="",this.resendText="",this.resendButtonText="",this.resendEvent="",this.id="otp",this._invalid=!1,this._error="",this._value="",this.handleComplete=async t=>{if(this._value=t,this.autoSubmit&&this.event){const r={};r[this.dataKey]=t;try{await K.processLoginflowEvent({event:this.event,data:r})}finally{this.emit("pont-otp:complete",{id:this.id,dataKey:this.dataKey,value:t,event:this.event})}return}this.emit("pont-otp:complete",{id:this.id,dataKey:this.dataKey,value:t,event:null})},this.handleFocus=()=>{this.emit("pont-otp:focus",{id:this.id,dataKey:this.dataKey})},this.handleBlur=()=>{this.emit("pont-otp:blur",{id:this.id,dataKey:this.dataKey})},this.handleResend=async()=>{if(this.resendEvent)try{await K.processLoginflowEvent({event:this.resendEvent})}finally{this.emit("pont-otp:resend",{id:this.id,event:this.resendEvent})}}}get _containerElement(){return this.querySelector(`pont-input-otp[part=${this.id?this.id:"otp"}]`)}get isFormField(){return!this.excludeFromForm}createRenderRoot(){return this}get value(){return this._value}validate(){const t=this._value.trim();return this.required&&!t?(this._invalid=!0,this._error=this.requiredError,!1):t.length!==this.length?(this._invalid=!0,this._error=this.incompleteError,!1):(this._invalid=!1,this._error="",!0)}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}buildOTPContentHTML(){const t=this.variant,r=this.length,o=(s,d)=>Array.from({length:d-s},(c,u)=>`<pont-input-otp-slot index="${s+u}"></pont-input-otp-slot>`).join(""),n=s=>`<pont-input-otp-group>${s}</pont-input-otp-group>`,i="<pont-input-otp-separator></pont-input-otp-separator>";if(t==="simple"){const s=Math.ceil(r/2);return n(o(0,s))+i+n(o(s,r))}if(t==="with_separator"){const s=Math.ceil(r/3);return n(o(0,s))+i+n(o(s,s*2))+i+n(o(s*2,r))}return t==="with_spacing"?Array.from({length:r},(s,d)=>n(`<pont-input-otp-slot index="${d}"></pont-input-otp-slot>`)).join(""):n(o(0,r))}render(){const t=this.variant||"digits_only";return Bs`
|
|
5707
5707
|
<pont-field ?disabled=${this.disabled} ?invalid=${this._invalid}>
|
|
5708
5708
|
<pont-input-otp
|
|
5709
5709
|
part=${this.id?this.id:"otp"}
|
|
@@ -5739,7 +5739,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5739
5739
|
</pont-button>
|
|
5740
5740
|
</div>
|
|
5741
5741
|
`:h}
|
|
5742
|
-
`}};exports.PontOtp.ROOT="otp";exports.PontOtp.TAG=`${rt}-${exports.PontOtp.ROOT}`;bt([a({type:Boolean,attribute:"exclude-from-form",converter:{fromAttribute:e=>e!==null&&e!=="false",toAttribute:e=>e?"":null}})],exports.PontOtp.prototype,"excludeFromForm",2);bt([a({type:Boolean})],exports.PontOtp.prototype,"required",2);bt([a({attribute:"required-error"})],exports.PontOtp.prototype,"requiredError",2);bt([a({attribute:"incomplete-error"})],exports.PontOtp.prototype,"incompleteError",2);bt([a()],exports.PontOtp.prototype,"variant",2);bt([a({type:Number})],exports.PontOtp.prototype,"length",2);bt([a({type:Number})],exports.PontOtp.prototype,"timeout",2);bt([a({attribute:"data-key"})],exports.PontOtp.prototype,"dataKey",2);bt([a()],exports.PontOtp.prototype,"name",2);bt([a({type:Boolean})],exports.PontOtp.prototype,"disabled",2);bt([a({type:Boolean,attribute:"auto-submit",converter:{fromAttribute:e=>e!==null&&e!=="false",toAttribute:e=>e?"":null}})],exports.PontOtp.prototype,"autoSubmit",2);bt([a()],exports.PontOtp.prototype,"event",2);bt([a({attribute:"resend-text"})],exports.PontOtp.prototype,"resendText",2);bt([a({attribute:"resend-button-text"})],exports.PontOtp.prototype,"resendButtonText",2);bt([a({attribute:"resend-event"})],exports.PontOtp.prototype,"resendEvent",2);bt([a()],exports.PontOtp.prototype,"id",2);bt([g()],exports.PontOtp.prototype,"_invalid",2);bt([g()],exports.PontOtp.prototype,"_error",2);bt([g()],exports.PontOtp.prototype,"_value",2);exports.PontOtp=bt([p("pont-otp")],exports.PontOtp);const Yo={duration:60,resend_event:"",resend_button_label:"Resend code",count_down_text:"Resend code in "};var qC=Object.defineProperty,zC=Object.getOwnPropertyDescriptor,Er=(e,t,r,o)=>{for(var n=o>1?void 0:o?zC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&qC(t,r,n),n};exports.PontOtpResend=class extends f{constructor(){super(...arguments),this.seed=_t(),this.duration=Yo.duration,this.resend_event=Yo.resend_event,this.resend_button_label=Yo.resend_button_label,this.count_down_text=Yo.count_down_text,this._remaining=0,this._handleResendClick=()=>{
|
|
5742
|
+
`}};exports.PontOtp.ROOT="otp";exports.PontOtp.TAG=`${rt}-${exports.PontOtp.ROOT}`;bt([a({type:Boolean,attribute:"exclude-from-form",converter:{fromAttribute:e=>e!==null&&e!=="false",toAttribute:e=>e?"":null}})],exports.PontOtp.prototype,"excludeFromForm",2);bt([a({type:Boolean})],exports.PontOtp.prototype,"required",2);bt([a({attribute:"required-error"})],exports.PontOtp.prototype,"requiredError",2);bt([a({attribute:"incomplete-error"})],exports.PontOtp.prototype,"incompleteError",2);bt([a()],exports.PontOtp.prototype,"variant",2);bt([a({type:Number})],exports.PontOtp.prototype,"length",2);bt([a({type:Number})],exports.PontOtp.prototype,"timeout",2);bt([a({attribute:"data-key"})],exports.PontOtp.prototype,"dataKey",2);bt([a()],exports.PontOtp.prototype,"name",2);bt([a({type:Boolean})],exports.PontOtp.prototype,"disabled",2);bt([a({type:Boolean,attribute:"auto-submit",converter:{fromAttribute:e=>e!==null&&e!=="false",toAttribute:e=>e?"":null}})],exports.PontOtp.prototype,"autoSubmit",2);bt([a()],exports.PontOtp.prototype,"event",2);bt([a({attribute:"resend-text"})],exports.PontOtp.prototype,"resendText",2);bt([a({attribute:"resend-button-text"})],exports.PontOtp.prototype,"resendButtonText",2);bt([a({attribute:"resend-event"})],exports.PontOtp.prototype,"resendEvent",2);bt([a()],exports.PontOtp.prototype,"id",2);bt([g()],exports.PontOtp.prototype,"_invalid",2);bt([g()],exports.PontOtp.prototype,"_error",2);bt([g()],exports.PontOtp.prototype,"_value",2);exports.PontOtp=bt([p("pont-otp")],exports.PontOtp);const Yo={duration:60,resend_event:"",resend_button_label:"Resend code",count_down_text:"Resend code in "};var qC=Object.defineProperty,zC=Object.getOwnPropertyDescriptor,Er=(e,t,r,o)=>{for(var n=o>1?void 0:o?zC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&qC(t,r,n),n};exports.PontOtpResend=class extends f{constructor(){super(...arguments),this.seed=_t(),this.duration=Yo.duration,this.resend_event=Yo.resend_event,this.resend_button_label=Yo.resend_button_label,this.count_down_text=Yo.count_down_text,this._remaining=0,this._handleResendClick=()=>{K.processLoginflowEvent({event:this.resend_event}),this._startCountdown()}}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontOtpResend.TAG}-${this.seed}`}get countdownId(){return`${this.rootId}-${exports.PontOtpResend.COUNTDOWN}`}get resendButtonId(){return`${this.rootId}-${exports.PontOtpResend.RESEND_BUTTON}`}connectedCallback(){super.connectedCallback(),this._startCountdown()}disconnectedCallback(){super.disconnectedCallback(),this._clearTimer()}updated(t){t.has("duration")&&this._startCountdown()}_startCountdown(){this._clearTimer();const t=this.duration;if(t<=0){this._remaining=0;return}this._remaining=t,this._timer=window.setInterval(()=>{this._remaining=Math.max(0,this._remaining-1),this._remaining<=0&&this._clearTimer()},1e3)}_clearTimer(){this._timer&&(clearInterval(this._timer),this._timer=void 0)}render(){const t=this._remaining>0;return l`
|
|
5743
5743
|
<div part=${exports.PontOtpResend.PARTS.root} id=${this.rootId}>
|
|
5744
5744
|
${t?l`
|
|
5745
5745
|
<pont-typography-muted
|
|
@@ -5759,7 +5759,7 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5759
5759
|
</pont-button>
|
|
5760
5760
|
`}
|
|
5761
5761
|
</div>
|
|
5762
|
-
`}};exports.PontOtpResend.ROOT="otp-resend";exports.PontOtpResend.COUNTDOWN="countdown";exports.PontOtpResend.RESEND_BUTTON="resend-button";exports.PontOtpResend.TAG=`${rt}-${exports.PontOtpResend.ROOT}`;exports.PontOtpResend.PARTS={root:exports.PontOtpResend.ROOT,countdown:`${exports.PontOtpResend.ROOT}-${exports.PontOtpResend.COUNTDOWN}`,resendButton:`${exports.PontOtpResend.ROOT}-${exports.PontOtpResend.RESEND_BUTTON}`};Er([a({type:String})],exports.PontOtpResend.prototype,"seed",2);Er([a({type:String,attribute:"custom-id"})],exports.PontOtpResend.prototype,"customId",2);Er([a({type:Number})],exports.PontOtpResend.prototype,"duration",2);Er([a({type:String,attribute:"resend-event"})],exports.PontOtpResend.prototype,"resend_event",2);Er([a({type:String,attribute:"resend-button-label"})],exports.PontOtpResend.prototype,"resend_button_label",2);Er([a({type:String,attribute:"count-down-text"})],exports.PontOtpResend.prototype,"count_down_text",2);Er([g()],exports.PontOtpResend.prototype,"_remaining",2);exports.PontOtpResend=Er([p("pont-otp-resend")],exports.PontOtpResend);const VC=[exports.PontEmailField,exports.PontPhoneField,exports.PontUsernameField,exports.PontIdentifierField,exports.PontNameField,exports.PontPasswordField,exports.PontConfirmField,exports.PontOtp],HC=[exports.PontPasskeyButton,exports.PontProviderButton,exports.PontLink];var GC=Object.defineProperty,KC=Object.getOwnPropertyDescriptor,Bo=(e,t,r,o)=>{for(var n=o>1?void 0:o?KC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&GC(t,r,n),n};exports.PontForm=class extends f{constructor(){super(...arguments),this.seed=_t(),this._loading=!1,this._handleSubmitClick=t=>{var r;this._pendingEvent=(r=t.detail)==null?void 0:r.event},this._handleSubmit=async t=>{if(t.preventDefault(),this._loading)return;const r=this._fields;if(!r.map(b=>b.validate()).every(Boolean))return;const i={};r.forEach(b=>{i[b.name]=b.value});const s=this._pendingEvent;if(this.onSubmit){this.onSubmit(i,s);return}if(!s)return;const d=new CustomEvent(exports.PontForm.SUBMIT_EVENT,{detail:{id:this.rootId,data:i,event:s},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(d),d.defaultPrevented)return;const c=this._interactives,u=r.map(b=>!!b.disabled),v=c.map(b=>!!b.disabled);this._setLoading(!0,r,u,c,v);try{const b=await
|
|
5762
|
+
`}};exports.PontOtpResend.ROOT="otp-resend";exports.PontOtpResend.COUNTDOWN="countdown";exports.PontOtpResend.RESEND_BUTTON="resend-button";exports.PontOtpResend.TAG=`${rt}-${exports.PontOtpResend.ROOT}`;exports.PontOtpResend.PARTS={root:exports.PontOtpResend.ROOT,countdown:`${exports.PontOtpResend.ROOT}-${exports.PontOtpResend.COUNTDOWN}`,resendButton:`${exports.PontOtpResend.ROOT}-${exports.PontOtpResend.RESEND_BUTTON}`};Er([a({type:String})],exports.PontOtpResend.prototype,"seed",2);Er([a({type:String,attribute:"custom-id"})],exports.PontOtpResend.prototype,"customId",2);Er([a({type:Number})],exports.PontOtpResend.prototype,"duration",2);Er([a({type:String,attribute:"resend-event"})],exports.PontOtpResend.prototype,"resend_event",2);Er([a({type:String,attribute:"resend-button-label"})],exports.PontOtpResend.prototype,"resend_button_label",2);Er([a({type:String,attribute:"count-down-text"})],exports.PontOtpResend.prototype,"count_down_text",2);Er([g()],exports.PontOtpResend.prototype,"_remaining",2);exports.PontOtpResend=Er([p("pont-otp-resend")],exports.PontOtpResend);const VC=[exports.PontEmailField,exports.PontPhoneField,exports.PontUsernameField,exports.PontIdentifierField,exports.PontNameField,exports.PontPasswordField,exports.PontConfirmField,exports.PontOtp],HC=[exports.PontPasskeyButton,exports.PontProviderButton,exports.PontLink];var GC=Object.defineProperty,KC=Object.getOwnPropertyDescriptor,Bo=(e,t,r,o)=>{for(var n=o>1?void 0:o?KC(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&GC(t,r,n),n};exports.PontForm=class extends f{constructor(){super(...arguments),this.seed=_t(),this._loading=!1,this._handleSubmitClick=t=>{var r;this._pendingEvent=(r=t.detail)==null?void 0:r.event},this._handleSubmit=async t=>{if(t.preventDefault(),this._loading)return;const r=this._fields;if(!r.map(b=>b.validate()).every(Boolean))return;const i={};r.forEach(b=>{i[b.name]=b.value});const s=this._pendingEvent;if(this.onSubmit){this.onSubmit(i,s);return}if(!s)return;const d=new CustomEvent(exports.PontForm.SUBMIT_EVENT,{detail:{id:this.rootId,data:i,event:s},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(d),d.defaultPrevented)return;const c=this._interactives,u=r.map(b=>!!b.disabled),v=c.map(b=>!!b.disabled);this._setLoading(!0,r,u,c,v);try{const b=await K.processLoginflowEvent({event:s,...Object.keys(i).length?{data:i}:{}});this._dispatch(exports.PontForm.SUCCESS_EVENT,{id:this.rootId,data:i,event:s,result:b})}catch(b){const w=b instanceof Error?b.message:String(b);this._dispatch(exports.PontForm.ERROR_EVENT,{id:this.rootId,data:i,event:s,message:w,error:b})}finally{this._setLoading(!1,r,u,c,v),this._pendingEvent=void 0}},this._handleReset=t=>{this._pendingEvent=void 0,this.onReset&&this.onReset(t),this._dispatch(exports.PontForm.RESET_EVENT,{id:this.rootId})}}createRenderRoot(){return this}get rootId(){return this.customId??`${exports.PontForm.TAG}-${this.seed}`}get _form(){const t=`form[part="${exports.PontForm.PARTS.root}"]`;return this.querySelector(t)}get _fields(){const t=this._form;return t?Array.from(t.querySelectorAll(VC.map(o=>o.TAG).join(", "))).filter(o=>typeof o.isFormField>"u"?!0:o.isFormField):[]}get _submit(){const t=this._form;if(!t)return null;const r=exports.PontSubmitButton.TAG;return t.querySelector(r)}get _interactives(){const t=this._form;if(!t)return[];const r=HC.map(o=>o.TAG).join(", ");return Array.from(t.querySelectorAll(r))}connectedCallback(){super.connectedCallback();const t=exports.PontSubmitButton.CLICK_EVENT;this.addEventListener(t,this._handleSubmitClick)}disconnectedCallback(){super.disconnectedCallback();const t=exports.PontSubmitButton.CLICK_EVENT;this.removeEventListener(t,this._handleSubmitClick)}firstUpdated(){const t=this._form;if(!t)return;Array.from(this.childNodes).filter(o=>o!==t).forEach(o=>t.appendChild(o))}_dispatch(t,r={}){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}_setLoading(t,r,o,n,i){r.forEach((d,c)=>{d.disabled=t?!0:o[c]}),n.forEach((d,c)=>{d.disabled=t?!0:i[c]});const s=this._submit;s&&(s.loading=t),this._loading=t}render(){return l`
|
|
5763
5763
|
<form
|
|
5764
5764
|
id="${this.rootId}"
|
|
5765
5765
|
part="${exports.PontForm.PARTS.root}"
|
|
@@ -5778,5 +5778,5 @@ Minimum version required to store current data is: `+F+`.
|
|
|
5778
5778
|
<pont-subtitle content="You can close this one."></pont-subtitle>
|
|
5779
5779
|
</pont-header>
|
|
5780
5780
|
<pont-link label="Continue here instead" event="continue_here"></pont-link>
|
|
5781
|
-
</pont-block>`;exports.PontProvider=class extends f{constructor(){var t,r;super(...arguments),this.env=null,this.locales=(t=this.env)==null?void 0:t.locales,this.effectiveLocales=(r=this.env)==null?void 0:r.locales,this.auth={isAuthenticated:!1,resolved:!1},this.renderSpec=null,this.branding=Lo,this.autoRedirect=!0,this._handleLocaleEvent=o=>{var s;const i=(s=o.detail)==null?void 0:s.locales;i&&this.setLocale(i)},this.BRANDING_LINK_ID="pont-branding-css",this.REDIRECT_ATTEMPT_KEY="sb_auth_redirect_attempt",this.REDIRECT_BOUNCE_WINDOW_MS=1e4}createRenderRoot(){return this}setLocale(t){this.locales!==t&&(this.locales=t,this.dispatchLocaleChangedEvent(t))}dispatchLocaleChangedEvent(t){this.dispatchEvent(new CustomEvent("pont:locale-changed",{detail:{locales:t},bubbles:!0,composed:!0}))}connectedCallback(){super.connectedCallback(),hP(),document.addEventListener("pont:set-locales",this._handleLocaleEvent),(async()=>{for(;!this.env||!this.env.domain;)await new Promise(r=>setTimeout(r,20));this.updateLocaleAndAuth()})().catch(r=>console.error("Error initializing PontProvider:",r))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pont:set-locales",this._handleLocaleEvent)}getBrandingCssUrl(){if(!this.env)return null;let t;try{t=Ah(this.env.domain)}catch(r){return console.warn("Could not resolve the auth base URL for branding:",r),null}return`${t}/auth/v1/apps/${this.env.appId}/branding.css`}loadBrandingCss(t){const r=document.head.querySelector(`link#${this.BRANDING_LINK_ID}`);if(r&&r.remove(),!t)return;const o=document.createElement("link");o.id=this.BRANDING_LINK_ID,o.rel="stylesheet";const n=Date.now(),i=t.includes("?")?"&":"?";o.href=`${t}${i}v=${n}`,o.onerror=s=>{console.warn("Failed to load branding CSS:",t,s)},document.head.appendChild(o)}configureAuth(t){
|
|
5781
|
+
</pont-block>`;exports.PontProvider=class extends f{constructor(){var t,r;super(...arguments),this.env=null,this.locales=(t=this.env)==null?void 0:t.locales,this.effectiveLocales=(r=this.env)==null?void 0:r.locales,this.auth={isAuthenticated:!1,resolved:!1},this.renderSpec=null,this.branding=Lo,this.autoRedirect=!0,this._handleLocaleEvent=o=>{var s;const i=(s=o.detail)==null?void 0:s.locales;i&&this.setLocale(i)},this.BRANDING_LINK_ID="pont-branding-css",this.REDIRECT_ATTEMPT_KEY="sb_auth_redirect_attempt",this.REDIRECT_BOUNCE_WINDOW_MS=1e4}createRenderRoot(){return this}setLocale(t){this.locales!==t&&(this.locales=t,this.dispatchLocaleChangedEvent(t))}dispatchLocaleChangedEvent(t){this.dispatchEvent(new CustomEvent("pont:locale-changed",{detail:{locales:t},bubbles:!0,composed:!0}))}connectedCallback(){super.connectedCallback(),hP(),document.addEventListener("pont:set-locales",this._handleLocaleEvent),(async()=>{for(;!this.env||!this.env.domain;)await new Promise(r=>setTimeout(r,20));this.updateLocaleAndAuth()})().catch(r=>console.error("Error initializing PontProvider:",r))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("pont:set-locales",this._handleLocaleEvent)}getBrandingCssUrl(){if(!this.env)return null;let t;try{t=Ah(this.env.domain)}catch(r){return console.warn("Could not resolve the auth base URL for branding:",r),null}return`${t}/auth/v1/apps/${this.env.appId}/branding.css`}loadBrandingCss(t){const r=document.head.querySelector(`link#${this.BRANDING_LINK_ID}`);if(r&&r.remove(),!t)return;const o=document.createElement("link");o.id=this.BRANDING_LINK_ID,o.rel="stylesheet";const n=Date.now(),i=t.includes("?")?"&":"?";o.href=`${t}${i}v=${n}`,o.onerror=s=>{console.warn("Failed to load branding CSS:",t,s)},document.head.appendChild(o)}configureAuth(t){K.configure({domain:t.domain,appId:t.appId,locales:this.effectiveLocales||this.locales||t.locales,signinUrl:t.signinUrl,signupUrl:t.signupUrl,invitationUrl:t.invitationUrl,onFlowStateChange:r=>{if(r.eventType==="flow_continued_elsewhere"){this.renderSpec=XC;return}r.render_spec&&(this.renderSpec=r.render_spec)},continueHereUrl:t.signinRedirectUrl,onAuthenticated:()=>{this.refreshAuthState()}})}updateLocaleAndAuth(){if(!this.env)return;const t=this.locales||this.env.locales||"";this.effectiveLocales!==t&&(this.effectiveLocales=t,this.dispatchLocaleChangedEvent(t)),this.configureAuth(this.env),$0(this.env),this.restoreThenRefreshAuthState(),this.loadBrandingCss(this.getBrandingCssUrl())}updated(t){var r;super.updated(t),(t.has("env")||t.has("locales"))&&(r=this.env)!=null&&r.domain&&this.updateLocaleAndAuth(),t.has("auth")&&this.handleAuthStateChange()}handleAuthStateChange(){if(!this.autoRedirect||!this.auth.isAuthenticated||!this.env)return;const t=QC({pathname:window.location.pathname,search:window.location.search,env:this.env});if(t){if(this.wasBouncedBackFrom(t)){this.clearRedirectAttempt(),K.invalidateSession(),this.refreshAuthState();return}this.recordRedirectAttempt(t),window.location.href=t}}recordRedirectAttempt(t){try{sessionStorage.setItem(this.REDIRECT_ATTEMPT_KEY,JSON.stringify({target:t,at:Date.now()}))}catch{}}clearRedirectAttempt(){try{sessionStorage.removeItem(this.REDIRECT_ATTEMPT_KEY)}catch{}}wasBouncedBackFrom(t){let r=null;try{r=sessionStorage.getItem(this.REDIRECT_ATTEMPT_KEY)}catch{return!1}if(!r||(this.clearRedirectAttempt(),this.getNavigationType()!=="navigate"))return!1;try{const o=JSON.parse(r);return o.target!==t||typeof o.at!="number"?!1:Date.now()-o.at<this.REDIRECT_BOUNCE_WINDOW_MS}catch{return!1}}getNavigationType(){try{const[t]=performance.getEntriesByType("navigation");return(t==null?void 0:t.type)??"navigate"}catch{return"navigate"}}refreshAuthState(){this.auth={isAuthenticated:K.isAuthenticated(),resolved:!0},this.dispatchAuthChangedEvent(this.auth)}dispatchAuthChangedEvent(t){this.dispatchEvent(new CustomEvent("pont:auth-changed",{detail:{...t},bubbles:!0,composed:!0}))}async restoreThenRefreshAuthState(){if(eu(window.location.search)){K.invalidateSession(),this.refreshAuthState();return}try{await K.restoreSession()}catch{}this.refreshAuthState()}};Sr([a({type:Object}),Wt({context:Nh})],exports.PontProvider.prototype,"env",2);Sr([a({type:String})],exports.PontProvider.prototype,"locales",2);Sr([g(),Wt({context:Bh})],exports.PontProvider.prototype,"effectiveLocales",2);Sr([g(),Wt({context:Pr})],exports.PontProvider.prototype,"auth",2);Sr([g(),Wt({context:Mh})],exports.PontProvider.prototype,"renderSpec",2);Sr([g(),Wt({context:Bi})],exports.PontProvider.prototype,"branding",2);Sr([a({type:Boolean})],exports.PontProvider.prototype,"autoRedirect",2);exports.PontProvider=Sr([p("pont-provider")],exports.PontProvider);var t2=Object.defineProperty,e2=Object.getOwnPropertyDescriptor,ru=(e,t,r,o)=>{for(var n=o>1?void 0:o?e2(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&t2(t,r,n),n};exports.SignedOut=class extends f{constructor(){super(...arguments),this._cachedChildren=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._cachedChildren.length===0&&(this._cachedChildren=Array.from(this.childNodes),this._cachedChildren.forEach(t=>this.removeChild(t)))}tryRemoveFallback(){requestAnimationFrame(()=>{const r=this.querySelector('[part="fallback"]');r==null||r.remove()})}updated(t){t.has("auth")&&this.tryRemoveFallback()}render(){var t;return!((t=this.auth)!=null&&t.resolved)||this.auth.isAuthenticated?l``:l` <div>${this._cachedChildren}</div> `}};ru([yt({context:Pr,subscribe:!0}),a({attribute:!1})],exports.SignedOut.prototype,"auth",2);exports.SignedOut=ru([p("pont-signed-out")],exports.SignedOut);var r2=Object.defineProperty,n2=Object.getOwnPropertyDescriptor,nu=(e,t,r,o)=>{for(var n=o>1?void 0:o?n2(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&r2(t,r,n),n};exports.SignedIn=class extends f{constructor(){super(...arguments),this._cachedChildren=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._cachedChildren.length===0&&(this._cachedChildren=Array.from(this.childNodes),this._cachedChildren.forEach(t=>this.removeChild(t)))}tryRemoveFallback(){requestAnimationFrame(()=>{const r=this.querySelector('[part="fallback"]');r==null||r.remove()})}updated(t){t.has("auth")&&this.tryRemoveFallback()}render(){var t;return!((t=this.auth)!=null&&t.resolved)||!this.auth.isAuthenticated?l``:l` <div>${this._cachedChildren}</div> `}};nu([yt({context:Pr,subscribe:!0}),a({attribute:!1})],exports.SignedIn.prototype,"auth",2);exports.SignedIn=nu([p("pont-signed-in")],exports.SignedIn);var o2=Object.defineProperty,i2=Object.getOwnPropertyDescriptor,ts=(e,t,r,o)=>{for(var n=o>1?void 0:o?i2(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&o2(t,r,n),n};exports.PontAuthenticated=class extends f{constructor(){super(...arguments),this._cachedChildren=[],this._loadingChildren=[],this._captured=!1,this.redirectUrl="",this.env=null}createRenderRoot(){return this}connectedCallback(){if(super.connectedCallback(),this._captured)return;this._captured=!0;const t=Array.from(this.childNodes);t.forEach(r=>this.removeChild(r));for(const r of t)r instanceof Element&&r.getAttribute("slot")==="loading"?this._loadingChildren.push(r):this._cachedChildren.push(r)}render(){var t;return this.auth?this.auth.resolved?this.auth.isAuthenticated?l`${this._cachedChildren}`:(window.location.href=this.redirectUrl||((t=this.env)==null?void 0:t.signinUrl),h):l`${this._loadingChildren}`:h}};ts([a({type:String})],exports.PontAuthenticated.prototype,"redirectUrl",2);ts([yt({context:Nh}),a({attribute:!1})],exports.PontAuthenticated.prototype,"env",2);ts([yt({context:Pr,subscribe:!0}),a({attribute:!1})],exports.PontAuthenticated.prototype,"auth",2);exports.PontAuthenticated=ts([p("pont-authenticated")],exports.PontAuthenticated);var s2=Object.defineProperty,a2=Object.getOwnPropertyDescriptor,ou=(e,t,r,o)=>{for(var n=o>1?void 0:o?a2(t,r):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(n=(o?s(t,r,n):s(n))||n);return o&&n&&s2(t,r,n),n};exports.AuthStateElement=class extends f{constructor(){super(...arguments),this._cachedChildren=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this._cachedChildren.length===0&&(this._cachedChildren=Array.from(this.childNodes),this._cachedChildren.forEach(t=>this.removeChild(t)))}tryRemoveFallback(){requestAnimationFrame(()=>{const r=this.querySelector('[part="fallback"]');r==null||r.remove()})}syncAuthChildren(){this.auth&&(this.auth.isAuthenticated?this.querySelectorAll("pont-signed-out").forEach(t=>t.remove()):this.querySelectorAll("pont-signed-in").forEach(t=>t.remove()))}updated(t){var r;t.has("auth")&&(r=this.auth)!=null&&r.resolved&&(this.syncAuthChildren(),this.tryRemoveFallback())}render(){var t;return(t=this.auth)!=null&&t.resolved?l` <div>${this._cachedChildren}</div> `:l``}};ou([yt({context:Pr,subscribe:!0}),a({attribute:!1})],exports.AuthStateElement.prototype,"auth",2);exports.AuthStateElement=ou([p("pont-auth-state")],exports.AuthStateElement);function l2(){return K}exports.BaseElement=Ut;exports.ORGANIZATION_CHANGED_EVENT=Xo;exports.ORGANIZATION_SWITCH_FAILED_EVENT=Xh;exports.PontAccountMenu=Ue;exports.PontAccountSettings=Rt;exports.PontMemberManagement=j;exports.PontOrganizationSwitcher=Jt;exports.PontPaginator=Wr;exports.PontUserSnippet=Xi;exports.closeAccountSettingsModal=Ol;exports.closeMemberManagementModal=Yh;exports.openAccountSettingsModal=xl;exports.openMemberManagementModal=Wh;exports.setLocales=Qh;exports.useAuthProvider=l2;
|
|
5782
5782
|
//# sourceMappingURL=index.js.map
|