@machinemetrics/mm-react-embeddable 2.0.0-5 → 2.0.0-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.
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),Ee=require("prop-types"),ge=require("styled-components"),te=r=>r&&r.__esModule?r:{default:r},L=te(t),k=te(Ee),ne=te(ge),Y=t.createContext(null),N=t.createContext({pending:[],authorize:()=>{},approve:()=>{},complete:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),ue="access_token",Q=r=>r?r.kind?r:r.accessToken?{kind:ue,accessToken:r.accessToken,expiresAt:r.expiresAt||null}:null:null,Re=60,ke=120,Ce=new Set(["host_not_allowed","unbound_host_bound_guest","invalid_token","provider_unavailable"]),J=typeof window!="undefined"&&window.location.protocol==="https:",Te=8e3,G=r=>{try{return new URL(r).origin}catch{return null}},se=(r,o)=>{const i=o==null?void 0:o.origin;return!i||G(r==null?void 0:r.authUrl)!==i?null:i},oe=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const o=r.split(".");return o.length<=2?r:o.slice(-2).join(".")},ee=(r,o)=>{try{const i=new URL(r),f=new URL(o);return i.protocol!==f.protocol?!0:oe(i.hostname)!==oe(f.hostname)}catch{return!0}},ce=(r,{onBlocked:o,onClosed:i})=>{const f=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!f)return o(),()=>{};const h=setInterval(()=>{f.closed&&(clearInterval(h),i())},1e3);return()=>clearInterval(h)},ie=({children:r,launcher:o,broker:i})=>{const f=t.useContext(Y),[h,E]=t.useState({}),[B,C]=t.useState({}),[x,A]=t.useState({}),[P,O]=t.useState({}),v=t.useRef(x);v.current=x;const g=t.useRef(h);g.current=h;const z=t.useRef(null),K=t.useRef({}),M=t.useRef({}),D=t.useRef({}),$=t.useRef(i);$.current=i;const _=t.useCallback(e=>{const n=M.current[e];if(!n)return;const s=a=>!a[e]||a[e].clientId?a:{...a,[e]:{...a[e],clientId:n}};E(s),O(s)},[]),c=t.useCallback((e,n)=>{e&&(O(s=>s[e]?s:{...s,[e]:{origin:e,reason:n,clientId:M.current[e]||null}}),_(e))},[_]),l=t.useCallback((e,{v2:n=!1,origin:s=null}={})=>{s&&(n&&v.current[s]||(E(a=>a[s]?a:{...a,[s]:{origin:s,authUrl:e.authUrl,silentUrl:e.silentUrl||null,status:n&&$.current?"broker":n&&e.silentUrl&&J?"silent":"interactive",v2:n,scope:e.scope||null,acceptsCredentials:D.current[s]||null,consent:null,error:null,clientId:e.clientId||M.current[s]||null,popupBlocked:!1}}),_(s)))},[_]),u=t.useRef({}),d=t.useCallback(e=>{u.current[e]&&(clearTimeout(u.current[e]),delete u.current[e])},[]),p=t.useCallback(e=>{d(e),E(n=>{if(!n[e])return n;const s={...n};return delete s[e],s})},[d]),m=t.useCallback(e=>{e&&(p(e),C(n=>({...n,[e]:(n[e]||0)+1})))},[p]),S=t.useCallback(e=>{E(n=>!n[e]||n[e].status==="interactive"?n:{...n,[e]:{...n[e],status:"interactive"}})},[]),y=t.useCallback(e=>{p(e.origin)},[p]),R=t.useCallback((e,n)=>{const s=se(e,n);if(s){if(ee(s,window.location.origin)){c(s,"cross-site-legacy");return}l(e,{origin:s})}},[l,c]);t.useEffect(()=>{if(!f)return;const e=[f.addListener("*","init",(n,s)=>{s!=null&&s.origin&&(n!=null&&n.clientId)&&(M.current[s.origin]=n.clientId,_(s.origin)),s!=null&&s.origin&&Array.isArray(n==null?void 0:n.acceptsCredentials)?D.current[s.origin]=n.acceptsCredentials:s!=null&&s.origin&&ee(s.origin,window.location.origin)&&c(s.origin,"cross-site-legacy")}),f.addListener("*","authorize",R),f.addListener("*","login",R),f.addListener("*","credential-request",(n,s)=>l(n,{v2:!0,origin:se(n,s)}))];return()=>e.forEach(n=>n())},[f,R,l,_,c]),t.useEffect(()=>{const e=n=>{const s=n==null?void 0:n.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const a=G(s.authUrl);if(!(!a||n.origin!==a)){if(s.type==="authorized"){if(s.accessToken){if(!g.current[a])return;A(b=>({...b,[a]:Q({accessToken:s.accessToken})})),p(a)}else m(a);return}S(a)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[p,m,S]);const F=t.useCallback((e,n)=>{const s=e==null?void 0:e.origin,a=Q(n);!s||!a||(A(b=>({...b,[s]:a})),p(s))},[p]),U=t.useCallback((e,n)=>{E(s=>s[e]?{...s,[e]:{...s[e],...n}}:s)},[]),w=t.useRef({}),I=t.useCallback(async(e,{approve:n}={})=>{const s=$.current,{origin:a}=e;let b;try{b=await s({origin:a,clientId:e.clientId,scope:e.scope,authUrl:e.authUrl},{approve:n})}catch{n?U(a,{error:{reason:"broker_unavailable"}}):U(a,{status:e.silentUrl&&J?"silent":"interactive"});return}if((b==null?void 0:b.status)===200&&b.credential){F(e,b.credential);return}if((b==null?void 0:b.status)===409&&b.consentRequired){U(a,{status:"interactive",consent:{client:b.client||null,stepUp:!!b.stepUp,scope:b.scope||e.scope},error:null});return}const V=(b==null?void 0:b.error)||"broker_error";if(!n&&Ce.has(V)){U(a,{status:e.silentUrl&&J?"silent":"interactive"});return}if(n&&V==="consent_denied"){U(a,{error:null});return}if(V==="rate_limited"&&!e.rateLimitRetried){const X=Math.min(Number(b==null?void 0:b.retryAfter)>0?Number(b.retryAfter):Re,ke),me={...e,rateLimitRetried:!0};d(a),u.current[a]=setTimeout(()=>{delete u.current[a],w.current[a]=!0,Z.current(me,{approve:n}).finally(()=>{delete w.current[a]})},X*1e3),U(a,{rateLimitRetried:!0});return}p(a),O(X=>({...X,[a]:{origin:a,reason:`broker:${V}`,detail:b||null,clientId:e.clientId||M.current[a]||null}}))},[F,U,p,d]),Z=t.useRef(I);Z.current=I,t.useEffect(()=>{Object.values(h).forEach(e=>{e.status!=="broker"||w.current[e.origin]||u.current[e.origin]||(w.current[e.origin]=!0,I(e).finally(()=>{delete w.current[e.origin]}))})},[h,I]);const W=t.useCallback(e=>!$.current||!(e!=null&&e.consent)?Promise.resolve():I(e,{approve:!0}),[I]);t.useEffect(()=>{const e=K.current;Object.values(h).forEach(n=>{n.status==="silent"&&!e[n.origin]&&(e[n.origin]=setTimeout(()=>{delete e[n.origin],S(n.origin)},Te))}),Object.keys(e).forEach(n=>{(!h[n]||h[n].status!=="silent")&&(clearTimeout(e[n]),delete e[n])})},[h,S]),t.useEffect(()=>()=>{z.current&&z.current(),Object.values(K.current).forEach(clearTimeout),Object.values(u.current).forEach(clearTimeout)},[]);const j=t.useCallback(e=>{z.current&&(z.current(),z.current=null);const n=o||ce;z.current=n(e,{onBlocked:()=>{E(s=>s[e.origin]?{...s,[e.origin]:{...s[e.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(e.v2){J&&E(s=>!s[e.origin]||!s[e.origin].silentUrl?s:{...s,[e.origin]:{...s[e.origin],status:"silent"}});return}m(e.origin)}})},[o,m]),T={pending:Object.values(h).filter(e=>e.status==="interactive"),authorize:j,approve:W,complete:F,dismiss:y,originEpochs:B,credentials:x,unsupported:P},q=Object.values(h).filter(e=>e.status==="silent"&&e.silentUrl);return L.default.createElement(N.Provider,{value:T},r,q.map(e=>L.default.createElement("iframe",{key:`mm-silent-auth-${e.origin}`,src:e.silentUrl,title:`MachineMetrics silent authorization (${e.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};ie.propTypes={children:k.default.node,launcher:k.default.func,broker:k.default.func};const _e=()=>t.useContext(N),ae=r=>{const{originEpochs:o}=t.useContext(N),i=G(r);return i&&o[i]||0},le=r=>{const{credentials:o}=t.useContext(N),i=G(r);return i&&o[i]||null},de=r=>{const{unsupported:o}=t.useContext(N),i=G(r);return i&&o[i]||null},fe=({children:r,authorizationLauncher:o,credentialBroker:i})=>{const[f,h]=t.useState({}),[E,B]=t.useState({}),C=t.useRef({}),x=t.useRef({}),A=t.useRef({}),P=t.useCallback((c,l)=>{var u;return!!((u=A.current[c])!=null&&u.has(l))},[]),O=t.useCallback((c,l,u)=>{h(d=>({...d,[c]:{origin:l,frameRef:u}}))},[]),v=t.useCallback(c=>{h(l=>{const u={...l};return delete u[c],u}),B(l=>{const u={...l};return delete u[c],u}),delete A.current[c]},[]);t.useEffect(()=>{const c=(u=[],d,p)=>{u.forEach(m=>m(d,p))},l=u=>{var F,U,w,I,Z,W,j;if(!((F=u==null?void 0:u.data)!=null&&F.instanceId))return;const{instanceId:d,type:p}=u.data,m=f[d],S=(w=(U=m==null?void 0:m.frameRef)==null?void 0:U.current)==null?void 0:w.contentWindow;if(!S||u.source!==S||u.origin!==m.origin)return;const y={origin:u.origin},R=C.current;if(p==="response"){const{callbackId:T,response:q,error:e}=u.data,n=x.current[T];n&&(n(q,e),delete x.current[T]);return}if(p==="mark-registered"){const{requestType:T}=u.data;A.current[d]||(A.current[d]=new Set),A.current[d].add(T);return}p==="ready"&&B(T=>({...T,[d]:!0})),c((I=R[d])==null?void 0:I[p],u.data,y),c((Z=R["*"])==null?void 0:Z[p],u.data,y),c((W=R[d])==null?void 0:W["*"],u.data,y),c((j=R["*"])==null?void 0:j["*"],u.data,y)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[f]);const g=t.useCallback((c,l,u)=>{var p,m;const d=f[c];if(!d){console.warn(`Origin not set for id: ${c}. Unable to send message.`);return}(m=(p=d==null?void 0:d.frameRef)==null?void 0:p.current)!=null&&m.contentWindow&&d.frameRef.current.contentWindow.postMessage({type:l,...u,instanceId:c},d.origin)},[f]),z=t.useRef(0),K=t.useCallback(()=>`${Date.now()}-${++z.current}`,[]),M=t.useCallback(async(c,l,u={})=>new Promise((d,p)=>{const m=K(),S=(y,R)=>{delete x.current[m],R?p(R):d(y)};x.current[m]=S,g(c,"request",{callbackId:m,requestType:l,data:u})}),[g]),D=t.useCallback((c,l)=>{g(c,"load-options",l)},[g]),$=t.useCallback((c,l)=>{g(c,"validate",l)},[g]),_=t.useMemo(()=>({registerFrame:O,unregisterFrame:v,sendMessage:g,sendRequest:M,loadOptions:D,validate:$,hasHandler:P,readyFrames:E,addListener:(c,l,u)=>(C.current[c]||(C.current[c]={}),C.current[c][l]||(C.current[c][l]=[]),C.current[c][l].push(u),()=>{C.current[c][l]=C.current[c][l].filter(d=>d!==u)})}),[O,v,g,M,D,$,P,E]);return L.default.createElement(Y.Provider,{value:_},L.default.createElement(ie,{launcher:o,broker:i},r))},H=(r,o,i)=>{const f=t.useContext(Y);if(f===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const h=t.useRef(i);t.useEffect(()=>{h.current=i},[i]),t.useEffect(()=>{if(!(!r||!o)){if(o.startsWith("key:")){const E=o.substring(4);return f.readyFrames[r]&&f.sendMessage(r,"subscribe-key",{keyChord:E}),f.addListener(r,`key-pressed:${E}`,(...C)=>h.current(...C))}return f.addListener(r,o,(...E)=>h.current(...E))}},[f,r,o])};fe.propTypes={children:k.default.node.isRequired,authorizationLauncher:k.default.func,credentialBroker:k.default.func};const re=ne.default.default||ne.default,we=1e4,Ie="credentials",Me=(r,o)=>`${r}/mm-embedded-interop?id=${encodeURIComponent(o)}&origin=${encodeURIComponent(window.location.origin)}&caps=${Ie}`,Se=re.iframe`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),Re=require("prop-types"),ke=require("styled-components"),re=r=>r&&r.__esModule?r:{default:r},L=re(t),R=re(Re),oe=re(ke),G=t.createContext(null),Y=t.createContext({pending:[],authorize:()=>{},approve:()=>{},complete:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),ie="access_token",ee=r=>r?r.kind?r:r.accessToken?{kind:ie,accessToken:r.accessToken,expiresAt:r.expiresAt||null}:null:null,Ce=60,Te=120,_e=new Set(["host_not_allowed","unbound_host_bound_guest","invalid_token","provider_unavailable"]),Q=typeof window!="undefined"&&window.location.protocol==="https:",we=8e3,V=r=>{try{return new URL(r).origin}catch{return null}},ue=(r,o)=>{const i=o==null?void 0:o.origin;return!i||V(r==null?void 0:r.authUrl)!==i?null:i},ce=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const o=r.split(".");return o.length<=2?r:o.slice(-2).join(".")},te=(r,o)=>{try{const i=new URL(r),f=new URL(o);return i.protocol!==f.protocol?!0:ce(i.hostname)!==ce(f.hostname)}catch{return!0}},ae=(r,{onBlocked:o,onClosed:i})=>{const f=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!f)return o(),()=>{};const b=setInterval(()=>{f.closed&&(clearInterval(b),i())},1e3);return()=>clearInterval(b)},le=({children:r,launcher:o,broker:i})=>{const f=t.useContext(G),[b,m]=t.useState({}),[D,k]=t.useState({}),[x,A]=t.useState({}),[P,O]=t.useState({}),H=t.useRef(x);H.current=x;const E=t.useRef(b);E.current=b;const z=t.useRef(null),N=t.useRef({}),I=t.useRef({}),Z=t.useRef({}),$=t.useRef(i);$.current=i;const T=t.useCallback(e=>{const n=I.current[e];if(!n)return;const s=a=>!a[e]||a[e].clientId?a:{...a,[e]:{...a[e],clientId:n}};m(s),O(s)},[]),c=t.useCallback((e,n)=>{e&&(O(s=>s[e]?s:{...s,[e]:{origin:e,reason:n,clientId:I.current[e]||null}}),T(e))},[T]),l=t.useCallback((e,{v2:n=!1,origin:s=null}={})=>{s&&(n&&H.current[s]||(m(a=>a[s]?a:{...a,[s]:{origin:s,authUrl:e.authUrl,silentUrl:e.silentUrl||null,status:n&&$.current?"broker":n&&e.silentUrl&&Q?"silent":"interactive",v2:n,scope:e.scope||null,acceptsCredentials:Z.current[s]||null,consent:null,error:null,clientId:e.clientId||I.current[s]||null,popupBlocked:!1}}),T(s)))},[T]),u=t.useRef({}),d=t.useCallback(e=>{u.current[e]&&(clearTimeout(u.current[e]),delete u.current[e])},[]),p=t.useCallback(e=>{d(e),m(n=>{if(!n[e])return n;const s={...n};return delete s[e],s})},[d]),h=t.useCallback(e=>{e&&(p(e),k(n=>({...n,[e]:(n[e]||0)+1})))},[p]),M=t.useCallback(e=>{m(n=>!n[e]||n[e].status==="interactive"?n:{...n,[e]:{...n[e],status:"interactive"}})},[]),y=t.useCallback(e=>{p(e.origin)},[p]),g=t.useCallback((e,n)=>{const s=ue(e,n);if(s){if(te(s,window.location.origin)){c(s,"cross-site-legacy");return}l(e,{origin:s})}},[l,c]);t.useEffect(()=>{if(!f)return;const e=[f.addListener("*","init",(n,s)=>{s!=null&&s.origin&&(n!=null&&n.clientId)&&(I.current[s.origin]=n.clientId,T(s.origin)),s!=null&&s.origin&&Array.isArray(n==null?void 0:n.acceptsCredentials)?Z.current[s.origin]=n.acceptsCredentials:s!=null&&s.origin&&te(s.origin,window.location.origin)&&c(s.origin,"cross-site-legacy")}),f.addListener("*","authorize",g),f.addListener("*","login",g),f.addListener("*","credential-request",(n,s)=>l(n,{v2:!0,origin:ue(n,s)}))];return()=>e.forEach(n=>n())},[f,g,l,T,c]),t.useEffect(()=>{const e=n=>{const s=n==null?void 0:n.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const a=V(s.authUrl);if(!(!a||n.origin!==a)){if(s.type==="authorized"){if(s.accessToken){if(!E.current[a])return;A(U=>({...U,[a]:ee({accessToken:s.accessToken})})),p(a)}else h(a);return}M(a)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[p,h,M]);const F=t.useCallback((e,n)=>{const s=e==null?void 0:e.origin,a=ee(n);!s||!a||(A(U=>({...U,[s]:a})),p(s))},[p]),S=t.useCallback((e,n)=>{m(s=>s[e]?{...s,[e]:{...s[e],...n}}:s)},[]),_=t.useRef({}),w=t.useCallback(async(e,{approve:n}={})=>{const s=$.current,{origin:a}=e;let U;try{U=await s({origin:a,clientId:e.clientId,scope:e.scope,authUrl:e.authUrl},{approve:n})}catch{n?S(a,{error:{reason:"broker_unavailable"}}):S(a,{status:e.silentUrl&&Q?"silent":"interactive"});return}const se=U==null?void 0:U.status,B=(U==null?void 0:U.body)||{};if(se===200&&B.credential){F(e,B.credential);return}if(se===409&&B.consentRequired){S(a,{status:"interactive",consent:{client:B.client||null,stepUp:!!B.stepUp,scope:B.scope||e.scope},error:null});return}const X=B.error||"broker_error";if(!n&&_e.has(X)){S(a,{status:e.silentUrl&&Q?"silent":"interactive"});return}if(n&&X==="consent_denied"){S(a,{error:null});return}if(X==="rate_limited"&&!e.rateLimitRetried){const J=Math.min(Number(B.retryAfter)>0?Number(B.retryAfter):Ce,Te),ge={...e,rateLimitRetried:!0};d(a),u.current[a]=setTimeout(()=>{delete u.current[a],_.current[a]=!0,W.current(ge,{approve:n}).finally(()=>{delete _.current[a]})},J*1e3),S(a,{rateLimitRetried:!0});return}p(a),O(J=>({...J,[a]:{origin:a,reason:`broker:${X}`,detail:U||null,clientId:e.clientId||I.current[a]||null}}))},[F,S,p,d]),W=t.useRef(w);W.current=w,t.useEffect(()=>{Object.values(b).forEach(e=>{e.status!=="broker"||_.current[e.origin]||u.current[e.origin]||(_.current[e.origin]=!0,w(e).finally(()=>{delete _.current[e.origin]}))})},[b,w]);const v=t.useCallback(e=>!$.current||!(e!=null&&e.consent)?Promise.resolve():w(e,{approve:!0}),[w]);t.useEffect(()=>{const e=N.current;Object.values(b).forEach(n=>{n.status==="silent"&&!e[n.origin]&&(e[n.origin]=setTimeout(()=>{delete e[n.origin],M(n.origin)},we))}),Object.keys(e).forEach(n=>{(!b[n]||b[n].status!=="silent")&&(clearTimeout(e[n]),delete e[n])})},[b,M]),t.useEffect(()=>()=>{z.current&&z.current(),Object.values(N.current).forEach(clearTimeout),Object.values(u.current).forEach(clearTimeout)},[]);const j=t.useCallback(e=>{z.current&&(z.current(),z.current=null);const n=o||ae;z.current=n(e,{onBlocked:()=>{m(s=>s[e.origin]?{...s,[e.origin]:{...s[e.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(e.v2){Q&&m(s=>!s[e.origin]||!s[e.origin].silentUrl?s:{...s,[e.origin]:{...s[e.origin],status:"silent"}});return}h(e.origin)}})},[o,h]),C={pending:Object.values(b).filter(e=>e.status==="interactive"),authorize:j,approve:v,complete:F,dismiss:y,originEpochs:D,credentials:x,unsupported:P},q=Object.values(b).filter(e=>e.status==="silent"&&e.silentUrl);return L.default.createElement(Y.Provider,{value:C},r,q.map(e=>L.default.createElement("iframe",{key:`mm-silent-auth-${e.origin}`,src:e.silentUrl,title:`MachineMetrics silent authorization (${e.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};le.propTypes={children:R.default.node,launcher:R.default.func,broker:R.default.func};const Ie=()=>t.useContext(Y),de=r=>{const{originEpochs:o}=t.useContext(Y),i=V(r);return i&&o[i]||0},fe=r=>{const{credentials:o}=t.useContext(Y),i=V(r);return i&&o[i]||null},pe=r=>{const{unsupported:o}=t.useContext(Y),i=V(r);return i&&o[i]||null},be=({children:r,authorizationLauncher:o,credentialBroker:i})=>{const[f,b]=t.useState({}),[m,D]=t.useState({}),k=t.useRef({}),x=t.useRef({}),A=t.useRef({}),P=t.useCallback((c,l)=>{var u;return!!((u=A.current[c])!=null&&u.has(l))},[]),O=t.useCallback((c,l,u)=>{b(d=>({...d,[c]:{origin:l,frameRef:u}}))},[]),H=t.useCallback(c=>{b(l=>{const u={...l};return delete u[c],u}),D(l=>{const u={...l};return delete u[c],u}),delete A.current[c]},[]);t.useEffect(()=>{const c=(u=[],d,p)=>{u.forEach(h=>h(d,p))},l=u=>{var F,S,_,w,W,v,j;if(!((F=u==null?void 0:u.data)!=null&&F.instanceId))return;const{instanceId:d,type:p}=u.data,h=f[d],M=(_=(S=h==null?void 0:h.frameRef)==null?void 0:S.current)==null?void 0:_.contentWindow;if(!M||u.source!==M||u.origin!==h.origin)return;const y={origin:u.origin},g=k.current;if(p==="response"){const{callbackId:C,response:q,error:e}=u.data,n=x.current[C];n&&(n(q,e),delete x.current[C]);return}if(p==="mark-registered"){const{requestType:C}=u.data;A.current[d]||(A.current[d]=new Set),A.current[d].add(C);return}p==="ready"&&D(C=>({...C,[d]:!0})),c((w=g[d])==null?void 0:w[p],u.data,y),c((W=g["*"])==null?void 0:W[p],u.data,y),c((v=g[d])==null?void 0:v["*"],u.data,y),c((j=g["*"])==null?void 0:j["*"],u.data,y)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[f]);const E=t.useCallback((c,l,u)=>{var p,h;const d=f[c];if(!d){console.warn(`Origin not set for id: ${c}. Unable to send message.`);return}(h=(p=d==null?void 0:d.frameRef)==null?void 0:p.current)!=null&&h.contentWindow&&d.frameRef.current.contentWindow.postMessage({type:l,...u,instanceId:c},d.origin)},[f]),z=t.useRef(0),N=t.useCallback(()=>`${Date.now()}-${++z.current}`,[]),I=t.useCallback(async(c,l,u={})=>new Promise((d,p)=>{const h=N(),M=(y,g)=>{delete x.current[h],g?p(g):d(y)};x.current[h]=M,E(c,"request",{callbackId:h,requestType:l,data:u})}),[E]),Z=t.useCallback((c,l)=>{E(c,"load-options",l)},[E]),$=t.useCallback((c,l)=>{E(c,"validate",l)},[E]),T=t.useMemo(()=>({registerFrame:O,unregisterFrame:H,sendMessage:E,sendRequest:I,loadOptions:Z,validate:$,hasHandler:P,readyFrames:m,addListener:(c,l,u)=>(k.current[c]||(k.current[c]={}),k.current[c][l]||(k.current[c][l]=[]),k.current[c][l].push(u),()=>{k.current[c][l]=k.current[c][l].filter(d=>d!==u)})}),[O,H,E,I,Z,$,P,m]);return L.default.createElement(G.Provider,{value:T},L.default.createElement(le,{launcher:o,broker:i},r))},K=(r,o,i)=>{const f=t.useContext(G);if(f===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const b=t.useRef(i);t.useEffect(()=>{b.current=i},[i]),t.useEffect(()=>{if(!(!r||!o)){if(o.startsWith("key:")){const m=o.substring(4);return f.readyFrames[r]&&f.sendMessage(r,"subscribe-key",{keyChord:m}),f.addListener(r,`key-pressed:${m}`,(...k)=>b.current(...k))}return f.addListener(r,o,(...m)=>b.current(...m))}},[f,r,o])};be.propTypes={children:R.default.node.isRequired,authorizationLauncher:R.default.func,credentialBroker:R.default.func};const ne=oe.default.default||oe.default,Me=1e4,Se="credentials",Ue=(r,o)=>`${r}/mm-embedded-interop?id=${encodeURIComponent(o)}&origin=${encodeURIComponent(window.location.origin)}&caps=${Se}`,Le=ne.iframe`
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  border: none;
5
5
  visibility: ${r=>r.$isReady?"visible":"hidden"};
6
- `,Ue=re.div`
6
+ `,xe=ne.div`
7
7
  width: 100%;
8
8
  height: 100%;
9
9
  display: flex;
@@ -16,10 +16,10 @@
16
16
  text-align: center;
17
17
  color: #555;
18
18
  font-size: 14px;
19
- `,pe=r=>{const o=r&&r.origin||"This app",i=r&&r.reason||"";switch(i){case"broker:scope_above_ceiling":return{title:`${o} can’t be authorized here`,detail:"It asks for permissions your role doesn’t have."};case"broker:origin_mismatch":case"broker:unknown_client":return{title:`${o} can’t be authorized here`,detail:"It isn’t registered to run at this address."};case"broker:cross_company_principal":return{title:`${o} can’t be authorized here`,detail:"It can’t be authorized for this account."};default:return i.startsWith("broker:")?{title:`${o} can’t be authorized here`,detail:"Authorization was refused."}:{title:`${o} can’t be embedded here`,detail:"It needs an update to support embedding from a different domain."}}},be=({entry:r})=>{const o=pe(r);return L.default.createElement(Ue,{"data-reason":r&&r.reason||void 0},L.default.createElement("div",{style:{fontWeight:600}},o.title),L.default.createElement("div",{style:{fontSize:12,color:"#888"}},o.detail))};be.propTypes={entry:k.default.shape({origin:k.default.string,name:k.default.string,reason:k.default.string,detail:k.default.object})};const Le=re.div`
19
+ `,he=r=>{const o=r&&r.origin||"This app",i=r&&r.reason||"";switch(i){case"broker:scope_above_ceiling":return{title:`${o} can’t be authorized here`,detail:"It asks for permissions your role doesn’t have."};case"broker:origin_mismatch":case"broker:unknown_client":return{title:`${o} can’t be authorized here`,detail:"It isn’t registered to run at this address."};case"broker:cross_company_principal":return{title:`${o} can’t be authorized here`,detail:"It can’t be authorized for this account."};default:return i.startsWith("broker:")?{title:`${o} can’t be authorized here`,detail:"Authorization was refused."}:{title:`${o} can’t be embedded here`,detail:"It needs an update to support embedding from a different domain."}}},me=({entry:r})=>{const o=he(r);return L.default.createElement(xe,{"data-reason":r&&r.reason||void 0},L.default.createElement("div",{style:{fontWeight:600}},o.title),L.default.createElement("div",{style:{fontSize:12,color:"#888"}},o.detail))};me.propTypes={entry:R.default.shape({origin:R.default.string,name:R.default.string,reason:R.default.string,detail:R.default.object})};const Ae=ne.div`
20
20
  height: 100%;
21
21
  display: flex;
22
22
  flex: 1;
23
23
  align-items: center;
24
24
  justify-content: center;
25
- `,xe=()=>L.default.createElement(Le,null,L.default.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),he=({id:r,src:o,path:i,onInit:f=()=>{},onTimeout:h,context:E={},params:B={},renderUnsupported:C,renderTimeout:x,...A})=>{if("isConfiguring"in A)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in E)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in E)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const P=t.useRef(),[O,v]=t.useState(),[g,z]=t.useState(0),[K,M]=t.useState(!1),[D,$]=t.useState(!1),_=ae(o),c=le(o),l=de(o),[u,d]=t.useState(0),[p,m]=t.useState(null),{registerFrame:S,unregisterFrame:y,sendMessage:R}=t.useContext(Y),[F,U]=t.useState(),w=t.useRef(),I=t.useRef(h),Z=t.useRef(f),W=t.useRef(!1),j=t.useCallback(()=>{W.current=!1,clearTimeout(w.current),z(0),M(!1),$(!1),m(null)},[]);t.useEffect(()=>{(_>0||u>0)&&j()},[_,u,j]),t.useEffect(()=>{I.current=h},[h]),t.useEffect(()=>{Z.current=f},[f]),t.useEffect(()=>{g&&R(r,"set-context",{context:{...E}})},[E,r,g]),t.useEffect(()=>{g&&R(r,"set-params",{params:B})},[B,r,g]),t.useEffect(()=>{i!==void 0&&U((i==null?void 0:i.indexOf("/"))===0?i:`/${i}`)},[i]),t.useEffect(()=>{F===void 0||!g||R(r,"navigate",{path:F})},[F,g,r,R]),t.useEffect(()=>{if(!o||!r||!P)return;j();const e=new URL(o);return S(r,e.origin,P),Z.current(),v(Me(e.origin,r)),()=>{y(r)}},[o,r,S,P,j]),t.useEffect(()=>{if(!(!O||W.current))return w.current=setTimeout(()=>{M(!0),I.current&&I.current()},we),()=>clearTimeout(w.current)},[O,o,_,u]);const T=t.useCallback(()=>{W.current=!0,clearTimeout(w.current),M(!1)},[]);H(r,"init",e=>{T(),Array.isArray(e==null?void 0:e.acceptsCredentials)&&m(e.acceptsCredentials)}),H(r,"authorize",T),H(r,"login",T),H(r,"credential-request",()=>{T(),$(!0)}),t.useEffect(()=>{if(!D||!c)return;const e=p;if(Array.isArray(e)&&!e.includes(c.kind))return;const n=c.kind==="access_token"?{accessToken:c.accessToken}:{};R(r,"credential",{...n,credential:c})},[D,c,p,r,R]),H(r,"ready",()=>{T(),z(e=>e+1)});const q=t.useRef();return H(r,"heartbeat",()=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{d(e=>e+1)},6e3)}),t.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]),l?C?C(l):L.default.createElement(be,{entry:l}):K&&!g?x?x():L.default.createElement(xe,null):L.default.createElement(Se,{key:`auth-epoch-${_}-frame-${u}`,$isReady:g,ref:P,src:O,...A})};he.propTypes={id:k.default.string,src:k.default.string.isRequired,path:k.default.string,onInit:k.default.func,onTimeout:k.default.func,renderUnsupported:k.default.func,renderTimeout:k.default.func};exports.CREDENTIAL_KIND_ACCESS_TOKEN=ue;exports.EmbeddedAuthorizationContext=N;exports.MMEmbeddableZone=he;exports.MMEmbeddableZoneContext=Y;exports.MMEmbeddableZoneProvider=fe;exports.isCrossSite=ee;exports.normalizeCredential=Q;exports.popupAuthorizationLauncher=ce;exports.unsupportedCopy=pe;exports.useEmbeddedAuthorizations=_e;exports.useEmbeddedCredential=le;exports.useEmbeddedEffect=H;exports.useEmbeddedOriginEpoch=ae;exports.useEmbeddedUnsupported=de;
25
+ `,ze=()=>L.default.createElement(Ae,null,L.default.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),Ee=({id:r,src:o,path:i,onInit:f=()=>{},onTimeout:b,context:m={},params:D={},renderUnsupported:k,renderTimeout:x,...A})=>{if("isConfiguring"in A)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in m)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in m)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const P=t.useRef(),[O,H]=t.useState(),[E,z]=t.useState(0),[N,I]=t.useState(!1),[Z,$]=t.useState(!1),T=de(o),c=fe(o),l=pe(o),[u,d]=t.useState(0),[p,h]=t.useState(null),{registerFrame:M,unregisterFrame:y,sendMessage:g}=t.useContext(G),[F,S]=t.useState(),_=t.useRef(),w=t.useRef(b),W=t.useRef(f),v=t.useRef(!1),j=t.useCallback(()=>{v.current=!1,clearTimeout(_.current),z(0),I(!1),$(!1),h(null)},[]);t.useEffect(()=>{(T>0||u>0)&&j()},[T,u,j]),t.useEffect(()=>{w.current=b},[b]),t.useEffect(()=>{W.current=f},[f]),t.useEffect(()=>{E&&g(r,"set-context",{context:{...m}})},[m,r,E]),t.useEffect(()=>{E&&g(r,"set-params",{params:D})},[D,r,E]),t.useEffect(()=>{i!==void 0&&S((i==null?void 0:i.indexOf("/"))===0?i:`/${i}`)},[i]),t.useEffect(()=>{F===void 0||!E||g(r,"navigate",{path:F})},[F,E,r,g]),t.useEffect(()=>{if(!o||!r||!P)return;j();const e=new URL(o);return M(r,e.origin,P),W.current(),H(Ue(e.origin,r)),()=>{y(r)}},[o,r,M,P,j]),t.useEffect(()=>{if(!(!O||v.current))return _.current=setTimeout(()=>{I(!0),w.current&&w.current()},Me),()=>clearTimeout(_.current)},[O,o,T,u]);const C=t.useCallback(()=>{v.current=!0,clearTimeout(_.current),I(!1)},[]);K(r,"init",e=>{C(),Array.isArray(e==null?void 0:e.acceptsCredentials)&&h(e.acceptsCredentials)}),K(r,"authorize",C),K(r,"login",C),K(r,"credential-request",()=>{C(),$(!0)}),t.useEffect(()=>{if(!Z||!c)return;const e=p;if(Array.isArray(e)&&!e.includes(c.kind))return;const n=c.kind==="access_token"?{accessToken:c.accessToken}:{};g(r,"credential",{...n,credential:c})},[Z,c,p,r,g]),K(r,"ready",()=>{C(),z(e=>e+1)});const q=t.useRef();return K(r,"heartbeat",()=>{q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{d(e=>e+1)},6e3)}),t.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]),l?k?k(l):L.default.createElement(me,{entry:l}):N&&!E?x?x():L.default.createElement(ze,null):L.default.createElement(Le,{key:`auth-epoch-${T}-frame-${u}`,$isReady:E,ref:P,src:O,...A})};Ee.propTypes={id:R.default.string,src:R.default.string.isRequired,path:R.default.string,onInit:R.default.func,onTimeout:R.default.func,renderUnsupported:R.default.func,renderTimeout:R.default.func};exports.CREDENTIAL_KIND_ACCESS_TOKEN=ie;exports.EmbeddedAuthorizationContext=Y;exports.MMEmbeddableZone=Ee;exports.MMEmbeddableZoneContext=G;exports.MMEmbeddableZoneProvider=be;exports.isCrossSite=te;exports.normalizeCredential=ee;exports.popupAuthorizationLauncher=ae;exports.unsupportedCopy=he;exports.useEmbeddedAuthorizations=Ie;exports.useEmbeddedCredential=fe;exports.useEmbeddedEffect=K;exports.useEmbeddedOriginEpoch=de;exports.useEmbeddedUnsupported=pe;
@@ -1,7 +1,7 @@
1
- import x, { createContext as le, useContext as G, useState as C, useRef as b, useCallback as m, useEffect as T, useMemo as pe } from "react";
2
- import w from "prop-types";
3
- import se from "styled-components";
4
- const re = le(null), J = le({
1
+ import x, { createContext as de, useContext as V, useState as M, useRef as g, useCallback as h, useEffect as R, useMemo as me } from "react";
2
+ import k from "prop-types";
3
+ import ie from "styled-components";
4
+ const ne = de(null), N = de({
5
5
  pending: [],
6
6
  authorize: () => {
7
7
  },
@@ -14,37 +14,37 @@ const re = le(null), J = le({
14
14
  originEpochs: {},
15
15
  credentials: {},
16
16
  unsupported: {}
17
- }), he = "access_token", oe = (t) => t ? t.kind ? t : t.accessToken ? {
18
- kind: he,
17
+ }), ge = "access_token", ce = (t) => t ? t.kind ? t : t.accessToken ? {
18
+ kind: ge,
19
19
  accessToken: t.accessToken,
20
20
  expiresAt: t.expiresAt || null
21
- } : null : null, me = 60, ge = 120, be = /* @__PURE__ */ new Set([
21
+ } : null : null, be = 60, Ee = 120, Re = /* @__PURE__ */ new Set([
22
22
  "host_not_allowed",
23
23
  "unbound_host_bound_guest",
24
24
  "invalid_token",
25
25
  "provider_unavailable"
26
- ]), te = typeof window != "undefined" && window.location.protocol === "https:", Ee = 8e3, N = (t) => {
26
+ ]), re = typeof window != "undefined" && window.location.protocol === "https:", Te = 8e3, Q = (t) => {
27
27
  try {
28
28
  return new URL(t).origin;
29
29
  } catch {
30
30
  return null;
31
31
  }
32
- }, ie = (t, s) => {
32
+ }, ue = (t, s) => {
33
33
  const c = s == null ? void 0 : s.origin;
34
- return !c || N(t == null ? void 0 : t.authUrl) !== c ? null : c;
35
- }, ce = (t) => {
34
+ return !c || Q(t == null ? void 0 : t.authUrl) !== c ? null : c;
35
+ }, le = (t) => {
36
36
  if (!t || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(t) || t.includes(":"))
37
37
  return t;
38
38
  const s = t.split(".");
39
39
  return s.length <= 2 ? t : s.slice(-2).join(".");
40
- }, ue = (t, s) => {
40
+ }, ae = (t, s) => {
41
41
  try {
42
42
  const c = new URL(t), d = new URL(s);
43
- return c.protocol !== d.protocol ? !0 : ce(c.hostname) !== ce(d.hostname);
43
+ return c.protocol !== d.protocol ? !0 : le(c.hostname) !== le(d.hostname);
44
44
  } catch {
45
45
  return !0;
46
46
  }
47
- }, Re = (t, { onBlocked: s, onClosed: c }) => {
47
+ }, ke = (t, { onBlocked: s, onClosed: c }) => {
48
48
  const d = window.open(
49
49
  t.authUrl,
50
50
  "mm-embed-auth",
@@ -53,34 +53,38 @@ const re = le(null), J = le({
53
53
  if (!d)
54
54
  return s(), () => {
55
55
  };
56
- const h = setInterval(() => {
57
- d.closed && (clearInterval(h), c());
56
+ const p = setInterval(() => {
57
+ d.closed && (clearInterval(p), c());
58
58
  }, 1e3);
59
- return () => clearInterval(h);
60
- }, ae = ({ children: t, launcher: s, broker: c }) => {
61
- const d = G(re), [h, E] = C({}), [H, I] = C({}), [$, S] = C({}), [q, y] = C({}), Y = b($);
62
- Y.current = $;
63
- const R = b(h);
64
- R.current = h;
65
- const F = b(null), V = b({}), A = b({}), Z = b({}), P = b(c);
59
+ return () => clearInterval(p);
60
+ }, fe = ({ children: t, launcher: s, broker: c }) => {
61
+ const d = V(ne), [p, b] = M({}), [Z, w] = M({}), [$, S] = M({}), [q, y] = M({}), G = g($);
62
+ G.current = $;
63
+ const E = g(p);
64
+ E.current = p;
65
+ const F = g(null), X = g({}), C = g({}), v = g({}), P = g(c);
66
66
  P.current = c;
67
- const U = m((e) => {
68
- const r = A.current[e];
67
+ const _ = h((e) => {
68
+ const r = C.current[e];
69
69
  if (!r)
70
70
  return;
71
71
  const n = (u) => !u[e] || u[e].clientId ? u : { ...u, [e]: { ...u[e], clientId: r } };
72
- E(n), y(n);
73
- }, []), i = m(
72
+ b(n), y(n);
73
+ }, []), i = h(
74
74
  (e, r) => {
75
75
  e && (y((n) => n[e] ? n : {
76
76
  ...n,
77
- [e]: { origin: e, reason: r, clientId: A.current[e] || null }
78
- }), U(e));
77
+ [e]: {
78
+ origin: e,
79
+ reason: r,
80
+ clientId: C.current[e] || null
81
+ }
82
+ }), _(e));
79
83
  },
80
- [U]
81
- ), l = m(
84
+ [_]
85
+ ), l = h(
82
86
  (e, { v2: r = !1, origin: n = null } = {}) => {
83
- n && (r && Y.current[n] || (E((u) => u[n] ? u : {
87
+ n && (r && G.current[n] || (b((u) => u[n] ? u : {
84
88
  ...u,
85
89
  [n]: {
86
90
  origin: n,
@@ -89,53 +93,56 @@ const re = le(null), J = le({
89
93
  // v2 entries try the invisible silent resolver first — but only on a host that can
90
94
  // frame login (https). Otherwise (and for legacy signals) go straight to interactive,
91
95
  // so an http host doesn't wait out a silent frame that can never load login.
92
- status: r && P.current ? "broker" : r && e.silentUrl && te ? "silent" : "interactive",
96
+ status: r && P.current ? "broker" : r && e.silentUrl && re ? "silent" : "interactive",
93
97
  v2: r,
94
98
  // v1.9: the scope the guest asked for; forwarded verbatim to the broker.
95
99
  scope: e.scope || null,
96
- acceptsCredentials: Z.current[n] || null,
100
+ acceptsCredentials: v.current[n] || null,
97
101
  consent: null,
98
102
  error: null,
99
103
  // clientId from the request payload (v2) or the cached init (legacy);
100
104
  // the host resolves the display name from it.
101
- clientId: e.clientId || A.current[n] || null,
105
+ clientId: e.clientId || C.current[n] || null,
102
106
  popupBlocked: !1
103
107
  }
104
- }), U(n)));
108
+ }), _(n)));
105
109
  },
106
- [U]
107
- ), o = b({}), a = m((e) => {
110
+ [_]
111
+ ), o = g({}), a = h((e) => {
108
112
  o.current[e] && (clearTimeout(o.current[e]), delete o.current[e]);
109
- }, []), f = m((e) => {
110
- a(e), E((r) => {
111
- if (!r[e])
112
- return r;
113
- const n = { ...r };
114
- return delete n[e], n;
115
- });
116
- }, [a]), g = m(
113
+ }, []), f = h(
117
114
  (e) => {
118
- e && (f(e), I((r) => ({
115
+ a(e), b((r) => {
116
+ if (!r[e])
117
+ return r;
118
+ const n = { ...r };
119
+ return delete n[e], n;
120
+ });
121
+ },
122
+ [a]
123
+ ), m = h(
124
+ (e) => {
125
+ e && (f(e), w((r) => ({
119
126
  ...r,
120
127
  [e]: (r[e] || 0) + 1
121
128
  })));
122
129
  },
123
130
  [f]
124
- ), O = m((e) => {
125
- E((r) => !r[e] || r[e].status === "interactive" ? r : {
131
+ ), A = h((e) => {
132
+ b((r) => !r[e] || r[e].status === "interactive" ? r : {
126
133
  ...r,
127
134
  [e]: { ...r[e], status: "interactive" }
128
135
  });
129
- }, []), j = m(
136
+ }, []), j = h(
130
137
  (e) => {
131
138
  f(e.origin);
132
139
  },
133
140
  [f]
134
- ), k = m(
141
+ ), T = h(
135
142
  (e, r) => {
136
- const n = ie(e, r);
143
+ const n = ue(e, r);
137
144
  if (n) {
138
- if (ue(n, window.location.origin)) {
145
+ if (ae(n, window.location.origin)) {
139
146
  i(n, "cross-site-legacy");
140
147
  return;
141
148
  }
@@ -144,7 +151,7 @@ const re = le(null), J = le({
144
151
  },
145
152
  [l, i]
146
153
  );
147
- T(() => {
154
+ R(() => {
148
155
  if (!d)
149
156
  return;
150
157
  const e = [
@@ -155,179 +162,185 @@ const re = le(null), J = le({
155
162
  // clientId is only a lookup key: the host resolves the display name from
156
163
  // it, and a broker binds it to the attested origin server-side.
157
164
  d.addListener("*", "init", (r, n) => {
158
- n != null && n.origin && (r != null && r.clientId) && (A.current[n.origin] = r.clientId, U(n.origin)), n != null && n.origin && Array.isArray(r == null ? void 0 : r.acceptsCredentials) ? Z.current[n.origin] = r.acceptsCredentials : n != null && n.origin && ue(n.origin, window.location.origin) && i(n.origin, "cross-site-legacy");
165
+ n != null && n.origin && (r != null && r.clientId) && (C.current[n.origin] = r.clientId, _(n.origin)), n != null && n.origin && Array.isArray(r == null ? void 0 : r.acceptsCredentials) ? v.current[n.origin] = r.acceptsCredentials : n != null && n.origin && ae(n.origin, window.location.origin) && i(n.origin, "cross-site-legacy");
159
166
  }),
160
- d.addListener("*", "authorize", k),
161
- d.addListener("*", "login", k),
167
+ d.addListener("*", "authorize", T),
168
+ d.addListener("*", "login", T),
162
169
  d.addListener(
163
170
  "*",
164
171
  "credential-request",
165
- (r, n) => l(r, { v2: !0, origin: ie(r, n) })
172
+ (r, n) => l(r, { v2: !0, origin: ue(r, n) })
166
173
  )
167
174
  ];
168
175
  return () => e.forEach((r) => r());
169
- }, [d, k, l, U, i]), T(() => {
176
+ }, [d, T, l, _, i]), R(() => {
170
177
  const e = (r) => {
171
178
  const n = r == null ? void 0 : r.data;
172
179
  if (!n || n.type !== "authorized" && n.type !== "authorize-failed")
173
180
  return;
174
- const u = N(n.authUrl);
181
+ const u = Q(n.authUrl);
175
182
  if (!(!u || r.origin !== u)) {
176
183
  if (n.type === "authorized") {
177
184
  if (n.accessToken) {
178
- if (!R.current[u])
185
+ if (!E.current[u])
179
186
  return;
180
- S((p) => ({
181
- ...p,
182
- [u]: oe({ accessToken: n.accessToken })
187
+ S((z) => ({
188
+ ...z,
189
+ [u]: ce({ accessToken: n.accessToken })
183
190
  })), f(u);
184
191
  } else
185
- g(u);
192
+ m(u);
186
193
  return;
187
194
  }
188
- O(u);
195
+ A(u);
189
196
  }
190
197
  };
191
198
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
192
- }, [f, g, O]);
193
- const B = m(
199
+ }, [f, m, A]);
200
+ const B = h(
194
201
  (e, r) => {
195
- const n = e == null ? void 0 : e.origin, u = oe(r);
196
- !n || !u || (S((p) => ({ ...p, [n]: u })), f(n));
202
+ const n = e == null ? void 0 : e.origin, u = ce(r);
203
+ !n || !u || (S((z) => ({ ...z, [n]: u })), f(n));
197
204
  },
198
205
  [f]
199
- ), z = m((e, r) => {
200
- E((n) => n[e] ? { ...n, [e]: { ...n[e], ...r } } : n);
201
- }, []), L = b({}), M = m(
206
+ ), O = h((e, r) => {
207
+ b((n) => n[e] ? { ...n, [e]: { ...n[e], ...r } } : n);
208
+ }, []), U = g({}), L = h(
202
209
  async (e, { approve: r } = {}) => {
203
210
  const n = P.current, { origin: u } = e;
204
- let p;
211
+ let z;
205
212
  try {
206
- p = await n(
207
- { origin: u, clientId: e.clientId, scope: e.scope, authUrl: e.authUrl },
213
+ z = await n(
214
+ {
215
+ origin: u,
216
+ clientId: e.clientId,
217
+ scope: e.scope,
218
+ authUrl: e.authUrl
219
+ },
208
220
  { approve: r }
209
221
  );
210
222
  } catch {
211
- r ? z(u, { error: { reason: "broker_unavailable" } }) : z(u, {
212
- status: e.silentUrl && te ? "silent" : "interactive"
223
+ r ? O(u, { error: { reason: "broker_unavailable" } }) : O(u, {
224
+ status: e.silentUrl && re ? "silent" : "interactive"
213
225
  });
214
226
  return;
215
227
  }
216
- if ((p == null ? void 0 : p.status) === 200 && p.credential) {
217
- B(e, p.credential);
228
+ const oe = z == null ? void 0 : z.status, H = (z == null ? void 0 : z.body) || {};
229
+ if (oe === 200 && H.credential) {
230
+ B(e, H.credential);
218
231
  return;
219
232
  }
220
- if ((p == null ? void 0 : p.status) === 409 && p.consentRequired) {
221
- z(u, {
233
+ if (oe === 409 && H.consentRequired) {
234
+ O(u, {
222
235
  status: "interactive",
223
236
  consent: {
224
- client: p.client || null,
225
- stepUp: !!p.stepUp,
226
- scope: p.scope || e.scope
237
+ client: H.client || null,
238
+ stepUp: !!H.stepUp,
239
+ scope: H.scope || e.scope
227
240
  },
228
241
  error: null
229
242
  });
230
243
  return;
231
244
  }
232
- const Q = (p == null ? void 0 : p.error) || "broker_error";
233
- if (!r && be.has(Q)) {
234
- z(u, {
235
- status: e.silentUrl && te ? "silent" : "interactive"
245
+ const ee = H.error || "broker_error";
246
+ if (!r && Re.has(ee)) {
247
+ O(u, {
248
+ status: e.silentUrl && re ? "silent" : "interactive"
236
249
  });
237
250
  return;
238
251
  }
239
- if (r && Q === "consent_denied") {
240
- z(u, { error: null });
252
+ if (r && ee === "consent_denied") {
253
+ O(u, { error: null });
241
254
  return;
242
255
  }
243
- if (Q === "rate_limited" && !e.rateLimitRetried) {
244
- const ee = Math.min(
245
- Number(p == null ? void 0 : p.retryAfter) > 0 ? Number(p.retryAfter) : me,
246
- ge
247
- ), fe = { ...e, rateLimitRetried: !0 };
256
+ if (ee === "rate_limited" && !e.rateLimitRetried) {
257
+ const te = Math.min(
258
+ Number(H.retryAfter) > 0 ? Number(H.retryAfter) : be,
259
+ Ee
260
+ ), he = { ...e, rateLimitRetried: !0 };
248
261
  a(u), o.current[u] = setTimeout(() => {
249
- delete o.current[u], L.current[u] = !0, v.current(fe, { approve: r }).finally(() => {
250
- delete L.current[u];
262
+ delete o.current[u], U.current[u] = !0, K.current(he, { approve: r }).finally(() => {
263
+ delete U.current[u];
251
264
  });
252
- }, ee * 1e3), z(u, { rateLimitRetried: !0 });
265
+ }, te * 1e3), O(u, { rateLimitRetried: !0 });
253
266
  return;
254
267
  }
255
- f(u), y((ee) => ({
256
- ...ee,
268
+ f(u), y((te) => ({
269
+ ...te,
257
270
  [u]: {
258
271
  origin: u,
259
- reason: `broker:${Q}`,
260
- detail: p || null,
261
- clientId: e.clientId || A.current[u] || null
272
+ reason: `broker:${ee}`,
273
+ detail: z || null,
274
+ clientId: e.clientId || C.current[u] || null
262
275
  }
263
276
  }));
264
277
  },
265
- [B, z, f, a]
266
- ), v = b(M);
267
- v.current = M, T(() => {
268
- Object.values(h).forEach((e) => {
269
- e.status !== "broker" || L.current[e.origin] || o.current[e.origin] || (L.current[e.origin] = !0, M(e).finally(() => {
270
- delete L.current[e.origin];
278
+ [B, O, f, a]
279
+ ), K = g(L);
280
+ K.current = L, R(() => {
281
+ Object.values(p).forEach((e) => {
282
+ e.status !== "broker" || U.current[e.origin] || o.current[e.origin] || (U.current[e.origin] = !0, L(e).finally(() => {
283
+ delete U.current[e.origin];
271
284
  }));
272
285
  });
273
- }, [h, M]);
274
- const K = m(
275
- (e) => !P.current || !(e != null && e.consent) ? Promise.resolve() : M(e, { approve: !0 }),
276
- [M]
286
+ }, [p, L]);
287
+ const Y = h(
288
+ (e) => !P.current || !(e != null && e.consent) ? Promise.resolve() : L(e, { approve: !0 }),
289
+ [L]
277
290
  );
278
- T(() => {
279
- const e = V.current;
280
- Object.values(h).forEach((r) => {
291
+ R(() => {
292
+ const e = X.current;
293
+ Object.values(p).forEach((r) => {
281
294
  r.status === "silent" && !e[r.origin] && (e[r.origin] = setTimeout(() => {
282
- delete e[r.origin], O(r.origin);
283
- }, Ee));
295
+ delete e[r.origin], A(r.origin);
296
+ }, Te));
284
297
  }), Object.keys(e).forEach((r) => {
285
- (!h[r] || h[r].status !== "silent") && (clearTimeout(e[r]), delete e[r]);
298
+ (!p[r] || p[r].status !== "silent") && (clearTimeout(e[r]), delete e[r]);
286
299
  });
287
- }, [h, O]), T(() => () => {
288
- F.current && F.current(), Object.values(V.current).forEach(clearTimeout), Object.values(o.current).forEach(clearTimeout);
300
+ }, [p, A]), R(() => () => {
301
+ F.current && F.current(), Object.values(X.current).forEach(clearTimeout), Object.values(o.current).forEach(clearTimeout);
289
302
  }, []);
290
- const W = m(
303
+ const W = h(
291
304
  (e) => {
292
305
  F.current && (F.current(), F.current = null);
293
- const r = s || Re;
306
+ const r = s || ke;
294
307
  F.current = r(e, {
295
308
  onBlocked: () => {
296
- E((n) => n[e.origin] ? {
309
+ b((n) => n[e.origin] ? {
297
310
  ...n,
298
311
  [e.origin]: { ...n[e.origin], popupBlocked: !0 }
299
312
  } : n);
300
313
  },
301
314
  onClosed: () => {
302
315
  if (e.v2) {
303
- te && E((n) => !n[e.origin] || !n[e.origin].silentUrl ? n : {
316
+ re && b((n) => !n[e.origin] || !n[e.origin].silentUrl ? n : {
304
317
  ...n,
305
318
  [e.origin]: { ...n[e.origin], status: "silent" }
306
319
  });
307
320
  return;
308
321
  }
309
- g(e.origin);
322
+ m(e.origin);
310
323
  }
311
324
  });
312
325
  },
313
- [s, g]
314
- ), _ = {
326
+ [s, m]
327
+ ), I = {
315
328
  // Hosts render UI for interactive entries only; silent resolution is
316
329
  // invisible by design.
317
- pending: Object.values(h).filter(
330
+ pending: Object.values(p).filter(
318
331
  (e) => e.status === "interactive"
319
332
  ),
320
333
  authorize: W,
321
- approve: K,
334
+ approve: Y,
322
335
  complete: B,
323
336
  dismiss: j,
324
- originEpochs: H,
337
+ originEpochs: Z,
325
338
  credentials: $,
326
339
  unsupported: q
327
- }, D = Object.values(h).filter(
340
+ }, D = Object.values(p).filter(
328
341
  (e) => e.status === "silent" && e.silentUrl
329
342
  );
330
- return /* @__PURE__ */ x.createElement(J.Provider, { value: _ }, t, D.map((e) => /* @__PURE__ */ x.createElement(
343
+ return /* @__PURE__ */ x.createElement(N.Provider, { value: I }, t, D.map((e) => /* @__PURE__ */ x.createElement(
331
344
  "iframe",
332
345
  {
333
346
  key: `mm-silent-auth-${e.origin}`,
@@ -339,179 +352,180 @@ const re = le(null), J = le({
339
352
  }
340
353
  )));
341
354
  };
342
- ae.propTypes = {
343
- children: w.node,
344
- launcher: w.func,
355
+ fe.propTypes = {
356
+ children: k.node,
357
+ launcher: k.func,
345
358
  /**
346
359
  * `async (request, { approve }) => result` where request =
347
360
  * `{ origin, clientId, scope, authUrl }` (origin is the zone-attested frame origin) and result
348
- * mirrors the authorization server's broker response: `{ status: 200, credential, scope,
349
- * client }`, `{ status: 409, consentRequired: true, client: { name, hostname }, stepUp }`, or
350
- * `{ status, error }`. Provided only by hosts that are themselves first-party clients.
361
+ * is `{ status, body }`: the HTTP status and the authorization server's parsed JSON, kept
362
+ * apart so a body field can never shadow the status. Bodies: `{ credential, scope, client }`
363
+ * on 200, `{ consentRequired: true, client: { name, hostname }, stepUp }` on 409, `{ error,
364
+ * … }` otherwise. Provided only by hosts that are themselves first-party clients.
351
365
  */
352
- broker: w.func
366
+ broker: k.func
353
367
  };
354
- const ye = () => G(J), Te = (t) => {
355
- const { originEpochs: s } = G(J), c = N(t);
368
+ const je = () => V(N), we = (t) => {
369
+ const { originEpochs: s } = V(N), c = Q(t);
356
370
  return c && s[c] || 0;
357
- }, ke = (t) => {
358
- const { credentials: s } = G(J), c = N(t);
371
+ }, Ie = (t) => {
372
+ const { credentials: s } = V(N), c = Q(t);
359
373
  return c && s[c] || null;
360
- }, we = (t) => {
361
- const { unsupported: s } = G(J), c = N(t);
374
+ }, _e = (t) => {
375
+ const { unsupported: s } = V(N), c = Q(t);
362
376
  return c && s[c] || null;
363
- }, Ie = ({ children: t, authorizationLauncher: s, credentialBroker: c }) => {
364
- const [d, h] = C({}), [E, H] = C({}), I = b({}), $ = b({}), S = b({}), q = m((i, l) => {
377
+ }, Ue = ({ children: t, authorizationLauncher: s, credentialBroker: c }) => {
378
+ const [d, p] = M({}), [b, Z] = M({}), w = g({}), $ = g({}), S = g({}), q = h((i, l) => {
365
379
  var o;
366
380
  return !!((o = S.current[i]) != null && o.has(l));
367
- }, []), y = m((i, l, o) => {
368
- h((a) => ({ ...a, [i]: { origin: l, frameRef: o } }));
369
- }, []), Y = m((i) => {
370
- h((l) => {
381
+ }, []), y = h((i, l, o) => {
382
+ p((a) => ({ ...a, [i]: { origin: l, frameRef: o } }));
383
+ }, []), G = h((i) => {
384
+ p((l) => {
371
385
  const o = { ...l };
372
386
  return delete o[i], o;
373
- }), H((l) => {
387
+ }), Z((l) => {
374
388
  const o = { ...l };
375
389
  return delete o[i], o;
376
390
  }), delete S.current[i];
377
391
  }, []);
378
- T(() => {
392
+ R(() => {
379
393
  const i = (o = [], a, f) => {
380
- o.forEach((g) => g(a, f));
394
+ o.forEach((m) => m(a, f));
381
395
  }, l = (o) => {
382
- var B, z, L, M, v, K, W;
396
+ var B, O, U, L, K, Y, W;
383
397
  if (!((B = o == null ? void 0 : o.data) != null && B.instanceId))
384
398
  return;
385
- const { instanceId: a, type: f } = o.data, g = d[a], O = (L = (z = g == null ? void 0 : g.frameRef) == null ? void 0 : z.current) == null ? void 0 : L.contentWindow;
386
- if (!O || o.source !== O || o.origin !== g.origin)
399
+ const { instanceId: a, type: f } = o.data, m = d[a], A = (U = (O = m == null ? void 0 : m.frameRef) == null ? void 0 : O.current) == null ? void 0 : U.contentWindow;
400
+ if (!A || o.source !== A || o.origin !== m.origin)
387
401
  return;
388
- const j = { origin: o.origin }, k = I.current;
402
+ const j = { origin: o.origin }, T = w.current;
389
403
  if (f === "response") {
390
- const { callbackId: _, response: D, error: e } = o.data, r = $.current[_];
391
- r && (r(D, e), delete $.current[_]);
404
+ const { callbackId: I, response: D, error: e } = o.data, r = $.current[I];
405
+ r && (r(D, e), delete $.current[I]);
392
406
  return;
393
407
  }
394
408
  if (f === "mark-registered") {
395
- const { requestType: _ } = o.data;
396
- S.current[a] || (S.current[a] = /* @__PURE__ */ new Set()), S.current[a].add(_);
409
+ const { requestType: I } = o.data;
410
+ S.current[a] || (S.current[a] = /* @__PURE__ */ new Set()), S.current[a].add(I);
397
411
  return;
398
412
  }
399
- f === "ready" && H((_) => ({ ..._, [a]: !0 })), i((M = k[a]) == null ? void 0 : M[f], o.data, j), i((v = k["*"]) == null ? void 0 : v[f], o.data, j), i((K = k[a]) == null ? void 0 : K["*"], o.data, j), i((W = k["*"]) == null ? void 0 : W["*"], o.data, j);
413
+ f === "ready" && Z((I) => ({ ...I, [a]: !0 })), i((L = T[a]) == null ? void 0 : L[f], o.data, j), i((K = T["*"]) == null ? void 0 : K[f], o.data, j), i((Y = T[a]) == null ? void 0 : Y["*"], o.data, j), i((W = T["*"]) == null ? void 0 : W["*"], o.data, j);
400
414
  };
401
415
  return window.addEventListener("message", l), () => {
402
416
  window.removeEventListener("message", l);
403
417
  };
404
418
  }, [d]);
405
- const R = m(
419
+ const E = h(
406
420
  (i, l, o) => {
407
- var f, g;
421
+ var f, m;
408
422
  const a = d[i];
409
423
  if (!a) {
410
424
  console.warn(`Origin not set for id: ${i}. Unable to send message.`);
411
425
  return;
412
426
  }
413
- (g = (f = a == null ? void 0 : a.frameRef) == null ? void 0 : f.current) != null && g.contentWindow && a.frameRef.current.contentWindow.postMessage(
427
+ (m = (f = a == null ? void 0 : a.frameRef) == null ? void 0 : f.current) != null && m.contentWindow && a.frameRef.current.contentWindow.postMessage(
414
428
  { type: l, ...o, instanceId: i },
415
429
  a.origin
416
430
  );
417
431
  },
418
432
  [d]
419
- ), F = b(0), V = m(() => `${Date.now()}-${++F.current}`, []), A = m(
433
+ ), F = g(0), X = h(() => `${Date.now()}-${++F.current}`, []), C = h(
420
434
  async (i, l, o = {}) => new Promise((a, f) => {
421
- const g = V(), O = (j, k) => {
422
- delete $.current[g], k ? f(k) : a(j);
435
+ const m = X(), A = (j, T) => {
436
+ delete $.current[m], T ? f(T) : a(j);
423
437
  };
424
- $.current[g] = O, R(i, "request", { callbackId: g, requestType: l, data: o });
438
+ $.current[m] = A, E(i, "request", { callbackId: m, requestType: l, data: o });
425
439
  }),
426
- [R]
427
- ), Z = m(
440
+ [E]
441
+ ), v = h(
428
442
  (i, l) => {
429
- R(i, "load-options", l);
443
+ E(i, "load-options", l);
430
444
  },
431
- [R]
432
- ), P = m(
445
+ [E]
446
+ ), P = h(
433
447
  (i, l) => {
434
- R(i, "validate", l);
448
+ E(i, "validate", l);
435
449
  },
436
- [R]
437
- ), U = pe(
450
+ [E]
451
+ ), _ = me(
438
452
  () => ({
439
453
  registerFrame: y,
440
- unregisterFrame: Y,
441
- sendMessage: R,
442
- sendRequest: A,
443
- loadOptions: Z,
454
+ unregisterFrame: G,
455
+ sendMessage: E,
456
+ sendRequest: C,
457
+ loadOptions: v,
444
458
  validate: P,
445
459
  hasHandler: q,
446
- readyFrames: E,
447
- addListener: (i, l, o) => (I.current[i] || (I.current[i] = {}), I.current[i][l] || (I.current[i][l] = []), I.current[i][l].push(o), () => {
448
- I.current[i][l] = I.current[i][l].filter((a) => a !== o);
460
+ readyFrames: b,
461
+ addListener: (i, l, o) => (w.current[i] || (w.current[i] = {}), w.current[i][l] || (w.current[i][l] = []), w.current[i][l].push(o), () => {
462
+ w.current[i][l] = w.current[i][l].filter((a) => a !== o);
449
463
  })
450
464
  }),
451
465
  [
452
466
  y,
453
- Y,
454
- R,
455
- A,
456
- Z,
467
+ G,
468
+ E,
469
+ C,
470
+ v,
457
471
  P,
458
472
  q,
459
- E
473
+ b
460
474
  ]
461
475
  );
462
- return /* @__PURE__ */ x.createElement(re.Provider, { value: U }, /* @__PURE__ */ x.createElement(ae, { launcher: s, broker: c }, t));
463
- }, X = (t, s, c) => {
464
- const d = G(re);
476
+ return /* @__PURE__ */ x.createElement(ne.Provider, { value: _ }, /* @__PURE__ */ x.createElement(fe, { launcher: s, broker: c }, t));
477
+ }, J = (t, s, c) => {
478
+ const d = V(ne);
465
479
  if (d === null)
466
480
  throw new Error(
467
481
  "useEmbeddedEffect must be used within a MMEmbeddableZoneProvider"
468
482
  );
469
- const h = b(c);
470
- T(() => {
471
- h.current = c;
472
- }, [c]), T(() => {
483
+ const p = g(c);
484
+ R(() => {
485
+ p.current = c;
486
+ }, [c]), R(() => {
473
487
  if (!(!t || !s)) {
474
488
  if (s.startsWith("key:")) {
475
- const E = s.substring(4);
476
- return d.readyFrames[t] && d.sendMessage(t, "subscribe-key", { keyChord: E }), d.addListener(
489
+ const b = s.substring(4);
490
+ return d.readyFrames[t] && d.sendMessage(t, "subscribe-key", { keyChord: b }), d.addListener(
477
491
  t,
478
- `key-pressed:${E}`,
479
- (...I) => h.current(...I)
492
+ `key-pressed:${b}`,
493
+ (...w) => p.current(...w)
480
494
  );
481
495
  }
482
496
  return d.addListener(
483
497
  t,
484
498
  s,
485
- (...E) => h.current(...E)
499
+ (...b) => p.current(...b)
486
500
  );
487
501
  }
488
502
  }, [d, t, s]);
489
503
  };
490
- Ie.propTypes = {
491
- children: w.node.isRequired,
504
+ Ue.propTypes = {
505
+ children: k.node.isRequired,
492
506
  /**
493
507
  * Optional interactive-step launcher for embedded authorizations,
494
508
  * `(entry, { onBlocked, onClosed }) => cleanup`. Defaults to a top-level
495
509
  * popup. Hosts that cannot open windows (Android WebView shells) drive
496
510
  * their own UI from useEmbeddedAuthorizations() instead.
497
511
  */
498
- authorizationLauncher: w.func,
512
+ authorizationLauncher: k.func,
499
513
  /**
500
514
  * Optional credential broker for hosts that are first-party MachineMetrics clients
501
515
  * (`async (request, { approve }) => result`, see EmbeddedAuthorizationManager). When present,
502
516
  * v2 credential requests are brokered server-side (no popup, no hidden frame) and consent is
503
517
  * rendered natively by the host from the broker's `client` identity.
504
518
  */
505
- credentialBroker: w.func
519
+ credentialBroker: k.func
506
520
  };
507
- const ne = se.default || se, _e = 1e4, Ue = "credentials", Le = (t, s) => `${t}/mm-embedded-interop?id=${encodeURIComponent(s)}&origin=${encodeURIComponent(
521
+ const se = ie.default || ie, Le = 1e4, Me = "credentials", Ce = (t, s) => `${t}/mm-embedded-interop?id=${encodeURIComponent(s)}&origin=${encodeURIComponent(
508
522
  window.location.origin
509
- )}&caps=${Ue}`, Me = ne.iframe`
523
+ )}&caps=${Me}`, Ae = se.iframe`
510
524
  width: 100%;
511
525
  height: 100%;
512
526
  border: none;
513
527
  visibility: ${(t) => t.$isReady ? "visible" : "hidden"};
514
- `, Ce = ne.div`
528
+ `, Oe = se.div`
515
529
  width: 100%;
516
530
  height: 100%;
517
531
  display: flex;
@@ -524,7 +538,7 @@ const ne = se.default || se, _e = 1e4, Ue = "credentials", Le = (t, s) => `${t}/
524
538
  text-align: center;
525
539
  color: #555;
526
540
  font-size: 14px;
527
- `, Ae = (t) => {
541
+ `, ze = (t) => {
528
542
  const s = t && t.origin || "This app", c = t && t.reason || "";
529
543
  switch (c) {
530
544
  case "broker:scope_above_ceiling":
@@ -552,34 +566,34 @@ const ne = se.default || se, _e = 1e4, Ue = "credentials", Le = (t, s) => `${t}/
552
566
  detail: "It needs an update to support embedding from a different domain."
553
567
  };
554
568
  }
555
- }, de = ({ entry: t }) => {
556
- const s = Ae(t);
557
- return /* @__PURE__ */ x.createElement(Ce, { "data-reason": t && t.reason || void 0 }, /* @__PURE__ */ x.createElement("div", { style: { fontWeight: 600 } }, s.title), /* @__PURE__ */ x.createElement("div", { style: { fontSize: 12, color: "#888" } }, s.detail));
569
+ }, pe = ({ entry: t }) => {
570
+ const s = ze(t);
571
+ return /* @__PURE__ */ x.createElement(Oe, { "data-reason": t && t.reason || void 0 }, /* @__PURE__ */ x.createElement("div", { style: { fontWeight: 600 } }, s.title), /* @__PURE__ */ x.createElement("div", { style: { fontSize: 12, color: "#888" } }, s.detail));
558
572
  };
559
- de.propTypes = {
560
- entry: w.shape({
561
- origin: w.string,
562
- name: w.string,
563
- reason: w.string,
564
- detail: w.object
573
+ pe.propTypes = {
574
+ entry: k.shape({
575
+ origin: k.string,
576
+ name: k.string,
577
+ reason: k.string,
578
+ detail: k.object
565
579
  })
566
580
  };
567
- const Oe = ne.div`
581
+ const xe = se.div`
568
582
  height: 100%;
569
583
  display: flex;
570
584
  flex: 1;
571
585
  align-items: center;
572
586
  justify-content: center;
573
- `, ze = () => /* @__PURE__ */ x.createElement(Oe, null, /* @__PURE__ */ x.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), xe = ({
587
+ `, $e = () => /* @__PURE__ */ x.createElement(xe, null, /* @__PURE__ */ x.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), Se = ({
574
588
  id: t,
575
589
  src: s,
576
590
  path: c,
577
591
  onInit: d = () => {
578
592
  },
579
- onTimeout: h,
580
- context: E = {},
581
- params: H = {},
582
- renderUnsupported: I,
593
+ onTimeout: p,
594
+ context: b = {},
595
+ params: Z = {},
596
+ renderUnsupported: w,
583
597
  renderTimeout: $,
584
598
  ...S
585
599
  }) => {
@@ -587,119 +601,119 @@ const Oe = ne.div`
587
601
  return console.error(
588
602
  "isConfiguring must be passed via the params prop to MMEmbeddableZone"
589
603
  ), null;
590
- if ("colorMode" in E)
604
+ if ("colorMode" in b)
591
605
  return console.error(
592
606
  "colorMode must be passed via the params prop to MMEmbeddableZone"
593
607
  ), null;
594
- if ("isFullScreen" in E)
608
+ if ("isFullScreen" in b)
595
609
  return console.error(
596
610
  "isFullScreen must be passed via the params prop to MMEmbeddableZone"
597
611
  ), null;
598
- const q = b(), [y, Y] = C(), [R, F] = C(0), [V, A] = C(!1), [Z, P] = C(!1), U = Te(s), i = ke(s), l = we(s), [o, a] = C(0), [f, g] = C(null), { registerFrame: O, unregisterFrame: j, sendMessage: k } = G(
599
- re
600
- ), [B, z] = C(), L = b(), M = b(h), v = b(d), K = b(!1), W = m(() => {
601
- K.current = !1, clearTimeout(L.current), F(0), A(!1), P(!1), g(null);
612
+ const q = g(), [y, G] = M(), [E, F] = M(0), [X, C] = M(!1), [v, P] = M(!1), _ = we(s), i = Ie(s), l = _e(s), [o, a] = M(0), [f, m] = M(null), { registerFrame: A, unregisterFrame: j, sendMessage: T } = V(
613
+ ne
614
+ ), [B, O] = M(), U = g(), L = g(p), K = g(d), Y = g(!1), W = h(() => {
615
+ Y.current = !1, clearTimeout(U.current), F(0), C(!1), P(!1), m(null);
602
616
  }, []);
603
- T(() => {
604
- (U > 0 || o > 0) && W();
605
- }, [U, o, W]), T(() => {
606
- M.current = h;
607
- }, [h]), T(() => {
608
- v.current = d;
609
- }, [d]), T(() => {
610
- R && k(t, "set-context", {
617
+ R(() => {
618
+ (_ > 0 || o > 0) && W();
619
+ }, [_, o, W]), R(() => {
620
+ L.current = p;
621
+ }, [p]), R(() => {
622
+ K.current = d;
623
+ }, [d]), R(() => {
624
+ E && T(t, "set-context", {
611
625
  context: {
612
- ...E
626
+ ...b
613
627
  }
614
628
  });
615
- }, [E, t, R]), T(() => {
616
- R && k(t, "set-params", { params: H });
617
- }, [H, t, R]), T(() => {
618
- c !== void 0 && z((c == null ? void 0 : c.indexOf("/")) === 0 ? c : `/${c}`);
619
- }, [c]), T(() => {
620
- B === void 0 || !R || k(t, "navigate", { path: B });
621
- }, [B, R, t, k]), T(() => {
629
+ }, [b, t, E]), R(() => {
630
+ E && T(t, "set-params", { params: Z });
631
+ }, [Z, t, E]), R(() => {
632
+ c !== void 0 && O((c == null ? void 0 : c.indexOf("/")) === 0 ? c : `/${c}`);
633
+ }, [c]), R(() => {
634
+ B === void 0 || !E || T(t, "navigate", { path: B });
635
+ }, [B, E, t, T]), R(() => {
622
636
  if (!s || !t || !q)
623
637
  return;
624
638
  W();
625
639
  const e = new URL(s);
626
- return O(t, e.origin, q), v.current(), Y(Le(e.origin, t)), () => {
640
+ return A(t, e.origin, q), K.current(), G(Ce(e.origin, t)), () => {
627
641
  j(t);
628
642
  };
629
- }, [s, t, O, q, W]), T(() => {
630
- if (!(!y || K.current))
631
- return L.current = setTimeout(() => {
632
- A(!0), M.current && M.current();
633
- }, _e), () => clearTimeout(L.current);
634
- }, [y, s, U, o]);
635
- const _ = m(() => {
636
- K.current = !0, clearTimeout(L.current), A(!1);
643
+ }, [s, t, A, q, W]), R(() => {
644
+ if (!(!y || Y.current))
645
+ return U.current = setTimeout(() => {
646
+ C(!0), L.current && L.current();
647
+ }, Le), () => clearTimeout(U.current);
648
+ }, [y, s, _, o]);
649
+ const I = h(() => {
650
+ Y.current = !0, clearTimeout(U.current), C(!1);
637
651
  }, []);
638
- X(t, "init", (e) => {
639
- _(), Array.isArray(e == null ? void 0 : e.acceptsCredentials) && g(e.acceptsCredentials);
640
- }), X(t, "authorize", _), X(t, "login", _), X(t, "credential-request", () => {
641
- _(), P(!0);
642
- }), T(() => {
643
- if (!Z || !i)
652
+ J(t, "init", (e) => {
653
+ I(), Array.isArray(e == null ? void 0 : e.acceptsCredentials) && m(e.acceptsCredentials);
654
+ }), J(t, "authorize", I), J(t, "login", I), J(t, "credential-request", () => {
655
+ I(), P(!0);
656
+ }), R(() => {
657
+ if (!v || !i)
644
658
  return;
645
659
  const e = f;
646
660
  if (Array.isArray(e) && !e.includes(i.kind))
647
661
  return;
648
662
  const r = i.kind === "access_token" ? { accessToken: i.accessToken } : {};
649
- k(t, "credential", { ...r, credential: i });
650
- }, [Z, i, f, t, k]), X(t, "ready", () => {
651
- _(), F((e) => e + 1);
663
+ T(t, "credential", { ...r, credential: i });
664
+ }, [v, i, f, t, T]), J(t, "ready", () => {
665
+ I(), F((e) => e + 1);
652
666
  });
653
- const D = b();
654
- return X(t, "heartbeat", () => {
667
+ const D = g();
668
+ return J(t, "heartbeat", () => {
655
669
  D.current && clearTimeout(D.current), D.current = setTimeout(() => {
656
670
  a((e) => e + 1);
657
671
  }, 6e3);
658
- }), T(() => () => {
672
+ }), R(() => () => {
659
673
  D.current && clearTimeout(D.current);
660
- }, []), l ? I ? I(l) : /* @__PURE__ */ x.createElement(de, { entry: l }) : V && !R ? $ ? $() : /* @__PURE__ */ x.createElement(ze, null) : /* @__PURE__ */ x.createElement(
661
- Me,
674
+ }, []), l ? w ? w(l) : /* @__PURE__ */ x.createElement(pe, { entry: l }) : X && !E ? $ ? $() : /* @__PURE__ */ x.createElement($e, null) : /* @__PURE__ */ x.createElement(
675
+ Ae,
662
676
  {
663
- key: `auth-epoch-${U}-frame-${o}`,
664
- $isReady: R,
677
+ key: `auth-epoch-${_}-frame-${o}`,
678
+ $isReady: E,
665
679
  ref: q,
666
680
  src: y,
667
681
  ...S
668
682
  }
669
683
  );
670
684
  };
671
- xe.propTypes = {
672
- id: w.string,
673
- src: w.string.isRequired,
674
- path: w.string,
675
- onInit: w.func,
676
- onTimeout: w.func,
685
+ Se.propTypes = {
686
+ id: k.string,
687
+ src: k.string.isRequired,
688
+ path: k.string,
689
+ onInit: k.func,
690
+ onTimeout: k.func,
677
691
  /**
678
692
  * Optional host-styled renderer for the structurally-unsupported embed
679
693
  * state (legacy app on a cross-site origin), `(entry) => ReactNode`. Falls
680
694
  * back to a minimal built-in placeholder.
681
695
  */
682
- renderUnsupported: w.func,
696
+ renderUnsupported: k.func,
683
697
  /**
684
698
  * Optional host-styled renderer for the handshake-timeout failure state
685
699
  * (the app is not embeddable / could not load), `() => ReactNode`. Falls
686
700
  * back to a minimal centered message.
687
701
  */
688
- renderTimeout: w.func
702
+ renderTimeout: k.func
689
703
  };
690
704
  export {
691
- he as CREDENTIAL_KIND_ACCESS_TOKEN,
692
- J as EmbeddedAuthorizationContext,
693
- xe as MMEmbeddableZone,
694
- re as MMEmbeddableZoneContext,
695
- Ie as MMEmbeddableZoneProvider,
696
- ue as isCrossSite,
697
- oe as normalizeCredential,
698
- Re as popupAuthorizationLauncher,
699
- Ae as unsupportedCopy,
700
- ye as useEmbeddedAuthorizations,
701
- ke as useEmbeddedCredential,
702
- X as useEmbeddedEffect,
703
- Te as useEmbeddedOriginEpoch,
704
- we as useEmbeddedUnsupported
705
+ ge as CREDENTIAL_KIND_ACCESS_TOKEN,
706
+ N as EmbeddedAuthorizationContext,
707
+ Se as MMEmbeddableZone,
708
+ ne as MMEmbeddableZoneContext,
709
+ Ue as MMEmbeddableZoneProvider,
710
+ ae as isCrossSite,
711
+ ce as normalizeCredential,
712
+ ke as popupAuthorizationLauncher,
713
+ ze as unsupportedCopy,
714
+ je as useEmbeddedAuthorizations,
715
+ Ie as useEmbeddedCredential,
716
+ J as useEmbeddedEffect,
717
+ we as useEmbeddedOriginEpoch,
718
+ _e as useEmbeddedUnsupported
705
719
  };
@@ -1,9 +1,9 @@
1
- (function(h,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("prop-types"),require("styled-components")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","styled-components"],t):(h=typeof globalThis!="undefined"?globalThis:h||self,t(h["mm-react-embeddable"]={},h.React,h.PropTypes,h.styled))})(this,(function(h,t,Ee,ge){"use strict";const ee=r=>r&&r.__esModule?r:{default:r},U=ee(t),C=ee(Ee),se=ee(ge),V=t.createContext(null),Y=t.createContext({pending:[],authorize:()=>{},approve:()=>{},complete:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),ue="access_token",te=r=>r?r.kind?r:r.accessToken?{kind:ue,accessToken:r.accessToken,expiresAt:r.expiresAt||null}:null:null,ke=60,Ce=120,Te=new Set(["host_not_allowed","unbound_host_bound_guest","invalid_token","provider_unavailable"]),J=typeof window!="undefined"&&window.location.protocol==="https:",_e=8e3,X=r=>{try{return new URL(r).origin}catch{return null}},oe=(r,u)=>{const c=u==null?void 0:u.origin;return!c||X(r==null?void 0:r.authUrl)!==c?null:c},ie=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const u=r.split(".");return u.length<=2?r:u.slice(-2).join(".")},re=(r,u)=>{try{const c=new URL(r),f=new URL(u);return c.protocol!==f.protocol?!0:ie(c.hostname)!==ie(f.hostname)}catch{return!0}},ce=(r,{onBlocked:u,onClosed:c})=>{const f=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!f)return u(),()=>{};const m=setInterval(()=>{f.closed&&(clearInterval(m),c())},1e3);return()=>clearInterval(m)},le=({children:r,launcher:u,broker:c})=>{const f=t.useContext(V),[m,g]=t.useState({}),[Z,_]=t.useState({}),[O,y]=t.useState({}),[q,x]=t.useState({}),N=t.useRef(O);N.current=O;const k=t.useRef(m);k.current=m;const $=t.useRef(null),G=t.useRef({}),L=t.useRef({}),W=t.useRef({}),F=t.useRef(c);F.current=c;const I=t.useCallback(e=>{const n=L.current[e];if(!n)return;const s=l=>!l[e]||l[e].clientId?l:{...l,[e]:{...l[e],clientId:n}};g(s),x(s)},[]),i=t.useCallback((e,n)=>{e&&(x(s=>s[e]?s:{...s,[e]:{origin:e,reason:n,clientId:L.current[e]||null}}),I(e))},[I]),a=t.useCallback((e,{v2:n=!1,origin:s=null}={})=>{s&&(n&&N.current[s]||(g(l=>l[s]?l:{...l,[s]:{origin:s,authUrl:e.authUrl,silentUrl:e.silentUrl||null,status:n&&F.current?"broker":n&&e.silentUrl&&J?"silent":"interactive",v2:n,scope:e.scope||null,acceptsCredentials:W.current[s]||null,consent:null,error:null,clientId:e.clientId||L.current[s]||null,popupBlocked:!1}}),I(s)))},[I]),o=t.useRef({}),d=t.useCallback(e=>{o.current[e]&&(clearTimeout(o.current[e]),delete o.current[e])},[]),p=t.useCallback(e=>{d(e),g(n=>{if(!n[e])return n;const s={...n};return delete s[e],s})},[d]),E=t.useCallback(e=>{e&&(p(e),_(n=>({...n,[e]:(n[e]||0)+1})))},[p]),A=t.useCallback(e=>{g(n=>!n[e]||n[e].status==="interactive"?n:{...n,[e]:{...n[e],status:"interactive"}})},[]),P=t.useCallback(e=>{p(e.origin)},[p]),T=t.useCallback((e,n)=>{const s=oe(e,n);if(s){if(re(s,window.location.origin)){i(s,"cross-site-legacy");return}a(e,{origin:s})}},[a,i]);t.useEffect(()=>{if(!f)return;const e=[f.addListener("*","init",(n,s)=>{s!=null&&s.origin&&(n!=null&&n.clientId)&&(L.current[s.origin]=n.clientId,I(s.origin)),s!=null&&s.origin&&Array.isArray(n==null?void 0:n.acceptsCredentials)?W.current[s.origin]=n.acceptsCredentials:s!=null&&s.origin&&re(s.origin,window.location.origin)&&i(s.origin,"cross-site-legacy")}),f.addListener("*","authorize",T),f.addListener("*","login",T),f.addListener("*","credential-request",(n,s)=>a(n,{v2:!0,origin:oe(n,s)}))];return()=>e.forEach(n=>n())},[f,T,a,I,i]),t.useEffect(()=>{const e=n=>{const s=n==null?void 0:n.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const l=X(s.authUrl);if(!(!l||n.origin!==l)){if(s.type==="authorized"){if(s.accessToken){if(!k.current[l])return;y(b=>({...b,[l]:te({accessToken:s.accessToken})})),p(l)}else E(l);return}A(l)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[p,E,A]);const j=t.useCallback((e,n)=>{const s=e==null?void 0:e.origin,l=te(n);!s||!l||(y(b=>({...b,[s]:l})),p(s))},[p]),z=t.useCallback((e,n)=>{g(s=>s[e]?{...s,[e]:{...s[e],...n}}:s)},[]),M=t.useRef({}),S=t.useCallback(async(e,{approve:n}={})=>{const s=F.current,{origin:l}=e;let b;try{b=await s({origin:l,clientId:e.clientId,scope:e.scope,authUrl:e.authUrl},{approve:n})}catch{n?z(l,{error:{reason:"broker_unavailable"}}):z(l,{status:e.silentUrl&&J?"silent":"interactive"});return}if((b==null?void 0:b.status)===200&&b.credential){j(e,b.credential);return}if((b==null?void 0:b.status)===409&&b.consentRequired){z(l,{status:"interactive",consent:{client:b.client||null,stepUp:!!b.stepUp,scope:b.scope||e.scope},error:null});return}const Q=(b==null?void 0:b.error)||"broker_error";if(!n&&Te.has(Q)){z(l,{status:e.silentUrl&&J?"silent":"interactive"});return}if(n&&Q==="consent_denied"){z(l,{error:null});return}if(Q==="rate_limited"&&!e.rateLimitRetried){const R=Math.min(Number(b==null?void 0:b.retryAfter)>0?Number(b.retryAfter):ke,Ce),Oe={...e,rateLimitRetried:!0};d(l),o.current[l]=setTimeout(()=>{delete o.current[l],M.current[l]=!0,v.current(Oe,{approve:n}).finally(()=>{delete M.current[l]})},R*1e3),z(l,{rateLimitRetried:!0});return}p(l),x(R=>({...R,[l]:{origin:l,reason:`broker:${Q}`,detail:b||null,clientId:e.clientId||L.current[l]||null}}))},[j,z,p,d]),v=t.useRef(S);v.current=S,t.useEffect(()=>{Object.values(m).forEach(e=>{e.status!=="broker"||M.current[e.origin]||o.current[e.origin]||(M.current[e.origin]=!0,S(e).finally(()=>{delete M.current[e.origin]}))})},[m,S]);const H=t.useCallback(e=>!F.current||!(e!=null&&e.consent)?Promise.resolve():S(e,{approve:!0}),[S]);t.useEffect(()=>{const e=G.current;Object.values(m).forEach(n=>{n.status==="silent"&&!e[n.origin]&&(e[n.origin]=setTimeout(()=>{delete e[n.origin],A(n.origin)},_e))}),Object.keys(e).forEach(n=>{(!m[n]||m[n].status!=="silent")&&(clearTimeout(e[n]),delete e[n])})},[m,A]),t.useEffect(()=>()=>{$.current&&$.current(),Object.values(G.current).forEach(clearTimeout),Object.values(o.current).forEach(clearTimeout)},[]);const B=t.useCallback(e=>{$.current&&($.current(),$.current=null);const n=u||ce;$.current=n(e,{onBlocked:()=>{g(s=>s[e.origin]?{...s,[e.origin]:{...s[e.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(e.v2){J&&g(s=>!s[e.origin]||!s[e.origin].silentUrl?s:{...s,[e.origin]:{...s[e.origin],status:"silent"}});return}E(e.origin)}})},[u,E]),w={pending:Object.values(m).filter(e=>e.status==="interactive"),authorize:B,approve:H,complete:j,dismiss:P,originEpochs:Z,credentials:O,unsupported:q},D=Object.values(m).filter(e=>e.status==="silent"&&e.silentUrl);return U.default.createElement(Y.Provider,{value:w},r,D.map(e=>U.default.createElement("iframe",{key:`mm-silent-auth-${e.origin}`,src:e.silentUrl,title:`MachineMetrics silent authorization (${e.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};le.propTypes={children:C.default.node,launcher:C.default.func,broker:C.default.func};const we=()=>t.useContext(Y),ae=r=>{const{originEpochs:u}=t.useContext(Y),c=X(r);return c&&u[c]||0},de=r=>{const{credentials:u}=t.useContext(Y),c=X(r);return c&&u[c]||null},fe=r=>{const{unsupported:u}=t.useContext(Y),c=X(r);return c&&u[c]||null},pe=({children:r,authorizationLauncher:u,credentialBroker:c})=>{const[f,m]=t.useState({}),[g,Z]=t.useState({}),_=t.useRef({}),O=t.useRef({}),y=t.useRef({}),q=t.useCallback((i,a)=>{var o;return!!((o=y.current[i])!=null&&o.has(a))},[]),x=t.useCallback((i,a,o)=>{m(d=>({...d,[i]:{origin:a,frameRef:o}}))},[]),N=t.useCallback(i=>{m(a=>{const o={...a};return delete o[i],o}),Z(a=>{const o={...a};return delete o[i],o}),delete y.current[i]},[]);t.useEffect(()=>{const i=(o=[],d,p)=>{o.forEach(E=>E(d,p))},a=o=>{var j,z,M,S,v,H,B;if(!((j=o==null?void 0:o.data)!=null&&j.instanceId))return;const{instanceId:d,type:p}=o.data,E=f[d],A=(M=(z=E==null?void 0:E.frameRef)==null?void 0:z.current)==null?void 0:M.contentWindow;if(!A||o.source!==A||o.origin!==E.origin)return;const P={origin:o.origin},T=_.current;if(p==="response"){const{callbackId:w,response:D,error:e}=o.data,n=O.current[w];n&&(n(D,e),delete O.current[w]);return}if(p==="mark-registered"){const{requestType:w}=o.data;y.current[d]||(y.current[d]=new Set),y.current[d].add(w);return}p==="ready"&&Z(w=>({...w,[d]:!0})),i((S=T[d])==null?void 0:S[p],o.data,P),i((v=T["*"])==null?void 0:v[p],o.data,P),i((H=T[d])==null?void 0:H["*"],o.data,P),i((B=T["*"])==null?void 0:B["*"],o.data,P)};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[f]);const k=t.useCallback((i,a,o)=>{var p,E;const d=f[i];if(!d){console.warn(`Origin not set for id: ${i}. Unable to send message.`);return}(E=(p=d==null?void 0:d.frameRef)==null?void 0:p.current)!=null&&E.contentWindow&&d.frameRef.current.contentWindow.postMessage({type:a,...o,instanceId:i},d.origin)},[f]),$=t.useRef(0),G=t.useCallback(()=>`${Date.now()}-${++$.current}`,[]),L=t.useCallback(async(i,a,o={})=>new Promise((d,p)=>{const E=G(),A=(P,T)=>{delete O.current[E],T?p(T):d(P)};O.current[E]=A,k(i,"request",{callbackId:E,requestType:a,data:o})}),[k]),W=t.useCallback((i,a)=>{k(i,"load-options",a)},[k]),F=t.useCallback((i,a)=>{k(i,"validate",a)},[k]),I=t.useMemo(()=>({registerFrame:x,unregisterFrame:N,sendMessage:k,sendRequest:L,loadOptions:W,validate:F,hasHandler:q,readyFrames:g,addListener:(i,a,o)=>(_.current[i]||(_.current[i]={}),_.current[i][a]||(_.current[i][a]=[]),_.current[i][a].push(o),()=>{_.current[i][a]=_.current[i][a].filter(d=>d!==o)})}),[x,N,k,L,W,F,q,g]);return U.default.createElement(V.Provider,{value:I},U.default.createElement(le,{launcher:u,broker:c},r))},K=(r,u,c)=>{const f=t.useContext(V);if(f===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const m=t.useRef(c);t.useEffect(()=>{m.current=c},[c]),t.useEffect(()=>{if(!(!r||!u)){if(u.startsWith("key:")){const g=u.substring(4);return f.readyFrames[r]&&f.sendMessage(r,"subscribe-key",{keyChord:g}),f.addListener(r,`key-pressed:${g}`,(..._)=>m.current(..._))}return f.addListener(r,u,(...g)=>m.current(...g))}},[f,r,u])};pe.propTypes={children:C.default.node.isRequired,authorizationLauncher:C.default.func,credentialBroker:C.default.func};const ne=se.default.default||se.default,Ie=1e4,Me="credentials",Se=(r,u)=>`${r}/mm-embedded-interop?id=${encodeURIComponent(u)}&origin=${encodeURIComponent(window.location.origin)}&caps=${Me}`,Ue=ne.iframe`
1
+ (function(m,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("prop-types"),require("styled-components")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","styled-components"],t):(m=typeof globalThis!="undefined"?globalThis:m||self,t(m["mm-react-embeddable"]={},m.React,m.PropTypes,m.styled))})(this,(function(m,t,ke,Ce){"use strict";const te=r=>r&&r.__esModule?r:{default:r},S=te(t),k=te(ke),ue=te(Ce),X=t.createContext(null),G=t.createContext({pending:[],authorize:()=>{},approve:()=>{},complete:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),oe="access_token",re=r=>r?r.kind?r:r.accessToken?{kind:oe,accessToken:r.accessToken,expiresAt:r.expiresAt||null}:null:null,Te=60,_e=120,we=new Set(["host_not_allowed","unbound_host_bound_guest","invalid_token","provider_unavailable"]),Q=typeof window!="undefined"&&window.location.protocol==="https:",Ie=8e3,J=r=>{try{return new URL(r).origin}catch{return null}},ie=(r,u)=>{const c=u==null?void 0:u.origin;return!c||J(r==null?void 0:r.authUrl)!==c?null:c},ce=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const u=r.split(".");return u.length<=2?r:u.slice(-2).join(".")},ne=(r,u)=>{try{const c=new URL(r),f=new URL(u);return c.protocol!==f.protocol?!0:ce(c.hostname)!==ce(f.hostname)}catch{return!0}},le=(r,{onBlocked:u,onClosed:c})=>{const f=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!f)return u(),()=>{};const b=setInterval(()=>{f.closed&&(clearInterval(b),c())},1e3);return()=>clearInterval(b)},ae=({children:r,launcher:u,broker:c})=>{const f=t.useContext(X),[b,E]=t.useState({}),[W,T]=t.useState({}),[O,y]=t.useState({}),[q,x]=t.useState({}),Y=t.useRef(O);Y.current=O;const g=t.useRef(b);g.current=b;const $=t.useRef(null),V=t.useRef({}),U=t.useRef({}),v=t.useRef({}),F=t.useRef(c);F.current=c;const w=t.useCallback(e=>{const n=U.current[e];if(!n)return;const s=l=>!l[e]||l[e].clientId?l:{...l,[e]:{...l[e],clientId:n}};E(s),x(s)},[]),i=t.useCallback((e,n)=>{e&&(x(s=>s[e]?s:{...s,[e]:{origin:e,reason:n,clientId:U.current[e]||null}}),w(e))},[w]),a=t.useCallback((e,{v2:n=!1,origin:s=null}={})=>{s&&(n&&Y.current[s]||(E(l=>l[s]?l:{...l,[s]:{origin:s,authUrl:e.authUrl,silentUrl:e.silentUrl||null,status:n&&F.current?"broker":n&&e.silentUrl&&Q?"silent":"interactive",v2:n,scope:e.scope||null,acceptsCredentials:v.current[s]||null,consent:null,error:null,clientId:e.clientId||U.current[s]||null,popupBlocked:!1}}),w(s)))},[w]),o=t.useRef({}),d=t.useCallback(e=>{o.current[e]&&(clearTimeout(o.current[e]),delete o.current[e])},[]),p=t.useCallback(e=>{d(e),E(n=>{if(!n[e])return n;const s={...n};return delete s[e],s})},[d]),h=t.useCallback(e=>{e&&(p(e),T(n=>({...n,[e]:(n[e]||0)+1})))},[p]),L=t.useCallback(e=>{E(n=>!n[e]||n[e].status==="interactive"?n:{...n,[e]:{...n[e],status:"interactive"}})},[]),P=t.useCallback(e=>{p(e.origin)},[p]),C=t.useCallback((e,n)=>{const s=ie(e,n);if(s){if(ne(s,window.location.origin)){i(s,"cross-site-legacy");return}a(e,{origin:s})}},[a,i]);t.useEffect(()=>{if(!f)return;const e=[f.addListener("*","init",(n,s)=>{s!=null&&s.origin&&(n!=null&&n.clientId)&&(U.current[s.origin]=n.clientId,w(s.origin)),s!=null&&s.origin&&Array.isArray(n==null?void 0:n.acceptsCredentials)?v.current[s.origin]=n.acceptsCredentials:s!=null&&s.origin&&ne(s.origin,window.location.origin)&&i(s.origin,"cross-site-legacy")}),f.addListener("*","authorize",C),f.addListener("*","login",C),f.addListener("*","credential-request",(n,s)=>a(n,{v2:!0,origin:ie(n,s)}))];return()=>e.forEach(n=>n())},[f,C,a,w,i]),t.useEffect(()=>{const e=n=>{const s=n==null?void 0:n.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const l=J(s.authUrl);if(!(!l||n.origin!==l)){if(s.type==="authorized"){if(s.accessToken){if(!g.current[l])return;y(z=>({...z,[l]:re({accessToken:s.accessToken})})),p(l)}else h(l);return}L(l)}};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[p,h,L]);const j=t.useCallback((e,n)=>{const s=e==null?void 0:e.origin,l=re(n);!s||!l||(y(z=>({...z,[s]:l})),p(s))},[p]),A=t.useCallback((e,n)=>{E(s=>s[e]?{...s,[e]:{...s[e],...n}}:s)},[]),I=t.useRef({}),M=t.useCallback(async(e,{approve:n}={})=>{const s=F.current,{origin:l}=e;let z;try{z=await s({origin:l,clientId:e.clientId,scope:e.scope,authUrl:e.authUrl},{approve:n})}catch{n?A(l,{error:{reason:"broker_unavailable"}}):A(l,{status:e.silentUrl&&Q?"silent":"interactive"});return}const ge=z==null?void 0:z.status,Z=(z==null?void 0:z.body)||{};if(ge===200&&Z.credential){j(e,Z.credential);return}if(ge===409&&Z.consentRequired){A(l,{status:"interactive",consent:{client:Z.client||null,stepUp:!!Z.stepUp,scope:Z.scope||e.scope},error:null});return}const R=Z.error||"broker_error";if(!n&&we.has(R)){A(l,{status:e.silentUrl&&Q?"silent":"interactive"});return}if(n&&R==="consent_denied"){A(l,{error:null});return}if(R==="rate_limited"&&!e.rateLimitRetried){const ee=Math.min(Number(Z.retryAfter)>0?Number(Z.retryAfter):Te,_e),$e={...e,rateLimitRetried:!0};d(l),o.current[l]=setTimeout(()=>{delete o.current[l],I.current[l]=!0,H.current($e,{approve:n}).finally(()=>{delete I.current[l]})},ee*1e3),A(l,{rateLimitRetried:!0});return}p(l),x(ee=>({...ee,[l]:{origin:l,reason:`broker:${R}`,detail:z||null,clientId:e.clientId||U.current[l]||null}}))},[j,A,p,d]),H=t.useRef(M);H.current=M,t.useEffect(()=>{Object.values(b).forEach(e=>{e.status!=="broker"||I.current[e.origin]||o.current[e.origin]||(I.current[e.origin]=!0,M(e).finally(()=>{delete I.current[e.origin]}))})},[b,M]);const K=t.useCallback(e=>!F.current||!(e!=null&&e.consent)?Promise.resolve():M(e,{approve:!0}),[M]);t.useEffect(()=>{const e=V.current;Object.values(b).forEach(n=>{n.status==="silent"&&!e[n.origin]&&(e[n.origin]=setTimeout(()=>{delete e[n.origin],L(n.origin)},Ie))}),Object.keys(e).forEach(n=>{(!b[n]||b[n].status!=="silent")&&(clearTimeout(e[n]),delete e[n])})},[b,L]),t.useEffect(()=>()=>{$.current&&$.current(),Object.values(V.current).forEach(clearTimeout),Object.values(o.current).forEach(clearTimeout)},[]);const B=t.useCallback(e=>{$.current&&($.current(),$.current=null);const n=u||le;$.current=n(e,{onBlocked:()=>{E(s=>s[e.origin]?{...s,[e.origin]:{...s[e.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(e.v2){Q&&E(s=>!s[e.origin]||!s[e.origin].silentUrl?s:{...s,[e.origin]:{...s[e.origin],status:"silent"}});return}h(e.origin)}})},[u,h]),_={pending:Object.values(b).filter(e=>e.status==="interactive"),authorize:B,approve:K,complete:j,dismiss:P,originEpochs:W,credentials:O,unsupported:q},D=Object.values(b).filter(e=>e.status==="silent"&&e.silentUrl);return S.default.createElement(G.Provider,{value:_},r,D.map(e=>S.default.createElement("iframe",{key:`mm-silent-auth-${e.origin}`,src:e.silentUrl,title:`MachineMetrics silent authorization (${e.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};ae.propTypes={children:k.default.node,launcher:k.default.func,broker:k.default.func};const Me=()=>t.useContext(G),de=r=>{const{originEpochs:u}=t.useContext(G),c=J(r);return c&&u[c]||0},fe=r=>{const{credentials:u}=t.useContext(G),c=J(r);return c&&u[c]||null},pe=r=>{const{unsupported:u}=t.useContext(G),c=J(r);return c&&u[c]||null},be=({children:r,authorizationLauncher:u,credentialBroker:c})=>{const[f,b]=t.useState({}),[E,W]=t.useState({}),T=t.useRef({}),O=t.useRef({}),y=t.useRef({}),q=t.useCallback((i,a)=>{var o;return!!((o=y.current[i])!=null&&o.has(a))},[]),x=t.useCallback((i,a,o)=>{b(d=>({...d,[i]:{origin:a,frameRef:o}}))},[]),Y=t.useCallback(i=>{b(a=>{const o={...a};return delete o[i],o}),W(a=>{const o={...a};return delete o[i],o}),delete y.current[i]},[]);t.useEffect(()=>{const i=(o=[],d,p)=>{o.forEach(h=>h(d,p))},a=o=>{var j,A,I,M,H,K,B;if(!((j=o==null?void 0:o.data)!=null&&j.instanceId))return;const{instanceId:d,type:p}=o.data,h=f[d],L=(I=(A=h==null?void 0:h.frameRef)==null?void 0:A.current)==null?void 0:I.contentWindow;if(!L||o.source!==L||o.origin!==h.origin)return;const P={origin:o.origin},C=T.current;if(p==="response"){const{callbackId:_,response:D,error:e}=o.data,n=O.current[_];n&&(n(D,e),delete O.current[_]);return}if(p==="mark-registered"){const{requestType:_}=o.data;y.current[d]||(y.current[d]=new Set),y.current[d].add(_);return}p==="ready"&&W(_=>({..._,[d]:!0})),i((M=C[d])==null?void 0:M[p],o.data,P),i((H=C["*"])==null?void 0:H[p],o.data,P),i((K=C[d])==null?void 0:K["*"],o.data,P),i((B=C["*"])==null?void 0:B["*"],o.data,P)};return window.addEventListener("message",a),()=>{window.removeEventListener("message",a)}},[f]);const g=t.useCallback((i,a,o)=>{var p,h;const d=f[i];if(!d){console.warn(`Origin not set for id: ${i}. Unable to send message.`);return}(h=(p=d==null?void 0:d.frameRef)==null?void 0:p.current)!=null&&h.contentWindow&&d.frameRef.current.contentWindow.postMessage({type:a,...o,instanceId:i},d.origin)},[f]),$=t.useRef(0),V=t.useCallback(()=>`${Date.now()}-${++$.current}`,[]),U=t.useCallback(async(i,a,o={})=>new Promise((d,p)=>{const h=V(),L=(P,C)=>{delete O.current[h],C?p(C):d(P)};O.current[h]=L,g(i,"request",{callbackId:h,requestType:a,data:o})}),[g]),v=t.useCallback((i,a)=>{g(i,"load-options",a)},[g]),F=t.useCallback((i,a)=>{g(i,"validate",a)},[g]),w=t.useMemo(()=>({registerFrame:x,unregisterFrame:Y,sendMessage:g,sendRequest:U,loadOptions:v,validate:F,hasHandler:q,readyFrames:E,addListener:(i,a,o)=>(T.current[i]||(T.current[i]={}),T.current[i][a]||(T.current[i][a]=[]),T.current[i][a].push(o),()=>{T.current[i][a]=T.current[i][a].filter(d=>d!==o)})}),[x,Y,g,U,v,F,q,E]);return S.default.createElement(X.Provider,{value:w},S.default.createElement(ae,{launcher:u,broker:c},r))},N=(r,u,c)=>{const f=t.useContext(X);if(f===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const b=t.useRef(c);t.useEffect(()=>{b.current=c},[c]),t.useEffect(()=>{if(!(!r||!u)){if(u.startsWith("key:")){const E=u.substring(4);return f.readyFrames[r]&&f.sendMessage(r,"subscribe-key",{keyChord:E}),f.addListener(r,`key-pressed:${E}`,(...T)=>b.current(...T))}return f.addListener(r,u,(...E)=>b.current(...E))}},[f,r,u])};be.propTypes={children:k.default.node.isRequired,authorizationLauncher:k.default.func,credentialBroker:k.default.func};const se=ue.default.default||ue.default,Se=1e4,Ue="credentials",Le=(r,u)=>`${r}/mm-embedded-interop?id=${encodeURIComponent(u)}&origin=${encodeURIComponent(window.location.origin)}&caps=${Ue}`,Ae=se.iframe`
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  border: none;
5
5
  visibility: ${r=>r.$isReady?"visible":"hidden"};
6
- `,Le=ne.div`
6
+ `,ze=se.div`
7
7
  width: 100%;
8
8
  height: 100%;
9
9
  display: flex;
@@ -16,10 +16,10 @@
16
16
  text-align: center;
17
17
  color: #555;
18
18
  font-size: 14px;
19
- `,be=r=>{const u=r&&r.origin||"This app",c=r&&r.reason||"";switch(c){case"broker:scope_above_ceiling":return{title:`${u} can’t be authorized here`,detail:"It asks for permissions your role doesn’t have."};case"broker:origin_mismatch":case"broker:unknown_client":return{title:`${u} can’t be authorized here`,detail:"It isn’t registered to run at this address."};case"broker:cross_company_principal":return{title:`${u} can’t be authorized here`,detail:"It can’t be authorized for this account."};default:return c.startsWith("broker:")?{title:`${u} can’t be authorized here`,detail:"Authorization was refused."}:{title:`${u} can’t be embedded here`,detail:"It needs an update to support embedding from a different domain."}}},me=({entry:r})=>{const u=be(r);return U.default.createElement(Le,{"data-reason":r&&r.reason||void 0},U.default.createElement("div",{style:{fontWeight:600}},u.title),U.default.createElement("div",{style:{fontSize:12,color:"#888"}},u.detail))};me.propTypes={entry:C.default.shape({origin:C.default.string,name:C.default.string,reason:C.default.string,detail:C.default.object})};const Ae=ne.div`
19
+ `,me=r=>{const u=r&&r.origin||"This app",c=r&&r.reason||"";switch(c){case"broker:scope_above_ceiling":return{title:`${u} can’t be authorized here`,detail:"It asks for permissions your role doesn’t have."};case"broker:origin_mismatch":case"broker:unknown_client":return{title:`${u} can’t be authorized here`,detail:"It isn’t registered to run at this address."};case"broker:cross_company_principal":return{title:`${u} can’t be authorized here`,detail:"It can’t be authorized for this account."};default:return c.startsWith("broker:")?{title:`${u} can’t be authorized here`,detail:"Authorization was refused."}:{title:`${u} can’t be embedded here`,detail:"It needs an update to support embedding from a different domain."}}},he=({entry:r})=>{const u=me(r);return S.default.createElement(ze,{"data-reason":r&&r.reason||void 0},S.default.createElement("div",{style:{fontWeight:600}},u.title),S.default.createElement("div",{style:{fontSize:12,color:"#888"}},u.detail))};he.propTypes={entry:k.default.shape({origin:k.default.string,name:k.default.string,reason:k.default.string,detail:k.default.object})};const Oe=se.div`
20
20
  height: 100%;
21
21
  display: flex;
22
22
  flex: 1;
23
23
  align-items: center;
24
24
  justify-content: center;
25
- `,ze=()=>U.default.createElement(Ae,null,U.default.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),he=({id:r,src:u,path:c,onInit:f=()=>{},onTimeout:m,context:g={},params:Z={},renderUnsupported:_,renderTimeout:O,...y})=>{if("isConfiguring"in y)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in g)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in g)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const q=t.useRef(),[x,N]=t.useState(),[k,$]=t.useState(0),[G,L]=t.useState(!1),[W,F]=t.useState(!1),I=ae(u),i=de(u),a=fe(u),[o,d]=t.useState(0),[p,E]=t.useState(null),{registerFrame:A,unregisterFrame:P,sendMessage:T}=t.useContext(V),[j,z]=t.useState(),M=t.useRef(),S=t.useRef(m),v=t.useRef(f),H=t.useRef(!1),B=t.useCallback(()=>{H.current=!1,clearTimeout(M.current),$(0),L(!1),F(!1),E(null)},[]);t.useEffect(()=>{(I>0||o>0)&&B()},[I,o,B]),t.useEffect(()=>{S.current=m},[m]),t.useEffect(()=>{v.current=f},[f]),t.useEffect(()=>{k&&T(r,"set-context",{context:{...g}})},[g,r,k]),t.useEffect(()=>{k&&T(r,"set-params",{params:Z})},[Z,r,k]),t.useEffect(()=>{c!==void 0&&z((c==null?void 0:c.indexOf("/"))===0?c:`/${c}`)},[c]),t.useEffect(()=>{j===void 0||!k||T(r,"navigate",{path:j})},[j,k,r,T]),t.useEffect(()=>{if(!u||!r||!q)return;B();const e=new URL(u);return A(r,e.origin,q),v.current(),N(Se(e.origin,r)),()=>{P(r)}},[u,r,A,q,B]),t.useEffect(()=>{if(!(!x||H.current))return M.current=setTimeout(()=>{L(!0),S.current&&S.current()},Ie),()=>clearTimeout(M.current)},[x,u,I,o]);const w=t.useCallback(()=>{H.current=!0,clearTimeout(M.current),L(!1)},[]);K(r,"init",e=>{w(),Array.isArray(e==null?void 0:e.acceptsCredentials)&&E(e.acceptsCredentials)}),K(r,"authorize",w),K(r,"login",w),K(r,"credential-request",()=>{w(),F(!0)}),t.useEffect(()=>{if(!W||!i)return;const e=p;if(Array.isArray(e)&&!e.includes(i.kind))return;const n=i.kind==="access_token"?{accessToken:i.accessToken}:{};T(r,"credential",{...n,credential:i})},[W,i,p,r,T]),K(r,"ready",()=>{w(),$(e=>e+1)});const D=t.useRef();return K(r,"heartbeat",()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{d(e=>e+1)},6e3)}),t.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]),a?_?_(a):U.default.createElement(me,{entry:a}):G&&!k?O?O():U.default.createElement(ze,null):U.default.createElement(Ue,{key:`auth-epoch-${I}-frame-${o}`,$isReady:k,ref:q,src:x,...y})};he.propTypes={id:C.default.string,src:C.default.string.isRequired,path:C.default.string,onInit:C.default.func,onTimeout:C.default.func,renderUnsupported:C.default.func,renderTimeout:C.default.func},h.CREDENTIAL_KIND_ACCESS_TOKEN=ue,h.EmbeddedAuthorizationContext=Y,h.MMEmbeddableZone=he,h.MMEmbeddableZoneContext=V,h.MMEmbeddableZoneProvider=pe,h.isCrossSite=re,h.normalizeCredential=te,h.popupAuthorizationLauncher=ce,h.unsupportedCopy=be,h.useEmbeddedAuthorizations=we,h.useEmbeddedCredential=de,h.useEmbeddedEffect=K,h.useEmbeddedOriginEpoch=ae,h.useEmbeddedUnsupported=fe,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
25
+ `,ye=()=>S.default.createElement(Oe,null,S.default.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),Ee=({id:r,src:u,path:c,onInit:f=()=>{},onTimeout:b,context:E={},params:W={},renderUnsupported:T,renderTimeout:O,...y})=>{if("isConfiguring"in y)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in E)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in E)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const q=t.useRef(),[x,Y]=t.useState(),[g,$]=t.useState(0),[V,U]=t.useState(!1),[v,F]=t.useState(!1),w=de(u),i=fe(u),a=pe(u),[o,d]=t.useState(0),[p,h]=t.useState(null),{registerFrame:L,unregisterFrame:P,sendMessage:C}=t.useContext(X),[j,A]=t.useState(),I=t.useRef(),M=t.useRef(b),H=t.useRef(f),K=t.useRef(!1),B=t.useCallback(()=>{K.current=!1,clearTimeout(I.current),$(0),U(!1),F(!1),h(null)},[]);t.useEffect(()=>{(w>0||o>0)&&B()},[w,o,B]),t.useEffect(()=>{M.current=b},[b]),t.useEffect(()=>{H.current=f},[f]),t.useEffect(()=>{g&&C(r,"set-context",{context:{...E}})},[E,r,g]),t.useEffect(()=>{g&&C(r,"set-params",{params:W})},[W,r,g]),t.useEffect(()=>{c!==void 0&&A((c==null?void 0:c.indexOf("/"))===0?c:`/${c}`)},[c]),t.useEffect(()=>{j===void 0||!g||C(r,"navigate",{path:j})},[j,g,r,C]),t.useEffect(()=>{if(!u||!r||!q)return;B();const e=new URL(u);return L(r,e.origin,q),H.current(),Y(Le(e.origin,r)),()=>{P(r)}},[u,r,L,q,B]),t.useEffect(()=>{if(!(!x||K.current))return I.current=setTimeout(()=>{U(!0),M.current&&M.current()},Se),()=>clearTimeout(I.current)},[x,u,w,o]);const _=t.useCallback(()=>{K.current=!0,clearTimeout(I.current),U(!1)},[]);N(r,"init",e=>{_(),Array.isArray(e==null?void 0:e.acceptsCredentials)&&h(e.acceptsCredentials)}),N(r,"authorize",_),N(r,"login",_),N(r,"credential-request",()=>{_(),F(!0)}),t.useEffect(()=>{if(!v||!i)return;const e=p;if(Array.isArray(e)&&!e.includes(i.kind))return;const n=i.kind==="access_token"?{accessToken:i.accessToken}:{};C(r,"credential",{...n,credential:i})},[v,i,p,r,C]),N(r,"ready",()=>{_(),$(e=>e+1)});const D=t.useRef();return N(r,"heartbeat",()=>{D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{d(e=>e+1)},6e3)}),t.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]),a?T?T(a):S.default.createElement(he,{entry:a}):V&&!g?O?O():S.default.createElement(ye,null):S.default.createElement(Ae,{key:`auth-epoch-${w}-frame-${o}`,$isReady:g,ref:q,src:x,...y})};Ee.propTypes={id:k.default.string,src:k.default.string.isRequired,path:k.default.string,onInit:k.default.func,onTimeout:k.default.func,renderUnsupported:k.default.func,renderTimeout:k.default.func},m.CREDENTIAL_KIND_ACCESS_TOKEN=oe,m.EmbeddedAuthorizationContext=G,m.MMEmbeddableZone=Ee,m.MMEmbeddableZoneContext=X,m.MMEmbeddableZoneProvider=be,m.isCrossSite=ne,m.normalizeCredential=re,m.popupAuthorizationLauncher=le,m.unsupportedCopy=me,m.useEmbeddedAuthorizations=Me,m.useEmbeddedCredential=fe,m.useEmbeddedEffect=N,m.useEmbeddedOriginEpoch=de,m.useEmbeddedUnsupported=pe,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@machinemetrics/mm-react-embeddable",
3
- "version": "2.0.0-5",
3
+ "version": "2.0.0-6",
4
4
  "license": "MIT",
5
5
  "module": "dist/mm-react-embeddable.es.js",
6
6
  "main": "dist/mm-react-embeddable.cjs.js",