import{L as e,m as o,j as n,A as s,X as t,M as r}from"../../vendor.js";import{useRef as l,useCallback as i,Fragment as a}from"react";import{C as c}from"../../defaults.js";import{E as p}from"../../contexts.js";import{a as d}from"../../hooks.js";import{O as m}from"../Option/index.js";import{D as x}from"../Draggable/index.js";import{D as u}from"../Droppable/index.js";import{E as v}from"../Editable/index.js";import{I as f}from"../Icon/index.js";import{T as j}from"../Text/index.js";import{P as h}from"./Property.js";var k=function(k){var N,y,b,g,D,E=k.element,w=k.parent,C=k.className,I=l(),P=l(),O=d(),T=O.getComponent,A=O.removeElement,L=O.moveElement,M=i((function(){return{element:E,parent:w}}),[E,w]),R=T(E.type)||c,S=(null==R||null===(N=R.render)||void 0===N?void 0:N.call(R,{element:E,component:R,parent:w,builder:O,className:e("oak-element-content-inner",E.className)}))||null,X=(null===(y=R.settings)||void 0===y||null===(b=y.fields)||void 0===b?void 0:o(b).call(b,(function(e){return!0===e.displayable&&(!e.condition||e.condition(E))})))||[];return n.exports.jsx(p.Provider,{value:M(),children:n.exports.jsx(u,{disabled:"row"===E.type,onDrop:function(e,o){null==L||L(e,E,{parent:w,position:o})},children:n.exports.jsx(x,{data:E,disabled:"row"===E.type,children:n.exports.jsxs("div",{ref:P,id:E.id||s(),className:e("oak-element","oak-"+E.type,C),children:[t(g=["row","col"]).call(g,E.type)?n.exports.jsx("div",{className:"oak-inner",children:S}):n.exports.jsxs("div",{className:"oak-inner oak-with-info",children:[n.exports.jsx("div",{className:"oak-element-icon",children:"function"==typeof(null==R?void 0:R.icon)?R.icon({component:R,className:"oak-icons"}):n.exports.jsx(f,{children:null==R?void 0:R.icon})}),n.exports.jsxs("div",{className:"oak-element-info",children:[n.exports.jsx("div",{className:"oak-element-type",children:n.exports.jsx(j,{children:null==R?void 0:R.name})}),n.exports.jsx("div",{className:"oak-element-content",children:S}),X.length>0&&n.exports.jsx("div",{className:"oak-element-props",children:r(X).call(X,(function(e,o){return n.exports.jsxs(a,{children:[n.exports.jsx(h,{field:e}),o<X.length-1&&n.exports.jsx(j,{name:"core.propertySeparator",default:", "})]},o)}))})]})]}),n.exports.jsxs("div",{className:"oak-options",children:[n.exports.jsx(m,{option:{icon:"clear"},className:"oak-remove",onClick:function(e){null==e||e.preventDefault(),A(E,{parent:w})}}),null===(D=R.options)||void 0===D?void 0:r(D).call(D,(function(e,o){var s;return n.exports.jsx(a,{children:null==e||null===(s=e.render)||void 0===s?void 0:s.call(e,{option:e,className:"oak-option",element:E,elementInnerRef:P,parent:w,component:R,builder:O,index:o})},o)})),R.editable&&n.exports.jsx(v,{element:E,component:R,ref:I,children:n.exports.jsx(m,{option:{icon:"edit"},className:"oak-edit",onClick:function(e){var o;null==e||e.preventDefault(),null===(o=I.current)||void 0===o||o.toggle()}})})]})]})})})})};export{k as E};
//# sourceMappingURL=index.js.map
