import{a as p}from"./chunk-42XIZ4MH.js";function T(e){return p({__type:"host",create:t=>Object.entries(e).reduce((r,[n,s])=>({...r,[n]:s(t)}),{})},Object.keys(e))}var k=e=>e!=null&&e!=="",a=e=>u(e,k);function u(e,t=r=>!!r){if(!e)return{};let r={};for(let n in e)t(e[n],n)&&(r[n]=e[n]);return r}var d=e=>{let t=a({"app.id":e.appId,"app.version":e.appVersion,"app.instanceId":e.appInstanceId,"extension.id":e.extensionId,"extension.name":e.extensionName,"extension.type":e.extensionType,platform:e.platform}),r=u({"extension.data":a({...e.extensionData}),site:a({url:e.siteUrl,id:e.tenantType==="SITE"?e.tenantId:void 0}),account:a({id:e.tenantType==="ACCOUNT"?e.tenantId:void 0})},n=>!!n&&Object.keys(n).length>0);return{tags:t,contexts:r}},x=class{constructor(e){this.message=e,this.captureException=()=>(console.error(this.message),""),this.captureMessage=()=>(console.error(this.message),""),this.startSpan=()=>(console.error(this.message),{}),this.addBreadcrumb=()=>{console.error(this.message)}}},i=e=>new x(e);var y=(e,{tags:t,contexts:r})=>{t&&e.setTags(t),r&&Object.entries(r).forEach(([n,s])=>typeof s<"u"&&e.setContext(n,s))},w=(e,t)=>{if(!t)return;let{tags:r,contexts:n}=d(t);y(e,{tags:r,contexts:n})},g=(e,t,r,n={},s="info",o)=>{let l=new r.Hub(e,t);return l.withScope(c=>{let{level:S=s,tags:f,contexts:C}=n;return c.setLevel(S),y(c,{tags:f,contexts:C}),o(c,l)})},m=class{constructor(e){this.sentry=e.sentrySDK,this.scope=new this.sentry.Scope,this.sentryClient=new this.sentry.BrowserClient({dsn:e.dsn,transport:e.transport??this.sentry.makeFetchTransport,integrations:this.sentry.getDefaultIntegrations({}),stackParser:this.sentry.defaultStackParser,tracesSampleRate:e.tracesSampleRate||1,debug:e.debug??!1,environment:e.environment,release:e.release}),w(this.scope,e.hostContext),this.scope.setClient(this.sentryClient),this.sentryClient.init()}},B=class extends m{constructor(){super(...arguments),this.addBreadcrumb=e=>{let t={type:e.type,category:e.category,message:e.message,level:e.level,data:e.data};this.scope.addBreadcrumb(t)},this.captureException=(e,t)=>g(this.sentryClient,this.scope,this.sentry,t,"error",r=>r.captureException(e)),this.captureMessage=(e,t)=>g(this.sentryClient,this.scope,this.sentry,t,"info",r=>r.captureMessage(e)),this.startSpan=(e,t)=>{let r={name:e.name,tags:e.tags};return this.sentry.startSpan({...r,scope:this.scope},t)}}},M=class extends m{constructor(){super(...arguments),this.addBreadcrumb=e=>{let t={type:e.type,category:e.category,message:e.message,level:e.level,data:e.data};this.scope.addBreadcrumb(t)},this.captureException=(e,t)=>this.sentryClient.captureException(e,{captureContext:{level:t?.level??"error",tags:t?.tags,contexts:t?.contexts}},this.scope),this.captureMessage=(e,t)=>this.sentryClient.captureMessage(e,t?.level??"error",{captureContext:{level:t?.level??"error",tags:t?.tags,contexts:t?.contexts}},this.scope),this.startSpan=(e,t)=>{let r={name:e.name,tags:e.tags};return this.sentry.startSpan({...r,scope:this.scope},t)}}},h=e=>`Sentry SDK version "${e}" is not supported. Please make sure to use monitoring SDK only in supported environments.`,I=e=>{try{return parseInt(e.split(".")[0],10)}catch{console.warn("Failed to parse Sentry SDK version");return}},v=({microFrontendEnvironment:e,sentrySDK:t,dsn:r,...n})=>{if(!t)return i("Unsupported environment - Sentry SDK is not loaded into the environment. Please make sure to use monitoring SDK only in supported environments.");if(!r)return i("Missing Sentry DSN in the app's monitoring configuration. Please make sure to set it.");try{let s=t.SDK_VERSION&&I(t.SDK_VERSION);return e?s&&s!==7?i(h(t.SDK_VERSION)):new B({...n,dsn:r,sentrySDK:t}):s&&s<7?i(h(t.SDK_VERSION)):new M({...n,dsn:r,sentrySDK:t})}catch(s){return i(`Failed to initialize monitoring client: ${s.message}`)}};var E=e=>e?.type==="SENTRY",U=({sentrySDK:e,sentryTransport:t,monitoringConfig:r,hostContext:n,microFrontendEnvironment:s})=>{if(E(r)){let{sentryOptions:o}=r;return()=>v({microFrontendEnvironment:s,dsn:o?.dsn,hostContext:n,sentrySDK:e,transport:t})}return()=>i("Invalid monitoring configuration. Please check the monitoring setup of your application.")};export{T as a,U as b};
//# sourceMappingURL=chunk-CR7DIEFQ.js.map