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