@capitalos/react 1.4.6-rc.1 → 1.4.6

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.
@@ -273,7 +273,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
273
273
  shippedAt: z_2.ZodNullable<z_2.ZodString>;
274
274
  trackingUpdates: z_2.ZodArray<z_2.ZodObject<{
275
275
  estimatedDeliveryAt: z_2.ZodNullable<z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>>;
276
- trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "returnedToSender"]>;
276
+ trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "deliveryIssue", "returnedToSender"]>;
277
277
  city: z_2.ZodNullable<z_2.ZodString>;
278
278
  createdAt: z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>;
279
279
  zipcode: z_2.ZodNullable<z_2.ZodString>;
@@ -283,14 +283,14 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
283
283
  state: string | null;
284
284
  zipcode: string | null;
285
285
  estimatedDeliveryAt: string | null;
286
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
286
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
287
287
  createdAt: string;
288
288
  }, {
289
289
  city: string | null;
290
290
  state: string | null;
291
291
  zipcode: string | null;
292
292
  estimatedDeliveryAt: string | Date | null;
293
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
293
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
294
294
  createdAt: string | Date;
295
295
  }>, "many">;
296
296
  status: z_2.ZodEnum<["canceled", "pending", "rejected", "returned", "shipped"]>;
@@ -314,7 +314,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
314
314
  state: string | null;
315
315
  zipcode: string | null;
316
316
  estimatedDeliveryAt: string | null;
317
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
317
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
318
318
  createdAt: string;
319
319
  }[];
320
320
  trackingNumber: string | null;
@@ -337,7 +337,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
337
337
  state: string | null;
338
338
  zipcode: string | null;
339
339
  estimatedDeliveryAt: string | Date | null;
340
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
340
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
341
341
  createdAt: string | Date;
342
342
  }[];
343
343
  trackingNumber: string | null;
@@ -365,7 +365,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
365
365
  state: string | null;
366
366
  zipcode: string | null;
367
367
  estimatedDeliveryAt: string | null;
368
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
368
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
369
369
  createdAt: string;
370
370
  }[];
371
371
  trackingNumber: string | null;
@@ -392,7 +392,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
392
392
  state: string | null;
393
393
  zipcode: string | null;
394
394
  estimatedDeliveryAt: string | Date | null;
395
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
395
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
396
396
  createdAt: string | Date;
397
397
  }[];
398
398
  trackingNumber: string | null;
@@ -454,7 +454,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
454
454
  state: string | null;
455
455
  zipcode: string | null;
456
456
  estimatedDeliveryAt: string | null;
457
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
457
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
458
458
  createdAt: string;
459
459
  }[];
460
460
  trackingNumber: string | null;
@@ -517,7 +517,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
517
517
  state: string | null;
518
518
  zipcode: string | null;
519
519
  estimatedDeliveryAt: string | Date | null;
520
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
520
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
521
521
  createdAt: string | Date;
522
522
  }[];
523
523
  trackingNumber: string | null;
@@ -273,7 +273,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
273
273
  shippedAt: z_2.ZodNullable<z_2.ZodString>;
274
274
  trackingUpdates: z_2.ZodArray<z_2.ZodObject<{
275
275
  estimatedDeliveryAt: z_2.ZodNullable<z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>>;
276
- trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "returnedToSender"]>;
276
+ trackingStatus: z_2.ZodEnum<["inTransit", "processedForDelivery", "delivered", "deliveryIssue", "returnedToSender"]>;
277
277
  city: z_2.ZodNullable<z_2.ZodString>;
278
278
  createdAt: z_2.ZodEffects<z_2.ZodUnion<[z_2.ZodString, z_2.ZodDate]>, string, string | Date>;
279
279
  zipcode: z_2.ZodNullable<z_2.ZodString>;
@@ -283,14 +283,14 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
283
283
  state: string | null;
284
284
  zipcode: string | null;
285
285
  estimatedDeliveryAt: string | null;
286
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
286
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
287
287
  createdAt: string;
288
288
  }, {
289
289
  city: string | null;
290
290
  state: string | null;
291
291
  zipcode: string | null;
292
292
  estimatedDeliveryAt: string | Date | null;
293
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
293
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
294
294
  createdAt: string | Date;
295
295
  }>, "many">;
296
296
  status: z_2.ZodEnum<["canceled", "pending", "rejected", "returned", "shipped"]>;
@@ -314,7 +314,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
314
314
  state: string | null;
315
315
  zipcode: string | null;
316
316
  estimatedDeliveryAt: string | null;
317
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
317
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
318
318
  createdAt: string;
319
319
  }[];
320
320
  trackingNumber: string | null;
@@ -337,7 +337,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
337
337
  state: string | null;
338
338
  zipcode: string | null;
339
339
  estimatedDeliveryAt: string | Date | null;
340
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
340
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
341
341
  createdAt: string | Date;
342
342
  }[];
343
343
  trackingNumber: string | null;
@@ -365,7 +365,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
365
365
  state: string | null;
366
366
  zipcode: string | null;
367
367
  estimatedDeliveryAt: string | null;
368
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
368
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
369
369
  createdAt: string;
370
370
  }[];
371
371
  trackingNumber: string | null;
@@ -392,7 +392,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
392
392
  state: string | null;
393
393
  zipcode: string | null;
394
394
  estimatedDeliveryAt: string | Date | null;
395
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
395
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
396
396
  createdAt: string | Date;
397
397
  }[];
398
398
  trackingNumber: string | null;
@@ -454,7 +454,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
454
454
  state: string | null;
455
455
  zipcode: string | null;
456
456
  estimatedDeliveryAt: string | null;
457
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
457
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
458
458
  createdAt: string;
459
459
  }[];
460
460
  trackingNumber: string | null;
@@ -517,7 +517,7 @@ declare const cardApiDtoSchema: z_2.ZodObject<{
517
517
  state: string | null;
518
518
  zipcode: string | null;
519
519
  estimatedDeliveryAt: string | Date | null;
520
- trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "returnedToSender";
520
+ trackingStatus: "inTransit" | "processedForDelivery" | "delivered" | "deliveryIssue" | "returnedToSender";
521
521
  createdAt: string | Date;
522
522
  }[];
523
523
  trackingNumber: string | null;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use client";var Ie=Object.defineProperty,Me=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},p=(e,n)=>Me(e,Oe(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var s=u=>{try{a(t.next(u))}catch(f){r(f)}},i=u=>{try{a(t.throw(u))}catch(f){r(f)}},a=u=>u.done?o(u.value):Promise.resolve(u.value).then(s,i);a((t=t.apply(e,n)).next())});import x,{useMemo as h,useContext as kn}from"react";import B from"react";import $,{createContext as mn,useContext as fn,useState as H,useMemo as Te,useCallback as ie,useEffect as gn}from"react";import Ye,{useMemo as en,useRef as nn,useEffect as tn}from"react";var b=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},O=class extends b{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Be,WindowMessenger as Ue}from"penpal";import{useCallback as Ne,useEffect as F,useMemo as ne,useRef as K,useState as fe}from"react";import{useRef as Ae}from"react";function R(e){let n=Ae(e);return n.current=e,n}var we={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=we)=>{try{let o=`${Se}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var j={log:Q("log"),warn:Q("warn"),error:Q("error")};function Y(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function q(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${Y(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ee(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new O}}function V(e){let t=ee(e).path;if(!t||typeof t!="string")throw new O;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var pe="1.4.6-rc.1";function $e(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function He(e){try{return decodeURIComponent(e)}catch(n){return e}}function ue({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?p(c({},n),{referer:window.location.href}):null,s=r?$e(r):null,i=new URL(e.baseUrl),a=He(e.token);return e.paramLocation==="search"?i.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(i.hash=e.paramKey+"="+encodeURIComponent(a)),i.searchParams.set("sdkVersion",pe),s&&i.searchParams.set("renderingContext",s),t&&i.searchParams.set("theme",t),i.toString()}catch(r){o==null||o(new O);return}}var me=1e4;function _e(e){return(...n)=>{try{let t=n.map(o=>{if(typeof o=="string")return o;if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch(r){return String(o)}}).join(" ");e(t)}catch(t){}}}function te({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[s,i]=fe(null),{log:a}=M(),u=R(o),f=R(t),d=R(r),m=ne(()=>_e(a),[a]);return F(()=>{let y=d.current?`[${d.current}] `:"";if(!e.current){a(`${y}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${y}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${y}Establishing Penpal connection to iframe`);let P=!0,E=new Ue({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),g=Be({messenger:E,methods:u.current,timeout:me,log:m});return g.promise.then(()=>{P&&(a(`${y}Penpal connection established successfully`),i(g))}).catch(I=>{var T;P&&(a(`${y}Penpal connection failed: ${I.message}. Timeout: ${me}ms`),(T=f.current)==null||T.call(f,I),i(null))}),()=>{P=!1,a(`${y}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),g.destroy(),i(null)}},[n,a,m]),s}function oe({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=K(o),s=K(n);return ne(()=>{if(e)return ue({tokenData:e,renderingContext:s.current,theme:t,onError:r.current})},[e,t,r,s])}function J(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:s,methods:i}=e,{tokenData:a,error:u,invalidateToken:f}=X(),{log:d,warn:m}=M(t),[y,P]=fe(!1),E=K(null);We(u,o);let g=ne(()=>n?V(n):a,[n,a]);F(()=>{g&&d(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${Y(g.token)}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)},[g,d,r.entryPoint]);let I=Ne(()=>{if(d("Token expired, invalidating..."),n){o==null||o(new b({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}f(),P(!1)},[d,n,f,o]);F(()=>{n&&a&&m("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,m]);let T=oe({tokenData:g,renderingContext:r,theme:s,onError:o});F(()=>{T?d(`Iframe URL generated: ${q(T).substring(0,1024)}...`):g&&m("Failed to generate iframe URL despite having token data")},[T,g,d,m]);let v=te({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:l=>{d(`Connection error: ${l.message}`),o==null||o(l),P(!0)},methods:c({onLoad:()=>{d("Iframe called onLoad()"),P(!0)},onError:l=>{let _=new b(l);d(`Iframe error: ${_.message}`),o==null||o(_)},onTokenExpired:I},i)});return{isLoaded:y,url:T,tokenData:g,iframeRef:E,connection:v}}function We(e,n){let t=K(!1);F(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}import{iframeResizer as je}from"iframe-resizer";import qe,{forwardRef as Ve,useEffect as Ke,useImperativeHandle as Je,useRef as Xe}from"react";var A=Ve((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Qe(e),s=Xe(null);return Ke(()=>{let i=s.current;return je(c({},r),i),()=>i.iFrameResizer&&i.iFrameResizer.removeListeners()}),Je(n,()=>s.current),qe.createElement("iframe",p(c({},o),{title:t,ref:s}))});A.displayName="IframeResizer";var Ze=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ge=new Set(Ze);function Qe(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Ge.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ge(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,s=w(t),{log:i}=M(t),a=nn(null),u=en(()=>V(n),[n]),d=oe({tokenData:u,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return tn(()=>{if(d){let m=q(d),y=m.substring(0,1024),P=m.length>1024;i(`Token exchange iframe URL: ${y}${P?"...":""}`)}},[d,i]),te({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:m=>{i(`Token exchange connection error: ${m.message}`),r==null||r(m)},methods:{onLoad:()=>{i("Token exchange iframe loaded")},onError:m=>{i(`Token exchange iframe error: ${m.message}`),r==null||r(new b(m))},tokenExchange:{onLongLivedToken:m=>{i("Token exchange complete: received long-lived token"),o(m)}}}}),Ye.createElement(A,{src:d,checkOrigin:!1,style:{display:"none"},log:s,ref:a,onLoad:()=>{i("Token exchange iframe HTML loaded successfully")},onError:m=>{i(`Token exchange iframe failed to load: ${m}`)}})}import{useCallback as on,useRef as rn}from"react";function Z(e){let n=rn(e);return n.current=e,on((...t)=>n.current(...t),[])}import z,{createContext as ln,useState as pn,useMemo as ke,useCallback as un}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(u){var f=u,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let d="mfa",m=an(()=>({entryPoint:d,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}),[d,t,o,r,s,i]);return sn.createElement(C,p(c({},a),{renderingContext:m,methods:{mfa:{onDone:e,onCancel:n}}}))}import xe,{useEffect as cn}from"react";var he={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function ye({onClose:e,children:n,ariaLabel:t="Modal dialog"}){cn(()=>{let r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return xe.createElement("div",{style:he.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},xe.createElement("div",{style:he.container},n))}import{useState as dn,useCallback as G}from"react";function Pe(){var f;let[e,n]=dn(null),{log:t}=M(),o=G(d=>(t("MFA requested"),new Promise((m,y)=>{n({context:d,resolve:m,reject:y})})),[t]),r=G(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),s=G(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),i=G(d=>{e&&(t("MFA error: "+d.message),e.resolve({success:!1,canceled:!1,error:d}),n(null))},[e,t]),a=!!e,u=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:u,requestMfa:o,handleMfaDone:r,handleMfaCancel:s,handleMfaError:i}}var re=ln(null);function be({children:e}){let[n,t]=pn(null),o=w(),{log:r}=M(),{requestMfa:s,handleMfaDone:i,handleMfaCancel:a,isMfaActive:u,mfaContext:f}=Pe(),d=un(v=>D(null,null,function*(){let l=yield s(v);return l.success?{success:!0}:l.canceled?{success:!1,canceled:!0}:{success:!1,error:l.error.message}}),[s]),m=ke(()=>n?{freezeCard:v=>D(null,null,function*(){try{let l=yield n.freezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}}),unfreezeCard:v=>D(null,null,function*(){try{let l=yield n.unfreezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}})}:null,[n]),y=ke(()=>({"system-messages":{requestMfa:d},mfa:{onDone:i,onCancel:a}}),[d,i,a]),{isLoaded:P,url:E,connection:g,iframeRef:I}=J({renderingContext:{entryPoint:"actions"},methods:y});z.useEffect(()=>{let v=!0;return g&&g.promise.then(l=>{v&&(t(l),r("Actions iframe child functions loaded"))}),()=>{v=!1}},[g,r]);let T=!P||!n;return z.createElement(re.Provider,{value:{childFunctions:n,actions:m,isLoading:T}},e,E&&z.createElement(A,{src:E,style:{display:"none"},checkOrigin:!1,log:o,ref:I,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:v=>{r(`Actions iframe failed to load: ${v}. This may indicate network issues or security policy blocking.`)}}),u&&f&&z.createElement(ye,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,p(c({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:i,onCancel:a}))))}var ve=mn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Cn=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,s]=H(void 0),[i,a]=H(void 0),[u,f]=H(void 0),[d,m]=H(!1),[y,P]=H(void 0),E=R(t),g=ie(()=>D(null,null,function*(){m(!0);try{let l=yield e();s(l),P(void 0);let _=ee(l),ae=new URL(_.path);ae.pathname="",a(ae.toString())}catch(l){P(l)}finally{m(!1)}}),[e]),I=ie(()=>{f(void 0)},[]);gn(()=>{u||g()},[u,g]);let T=ie(l=>{f(l),s(void 0),P(void 0)},[]),v=Te(()=>{if(u&&!i)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:u?{token:u,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:d,error:y,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[u,d,y,I,i,n]);return $.createElement($.Fragment,null,$.createElement(ve.Provider,{value:v},$.createElement(be,null,o)),r&&!u&&$.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function w(e){let{enableLogging:n}=X();return e!==void 0?e:n}function M(e){let n=w(e),{loggerRef:t}=X(),o=Z(i=>{var a;j.log(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=Z(i=>{var a;j.warn(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),s=Z(i=>{var a;j.error(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return Te(()=>({log:o,warn:r,error:s}),[o,r,s])}function C(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:s,renderingContext:i,methods:a,theme:u,sizeWidth:f}=e,d=w(o),{log:m}=M(o),{isLoaded:y,url:P,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:d,onError:r,renderingContext:i,theme:u,methods:a});if(!E||!P)return B.createElement(B.Fragment,null,s||null);let I=i.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!y&&s,B.createElement(A,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:d,ref:g,hidden:!y,onLoad:()=>{m(`Main iframe HTML loaded successfully for entry point: ${i.entryPoint}`)},onError:T=>{m(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!I)return;let v=`${parseInt(T.height)+12}px`;T.iframe.style.height=v},sizeWidth:f}))}import N,{useMemo as xn}from"react";import{useState as hn}from"react";import S,{useState as Le}from"react";var U={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Ee=()=>S.createElement("svg",{style:U.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},S.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function se({onClick:e,isLoading:n=!1}){let[t,o]=Le(!1),[r,s]=Le(!1),i=c(c(c(c({},U.bugButton),n&&U.loadingButton),!n&&t&&U.bugButtonHover),!n&&r&&U.bugButtonFocus);return n?S.createElement("div",{style:i},S.createElement("style",null,`
1
+ "use client";var Ie=Object.defineProperty,Me=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},p=(e,n)=>Me(e,Oe(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var s=u=>{try{a(t.next(u))}catch(f){r(f)}},i=u=>{try{a(t.throw(u))}catch(f){r(f)}},a=u=>u.done?o(u.value):Promise.resolve(u.value).then(s,i);a((t=t.apply(e,n)).next())});import x,{useMemo as h,useContext as kn}from"react";import B from"react";import $,{createContext as mn,useContext as fn,useState as H,useMemo as Te,useCallback as ie,useEffect as gn}from"react";import Ye,{useMemo as en,useRef as nn,useEffect as tn}from"react";var b=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},O=class extends b{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Be,WindowMessenger as Ue}from"penpal";import{useCallback as Ne,useEffect as F,useMemo as ne,useRef as K,useState as fe}from"react";import{useRef as Ae}from"react";function R(e){let n=Ae(e);return n.current=e,n}var we={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=we)=>{try{let o=`${Se}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var j={log:Q("log"),warn:Q("warn"),error:Q("error")};function Y(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function q(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${Y(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ee(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new O}}function V(e){let t=ee(e).path;if(!t||typeof t!="string")throw new O;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var pe="1.4.6";function $e(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function He(e){try{return decodeURIComponent(e)}catch(n){return e}}function ue({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?p(c({},n),{referer:window.location.href}):null,s=r?$e(r):null,i=new URL(e.baseUrl),a=He(e.token);return e.paramLocation==="search"?i.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(i.hash=e.paramKey+"="+encodeURIComponent(a)),i.searchParams.set("sdkVersion",pe),s&&i.searchParams.set("renderingContext",s),t&&i.searchParams.set("theme",t),i.toString()}catch(r){o==null||o(new O);return}}var me=1e4;function _e(e){return(...n)=>{try{let t=n.map(o=>{if(typeof o=="string")return o;if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch(r){return String(o)}}).join(" ");e(t)}catch(t){}}}function te({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[s,i]=fe(null),{log:a}=M(),u=R(o),f=R(t),d=R(r),m=ne(()=>_e(a),[a]);return F(()=>{let y=d.current?`[${d.current}] `:"";if(!e.current){a(`${y}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${y}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${y}Establishing Penpal connection to iframe`);let P=!0,E=new Ue({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),g=Be({messenger:E,methods:u.current,timeout:me,log:m});return g.promise.then(()=>{P&&(a(`${y}Penpal connection established successfully`),i(g))}).catch(I=>{var T;P&&(a(`${y}Penpal connection failed: ${I.message}. Timeout: ${me}ms`),(T=f.current)==null||T.call(f,I),i(null))}),()=>{P=!1,a(`${y}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),g.destroy(),i(null)}},[n,a,m]),s}function oe({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=K(o),s=K(n);return ne(()=>{if(e)return ue({tokenData:e,renderingContext:s.current,theme:t,onError:r.current})},[e,t,r,s])}function J(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:s,methods:i}=e,{tokenData:a,error:u,invalidateToken:f}=X(),{log:d,warn:m}=M(t),[y,P]=fe(!1),E=K(null);We(u,o);let g=ne(()=>n?V(n):a,[n,a]);F(()=>{g&&d(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${Y(g.token)}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)},[g,d,r.entryPoint]);let I=Ne(()=>{if(d("Token expired, invalidating..."),n){o==null||o(new b({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}f(),P(!1)},[d,n,f,o]);F(()=>{n&&a&&m("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,m]);let T=oe({tokenData:g,renderingContext:r,theme:s,onError:o});F(()=>{T?d(`Iframe URL generated: ${q(T).substring(0,1024)}...`):g&&m("Failed to generate iframe URL despite having token data")},[T,g,d,m]);let v=te({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:l=>{d(`Connection error: ${l.message}`),o==null||o(l),P(!0)},methods:c({onLoad:()=>{d("Iframe called onLoad()"),P(!0)},onError:l=>{let _=new b(l);d(`Iframe error: ${_.message}`),o==null||o(_)},onTokenExpired:I},i)});return{isLoaded:y,url:T,tokenData:g,iframeRef:E,connection:v}}function We(e,n){let t=K(!1);F(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}import{iframeResizer as je}from"iframe-resizer";import qe,{forwardRef as Ve,useEffect as Ke,useImperativeHandle as Je,useRef as Xe}from"react";var A=Ve((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Qe(e),s=Xe(null);return Ke(()=>{let i=s.current;return je(c({},r),i),()=>i.iFrameResizer&&i.iFrameResizer.removeListeners()}),Je(n,()=>s.current),qe.createElement("iframe",p(c({},o),{title:t,ref:s}))});A.displayName="IframeResizer";var Ze=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ge=new Set(Ze);function Qe(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Ge.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ge(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,s=w(t),{log:i}=M(t),a=nn(null),u=en(()=>V(n),[n]),d=oe({tokenData:u,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return tn(()=>{if(d){let m=q(d),y=m.substring(0,1024),P=m.length>1024;i(`Token exchange iframe URL: ${y}${P?"...":""}`)}},[d,i]),te({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:m=>{i(`Token exchange connection error: ${m.message}`),r==null||r(m)},methods:{onLoad:()=>{i("Token exchange iframe loaded")},onError:m=>{i(`Token exchange iframe error: ${m.message}`),r==null||r(new b(m))},tokenExchange:{onLongLivedToken:m=>{i("Token exchange complete: received long-lived token"),o(m)}}}}),Ye.createElement(A,{src:d,checkOrigin:!1,style:{display:"none"},log:s,ref:a,onLoad:()=>{i("Token exchange iframe HTML loaded successfully")},onError:m=>{i(`Token exchange iframe failed to load: ${m}`)}})}import{useCallback as on,useRef as rn}from"react";function Z(e){let n=rn(e);return n.current=e,on((...t)=>n.current(...t),[])}import z,{createContext as ln,useState as pn,useMemo as ke,useCallback as un}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(u){var f=u,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let d="mfa",m=an(()=>({entryPoint:d,mfaId:t,destination:o,codeLength:r,canResendAfter:s,operationName:i}),[d,t,o,r,s,i]);return sn.createElement(C,p(c({},a),{renderingContext:m,methods:{mfa:{onDone:e,onCancel:n}}}))}import xe,{useEffect as cn}from"react";var he={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function ye({onClose:e,children:n,ariaLabel:t="Modal dialog"}){cn(()=>{let r=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return xe.createElement("div",{style:he.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},xe.createElement("div",{style:he.container},n))}import{useState as dn,useCallback as G}from"react";function Pe(){var f;let[e,n]=dn(null),{log:t}=M(),o=G(d=>(t("MFA requested"),new Promise((m,y)=>{n({context:d,resolve:m,reject:y})})),[t]),r=G(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),s=G(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),i=G(d=>{e&&(t("MFA error: "+d.message),e.resolve({success:!1,canceled:!1,error:d}),n(null))},[e,t]),a=!!e,u=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:u,requestMfa:o,handleMfaDone:r,handleMfaCancel:s,handleMfaError:i}}var re=ln(null);function be({children:e}){let[n,t]=pn(null),o=w(),{log:r}=M(),{requestMfa:s,handleMfaDone:i,handleMfaCancel:a,isMfaActive:u,mfaContext:f}=Pe(),d=un(v=>D(null,null,function*(){let l=yield s(v);return l.success?{success:!0}:l.canceled?{success:!1,canceled:!0}:{success:!1,error:l.error.message}}),[s]),m=ke(()=>n?{freezeCard:v=>D(null,null,function*(){try{let l=yield n.freezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}}),unfreezeCard:v=>D(null,null,function*(){try{let l=yield n.unfreezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}})}:null,[n]),y=ke(()=>({"system-messages":{requestMfa:d},mfa:{onDone:i,onCancel:a}}),[d,i,a]),{isLoaded:P,url:E,connection:g,iframeRef:I}=J({renderingContext:{entryPoint:"actions"},methods:y});z.useEffect(()=>{let v=!0;return g&&g.promise.then(l=>{v&&(t(l),r("Actions iframe child functions loaded"))}),()=>{v=!1}},[g,r]);let T=!P||!n;return z.createElement(re.Provider,{value:{childFunctions:n,actions:m,isLoading:T}},e,E&&z.createElement(A,{src:E,style:{display:"none"},checkOrigin:!1,log:o,ref:I,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:v=>{r(`Actions iframe failed to load: ${v}. This may indicate network issues or security policy blocking.`)}}),u&&f&&z.createElement(ye,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,p(c({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:i,onCancel:a}))))}var ve=mn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Cn=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,s]=H(void 0),[i,a]=H(void 0),[u,f]=H(void 0),[d,m]=H(!1),[y,P]=H(void 0),E=R(t),g=ie(()=>D(null,null,function*(){m(!0);try{let l=yield e();s(l),P(void 0);let _=ee(l),ae=new URL(_.path);ae.pathname="",a(ae.toString())}catch(l){P(l)}finally{m(!1)}}),[e]),I=ie(()=>{f(void 0)},[]);gn(()=>{u||g()},[u,g]);let T=ie(l=>{f(l),s(void 0),P(void 0)},[]),v=Te(()=>{if(u&&!i)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:u?{token:u,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:d,error:y,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[u,d,y,I,i,n]);return $.createElement($.Fragment,null,$.createElement(ve.Provider,{value:v},$.createElement(be,null,o)),r&&!u&&$.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function w(e){let{enableLogging:n}=X();return e!==void 0?e:n}function M(e){let n=w(e),{loggerRef:t}=X(),o=Z(i=>{var a;j.log(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=Z(i=>{var a;j.warn(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),s=Z(i=>{var a;j.error(i,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return Te(()=>({log:o,warn:r,error:s}),[o,r,s])}function C(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:s,renderingContext:i,methods:a,theme:u,sizeWidth:f}=e,d=w(o),{log:m}=M(o),{isLoaded:y,url:P,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:d,onError:r,renderingContext:i,theme:u,methods:a});if(!E||!P)return B.createElement(B.Fragment,null,s||null);let I=i.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!y&&s,B.createElement(A,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:d,ref:g,hidden:!y,onLoad:()=>{m(`Main iframe HTML loaded successfully for entry point: ${i.entryPoint}`)},onError:T=>{m(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!I)return;let v=`${parseInt(T.height)+12}px`;T.iframe.style.height=v},sizeWidth:f}))}import N,{useMemo as xn}from"react";import{useState as hn}from"react";import S,{useState as Le}from"react";var U={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Ee=()=>S.createElement("svg",{style:U.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},S.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function se({onClick:e,isLoading:n=!1}){let[t,o]=Le(!1),[r,s]=Le(!1),i=c(c(c(c({},U.bugButton),n&&U.loadingButton),!n&&t&&U.bugButtonHover),!n&&r&&U.bugButtonFocus);return n?S.createElement("div",{style:i},S.createElement("style",null,`
2
2
  @keyframes pulse {
3
3
  0%, 100% {
4
4
  opacity: 1;