import{a as d}from"./chunk-4EEGS4SZ.js";import{a as S}from"./chunk-Y46LOK5X.js";import{d as m,e as f}from"./chunk-DFPET44C.js";import{k as a}from"./chunk-PNYIEM2I.js";import{c as u,d as g,e as r,f as h}from"./chunk-DQXXLIFV.js";import{fd as F,ja as c}from"./chunk-LU6Q5ONP.js";import{a as n}from"./chunk-5VMFMKJR.js";g();F();h();var p=class extends f{constructor(e,s){super(e,{featureId:m.Edit,onSelected:t=>{if(!r.isSet(t.commitRecord)||r.isFunction(this.featureSettings.recordFeature)&&!this.featureSettings.recordFeature(t.commitRecord,t))return;let o=this.getInputFields(t);if(!o)return;let i=this.dialogService.open({id:d.DialogPawDatagridEditFormFeatureForm,title:this.featureSettings.title||"",styleClass:this.featureSettings.styleClass,size:this.featureSettings.size,onClose:()=>{t.clearAddRecord(),t.clearCommitRecord(),t.clearSelection()},component:S,bindings:{fields:o,groups:this.featureSettings.groups,grouppingStyleClass:this.featureSettings.grouppingStyleClass,model:n({},t.commitRecord),actions:[{id:"datagrid-edit-record-cancel",label:"Cancel",type:"paw-chip-btn",onSelected:()=>{i.close()}}],settings:{onSubmit:(l,I)=>this.featureSettings.submitRecord(l,t)},submitAction:{id:"datagrid-edit-record-submit"}}})},display:"selection"}),this.featureSettings=s,this.dialogService=c(a),e.icon="fa-regular fa-edit",e.title="Edit",e.label=""}recordFeature(e,s){return this.featureSettings.recordFeature?this.featureSettings.recordFeature(e,s):!0}getInputFields(e){return r.isFunction(this.featureSettings.getColumns)?this.getInputFieldsForColumns(e):r.isFunction(this.featureSettings.getInputFields)?this.getInputFieldsFromCustomFields(e):null}getInputFieldsForColumns(e){if(!r.isSet(e.commitRecord)||!this.featureSettings.getColumns)return null;let s=e.getInputFieldsFor(e.commitRecord);if(!r.isSet(s))return null;let t=e.getFieldSet(e.commitRecord);return u.iterate(this.featureSettings.getColumns(),o=>{let i=r.isFunction(o.inputField)?o.inputField(e.commitRecord,e):o.inputField;!i||u.exists(s,l=>l.id===i.id)||(i.bind.fieldSet=t,s.push(n({},i)))}),s}getInputFieldsFromCustomFields(e){if(!r.isSet(e.commitRecord)||!this.featureSettings.getInputFields)return null;let s=e.getInputFieldsFor(e.commitRecord);if(!r.isSet(s))return null;let t=[],o=e.getFieldSet(e.commitRecord);return u.iterate(this.featureSettings.getInputFields(),i=>{i&&(i.bind||(i.bind={}),i.bind.fieldSet=o,t.push(n({},i)))}),t}};export{p as a};
