1import{j as t,G as E,B as R,M,u as v,I as w,z as N,f as T,E as y,q as S,d as O,W as L,w as P}from"./csw-BtSoxXyh.js";import{T as f,a as c}from"./index-BOEJzWDT.js";const _="/customer/communication/communication-management/v1/communications",D="/customer/communication/communication-management/v1/communications/{id}/mark",k={getMarketingCommunications:_,markCommunication:D};function G(){return{deleteCommunicationErrorCode:null,services:{[k.getMarketingCommunications]:{response:{}}}}}function U(e,i){return e.services[k.getMarketingCommunications].response.communications=I(e)?.filter(l=>l.id!==i),e}function B(e,i){return e.services[k.getMarketingCommunications].response=i,e}function I(e){return e.services[k.getMarketingCommunications].response.communications}function F(e){return I(e)?.[0]?.content?.headline}const K="Aktuellt för dig",V="Stäng annons",u={heading:K,dismissButton:V},X="EMMA_MEDIA_REGISTRY";function b({type:e,id:i,headline:l,components:a,size:s,assetPath:d,marketingAreaMediaRegistries:o,triggerEvent:n}){const r=a?.find(g=>g.componentType===e);if(!a||!r||e!=="IMAGE"&&e!=="CALL_TO_ACTION"&&e!=="MARKDOWN")return null;if(e==="IMAGE")return t.jsx("img",{style:{height:"100%",objectFit:"cover",objectPosition:"center",overflow:"hidden"},src:r.imageContent.registry===X&&o?o+r.imageContent.imagePath:d+"/kapitalforsakring.svg",className:`${s==="small"?"card-img-top":"card-img"}`,alt:r.imageContent.description,"data-test-id":"marketing-card-image",onError:g=>{g.target.onerror=null,g.target.src=d+"/kapitalforsakring.svg",g.target.alt="",Object.assign(g.target.style,{objectFit:"contain",objectPosition:"center",backgroundColor:"var(--cloud)",padding:s==="large"&&"2.25rem"})}});if(e==="CALL_TO_ACTION")return t.jsx(t.Fragment,{children:r.callToActionContent.type==="EXTERNAL"?t.jsx(E,{text:r.callToActionContent.urlText,dataTestId:"marketing-card-CTA-external",link:r.callToActionContent.url,onClick:()=>{n(f.marketingCommunicationClicked,{args:{location:u.heading,title:l,label:r.callToActionContent.urlText,type:"EXTERNAL"}}),n(c.markCommunication,{id:i,markType:c.callToActionClicked})}}):t.jsx(R,{dataTestId:"marketing-card-CTA-internal",buttonType:"link",label:r.callToActionContent.urlText,onClick:()=>{n(c.markCommunication,{id:i,markType:c.callToActionClicked}),n(f.marketingCommunicationClicked,{args:{location:u.heading,title:l,label:r.callToActionContent.urlText,type:"INTERNAL"}}),n(c.marketingAreaInternalLinkClicked,{type:r.callToActionContent.type,url:r.callToActionContent.url})}})});if(e==="MARKDOWN")return t.jsx("div",{"data-test-id":"marketing-card-markdown","aria-label":r.markdownContent,role:"region",children:t.jsx("div",{"aria-hidden":"true",children:t.jsx(M,{children:r.markdownContent})})})}const W={small:0,large:600};function z({marketingCommunication:e,assetPath:i,marketingAreaMediaRegistries:l,triggerEvent:a}){const{size:s,setRef:d}=v(W),o=e.content.components;return e?t.jsxs("div",{className:"position-relative","data-test-id":"marketing-card-component",children:[t.jsxs("div",{className:"card overflow-hidden bg-white",ref:d,style:{border:"1px solid var(--smoke)",borderRadius:"8px",display:"flex",flexDirection:s==="large"?"row":"column",height:s==="large"?"342px":"auto"},children:[t.jsx("div",{style:{flex:"1 1 0",minHeight:s==="small"?"200px":"auto"},children:t.jsx(b,{components:o,type:"IMAGE",size:s,assetPath:i,marketingAreaMediaRegistries:l})}),t.jsx("div",{style:{display:"flex",alignItems:"center",flex:"1 1 0"},children:t.jsxs("div",{className:"d-flex flex-column",style:{padding:s==="large"?"2.5rem":"1.5rem",flex:"1 1 0",textWrap:"pretty"},children:[t.jsx("h3",{id:"marketing-card-heading",className:"text-blue mb-1","data-test-id":"marketing-card-heading",children:e.content.headline}),t.jsx(b,{components:o,type:"MARKDOWN",size:s}),t.jsx("div",{children:t.jsx(b,{components:o,type:"CALL_TO_ACTION",id:e.id,headline:e.content.headline,triggerEvent:a})})]})})]}),t.jsx("button",{className:"btn position-absolute d-flex align-items-center justify-content-center rounded-circle hover-scale-lg",style:{top:"16px",right:"16px",width:"36px",height:"36px",padding:"4px",background:"var(--cloud)",border:"1px solid var(--baby)",zIndex:900},tabIndex:0,"aria-label":u.dismissButton,"data-test-id":"marketing-dismiss-button",onClick:n=>{n.stopPropagation(),a(c.markCommunication,{id:e.id,markType:c.deleteCommunication}),a(f.marketingCommunicationDeleteClicked,{args:{label:u.dismissButton,location:u.heading,title:e.content.headline}})},onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),n.stopPropagation(),a(c.markCommunication,{id:e.id,markType:c.deleteCommunication}),a(f.marketingCommunicationDeleteClicked,{args:{label:u.dismissButton,location:u.heading,title:e.content.headline}}))},children:t.jsx(w,{icon:N.CROSS_24,"aria-hidden":"true",width:"36px",height:"36px",style:{color:"var(--blue)"}})})]}):null}const Y=(e,i=.75)=>{const[l,a]=T.useState(!1),[s,d]=T.useState(!1);return T.useEffect(()=>{const o=e.current;if(!o||s)return;const n=new IntersectionObserver(([r])=>{r.isIntersecting&&(a(!0),d(!0),n.unobserve(o))},{threshold:i});return n.observe(o),()=>{o&&n.unobserve(o)}},[e,s,i]),l};function q({marketingCommunications:e,assetPath:i,marketingAreaMediaRegistries:l,triggerEvent:a}){const s=T.useRef(null),d=Y(s);if(T.useEffect(()=>{e?.length>0&&d&&(a(c.markCommunication,{id:e[0].id,markType:c.communicationRead}),a(f.marketingCommunicationShown,{args:{location:u.heading,title:e[0].content.headline}}))},[d,e,a]),!e?.length>0)return null;function o(){return t.jsxs("section",{ref:s,children:[t.jsx("h3",{className:"mb-1","data-test-id":"marketing-area-heading",children:u.heading}),t.jsx(z,{marketingCommunication:e[0],assetPath:i,marketingAreaMediaRegistries:l,triggerEvent:a})]})}return t.jsx(o,{})}function $({ajax:e,profile:i,assetPath:l,marketingAreaMediaRegistries:a,limit:s=10,productC
1ontext:d="CENTRAL"}){const o={...y},n=S(G()),r=new O;function g(){const m={};m.limit=s,m.categories="MARKETING_OFFER",m.sortBy="EXPIRATION_DATETIME",m.sortOrder="ASCENDING",m.productContext=d;const p=new URLSearchParams(m);e.apip({url:k.getMarketingCommunications+"?"+p.toString(),type:"GET",headers:{"X-LF-Profile":JSON.stringify({customerId:i.customerId,profileType:i.profileType,subjectUserId:i.subjectUserId})}}).always(h=>{n.swap(B,h),r.resolve()})}function j(m,p){e.apip({url:P(k.markCommunication,{id:m}),type:"PUT",headers:{"X-LF-Profile":JSON.stringify({customerId:i.customerId,profileType:i.profileType,...i.profileType==="SUPPORT_USER"||i.profileType==="CUSTOMER_PROXY_SUPPORT_USER"?{subjectUserId:i.subjectUserId}:{}})},data:{mark:p}}).always(()=>{p==="DELETED"&&n.swap(U,m)})}return o.marketingAreaView=(function(){return{render:function(m){const p=L({target:m,Component:q,getProps:function(){return{assetPath:l,model:n,marketingCommunications:I(n.deref()),controller:o,marketingAreaMediaRegistries:a,triggerEvent:function(C,A){C===c.marketingAreaInternalLinkClicked?o.trigger(c.marketingAreaInternalLinkClicked,A):f[C]?o.trigger(C,{eventName:C,args:A.args}):C===c.markCommunication&&j(A.id,A.markType)}}}});p.render();const h=I(n.deref());h?.length>0&&o.trigger(f.marketingCommunicationAvailable,{eventName:f.marketingCommunicationAvailable,args:{location:u.heading,title:h[0].content.headline}});const x={...y};return x.listenTo(n,"change",p.render),x.remove=function(){x.stopListening(),p.unmountComponent()},x},getPromise:function(){return r},prepare:function(){g()}}})(),o.getMarketingCommunicationTitle=function(){return F(n.deref())},o}export{$ as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.