Liferay.Loader.define("layout-seo-web@2.0.66/js/seo/display_page_templates/components/MappingPanel",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../constants","../hooks/useOnClickOutside"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var l=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),n=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),i=(a("liferay!frontend-js-react-web$prop-types"),_interopRequireWildcard(a("liferay!frontend-js-react-web$react"))),o=a("../constants"),c=_interopRequireDefault(a("../hooks/useOnClickOutside"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}const noop=()=>{},normalizeField=({key:e,label:t})=>({label:t,value:e});var u=function MappingPanel({isActive:e=!1,name:t,fields:a,field:u,fieldTypes:d=[],source:p,onSelect:f=noop,clearSelectionOnClose:s=!1}){const[y,g]=(0,i.useState)(!1),[m,b]=(0,i.useState)((null==u?void 0:u.key)||a[0].key),_=(0,i.useRef)(null);return(0,c.default)([_.current],(()=>{y&&(g(!1),s&&b(a[0].key))})),i.default.createElement("div",{className:"dpt-mapping-panel-wrapper",ref:_},i.default.createElement(l.ClayButtonWithIcon,{className:(0,n.default)("dpt-mapping-btn",{active:e}),displayType:"secondary",monospaced:!0,onClick:()=>{g((e=>!e))},symbol:"bolt",title:Liferay.Language.get("map")}),y&&i.default.createElement("div",{className:"dpt-mapping-panel popover popover-scrollable",onClick:e=>e.stopPropagation()},i.default.createElement("div",{className:"popover-body"},i.default.createElement(r.default.Group,{small:!0},i.default.createElement("label",{htmlFor:"".concat(t,"_mappingSelectorSource")},Liferay.Language.get("source")),i.default.createElement(r.ClayInput,{id:"".concat(t,"_mappingSelectorSource"),readOnly:!0,value:p.initialValue})),i.default.createElement(r.default.Group,{small:!0},i.default.createElement("label",{htmlFor:"".concat(t,"_mappingSelectorFieldSelect")},Liferay.Language.get("field")),i.default.createElement(r.ClaySelectWithOption,{id:"".concat(t,"_mappingSelectorFieldSelect"),onChange:e=>{const{value:t}=e.target,l=a.find((({key:e})=>e===t));b(l.key)},options:a.map(normalizeField),value:m})),i.default.createElement(l.default,{block:!0,disabled:(null==u?void 0:u.key)===m,displayType:"primary",onClick:()=>{const e=a.find((({key:e})=>e===m));f({field:e,source:p})}},d.includes(o.FIELD_TYPES.TEXT)?Liferay.Language.get("add-field"):Liferay.Language.get("map-content")))))};t.default=u}}));
//# sourceMappingURL=MappingPanel.js.map