import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{C as t,E as n,U as r,V as i,Y as a,Z as o,_ as s,at as c,k as l,lt as u,o as d,ot as f,p,tt as m,v as h,w as g,x as _,y as v,z as y}from"./vue-vendor-BesOWAOD.js";import{B as b,I as x,L as S,T as C,h as w}from"./naive-ui-D5Qi7mR8.js";import{t as T}from"../index.js";import{t as E}from"./form-vendor-BQ0UzIdB.js";l();var D={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 1024 1024`},O=[h(`path`,{d:`M909.3 506.3L781.7 405.6a7.23 7.23 0 0 0-11.7 5.7V476H548V254h64.8c6 0 9.4-7 5.7-11.7L517.7 114.7a7.14 7.14 0 0 0-11.3 0L405.6 242.3a7.23 7.23 0 0 0 5.7 11.7H476v222H254v-64.8c0-6-7-9.4-11.7-5.7L114.7 506.3a7.14 7.14 0 0 0 0 11.3l127.5 100.8c4.7 3.7 11.7.4 11.7-5.7V548h222v222h-64.8c-6 0-9.4 7-5.7 11.7l100.8 127.5c2.9 3.7 8.5 3.7 11.3 0l100.8-127.5c3.7-4.7.4-11.7-5.7-11.7H548V548h222v64.8c0 6 7 9.4 11.7 5.7l127.5-100.8a7.3 7.3 0 0 0 .1-11.4z`,fill:`currentColor`},null,-1)],k=n({name:`DragOutlined`,render:function(e,t){return i(),_(`svg`,D,O)}});l(),o(),f();var A=e(E(),1),j={key:1,class:`dynamic-form`},M={class:`dynamic-form-item list-group-item`},N=n({__name:`index`,props:{list:{type:Object},options:{type:Object},title:{type:String,default:``},draggable:{type:Boolean,default:!1}},setup(e){let{t:n}=d(),o=e,l=m(!0);y(()=>{window.addEventListener(`resize`,()=>{l.value=window.innerWidth>768})});let f=(e=0)=>{e===0?o.list?.push(JSON.parse(JSON.stringify(D.value))):o.list?.splice(e+1,0,JSON.parse(JSON.stringify(D.value)))},E=e=>{o.list?.splice(e,1)},D=s(()=>{let e={};return o.options?.forEach(t=>{e[t.id]=t.sdt}),e});return(o,s)=>{let d=S,m=b,y=w,D=x;return!e.list||e.list?.length===0?(i(),v(d,{key:0,type:`primary`,secondary:``,round:``,onClick:s[0]||=e=>f(0)},{default:a(()=>[t(u(c(n)(`add a line {msg}`,{msg:e.title})),1)]),_:1})):(i(),_(`div`,j,[e.draggable?(i(),_(p,{key:0},[g(m,{class:`mtb10`,"show-icon":``,type:`info`},{default:a(()=>[t(u(c(n)(`tip: long press the drag icon after each column option to drag up and down to change the order`)),1)]),_:1}),g(c(A.default),{list:e.list,"item-key":`id`,tag:`transition-group`,"component-data":{tag:`ul`,type:`transition-group`},animation:200,handle:`.draggable-handle`},{item:a(r=>[h(`div`,M,[g(D,null,{default:a(()=>[g(T,{data:e.list[r.index],options:e.options,inline:l.value},{actions:a(()=>[g(y,null,{default:a(()=>[g(d,{title:c(n)(`drag and drop to change the order`),class:`draggable-handle mr10`,type:`default`,round:``},{default:a(()=>[g(c(C),null,{default:a(()=>[g(c(k))]),_:1})]),_:1},8,[`title`]),g(d,{class:`mr10`,type:`success`,secondary:``,round:``,onClick:e=>f(r.index)},{default:a(()=>[t(u(c(n)(`add {msg}`,{msg:e.title})),1)]),_:1},8,[`onClick`]),g(d,{class:`mr10`,type:`error`,secondary:``,round:``,onClick:e=>E(r.index)},{default:a(()=>[t(u(c(n)(`delete`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),_:2},1032,[`data`,`options`,`inline`])]),_:2},1024)])]),_:1},8,[`list`])],64)):(i(!0),_(p,{key:1},r(e.list,(r,o)=>(i(),_(`div`,{class:`dynamic-form-item`,key:o},[g(T,{data:e.list[o],options:e.options,inline:l.value},{actions:a(()=>[g(y,null,{default:a(()=>[g(d,{class:`mr10`,type:`success`,secondary:``,round:``,onClick:e=>f(o)},{default:a(()=>[t(u(c(n)(`add {msg}`,{msg:e.title})),1)]),_:1},8,[`onClick`]),g(d,{class:`mr10`,type:`error`,secondary:``,round:``,onClick:e=>E(o)},{default:a(()=>[t(u(c(n)(`delete`)),1)]),_:1},8,[`onClick`])]),_:2},1024)]),_:2},1032,[`data`,`options`,`inline`])]))),128))]))}}});l();var P=n({__name:`index`,props:{list:{type:Object},options:{type:Object},title:{type:String,default:``}},emits:[`update:list`],setup(e,{emit:t}){let n=e,r=t;return y(()=>{n.list||r(`update:list`,[])}),(t,n)=>(i(),v(N,{list:e.list,options:e.options,title:e.title},null,8,[`list`,`options`,`title`]))}});export{P as default};