1"use strict";(self.webpackChunksanchiconnect_frontend_angular=self.webpackChunksanchiconnect_frontend_angular||[]).push([["default-src_app_shared_common-components_certificate-viewer-modal_certificate-viewer-modal_co-b08c9f"],{81204:(y,g,a)=>{a.d(g,{q:()=>P});var _=a(71670),m=a(4155),p=a(26290),t=a(3184),v=a(2929),C=a(23132),M=a(15420),w=a(56900),E=a(36362),b=a(2047);function x(o,d){if(1&o){const e=t.EpF();t.TgZ(0,"div",1)(1,"div",1)(2,"div",2)(3,"div",3)(4,"div",4)(5,"a",5),t.NdJ("click",function(){return t.CHM(e),t.oxw().downloadCertiAsImage()}),t.TgZ(6,"span",6),t._uU(7,"Download as Image"),t.qZA()(),t.TgZ(8,"a",7),t.NdJ("click",function(){return t.CHM(e),t.oxw().downloadCerti()}),t.TgZ(9,"span",6),t._uU(10,"Download as PDF"),t.qZA()()(),t.TgZ(11,"button",8),t.NdJ("click",function(){return t.CHM(e),t.oxw().closeModal()}),t.qZA()(),t.TgZ(12,"div",9),t._UZ(13,"iframe",10),t.ALo(14,"safeHtml"),t.qZA()()()()}if(2&o){const e=t.oxw();t.xp6(13),t.Q6J("src",t.xi3(14,1,"/certi?certificateNo="+e.certificates[0].number,"resourceUrl"),t.uOi)}}const u={style:{margin:"0"}};let P=(()=>{class o{constructor(e,n,i,r){this.profileService=e,this.imagekit=n,this.siteMetadataService=i,this.activeModal=r,this.certificateType="profile",this.certificates=[]}ngOnInit(){this.siteMetadataService.setTitle("Certificate"),this.certificateNumber?this.certificates=[{number:this.certificateNumber}]:this.enrollId?this.coursesCertificates():this.fetchCertificates()}coursesCertificates(){this.profileService.courseCertificates(this.enrollId).subscribe(e=>{e&&(this.certificates=e.data||[])})}fetchCertificates(){this.profileService.getCertificates(this.certificateType).subscribe(e=>{e&&(this.certificates=e.data||[])})}stripCaptureArtifacts(e){try{const n=null==e?void 0:e.contentDocument;if(!n)return;n.querySelectorAll("noscript").forEach(i=>{var r;return null===(r=i.parentNode)||void 0===r?void 0:r.removeChild(i)})}catch(n){}}downloadCerti(){var e=this;return(0,_.Z)(function*(){var n;const i=document.getElementById("certificate-div");e.stripCaptureArtifacts(i);const r=(null===(n=null==i?void 0:i.contentDocument)||void 0===n?void 0:n.getElementById("cerificate-view"))||i;(0,m.YM)(r,u).then(function(c){return function I(o){return new Promise((d,e)=>{const n=new Image;n.onload=()=>d({width:n.naturalWidth,height:n.naturalHeight}),n.onerror=e,n.src=o})}(c).then(function(s){const l=new p.kH(s.width>=s.height?"landscape":"portrait"),f=l.internal.pageSize.getWidth();l.addImage(c,"PNG",0,0,f,s.height*f/s.width),l.save("my-certificate.pdf")})}).catch(function(c){console.error("oops, something went wrong!",c)})})()}downloadCertiAsImage(){var e=this;return(0,_.Z)(function*(){var n;const i=document.getElementById("certificate-div");e.stripCaptureArtifacts(i);const r=(null===(n=null==i?void 0:i.contentDocument)||void 0===n?void 0:n.getElementById("cerificate-view"))||i;(0,m.YM)(r,u).then(function(c){const s=document.createElement("a");s.download="my-certificate.png",s.href=c,s.click()}).catch(function(c){console.error("oops, something went wrong!",c)})})()}saveAs(e,n){var i=document.createElement("a");"string"==typeof i.download?(i.href=e,i.download=n,document.body.appendChild(i),i.click(),document.body.removeChild(i)):window.open(e)}closeModal(){this.activeModal.close()}}return o.\u0275fac=function(e){return new(e||o)(t.Y36(v.H),t.Y36(C.X),t.Y36(M.D),t.Y36(w.Kz))},o.\u0275cmp=t.Xpm({type:o,selectors:[["app-certificate-viewer-modal"]],inputs:{enrollId:"enrollId",certificateNumber:"certificateNumber",certificateType:"certificateType"},decls:1,vars:1,consts:[["class","",4,"ngIf"],[1,""],[1,"rounded","shadow-sm","pt-5","pb-5"],[1,"card-title","m-0","d-flex","justify-content-start","align-items-center","d-none","d-md-flex","ms-md-9","justify-content-between"],[1,"d-flex","align-items-center"],[1,"btn","btn-dark","text-white","mb-2","ls-2","px-6",3,"click"],[1,"indicator-label"],[1,"btn","btn-dark","text-white","mb-2","ls-2","px-6","ms-3",3,"click"],["type","button","aria-label","Close",1,"btn-close","me-md-9",3,"click"],[1,"aspect-ratio","mx-auto"],["id","certificate-div","frameborder","0",3,"src"]],template:function(e,n){1&e&&t.YNc(0,x,15,4,"div",0),2&e&&t.Q6J("ngIf",null==n.certificates?null:n.certificates.length)},directives:[E.O5],pipes:[b.z],styles:[".image-certi[_ngcontent-%COMP%]{background-size:contain;background-repeat:no-repeat}.aspect-ratio[_ngcontent-%COMP%]{position:relative;height:707px;width:1000px;padding-bottom:56.25%}.aspect-ratio[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{position:absolute;width:100%;height:100%;left:0;top:0;margin-bottom:30px}.hidden-certi-ele[_ngcontent-%COMP%]{height:100vh;width:100vw;position:absolute;z-index:0;inset:0}.hidden-certi-ele[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{height:100vh;width:100vw}"]}),o})()},46650:(y,g,a)=>{a.d(g,{d:()=>P});var _=a(71670),m=a(4155),p=a(26290),t=a(3184),v=a(2929),C=a(15420),M=a(56900),w=a(36362),E=a(2047);
1function b(o,d){1&o&&(t.TgZ(0,"div",2)(1,"span"),t._uU(2,"Loading ID card\u2026"),t.qZA()())}function x(o,d){if(1&o){const e=t.EpF();t.TgZ(0,"div")(1,"div",5)(2,"div",6)(3,"div",7)(4,"a",8),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).downloadAsImage()}),t.TgZ(5,"span",9),t._uU(6,"Download as Image"),t.qZA()(),t.TgZ(7,"a",10),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).downloadAsPdf()}),t.TgZ(8,"span",9),t._uU(9,"Download as PDF"),t.qZA()()(),t.TgZ(10,"button",11),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).closeModal()}),t.qZA()(),t.TgZ(11,"div",12),t._UZ(12,"iframe",13),t.ALo(13,"safeHtml"),t.qZA()()()}if(2&o){const e=t.oxw(2);t.xp6(12),t.Q6J("src",t.xi3(13,1,"/id-card?cardNumber="+e.card.number+"&embed=1","resourceUrl"),t.uOi)}}function u(o,d){if(1&o){const e=t.EpF();t.TgZ(0,"div",2),t._UZ(1,"i",14),t.TgZ(2,"h5"),t._uU(3,"No ID card yet"),t.qZA(),t.TgZ(4,"p",15),t._uU(5,"An ID card hasn't been generated for your profile yet."),t.qZA(),t.TgZ(6,"button",16),t.NdJ("click",function(){return t.CHM(e),t.oxw(2).closeModal()}),t._uU(7,"Close"),t.qZA()()}}function I(o,d){if(1&o&&(t.ynx(0),t.YNc(1,x,14,4,"div",3),t.YNc(2,u,8,0,"ng-template",null,4,t.W1O),t.BQk()),2&o){const e=t.MAs(3),n=t.oxw();t.xp6(1),t.Q6J("ngIf",null==n.card?null:n.card.number)("ngIfElse",e)}}let P=(()=>{class o{constructor(e,n,i){this.profileService=e,this.siteMetadataService=n,this.activeModal=i,this.card=null,this.loading=!0}ngOnInit(){if(this.siteMetadataService.setTitle("ID Card"),this.cardNumber)return this.card={number:this.cardNumber},void(this.loading=!1);this.profileService.getMyIdCard().subscribe(e=>{this.card=(null==e?void 0:e.data)||null,this.loading=!1},()=>{this.loading=!1})}captureCardElement(){return(0,_.Z)(function*(){var e;const n=document.getElementById("id-card-div");if(!n)return null;const i=n.contentDocument||(null===(e=n.contentWindow)||void 0===e?void 0:e.document)||null;return(null==i?void 0:i.querySelector(".id-card"))||n})()}downloadAsImage(){var e=this;return(0,_.Z)(function*(){const n=yield e.captureCardElement();if(n)try{const i=yield(0,m.YM)(n,{cacheBust:!0,backgroundColor:"#ffffff"}),r=document.createElement("a");r.download="id-card.png",r.href=i,r.click()}catch(i){console.error("Failed to download as image",i)}})()}downloadAsPdf(){var e=this;return(0,_.Z)(function*(){const n=yield e.captureCardElement();if(n)try{const i=yield(0,m.YM)(n,{cacheBust:!0,backgroundColor:"#ffffff"}),c=(new p.kH).getImageProperties(i),s=c.width>=c.height,O=s?"landscape":"portrait",l=200,f=Math.min(c.width,c.height)/Math.max(c.width,c.height)*l,h=s?l:f,T=s?f:l,D=new p.kH({unit:"mm",orientation:O,format:[h,T]});D.addImage(i,"PNG",0,0,h,T),D.save("id-card.pdf")}catch(i){console.error("Failed to download as PDF",i)}})()}closeModal(){this.activeModal.close()}}return o.\u0275fac=function(e){return new(e||o)(t.Y36(v.H),t.Y36(C.D),t.Y36(M.Kz))},o.\u0275cmp=t.Xpm({type:o,selectors:[["app-id-card-viewer-modal"]],inputs:{cardNumber:"cardNumber"},decls:2,vars:2,consts:[["class","text-center py-5",4,"ngIf"],[4,"ngIf"],[1,"text-center","py-5"],[4,"ngIf","ngIfElse"],["noCard",""],[1,"rounded","shadow-sm","pt-5","pb-5"],[1,"card-title","m-0","d-flex","justify-content-start","align-items-center","d-none","d-md-flex","ms-md-9","justify-content-between"],[1,"d-flex","align-items-center"],[1,"btn","btn-dark","text-white","mb-2","ls-2","px-6",3,"click"],[1,"indicator-label"],[1,"btn","btn-dark","text-white","mb-2","ls-2","px-6","ms-3",3,"click"],["type","button","aria-label","Close",1,"btn-close","me-md-9",3,"click"],[1,"aspect-ratio","mx-auto"],["id","id-card-div","frameborder","0",3,"src"],[1,"fa","fa-id-card","fs-1","text-muted","mb-3"],[1,"text-muted"],["type","button",1,"btn","btn-secondary",3,"click"]],template:function(e,n){1&e&&(t.YNc(0,b,3,0,"div",0),t.YNc(1,I,4,2,"ng-container",1)),2&e&&(t.Q6J("ngIf",n.loading),t.xp6(1),t.Q6J("ngIf",!n.loading))},directives:[w.O5],pipes:[E.z],styles:['@charset "UTF-8";.aspect-ratio[_ngcontent-%COMP%]{position:relative;width:100%;max-width:960px;min-height:77vh;background:#f9fafb;border-radius:12px;overflow:hidden;margin:0 auto}.aspect-ratio[_ngcontent-%COMP%] iframe[_ngcontent-%COMP%]{width:100%;height:100%;min-height:inherit;border:0;display:block}
1[_nghost-%COMP%] .modal-dialog{max-width:1000px}[_nghost-%COMP%] .modal-content{max-height:92vh}[_nghost-%COMP%] .modal-body{max-height:calc(92vh - 120px);overflow-y:auto}']}),o})()}}]); 2//# sourceMappingURL=default-src_app_shared_common-components_certificate-viewer-modal_certificate-viewer-modal_co-b08c9f.a97114904ec32d7c.js.map
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.