import{c as re}from"./chunk-XZELSHJP.js";import{x as de,y as pe}from"./chunk-AUG6ZMIQ.js";import{c as ge}from"./chunk-JQJV7TYV.js";import{c as ce}from"./chunk-YM543BQE.js";import{l as ne,m as se,o as ae,p as le}from"./chunk-STBSUBIU.js";import{Aa as U,Ac as te,Ba as b,Ca as x,Cb as F,Da as Z,Fd as P,Gb as H,Hb as f,Jb as W,Jc as ie,Ka as y,Kb as A,Kc as oe,Qb as Y,Rb as G,Sb as X,Tb as g,Ub as h,Vb as z,Zb as C,_b as J,ac as m,cc as w,dc as k,ec as I,fb as N,ga as E,ha as L,ic as Q,jc as $,kb as u,kc as S,lb as c,lc as j,qa as _,qc as K,ra as B,rc as q,sa as R,xb as O,xd as T,zc as ee}from"./chunk-NW2U37DI.js";import{j as D}from"./chunk-TWZW5B45.js";var be=[[["ngx-dropzone-label"]]],xe=["ngx-dropzone-label"];function ye(i,a){if(i&1){let e=C();g(0,"ngx-dropzone-remove-badge",1),m("click",function(o){b(e);let n=w();return x(n._remove(o))}),h()}}var ze=["fileInput"],Ce=[[["ngx-dropzone-preview"]],"*",[["ngx-dropzone-label"]]],Ie=["ngx-dropzone-preview","*","ngx-dropzone-label"];function De(i,a){i&1&&I(0,2,["*ngIf","!_hasPreviews"])}var ue=(()=>{class i{}return i.\u0275fac=function(e){return new(e||i)},i.\u0275dir=R({type:i,selectors:[["ngx-dropzone-label"]]}),i})();function v(i){return i!=null&&`${i}`!="false"}function we(i){return!isNaN(parseFloat(i))&&!isNaN(Number(i))?Number(i):null}var Pe=(()=>{class i{}return i.\u0275fac=function(e){return new(e||i)},i.\u0275cmp=_({type:i,selectors:[["ngx-dropzone-remove-badge"]],decls:3,vars:0,consts:[["x1","0","y1","0","x2","10","y2","10"],["x1","0","y1","10","x2","10","y2","0"]],template:function(e,t){e&1&&(Z(),g(0,"svg"),z(1,"line",0)(2,"line",1),h())},styles:["[_nghost-%COMP%]{display:flex;justify-content:center;align-items:center;height:22px;width:22px;position:absolute;top:5px;right:5px;border-radius:50%;background:#bbb;color:#333;cursor:pointer}[_nghost-%COMP%]:hover{background:#aeaeae}[_nghost-%COMP%] > svg[_ngcontent-%COMP%]{height:10px;width:10px}[_nghost-%COMP%] > svg[_ngcontent-%COMP%] > line[_ngcontent-%COMP%]{stroke-width:2px;stroke:#fff}"]}),i})(),V=function(i){return i[i.BACKSPACE=8]="BACKSPACE",i[i.DELETE=46]="DELETE",i}(V||{}),Me=(()=>{class i{constructor(e){this.sanitizer=e,this._removable=!1,this.removed=new y,this.tabIndex=0}set file(e){this._file=e}get file(){return this._file}get removable(){return this._removable}set removable(e){this._removable=v(e)}keyEvent(e){switch(e.keyCode){case V.BACKSPACE:case V.DELETE:this.remove();break;default:break}}get hostStyle(){return this.sanitizer.bypassSecurityTrustStyle(`
			display: flex;
			height: 140px;
			min-height: 140px;
			min-width: 180px;
			max-width: 180px;
			justify-content: center;
			align-items: center;
			padding: 0 20px;
			margin: 10px;
			border-radius: 5px;
			position: relative;
		`)}_remove(e){e.stopPropagation(),this.remove()}remove(){this._removable&&this.removed.next(this.file)}readFile(){return D(this,null,function*(){return new Promise((e,t)=>{let o=new FileReader;if(o.onload=n=>{e(n.target.result)},o.onerror=n=>{console.error(`FileReader failed on file ${this.file.name}.`),t(n)},!this.file)return t("No file to read. Please provide a file using the [file] Input property.");o.readAsDataURL(this.file)})})}}return i.\u0275fac=function(e){return new(e||i)(c(ne))},i.\u0275cmp=_({type:i,selectors:[["ngx-dropzone-preview"]],hostVars:3,hostBindings:function(e,t){e&1&&m("keyup",function(n){return t.keyEvent(n)}),e&2&&(J("tabindex",t.tabIndex),A(t.hostStyle))},inputs:{file:"file",removable:"removable"},outputs:{removed:"removed"},ngContentSelectors:xe,decls:2,vars:1,consts:[[3,"click",4,"ngIf"],[3,"click"]],template:function(e,t){e&1&&(k(be),I(0),F(1,ye,1,0,"ngx-dropzone-remove-badge",0)),e&2&&(u(),f("ngIf",t.removable))},dependencies:[Pe,T],styles:["[_nghost-%COMP%]{background-image:linear-gradient(to top,#ededed,#efefef,#f1f1f1,#f4f4f4,#f6f6f6)}[_nghost-%COMP%]:hover, [_nghost-%COMP%]:focus{background-image:linear-gradient(to top,#e3e3e3,#ebeaea,#e8e7e7,#ebeaea,#f4f4f4);outline:0}[_nghost-%COMP%]:hover   ngx-dropzone-remove-badge[_ngcontent-%COMP%], [_nghost-%COMP%]:focus   ngx-dropzone-remove-badge[_ngcontent-%COMP%]{opacity:1}[_nghost-%COMP%]   ngx-dropzone-remove-badge[_ngcontent-%COMP%]{opacity:0}[_nghost-%COMP%]     ngx-dropzone-label{overflow-wrap:break-word}"]}),i})(),me=(()=>{class i{parseFileList(e,t,o,n){let r=[],l=[];for(let d=0;d<e.length;d++){let p=e.item(d);if(!this.isAccepted(p,t)){this.rejectFile(l,p,"type");continue}if(o&&p.size>o){this.rejectFile(l,p,"size");continue}if(!n&&r.length>=1){this.rejectFile(l,p,"no_multiple");continue}r.push(p)}return{addedFiles:r,rejectedFiles:l}}isAccepted(e,t){if(t==="*")return!0;let o=t.split(",").map(s=>s.toLowerCase().trim()),n=e.type.toLowerCase(),r=e.name.toLowerCase();return!!o.find(s=>s.endsWith("/*")?n.split("/")[0]===s.split("/")[0]:s.startsWith(".")?r.endsWith(s):s==n)}rejectFile(e,t,o){let n=t;n.reason=o,e.push(n)}}return i.\u0275fac=function(e){return new(e||i)},i.\u0275prov=E({token:i,factory:i.\u0275fac}),i})(),fe=(()=>{class i{constructor(e){this.service=e,this.change=new y,this.accept="*",this._disabled=!1,this._multiple=!0,this._maxFileSize=void 0,this._expandable=!1,this._disableClick=!1,this._processDirectoryDrop=!1,this._isHovered=!1}get _hasPreviews(){return!!this._previewChildren.length}get disabled(){return this._disabled}set disabled(e){this._disabled=v(e),this._isHovered&&(this._isHovered=!1)}get multiple(){return this._multiple}set multiple(e){this._multiple=v(e)}get maxFileSize(){return this._maxFileSize}set maxFileSize(e){this._maxFileSize=we(e)}get expandable(){return this._expandable}set expandable(e){this._expandable=v(e)}get disableClick(){return this._disableClick}set disableClick(e){this._disableClick=v(e)}get processDirectoryDrop(){return this._processDirectoryDrop}set processDirectoryDrop(e){this._processDirectoryDrop=v(e)}_onClick(){this.disableClick||this.showFileSelector()}_onDragOver(e){this.disabled||(this.preventDefault(e),this._isHovered=!0)}_onDragLeave(){this._isHovered=!1}_onDrop(e){if(!this.disabled)if(this.preventDefault(e),this._isHovered=!1,!this.processDirectoryDrop||!DataTransferItem.prototype.webkitGetAsEntry)this.handleFileDrop(e.dataTransfer.files);else{let t=e.dataTransfer.items;if(t.length>0){let o=[],n=[];for(let l=0;l<t.length;l++){let s=t[l].webkitGetAsEntry();s.isFile?o.push(e.dataTransfer.files[l]):s.isDirectory&&n.push(s)}let r=new DataTransfer;if(o.forEach(l=>{r.items.add(l)}),!n.length&&r.items.length&&this.handleFileDrop(r.files),n.length){let l=[];for(let s of n)l.push(this.extractFilesFromDirectory(s));Promise.all(l).then(s=>{s.reduce((d,p)=>[...d,...p]).forEach(d=>{r.items.add(d)}),this.handleFileDrop(r.files)})}}}}extractFilesFromDirectory(e){function t(o){return D(this,null,function*(){try{return yield new Promise((n,r)=>o.file(n,r))}catch(n){console.log("Error converting a fileEntry to a File: ",n)}})}return new Promise((o,n)=>{let r=[],l=e.createReader(),s=()=>{l.readEntries(d=>D(this,null,function*(){if(!d.length)o(r);else{let p=d.filter(M=>M.isFile);for(let M of p){let _e=yield t(M);r.push(_e)}s()}}))};s()})}showFileSelector(){this.disabled||this._fileInput.nativeElement.click()}_onFilesSelected(e){let t=e.target.files;this.handleFileDrop(t),this._fileInput.nativeElement.value="",this.preventDefault(e)}handleFileDrop(e){let t=this.service.parseFileList(e,this.accept,this.maxFileSize,this.multiple);this.change.next({addedFiles:t.addedFiles,rejectedFiles:t.rejectedFiles,source:this})}preventDefault(e){e.preventDefault(),e.stopPropagation()}}return i.\u0275fac=function(e){return new(e||i)(c(me,2))},i.\u0275cmp=_({type:i,selectors:[["ngx-dropzone"],["","ngx-dropzone",""]],contentQueries:function(e,t,o){if(e&1&&Q(o,Me,5),e&2){let n;S(n=j())&&(t._previewChildren=n)}},viewQuery:function(e,t){if(e&1&&$(ze,7),e&2){let o;S(o=j())&&(t._fileInput=o.first)}},hostVars:8,hostBindings:function(e,t){e&1&&m("click",function(){return t._onClick()})("dragover",function(n){return t._onDragOver(n)})("dragleave",function(){return t._onDragLeave()})("drop",function(n){return t._onDrop(n)}),e&2&&W("ngx-dz-disabled",t.disabled)("expandable",t.expandable)("unclickable",t.disableClick)("ngx-dz-hovered",t._isHovered)},inputs:{accept:"accept",disabled:"disabled",multiple:"multiple",maxFileSize:"maxFileSize",expandable:"expandable",disableClick:"disableClick",processDirectoryDrop:"processDirectoryDrop",id:"id",ariaLabel:[0,"aria-label","ariaLabel"],ariaLabelledby:[0,"aria-labelledby","ariaLabelledby"],ariaDescribedBy:[0,"aria-describedby","ariaDescribedBy"]},outputs:{change:"change"},features:[ee([me])],ngContentSelectors:Ie,decls:5,vars:8,consts:[["fileInput",""],["type","file",3,"change","id","multiple","accept","disabled"],[4,"ngIf"]],template:function(e,t){if(e&1){let o=C();k(Ce),g(0,"input",1,0),m("change",function(r){return b(o),x(t._onFilesSelected(r))}),h(),F(2,De,1,0,"ng-content",2),I(3),I(4,1)}e&2&&(f("id",t.id)("multiple",t.multiple)("accept",t.accept)("disabled",t.disabled),H("aria-label",t.ariaLabel)("aria-labelledby",t.ariaLabelledby)("aria-describedby",t.ariaDescribedBy),u(2),f("ngIf",!t._hasPreviews))},dependencies:[T],styles:["[_nghost-%COMP%]{display:flex;align-items:center;height:180px;background:#fff;cursor:pointer;color:#717386;border:2px dashed #717386;border-radius:5px;font-size:16px;overflow-x:auto}.ngx-dz-hovered[_nghost-%COMP%]{border-style:solid}.ngx-dz-disabled[_nghost-%COMP%]{opacity:.5;cursor:no-drop;pointer-events:none}.expandable[_nghost-%COMP%]{overflow:hidden;height:unset;min-height:180px;flex-wrap:wrap}.unclickable[_nghost-%COMP%]{cursor:default}[_nghost-%COMP%]     ngx-dropzone-label{text-align:center;z-index:10;margin:10px auto}[_nghost-%COMP%]   input[_ngcontent-%COMP%]{width:.1px;height:.1px;opacity:0;overflow:hidden;position:absolute;z-index:-1}[_nghost-%COMP%]   input[_ngcontent-%COMP%]:focus +   ngx-dropzone-label{outline:1px dotted #000;outline:-webkit-focus-ring-color auto 5px}"]}),i})();var he=(()=>{class i{}return i.\u0275fac=function(e){return new(e||i)},i.\u0275mod=B({type:i}),i.\u0275inj=L({imports:[[P]]}),i})();function Oe(i,a){if(i&1){let e=C();g(0,"div",1),z(1,"img",2),g(2,"button",3),m("click",function(o){let n=b(e),r=n.$implicit,l=n.$index,s=w();return x(s.onimageRemove(o,r,l))}),z(3,"i",4),h()()}if(i&2){let e=a.$implicit;u(),f("src",e,N)}}var at=(()=>{class i extends le{ngOnChanges(e){this.featureImage=[],e?.media?.currentValue&&e.media.currentValue.map(t=>{t?.articlefeatureimage?this.featureImage.push(t.articlefeatureimage):t?.profileimage&&this.featureImage.push(t.profileimage)})}constructor(e,t,o,n,r){super(n),this.translate=e,this.toastr=t,this.route=o,this.fb=r,this.onImageUploaded=new y,this.featureImage=[],this.ticketName=[],this.form=this.fb.group({image:null})}onImageUpload(e){if(e?.rejectedFiles?.length>0){this.showError("The file type is not supported");return}let t=this.directTypes?.split(",")||this.setting?.FILE_UPLOAD_TYPES.split(","),o=e.addedFiles?.[0],n=o.name.split(".").pop();if(!t.includes(n)){this.showError("The file type is not supported");return}let r=this.directSize||this.setting?.FILE_UPLOAD_MAX;if(o.size/1024/1024>r){this.showError("The file size is too large");return}let l=this.setting?.MAX_FILE_UPLOAD;if(this.featureImage.length>=l){this.showError("The max files limit has been reached");return}if(this.featureImage.length>=this.maxLength){this.showError("The max files limit has been reached");return}let s=new FileReader;s.onload=()=>{this.featureImage.push(s.result)},s.readAsDataURL(o),this.form.patchValue({image:o}),this.ticketName.push(this.form.controls.image.value),this.onImageUploaded.emit({ticketName:this.ticketName})}showError(e){this.toastr.error(this.translate.transform(e),this.translate.transform("Error"))}onimageRemove(e,t,o){e.preventDefault(),e.stopPropagation(),this.featureImage.splice(this.featureImage.indexOf(t),1),this.ticketName?.splice(o,1);let n=this.media?.filter(r=>r.profileimage===t);this.onImageUploaded.emit({ticketName:this.ticketName,mediaremoveIds:n})}static{this.\u0275fac=function(t){return new(t||i)(c(ce),c(se),c(re),c(ae),c(de))}}static{this.\u0275cmp=_({type:i,selectors:[["app-image-upload"]],inputs:{directSize:"directSize",directTypes:"directTypes",disabled:"disabled",setting:"setting",maxLength:"maxLength",media:"media",articlefeatureimage:"articlefeatureimage"},outputs:{onImageUploaded:"onImageUploaded"},standalone:!0,features:[O,U,te],decls:6,vars:4,consts:[["ngx-dropzone","",1,"custom-dropzone",3,"change","disabled"],[1,"dropzone-preview","m-1","rounded-1","overflow-hidden"],["alt","image",1,"dropzone-image",3,"src"],[1,"dropzone-remove",3,"click"],[1,"fa","fa-close"]],template:function(t,o){t&1&&(g(0,"div",0),m("change",function(r){return o.onImageUpload(r)}),G(1,Oe,4,1,"div",1,Y),g(3,"ngx-dropzone-label"),K(4),ie(5,"translate"),h()()),t&2&&(f("disabled",o.disabled),u(),X(o.featureImage),u(3),q(oe(5,2,"upload")))},dependencies:[P,ge,he,fe,ue,pe],styles:[".dropzone-preview{position:relative}  .dropzone-image{width:160px;aspect-ratio:1}  .dropzone-remove{position:absolute;width:1rem;height:1rem;border-radius:50%;outline:none;border:1px solid var(--bs-danger);background:transparent;top:2%;right:2%;color:var(--bs-danger);display:flex;align-items:center;justify-content:center;padding:.5rem}  .dropzone-remove .fa{font-size:small!important}"]})}}return i})();export{he as a,at as b};
