"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[85473],{85473:(e,n,o)=>{o.r(n),o.d(n,{AddonModDataFieldFileComponent:()=>u});var t=o(10093),i=o(24942),a=o(95209),d=o(86654),l=o(54438),r=o(60177),s=o(89417),p=o(2910),m=o(95638),c=o(31498),f=o(25880),_=o(73955);function AddonModDataFieldFileComponent_ng_container_0_core_input_errors_3_Template(e,n){if(1&e&&l.nrm(0,"core-input-errors",4),2&e){const e=l.XpG(2);l.Y8G("errorText",e.error)}}function AddonModDataFieldFileComponent_ng_container_0_Template(e,n){if(1&e&&(l.qex(0),l.nrm(1,"core-attachments",2),l.nI1(2,"translate"),l.DNE(3,AddonModDataFieldFileComponent_ng_container_0_core_input_errors_3_Template,1,1,"core-input-errors",3),l.bVm()),2&e){const e=l.XpG();l.R7$(),l.Y8G("files",e.files)("maxSize",e.maxSizeBytes)("component",e.component)("componentId",e.componentId)("allowOffline",!0)("courseId",null==e.database?null:e.database.course)("required",e.field.required)("title",l.bMT(2,9,"addon.mod_data_fields_file.fieldtypelabel")),l.R7$(2),l.Y8G("ngIf",e.error)}}function AddonModDataFieldFileComponent_ng_container_1_Template(e,n){if(1&e&&(l.qex(0,5),l.nrm(1,"ion-input",6),l.bVm()),2&e){const e=l.XpG();l.Y8G("formGroup",e.form),l.R7$(),l.Y8G("formControlName","f_"+e.field.id)("placeholder",e.field.name)}}function AddonModDataFieldFileComponent_ng_container_2_Template(e,n){if(1&e&&(l.qex(0),l.j41(1,"div"),l.nrm(2,"core-files",7),l.k0s(),l.bVm()),2&e){const e=l.XpG();l.R7$(2),l.Y8G("files",e.files)("component",e.component)("componentId",e.componentId)("alwaysDownload",!0)}}let u=(()=>{var e;class AddonModDataFieldFileComponent extends t.u{constructor(){super(...arguments),this.files=[]}getFiles(e){let n=(null==e?void 0:e.files)||[];return n.length>0&&(n=[n[0]]),n}init(){if(this.searchMode)return this.addControl(`f_${this.field.id}`),void 0;this.component=a.$W,this.componentId=this.database.coursemodule,this.updateValue(this.value),this.editMode&&(this.maxSizeBytes=parseInt(this.field.param3,10),i.CoreFileSession.setFiles(this.component,`${this.database.id}_${this.field.id}`,this.files))}updateValue(e){this.value=e,this.files=this.getFiles(e)}}return(e=AddonModDataFieldFileComponent).ɵfac=(()=>{let n;return function AddonModDataFieldFileComponent_Factory(o){return(n||(n=l.xGo(e)))(o||e)}})(),e.ɵcmp=l.VBU({type:e,selectors:[["addon-mod-data-field-file"]],standalone:!0,features:[l.Vt3,l.aNF],decls:3,vars:3,consts:[[4,"ngIf"],[3,"formGroup",4,"ngIf"],["maxSubmissions","1",3,"files","maxSize","component","componentId","allowOffline","courseId","required","title"],[3,"errorText",4,"ngIf"],[3,"errorText"],[3,"formGroup"],["type","text",3,"formControlName","placeholder"],[3,"files","component","componentId","alwaysDownload"]],template:function AddonModDataFieldFileComponent_Template(e,n){1&e&&l.DNE(0,AddonModDataFieldFileComponent_ng_container_0_Template,4,11,"ng-container",0)(1,AddonModDataFieldFileComponent_ng_container_1_Template,2,3,"ng-container",1)(2,AddonModDataFieldFileComponent_ng_container_2_Template,3,4,"ng-container",0),2&e&&(l.Y8G("ngIf",n.editMode&&n.form),l.R7$(),l.Y8G("ngIf",n.searchMode&&n.form),l.R7$(),l.Y8G("ngIf",n.displayMode))},dependencies:[d.n,r.bT,s.BC,s.cb,p.$w,p.Gw,s.j4,s.JD,m.V,c.Y,f.q,_.D9],encapsulation:2}),AddonModDataFieldFileComponent})()}}]);