import{UserInterface as n,DataType as t}from"@sankhyalabs/core";import{a as o,G as r,D as e}from"./p-9019a32f.js";const u=new Map([[n.DATE,"calendar"],[n.DATETIME,"calendar-clock"],[n.ELAPSEDTIME,"timer-outline"],[n.TIME,"timer-outline"],[n.DECIMALNUMBER,"number"],[n.INTEGERNUMBER,"number"],[n.FILE,"zip"],[n.IMAGE,"pdf"],[n.HTML,"tag_code"],[n.SEARCH,"search"],[n.SEARCHPLUS,"search"],[n.OPTIONSELECTOR,"list"],[n.CHECKBOX,"list"],[n.SWITCH,"boolean"],[n.PASSWORD,"eye-off"]]),i="container-available-fields";var l;function c(n,t,o,r){var e;const u=null===(e=null==n?void 0:n[t])||void 0===e?void 0:e.children;return u?Array.from(u).map((({fieldConfig:n})=>Object.assign(Object.assign({},n),{group:o,tab:r}))):[]}function a(n,t){return n.map((n=>Object.assign(Object.assign({},n),{fields:n.fields.map((n=>Object.assign(Object.assign({},n),{tab:t})))})))}function f(n,o,r){var e;if(null==n||!o||!r)return;const u=null===(e=o.getField(r))||void 0===e?void 0:e.dataType;if(null==u)return;if(void 0!==(null==n?void 0:n.waitmessage))return;const i=u!==t.OBJECT&&u!==t.DATE&&"object"==typeof n?n.value:n;return u===t.OBJECT?JSON.stringify(i):i}function s(n,t,o){if(!o)return!0;const r=o.properties||{},e=!0!==o[n];return r.hasOwnProperty(t)?"S"!==r[t]:e}function d(n,t,o){return!(!t||!0!==t[n])||o}function v(n){return u.get(n)||"text"}function b(n,t){var o,r;const e=t("snkFormConfig.form.newGuide"),u=null!==(r=null===(o=n.filter((n=>n.name.includes(e))))||void 0===o?void 0:o.length)&&void 0!==r?r:0;return 0===u?e:`${e} (${u})`}function m(n){const t=[];return n.forEach((n=>{n.forEach((({fields:n})=>{null==n||n.forEach((n=>{t.push(function(n){const t={cleanOnCopy:n.cleanOnCopy||!1,group:n.group===r.noGroup?void 0:n.group,label:n.label,name:n.name,required:n.required,readOnly:n.readOnly,tab:n.tab};return null!=n.defaultValue&&(t.defaultValue=null==n.defaultValue.type?{type:e.fixed,value:n.defaultValue}:n.defaultValue),t}(n))}))}))})),t}function p(n,t,r,e){const u=n.map((n=>{const t=n.tab;return Object.assign(Object.assign({},n),{tab:t&&t!==o.general?n.tab:o.main})})),i=function(n){const t=new Map;return y(n).forEach((n=>{t.set(n.name,[])})),t}(t);if(null==u?void 0:u.length){for(let n of i.keys()){const t=S(k(M(u,n,e),r,e));i.set(n,t)}return i}}function j(n,t){let r=n.tabs?[...n.tabs]:function(n){const t=[];let o=1;return null==n||n.forEach((n=>{const r=n.tab;(function(n,t){return n&&!t.map((n=>n.name)).includes(n)})(r,t)&&(t.push({name:r,label:r,visible:!0,order:o}),o+=1)})),t}(null==n?void 0:n.fields);return r=y(r),r=function(n){return n.map((n=>Object.assign(Object.assign({},n),{name:n.name?n.name:n.label})))}(r),function(n,t){const r={name:o.main,label:t,visible:!0};return n.some((n=>n.name===o.main))?n=n.map((n=>n.name===o.main?r:n)):n.unshift(r),n}(r,t)}function O(n,t=0,o){var r;if(!n||!n.metadata)return[];const e=(null===(r=n.metadata)||void 0===r?void 0:r.children)||[],u=[];for(const n of e){const r=o.find((t=>n.label===t.label));r?r.isCustom=!0:u.push({label:n.label,name:n.name,visible:!0,isCustom:!0,order:t++})}return u}function y(n){return[...n.filter((n=>n.label!==o.general))]}function g(n,t){n.label||(n.label=t.label)}function h(n,t){n.tab||(n.tab=t)}function w(n){n.group||(n.group=r.noGroup)}function C(n){var t;return!0===(null===(t=null==n?void 0:n.properties)||void 0===t?void 0:t.visibleOnConfig)&&!1===(null==n?void 0:n.visible)}function k(n,t,o){const e=new Map;e.set(r.noGroup,[]);for(let r of n){const n=t.getField(r.name);((null==n?void 0:n.visible)||C(n))&&(g(r,n),h(r,o),w(r),e.has(r.group)?e.get(r.group).push(r):e.set(r.group,[r]))}return e}function M(n,t,o){return n.filter((n=>{const r=function(n,t){var o;return"string"==typeof n?n:null!==(o=null==n?void 0:n.label)&&void 0!==o?o:t}(n.tab,o);return r===t}))}function S(n){const t=[];for(let o of n.keys())t.push({name:o,fields:n.get(o)});return t}!function(n){n.FROM="from",n.TO="to"}(l||(l={}));export{i as I,l as S,O as a,j as b,p as c,b as d,c as e,f,m as g,s as h,d as i,v as j,a as u}