-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path209.058872db94124c6e.js
1 lines (1 loc) · 21.9 KB
/
209.058872db94124c6e.js
1
"use strict";(self.webpackChunkangular_SIMAt=self.webpackChunkangular_SIMAt||[]).push([[209],{209:(te,D,m)=>{m.r(D),m.d(D,{CameraModule:()=>O});var b=m(9808),y=m(7423),S=m(5245),f=m(6696),A=m(72),r=m(5e3);const P=["video"],k=["canvas"];function _(t,o){if(1&t){const e=r.EpF();r.TgZ(0,"div",6),r.NdJ("click",function(){return r.CHM(e),r.oxw().rotateVideoInput(!0)}),r.qZA()}}class I{constructor(o,e,i){this._mimeType=null,this._imageAsBase64=null,this._imageAsDataUrl=null,this._imageData=null,this._mimeType=e,this._imageAsDataUrl=o,this._imageData=i}static getDataFromDataUrl(o,e){return o.replace(`data:${e};base64,`,"")}get imageAsBase64(){return this._imageAsBase64?this._imageAsBase64:this._imageAsBase64=I.getDataFromDataUrl(this._imageAsDataUrl,this._mimeType)}get imageAsDataUrl(){return this._imageAsDataUrl}get imageData(){return this._imageData}}let F=(()=>{class t{constructor(){this.width=640,this.height=480,this.videoOptions=t.DEFAULT_VIDEO_OPTIONS,this.allowCameraSwitch=!0,this.captureImageData=!1,this.imageType=t.DEFAULT_IMAGE_TYPE,this.imageQuality=t.DEFAULT_IMAGE_QUALITY,this.imageCapture=new r.vpe,this.initError=new r.vpe,this.imageClick=new r.vpe,this.cameraSwitched=new r.vpe,this.availableVideoInputs=[],this.videoInitialized=!1,this.activeVideoInputIndex=-1,this.mediaStream=null,this.activeVideoSettings=null}set trigger(e){this.triggerSubscription&&this.triggerSubscription.unsubscribe(),this.triggerSubscription=e.subscribe(()=>{this.takeSnapshot()})}set switchCamera(e){this.switchCameraSubscription&&this.switchCameraSubscription.unsubscribe(),this.switchCameraSubscription=e.subscribe(i=>{"string"==typeof i?this.switchToVideoInput(i):this.rotateVideoInput(!1!==i)})}static getMediaConstraintsForDevice(e,i){const a=i||this.DEFAULT_VIDEO_OPTIONS;return e&&(a.deviceId={exact:e}),a}static getDeviceIdFromMediaStreamTrack(e){if(e.getSettings&&e.getSettings()&&e.getSettings().deviceId)return e.getSettings().deviceId;if(e.getConstraints&&e.getConstraints()&&e.getConstraints().deviceId){const i=e.getConstraints().deviceId;return t.getValueFromConstrainDOMString(i)}}static getFacingModeFromMediaStreamTrack(e){if(e){if(e.getSettings&&e.getSettings()&&e.getSettings().facingMode)return e.getSettings().facingMode;if(e.getConstraints&&e.getConstraints()&&e.getConstraints().facingMode){const i=e.getConstraints().facingMode;return t.getValueFromConstrainDOMString(i)}}}static isUserFacing(e){const i=t.getFacingModeFromMediaStreamTrack(e);return!!i&&"user"===i.toLowerCase()}static getValueFromConstrainDOMString(e){if(e){if(e instanceof String)return String(e);if(Array.isArray(e)&&Array(e).length>0)return String(e[0]);if("object"==typeof e){if(e.exact)return String(e.exact);if(e.ideal)return String(e.ideal)}}return null}ngAfterViewInit(){this.detectAvailableDevices().then(()=>{this.switchToVideoInput(null)}).catch(e=>{this.initError.next({message:e}),this.switchToVideoInput(null)})}ngOnDestroy(){this.stopMediaTracks(),this.unsubscribeFromSubscriptions()}takeSnapshot(){const e=this.nativeVideoElement,i={width:this.width,height:this.height};e.videoWidth&&(i.width=e.videoWidth,i.height=e.videoHeight);const a=this.canvas.nativeElement;a.width=i.width,a.height=i.height;const s=a.getContext("2d");s.drawImage(e,0,0);const n=this.imageType?this.imageType:t.DEFAULT_IMAGE_TYPE,d=a.toDataURL(n,this.imageQuality?this.imageQuality:t.DEFAULT_IMAGE_QUALITY);let h=null;this.captureImageData&&(h=s.getImageData(0,0,a.width,a.height)),this.imageCapture.next(new I(d,n,h))}rotateVideoInput(e){this.availableVideoInputs&&this.availableVideoInputs.length>1&&this.switchToVideoInput(this.availableVideoInputs[(this.activeVideoInputIndex+(e?1:this.availableVideoInputs.length-1))%this.availableVideoInputs.length].deviceId)}switchToVideoInput(e){this.videoInitialized=!1,this.stopMediaTracks(),this.initWebcam(e,this.videoOptions)}videoResize(){}get videoWidth(){const e=this.getVideoAspectRatio();return Math.min(this.width,this.height*e)}get videoHeight(){const e=this.getVideoAspectRatio();return Math.min(this.height,this.width/e)}get videoStyleClasses(){let e="";return this.isMirrorImage()&&(e+="mirrored "),e.trim()}get nativeVideoElement(){return this.video.nativeElement}getVideoAspectRatio(){const e=this.nativeVideoElement;return e.videoWidth&&e.videoWidth>0&&e.videoHeight&&e.videoHeight>0?e.videoWidth/e.videoHeight:this.width/this.height}initWebcam(e,i){const a=this.nativeVideoElement;if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){const s=t.getMediaConstraintsForDevice(e,i);navigator.mediaDevices.getUserMedia({video:s}).then(n=>{this.mediaStream=n,a.srcObject=n,a.play(),this.activeVideoSettings=n.getVideoTracks()[0].getSettings();const l=t.getDeviceIdFromMediaStreamTrack(n.getVideoTracks()[0]);this.cameraSwitched.next(l),this.detectAvailableDevices().then(()=>{this.activeVideoInputIndex=l?this.availableVideoInputs.findIndex(d=>d.deviceId===l):-1,this.videoInitialized=!0}).catch(()=>{this.activeVideoInputIndex=-1,this.videoInitialized=!0})}).catch(n=>{this.initError.next({message:n.message,mediaStreamError:n})})}else this.initError.next({message:"Cannot read UserMedia from MediaDevices."})}getActiveVideoTrack(){return this.mediaStream?this.mediaStream.getVideoTracks()[0]:null}isMirrorImage(){if(!this.getActiveVideoTrack())return!1;{let e="auto";switch(this.mirrorImage&&("string"==typeof this.mirrorImage?e=String(this.mirrorImage).toLowerCase():this.mirrorImage.x&&(e=this.mirrorImage.x.toLowerCase())),e){case"always":return!0;case"never":return!1}}return t.isUserFacing(this.getActiveVideoTrack())}stopMediaTracks(){this.mediaStream&&this.mediaStream.getTracks&&(this.nativeVideoElement.pause(),this.mediaStream.getTracks().forEach(e=>e.stop()))}unsubscribeFromSubscriptions(){this.triggerSubscription&&this.triggerSubscription.unsubscribe(),this.switchCameraSubscription&&this.switchCameraSubscription.unsubscribe()}detectAvailableDevices(){return new Promise((e,i)=>{(class V{static getAvailableVideoInputs(){return navigator.mediaDevices&&navigator.mediaDevices.enumerateDevices?new Promise((o,e)=>{navigator.mediaDevices.enumerateDevices().then(i=>{o(i.filter(a=>"videoinput"===a.kind))}).catch(i=>{e(i.message||i)})}):Promise.reject("enumerateDevices() not supported.")}}).getAvailableVideoInputs().then(a=>{this.availableVideoInputs=a,e(a)}).catch(a=>{this.availableVideoInputs=[],i(a)})})}}return t.DEFAULT_VIDEO_OPTIONS={facingMode:"environment"},t.DEFAULT_IMAGE_TYPE="image/jpeg",t.DEFAULT_IMAGE_QUALITY=.92,t.\u0275fac=function(e){return new(e||t)},t.\u0275cmp=r.Xpm({type:t,selectors:[["webcam"]],viewQuery:function(e,i){if(1&e&&(r.Gf(P,7),r.Gf(k,7)),2&e){let a;r.iGM(a=r.CRH())&&(i.video=a.first),r.iGM(a=r.CRH())&&(i.canvas=a.first)}},inputs:{width:"width",height:"height",videoOptions:"videoOptions",allowCameraSwitch:"allowCameraSwitch",mirrorImage:"mirrorImage",captureImageData:"captureImageData",imageType:"imageType",imageQuality:"imageQuality",trigger:"trigger",switchCamera:"switchCamera"},outputs:{imageCapture:"imageCapture",initError:"initError",imageClick:"imageClick",cameraSwitched:"cameraSwitched"},decls:6,vars:7,consts:[[1,"webcam-wrapper",3,"click"],["autoplay","","muted","","playsinline","",3,"width","height","resize"],["video",""],["class","camera-switch",3,"click",4,"ngIf"],[3,"width","height"],["canvas",""],[1,"camera-switch",3,"click"]],template:function(e,i){1&e&&(r.TgZ(0,"div",0),r.NdJ("click",function(){return i.imageClick.next()}),r.TgZ(1,"video",1,2),r.NdJ("resize",function(){return i.videoResize()}),r.qZA(),r.YNc(3,_,1,0,"div",3),r._UZ(4,"canvas",4,5),r.qZA()),2&e&&(r.xp6(1),r.Tol(i.videoStyleClasses),r.Q6J("width",i.videoWidth)("height",i.videoHeight),r.xp6(2),r.Q6J("ngIf",i.allowCameraSwitch&&i.availableVideoInputs.length>1&&i.videoInitialized),r.xp6(1),r.Q6J("width",i.width)("height",i.height))},directives:[b.O5],styles:[".webcam-wrapper[_ngcontent-%COMP%]{display:inline-block;position:relative;line-height:0}.webcam-wrapper[_ngcontent-%COMP%] video.mirrored[_ngcontent-%COMP%]{transform:scaleX(-1)}.webcam-wrapper[_ngcontent-%COMP%] canvas[_ngcontent-%COMP%]{display:none}.webcam-wrapper[_ngcontent-%COMP%] .camera-switch[_ngcontent-%COMP%]{background-color:#0000001a;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAE9UlEQVR42u2aT2hdRRTGf+cRQqghSqihdBFDkRISK2KDfzDWxHaRQHEhaINKqa1gKQhd6EZLN+IidCH+Q0oWIkVRC21BQxXRitVaSbKoJSGtYGoK2tQ/tU1jY5v0c5F54Xl7b/KSO/PyEt+3e5f75p7zzZwzZ74zUEIJJfyfYaEGllQGVAGZlENdBy6Z2cSiYFTSKkkfS/pH/nBF0kFJdUW9AiRVASeAukD8DgNrzOySrwEzng18KaDzALXuG8W3AiStAvqBisBRNg40mtlPxbYCOgvgPO4bncWW+JpVeDQXRQhIygDfA00F5r0XuNfMrgclQFI98DDQCNQA5ZFXqoCWBVp8XwHRHeEqcN7loy/NbHBesyqpQ1KfFj/6nC+ZvFaApFrgPaCZpYVvgCfNbDiRAElNwGFg+RIt/X8H2s2s9wYCJDUAR4HqJX7++RN40MwGpgmQVAH0AQ2BPz4AHHPl8nBOAqtyFWQjsA6oL4Ada81sPDv7uwImod8kvSJp9RyS8O2SXnb/DYVd2Y9VSroQ4ANXJO2WVJmixqh0kzMWwL4LkiqRtDnA4D1zmfE8j9g9AezcnAHaPcfXdbfdnPZ2Yps6+DwAvO/Z1naTdApY7Xng48BDZnY1MpMVQBuw3iXc5Tnb0wBwBPjUzP6eoezuArZ6svM0geJLkvZEYnl3nkntoqROSbckSW2Suj3ZOIangc7GPJuUtNGdFIfmMeavktoSSKiW9LMPw30Q8JqkekmjCbOZRhuclLQjgYSNxUBAj6RyZ9ATgUJpUtJTCSR8vpAEXHAyWK5BXYFIGHOlepSAloUk4NEYgyoknQhEwhFJ0e8h6VSaQeerCb5uZgdi9utxYBNwOUD93hIVXswM4INCi6K9wAszFC2DwLOBDjHbYp59karIUnRdzYy/3ClqVklaUhfwTICj7K25OqA7a4wWagVsm4Me/xzwg2cCqqONFzO7DPxSCAJi436GUBgHHguQD2oTlJ55oSzP9ybccsttSJw1szdjFOSnI/8dTCGZHwcORp4Nx7y3B1iZ8/sm4MW8/Euxg5wIsS/HaAp3zeP4/G7obRDXI4jiTIA22H7Xdc7X+S3A5lC7QBQ357aq3VAjCeSkwUfAJrfvz+R8A9ADLAtZB+TinpjC5JMA+//jwPZZnF8G7J+L8z4IWB/zbG+gIujVWfLBW/NStVMmqaG4POJRsIjix7h8IGnLQuoBbQki5sVAJHyYm7YkNaRRtXwQ8G1cHpX0iKRrgUjYno17Sf0LrQhJUkdCeHWkVITGJI0k1QeS3ikGSUzOyJUJJNznYneuOCnpTldcxa2kP3xJYqOeSDjqZG8ShJLnE8TTuMS6Iyu1BW7djZqkfo9N0QOuYJmYQddfB7RG+gLTNzqAY9FrL+5/nwEbvDdJJe3zzOrhNP3AWRqmk55t3ZcBuj3b2gb0Sbrbo/NNzk7fFzu7s/E5EiC+rrmeQU0Kx2skvRFoOx2ZzlmSdgbsw49JetvtBpk8nM64d/cGbNtJ0s7cGyJlwHeEv+t3nqnLSgPAUOSGyG3AHUxdzqoJbEcvcL+ZTeTeEapzJKxgaeOcc/7Mf06D7kFrguS0VDAMtGadv+E47DT9tcChJej8ISfpD+abgTe45uOkFi8mnQ+JBVQ+d4VXuOptjavcyot8pq86mfwk8LWZnaOEEkoooYQSSojDv8AhQNeGfe0jAAAAAElFTkSuQmCC);background-repeat:no-repeat;border-radius:5px;position:absolute;right:13px;top:10px;height:48px;width:48px;background-size:80%;cursor:pointer;background-position:center;transition:background-color .2s ease}.webcam-wrapper[_ngcontent-%COMP%] .camera-switch[_ngcontent-%COMP%]:hover{background-color:#0000002e}"]}),t})(),J=(()=>{class t{}return t.\u0275fac=function(e){return new(e||t)},t.\u0275mod=r.oAB({type:t}),t.\u0275inj=r.cJS({imports:[[b.ez]]}),t})(),x=(()=>{class t{constructor(e){this._router=e}canActivate(e,i){var a;const s=null===(a=this._router.getCurrentNavigation())||void 0===a?void 0:a.extras;return(null==s?void 0:s.state)?s.state.allowCamera:(this._router.navigateByUrl("app/home"),!1)}}return t.\u0275fac=function(e){return new(e||t)(r.LFG(f.F0))},t.\u0275prov=r.Yz7({token:t,factory:t.\u0275fac,providedIn:"root"}),t})();var Q=m(7579),E=m(1271),T=m(655),p=(()=>{return(t=p||(p={}))[t.Up=1]="Up",t[t.Down=3]="Down",t[t.Right=6]="Right",t[t.Left=8]="Left",t[t.UpMirrored=2]="UpMirrored",t[t.DownMirrored=4]="DownMirrored",t[t.LeftMirrored=5]="LeftMirrored",t[t.RightMirrored=7]="RightMirrored",t[t.Default=0]="Default",t[t.NotJpeg=-1]="NotJpeg",t[t.NotDefined=-2]="NotDefined",p;var t})();class g{}g.getOrientation=t=>new Promise((o,e)=>{try{const i=new FileReader;i.onload=()=>{const a=new DataView(i.result);if(!a.byteLength||65496!==a.getUint16(0,!1))return o(p.NotDefined);const s=a.byteLength;let n=2;for(;n<s;){const l=a.getUint16(n,!1);if(n+=2,65505===l){if(1165519206!==a.getUint32(n+=2,!1))return o(p.NotJpeg);const d=18761===a.getUint16(n+=6,!1);n+=a.getUint32(n+4,d);const h=a.getUint16(n,d);n+=2;for(let c=0;c<h;c++)if(274===a.getUint16(n+12*c,d))return o(a.getUint16(n+12*c+8,d))}else{if(65280!=(65280&l))break;n+=a.getUint16(n,!1)}}return o(p.NotJpeg)},i.readAsArrayBuffer(t)}catch(i){return e(p.Default)}}),g.uploadFile=(t,o=!0,e=!1)=>new Promise(function(i,a){const s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=/iPad|iPhone|iPod/i.test(navigator.userAgent);Promise.resolve(s||n).then(l=>l?g.generateUploadInputNative(window.document,o,e):g.generateUploadInputRenderer(t,o,e)).then(l=>{const d=l?Array.from(l):[],h=d.map(v=>g.getOrientation(v)),c=d.map(v=>g.fileToDataURL(v));let u=[];Promise.all(h).then(v=>(u=v,Promise.all(c))).then(v=>{const w=v.map((C,M)=>({image:C.dataUrl,orientation:u[M],fileName:C.fileName}));i(o?w:w[0])})}).catch(l=>a(l))}),g.fileToDataURL=t=>new Promise((o,e)=>{const i=new FileReader;i.onload=a=>{o({dataUrl:a.target.result,fileName:t.name})};try{i.readAsDataURL(t)}catch(a){e(`ngx-image-compress - probably no file have been selected: ${a}`)}}),g.generateUploadInputRenderer=(t,o=!0,e=!1)=>{let i=!1;return new Promise((a,s)=>{const n=t.createElement("input");t.setStyle(n,"display","none"),t.setProperty(n,"type","file"),t.setProperty(n,"accept","image/*"),o&&t.setProperty(n,"multiple","true"),t.listen(n,"click",l=>{l.target.value=""}),t.listen(n,"change",l=>{i=!0,a(l.target.files)}),e&&window.addEventListener("focus",()=>{setTimeout(()=>{i||s(new Error("file upload on blur - no file selected"))},300)},{once:!0}),n.click()})},g.generateUploadInputNative=(t,o=!0,e=!1)=>{let i=!1;return new Promise((a,s)=>{const n=t.createElement("input");n.id="upload-input"+new Date,n.style.display="none",n.setAttribute("type","file"),n.setAttribute("accept","image/*"),o&&n.setAttribute("multiple","true"),t.body.appendChild(n),n.addEventListener("change",()=>{i=!0,a(n.files),t.body.removeChild(t.getElementById(n.id))},{once:!0}),e&&window.addEventListener("focus",()=>{setTimeout(()=>{!i&&t.getElementById(n.id)&&(s(new Error("file upload on blur - no file selected")),t.body.removeChild(t.getElementById(n.id)))},300)},{once:!0}),n.click()})},g.compress=(t,o,e,i=50,a=50,s=0,n=0)=>new Promise(function(l,d){a/=100,i/=100;const h=new Image;h.onload=()=>{const c=e.createElement("canvas"),u=c.getContext("2d");if(!u)return d("No canvas context available");let v=h.naturalWidth,w=h.naturalHeight;if(!CSS.supports("image-orientation","from-image")&&(o===p.Right||o===p.Left)){const ee=v;v=w,w=ee}i=Math.min(i,s?s/v:1,n?n/w:1),c.width=v*i,c.height=w*i;const U=Math.PI/180;CSS.supports("image-orientation","from-image")||o===p.Up?u.drawImage(h,0,0,c.width,c.height):o===p.Right?(u.save(),u.rotate(90*U),u.translate(0,-c.width),u.drawImage(h,0,0,c.height,c.width),u.restore()):o===p.Left?(u.save(),u.rotate(-90*U),u.translate(-c.width,0),u.drawImage(h,0,0,c.height,c.width),u.restore()):o===p.Down?(u.save(),u.rotate(180*U),u.translate(-c.width,-c.height),u.drawImage(h,0,0,c.width,c.height),u.restore()):u.drawImage(h,0,0,c.width,c.height);const K=t.substr(5,t.split(";")[0].length-5),$=c.toDataURL(K,a);l($)},h.onerror=c=>d(c),h.src=t}),g.byteCount=t=>encodeURI(t).split(/%..|./).length-1,g.getImageMaxSize=(t,o,e,i=!1)=>(0,T.mG)(void 0,void 0,void 0,function*(){const s=d=>(d/1024/1024).toFixed(2);o&&console.debug("NgxImageCompress - Opening upload window");let l,n=yield g.uploadFile(e,!1,i);for(let d=0;d<10;d++){const h=g.byteCount(n.image);l=yield g.compress(n.image,n.orientation,e,50,100);const c=g.byteCount(l);if(console.debug("NgxImageCompress -","Compression from",s(h),"MB to",s(c),"MB"),c>=h)throw 0===d?(o&&console.debug("NgxImageCompress -","File can't be reduced at all - returning the original",s(h),"MB large"),n.image):(o&&console.debug("NgxImageCompress -","File can't be reduced more - returning the best we can, which is ",s(h),"MB large"),n.image);if(c<1024*t*1024)return o&&console.debug("NgxImageCompress -","Here your file",s(c),"MB large"),l;if(9===d)throw o&&console.debug("NgxImageCompress -","File can't reach the desired size after",10,"tries. Returning file ",s(h),"MB large"),n.image;o&&console.debug("NgxImageCompress -","Reached",s(c),"MB large. Trying another time after",d+1,"times"),n.image=l}throw o&&console.debug("NgxImageCompress - Unexpected error"),""});let z=(()=>{class t{constructor(e){this.DOC_ORIENTATION=p,this.render=e.createRenderer(null,null)}byteCount(e){return g.byteCount(e)}getOrientation(e){return g.getOrientation(e)}uploadFile(){return g.uploadFile(this.render,!1)}uploadMultipleFiles(){return g.uploadFile(this.render,!0)}uploadFileOrReject(){return g.uploadFile(this.render,!1,!0)}uploadMultipleFilesOrReject(){return g.uploadFile(this.render,!0,!0)}compressFile(e,i,a=50,s=50,n=0,l=0){return g.compress(e,i,this.render,a,s,n,l)}uploadAndGetImageWithMaxSize(e=1,i=!1,a=!1){return g.getImageMaxSize(e,i,this.render,a)}}return t.\u0275fac=function(e){return new(e||t)(r.LFG(r.FYo))},t.\u0275prov=r.Yz7({token:t,factory:t.\u0275fac,providedIn:"root"}),t})();const L=["buttonRow"];let R=(()=>{class t{constructor(e,i,a,s){this._snackbar=e,this._router=i,this._route=a,this._imageCompress=s,this.height=0,this.width=0,this.height=screen.height,this.width=screen.width,this.TriggerSubject=new Q.x}get trigger$(){return this.TriggerSubject.asObservable()}get videoOptions(){return{width:{min:640,ideal:1920},height:{min:480,ideal:1080},facingMode:{ideal:"user"}}}handleInitError(e){e.mediaStreamError&&"NotAllowedError"===e.mediaStreamError.name&&this._snackbar.open("Camera access was not allowed by user!","Error",{verticalPosition:"top"})}imageCaptured(e){const{imageAsDataUrl:i}=e;this._imageCompress.compressFile(i,0,50,50).then(a=>{this._router.navigate(["preview"],{relativeTo:this._route,state:{imageAsDataUrl:a,allowCamera:!0}})})}takePicture(){this.TriggerSubject.next()}ngOnInit(){}ngAfterViewInit(){}ngOnDestroy(){}}return t.\u0275fac=function(e){return new(e||t)(r.Y36(E.ux),r.Y36(f.F0),r.Y36(f.gz),r.Y36(z))},t.\u0275cmp=r.Xpm({type:t,selectors:[["app-camera"]],viewQuery:function(e,i){if(1&e&&r.Gf(L,5),2&e){let a;r.iGM(a=r.CRH())&&(i.buttonRow=a.first)}},decls:14,vars:5,consts:[[1,"wrapper"],[3,"height","width","videoOptions","allowCameraSwitch","trigger","initError","imageCapture"],[1,"button-row"],[1,"col-12"],[1,"row"],[1,"col-4","text-center"],["mat-fab","","color","secondary","routerLink","/app/home","aria-label","Example icon button with a delete icon"],["mat-fab","","color","primary","aria-label","Example icon button with a delete icon",3,"click"]],template:function(e,i){1&e&&(r.TgZ(0,"div",0)(1,"webcam",1),r.NdJ("initError",function(s){return i.handleInitError(s)})("imageCapture",function(s){return i.imageCaptured(s)}),r.qZA(),r.TgZ(2,"div",2)(3,"div",3)(4,"div",4)(5,"div",5)(6,"button",6)(7,"mat-icon"),r._uU(8,"close"),r.qZA()()(),r.TgZ(9,"div",5)(10,"button",7),r.NdJ("click",function(){return i.takePicture()}),r.TgZ(11,"mat-icon"),r._uU(12,"photo_camera"),r.qZA()()(),r._UZ(13,"div",5),r.qZA()()()()),2&e&&(r.xp6(1),r.Q6J("height",i.height)("width",i.width)("videoOptions",i.videoOptions)("allowCameraSwitch",!1)("trigger",i.trigger$))},directives:[F,y.lW,f.rH,S.Hw],styles:[".wrapper[_ngcontent-%COMP%]{height:100vh;width:100vw}.wrapper[_ngcontent-%COMP%] .button-row[_ngcontent-%COMP%]{bottom:12px;position:fixed;width:100%}"]}),t})();var G=m(5861);class Z{constructor(o={}){this.employee_id=o.employee_id,this.date=o.date,this.latitude=o.latitude,this.longitude=o.longitude,this.photo=o.photo,this.time=o.time}}var Y=m(2223),H=m(629),W=m(9511),j=m(1481);const X=["img"],N=function(){return{allowCamera:!0}},q=[{path:"",canActivate:[x],component:R},{path:"preview",canActivate:[x],component:(()=>{class t{constructor(e,i,a,s,n,l,d,h){var c;this._router=e,this.spinner=i,this._snackbar=a,this._attendanceService=s,this._authService=n,this._datePipe=l,this._timeService=d,this._locationService=h,this.image=null===(c=this._router.getCurrentNavigation())||void 0===c?void 0:c.extras.state}convertBase64ToBlob(e){const i=e.split(";base64,"),a=i[0].split(":")[1],s=window.atob(i[1]),n=new Uint8Array(s.length);for(let l=0;l<s.length;++l)n[l]=s.charCodeAt(l);return new Blob([n],{type:a})}imageOk(){var e=this;return(0,G.Z)(function*(){var i,a;e.spinner.show();try{const s=new Z;s.employee_id=e._authService.getUserData().id,s.date=e._datePipe.transform(e._timeService.currentTimestamp,"yyyy-MM-dd"),s.latitude=e._locationService.position.latitude,s.longitude=e._locationService.position.longitude,s.time=e._datePipe.transform(e._timeService.currentTimestamp,"HH:mm:ss"),s.photo=e.convertBase64ToBlob(e.image.imageAsDataUrl),null!==(null===(i=e._attendanceService.attendanceStatus)||void 0===i?void 0:i.personal_calender.check_in)&&null===(null===(a=e._attendanceService.attendanceStatus)||void 0===a?void 0:a.personal_calender.check_out)?yield e._attendanceService.checkOut(s):yield e._attendanceService.checkIn(s),e._attendanceService.getStatus(),e._router.navigateByUrl("/app/home")}catch(s){console.error(s),e._snackbar.open(JSON.stringify(s.Message?s.Message:s),"error")}finally{e.spinner.hide()}})()}ngOnInit(){}ngAfterViewInit(){let e=this.img.nativeElement;e.style.height="inherit",e.style.transform="scaleX(-1)"}}return t.\u0275fac=function(e){return new(e||t)(r.Y36(f.F0),r.Y36(A.t2),r.Y36(E.ux),r.Y36(Y.v),r.Y36(H.e),r.Y36(b.uU),r.Y36(W.f),r.Y36(j.a))},t.\u0275cmp=r.Xpm({type:t,selectors:[["app-preview"]],viewQuery:function(e,i){if(1&e&&r.Gf(X,5),2&e){let a;r.iGM(a=r.CRH())&&(i.img=a.first)}},decls:17,vars:4,consts:[[1,"wrapper"],["bdColor","rgba(0, 0, 0, 0.8)","size","medium","color","#fff","type","ball-clip-rotate",3,"fullScreen"],[2,"color","white"],[1,"image-fluid",3,"src"],["img",""],[1,"button-row"],[1,"col-12"],[1,"row","px-5"],[1,"col-6","text-start"],["mat-fab","","color","secondary","routerLink","../",3,"state"],[1,"col-6","text-end"],["mat-fab","","color","primary",3,"click"]],template:function(e,i){1&e&&(r.TgZ(0,"div",0)(1,"ngx-spinner",1)(2,"p",2),r._uU(3,"Loading..."),r.qZA()(),r._UZ(4,"img",3,4),r.TgZ(6,"div",5)(7,"div",6)(8,"div",7)(9,"div",8)(10,"button",9)(11,"mat-icon"),r._uU(12,"close"),r.qZA()()(),r.TgZ(13,"div",10)(14,"button",11),r.NdJ("click",function(){return i.imageOk()}),r.TgZ(15,"mat-icon"),r._uU(16,"check"),r.qZA()()()()()()()),2&e&&(r.xp6(1),r.Q6J("fullScreen",!0),r.xp6(3),r.Q6J("src",i.image.imageAsDataUrl,r.LSH),r.xp6(6),r.Q6J("state",r.DdM(3,N)))},directives:[A.Ro,y.lW,f.rH,S.Hw],styles:[".wrapper[_ngcontent-%COMP%]{height:100vh;width:100vw}.wrapper[_ngcontent-%COMP%] .button-row[_ngcontent-%COMP%]{bottom:24px;position:fixed;width:100%}"]}),t})()}];let O=(()=>{class t{}return t.\u0275fac=function(e){return new(e||t)},t.\u0275mod=r.oAB({type:t}),t.\u0275inj=r.cJS({imports:[[b.ez,J,f.Bz.forChild(q),A.ef,S.Ps,y.ot]]}),t})()}}]);