import{b as B,j as o,p as a,F as g,l as D,k as m,i as u,G as b,u as i,D as f,J as h,q as d,s as x,g as C,K as y,a as E,f as S,A as P}from"./vue-Cm77DuTi.js";import{af as I,ag as T,b as l,M as V,ah as X,g as j,_ as F}from"./app-QjDgb7aF.js";import{v as G}from"./v4-Dnyct6Ft.js";const L={class:"vjoppmmu"},R={tabindex:"-1"},q=["value"],z={class:"customize-container"},J=["onClick"],K=["onClick","aria-label"],O={class:"handle"},Q=B({__name:"MkWidgets",props:{widgets:{},edit:{type:Boolean}},emits:["updateWidgets","addWidget","removeWidget","updateWidget","exit"],setup(v,{emit:$}){const A=v,p=$,k={},w=s=>{k[s].configure()},r=E(null),M=()=>{r.value!=null&&(p("addWidget",{name:r.value,id:G(),data:{}}),r.value=null)},N=s=>{p("removeWidget",s)},W=(s,t)=>{p("updateWidget",{id:s,data:t})},_=S({get:()=>A.widgets,set:s=>{p("updateWidgets",s)}});function U(s,t){const c=e=>{if(e.tagName==="A")return!0;if(e.parentElement)return c(e.parentElement)};c(t.target)||["INPUT","TEXTAREA","IMG","VIDEO","CANVAS"].includes(t.target.tagName)||t.target.attributes.contenteditable||window.getSelection()?.toString()===""&&j([{type:"label",text:l.t(`_widgets.${s.name}`)},{icon:"ph-gear-six ph-bold ph-lg",text:l.ts.settings,action:()=>{w(s.id)}}],t)}return(s,t)=>{const c=P("focus");return o(),a("div",L,[v.edit?(o(),a(g,{key:0},[D((o(),a("header",R,[m(I,{modelValue:r.value,"onUpdate:modelValue":t[0]||(t[0]=e=>r.value=e),style:{"margin-bottom":"var(--margin)"},class:"mk-widget-select"},{label:u(()=>[h(f(i(l).ts.selectWidget),1)]),default:u(()=>[(o(!0),a(g,null,b(i(T),e=>(o(),a("option",{key:e,value:e},f(i(l).t(`_widgets.${e}`)),9,q))),128))]),_:1},8,["modelValue"]),m(V,{inline:"",primary:"",class:"mk-widget-add",onClick:M},{default:u(()=>[t[3]||(t[3]=d("i",{class:"ph-plus ph-bold ph-lg"},null,-1)),h(" "+f(i(l).ts.add),1)]),_:1}),m(V,{inline:"",onClick:t[1]||(t[1]=e=>s.$emit("exit"))},{default:u(()=>[h(f(i(l).ts.close),1)]),_:1})])),[[c]]),m(i(X),{modelValue:_.value,"onUpdate:modelValue":t[2]||(t[2]=e=>_.value=e),handle:".handle",animation:"150"},{default:u(()=>[(o(!0),a(g,null,b(_.value,e=>(o(),a("div",{key:e.id},[d("div",z,[d("button",{class:"config _button",onClick:x(n=>w(e.id),["prevent","stop"])},[...t[4]||(t[4]=[d("i",{class:"ph-gear-six ph-bold ph-lg"},null,-1)])],8,J),d("button",{class:"remove _button",onClick:x(n=>N(e),["prevent","stop"]),"aria-label":i(l).t("close")},[...t[5]||(t[5]=[d("i",{class:"ph-x ph-bold ph-lg"},null,-1)])],8,K),d("div",O,[(o(),C(y(`mkw-${e.name}`),{ref_for:!0,ref:n=>k[e.id]=n,class:"widget",widget:e,onUpdateProps:n=>W(e.id,n)},null,40,["widget","onUpdateProps"]))])])]))),128))]),_:1},8,["modelValue"])],64)):(o(!0),a(g,{key:1},b(v.widgets,e=>(o(),C(y(`mkw-${e.name}`),{key:e.id,ref_for:!0,ref:n=>k[e.id]=n,class:"widget",widget:e,onUpdateProps:n=>W(e.id,n),onContextmenu:x(n=>U(e,n),["stop"])},null,40,["widget","onUpdateProps","onContextmenu"]))),128))])}}}),ee=F(Q,[["__scopeId","data-v-7d8cede4"]]);export{ee as X};
//# sourceMappingURL=MkWidgets-D7JOo9SI.js.map
