Liferay.Loader.define("data-engine-taglib@3.3.50/data_layout_builder/js/utils/settingsForm.es",["module","exports","require","data-engine-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useSettingsContextFilter=function useSettingsContextFilter(e){const{defaultLanguageId:t,editingLanguageId:r}=(0,n.useFormState)(),{disabledProperties:a,disabledTabs:o,unimplementedProperties:s,visibleProperties:l}=(0,n.useConfig)();return(0,i.useMemo)((()=>filterSettingsContext({defaultLanguageId:t,disabledProperties:a,disabledTabs:o,editingLanguageId:r,settingsContext:e,unimplementedProperties:s,visibleProperties:l})),[t,a,o,r,e,s,l])};var n=r("data-engine-js-components-web"),i=r("liferay!frontend-js-react-web$react");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,i=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}const getPredefinedValues=({locale:e,localizedValue:t,options:r})=>{const n=t[e];if(!Array.isArray(n))return n;const i=new Set(r.map((({value:e})=>e)));return n.filter((e=>i.has(e)))},filterSettingsContext=e=>{let{defaultLanguageId:t,disabledProperties:r,disabledTabs:i,editingLanguageId:a,settingsContext:{pages:o},unimplementedProperties:s,visibleProperties:l}=e,d=_objectWithoutProperties(e.settingsContext,["pages"]);const c=new Set([...s,...r]),u=new Set(i),p=o.filter((({title:e})=>!u.has(e))),b=new n.PagesVisitor(p).mapFields((({fieldName:e,instanceId:r,locale:i,localizedValue:o,name:s,options:d,portletNamespace:u,repeatedIndex:p})=>{const getName=()=>(0,n.generateName)(s,{editingLanguageId:a,fieldName:e,instanceId:r,portletNamespace:u,repeatedIndex:p}),b={defaultLanguageId:t,editingLanguageId:a};if(c.has(e))return b.name=getName(),b.visibilityExpression="FALSE",b.visible=!1,b;switch(l.includes(e)&&(b.visibilityExpression="TRUE",b.visible=!0),e){case"dataSourceType":b.name=getName(),b.predefinedValue='["manual"]',s.includes("form_web")||(b.readOnly=!0,b.visibilityExpression="FALSE",b.visible=!1);break;case"ddmDataProviderInstanceId":case"ddmDataProviderInstanceOutput":s.includes("form_web")||(b.visibilityExpression="FALSE",b.visible=!1);break;case"localizable":b.showAsSwitcher=!0;break;case"name":b.readOnly=!0;break;case"predefinedValue":b.localizedValue=_objectSpread(_objectSpread({},o),{},{[i]:getPredefinedValues({locale:i,localizedValue:o,options:d})}),b.name=getName();break;case"repeatable":s.includes("form_web")||(b.name=getName(),b.showMaximumRepetitionsInfo=!1);break;default:b.name=getName()}return b}),!0);return _objectSpread(_objectSpread({},d),{},{pages:b})}}}));
//# sourceMappingURL=settingsForm.es.js.map