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