
/* eslint-disable */
// sd-skip-auto-import
import cloneDeep from"lodash.clonedeep";import extensionUtil from"@/common/services/extension-util";const renderMap={};const renderMapForDisplay={};const renderModuleMap={};extensionUtil.parse(require.context("./component-library",false,/-render\.(?:js|vue)$/),require.context("../../src_product",true,/_form-designer\/component-library\/[a-z-]+-render\.(?:js|vue)$/),require.context("../../src_custom/_form-designer/component-library",false,/-render\.(?:js|vue)$/)).forEach((e=>{const r=e.fileName.replace(/-render\.(?:js|vue)$/,"");const t=e.getModule();renderMap[r]=t.default;renderModuleMap[r]=t;if(t.forDisplay)renderMapForDisplay[r]=t.forDisplay}));const themeMap={};extensionUtil.parse(require.context("./themes",true,/theme\.scss$/),require.context("../../src_product",true,/_form-designer\/themes\/.*\/theme\.scss$/),require.context("../../src_custom/_form-designer/themes",true,/theme\.scss$/)).forEach((e=>{const r=e.path.split("/");let t;if(!e.isProduct)t=r[1];else t=r[1]+"-"+r[r.length-2];themeMap[t]=e.getModule}));class RuntimeUtil{getRender(e,r=false){if(r)return renderMapForDisplay[e];else return renderMap[e]}getStyleId(e){return`sd-form-designer-theme-${e}`}loadTheme(e){themeMap[e]()}unloadTheme(e){}processChildrenInLayout(e,r,t=true){e.forEach((e=>{if("layout"!==e?.attrFD?.category)return;const n=renderModuleMap[e.attrFD.cid]?.processChildren;if(n)n(e,(n=>{r(n,e);if(t)this.processChildrenInLayout([n],r)}))}))}processComponentAndChildren(e,r){e.forEach((e=>{r(e);this.processChildrenInLayout([e],r)}))}mergeTransientFields(e){const r=cloneDeep(e);if(r.head.attrFD.fields){let e=0;const t=r.fields.filter((e=>e.attrFD?.cid));r.fields=r.head.attrFD.fields.map((r=>r||t[e++]));delete r.head.attrFD.fields}this.processChildrenInLayout(r.fields,(r=>{if(!r.attrFD.refId)return;let t=e.fields.find((e=>e.attrFD?.id===r.attrFD.refId));t=cloneDeep(t);delete r.attrFD.refId;for(const e of Object.getOwnPropertyNames(t))r[e]=t[e]}));return r}getTableInfo(e,r){const t=this.mergeTransientFields({fields:e,head:{attrFD:r}});e=t.fields;r=t.head.attrFD;const n=[[]];let s=0;e.filter((e=>e.attrFD?.cid&&!e.attrFD.hidden)).forEach((e=>{const{name:t,attrFD:{columns:o,cid:i}}=e;const a={cid:i,name:t,columns:o,...e.attrFD.formItemProps,component:this.getRender(i),componentForDisplay:this.getRender(i,true),transient:e.attrFD.transient,field:e};if(e.attrFD.hideLabel)a.label=null;if(s+o>r.columns){n.push([]);s=0}n[n.length-1].push(a);s+=o}));return n}}const componentLibraryMixin={created(){this.componentLibrary=renderMap;this.componentLibraryForDisplay=renderMapForDisplay}};export default new RuntimeUtil;export{componentLibraryMixin};