"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),h=require("@aplus-frontend/antdv"),k=require("vuedraggable");require("../../../../config-provider/index.js");require("../sortable/index.vue.js");const q=require("./context.js"),E=require("../../../../config-provider/hooks/use-namespace.js"),z=require("../../../../config-provider/hooks/use-locale.js"),C=require("../sortable/index.vue2.js"),D={key:0},M={key:1},R={key:2},F=e.defineComponent({__name:"index",props:{value:{},onReset:{type:Function}},emits:["update:value"],setup(y,{emit:_}){const l=e.ref([]),r=e.ref([]),u=e.ref([]),{b:i}=E.useNamespace("ap-column-setting-sorter"),{t:f}=z.useLocale(),d=y,x=_;q.useProvideSorterMethods({fixedToLeft:V,fixedToRight:w,unFixed:B});function N(t,n){const o=n[0].findIndex(a=>a.key===t.key);if(~o)n[0].splice(o,1);else{const a=n[1].findIndex(c=>c.key===t.key);n[1].splice(a,1)}}function m(t,n){const o=[...e.unref(l.value)],a=[...e.unref(u.value)],c=[...e.unref(r.value)],v={left:{target:o,search:[c,a]},right:{target:a,search:[c,o]},normal:{target:c,search:[o,a]}}[n];return n==="right"?v.target.unshift(t):v.target.push(t),N(t,v.search),[...o,...c,...a]}function V(t){const n=m(t,"left");s(n)}function w(t){const n=m(t,"right");s(n)}function B(t){const n=m(t,"normal");s(n)}function p(t){return t.children?.length?t.children.some(n=>n.show):t.show}function g(t,n){t.value?t.value.push(n):t.value=[n]}const T=e.computed(()=>{let t=0;function n(o){for(const a of o)a.children?.length?n(a.children):a.show&&(t+=1)}return n(d.value),t});function L(t){s([...t,...e.unref(r),...e.unref(u)])}function S(t){s([...e.unref(l),...t,...e.unref(u)])}function b(t){s([...e.unref(l),...e.unref(r),...t])}function s(t){x("update:value",t)}return e.watch(()=>d.value,t=>{if(t){l.value=[],r.value=[],u.value=[];for(const n of t)n.fixed==="left"?g(l,n):n.fixed==="right"?g(u,n):g(r,n)}},{immediate:!0}),(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(i)())},[e.createVNode(e.unref(h.Flex),{class:e.normalizeClass(e.unref(i)("header")),align:"center",justify:"space-between"},{default:e.withCtx(()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("header-title")),style:{flex:"1"}},e.toDisplayString(e.unref(f)("ap.apTable.setting.selectCount",{count:T.value})),3),e.createVNode(e.unref(h.Typography).Link,{onClick:d.onReset},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(f)("ap.apTable.setting.reset")),1)]),_:1},8,["onClick"])]),_:1},8,["class"]),e.createVNode(e.unref(h.Divider),{style:{margin:"0px"}}),e.createElementVNode("div",{class:e.normalizeClass(e.unref(i)("content"))},[l.value.length?(e.openBlock(),e.createElementBlock("div",D,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.fixToLeft")),3),e.createVNode(e.unref(k),{"model-value":l.value,"item-key":"key","onUpdate:modelValue":L},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0),r.value.length?(e.openBlock(),e.createElementBlock("div",M,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.unFixed")),3),e.createVNode(e.unref(k),{"model-value":r.value,"item-key":"key","onUpdate:modelValue":S},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0),u.value.length?(e.openBlock(),e.createElementBlock("div",R,[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i)("section-title"))},e.toDisplayString(e.unref(f)("ap.apTable.setting.fixToRight")),3),e.createVNode(e.unref(k),{"model-value":u.value,"item-key":"key","onUpdate:modelValue":b},{item:e.withCtx(({element:o})=>[p(o)?(e.openBlock(),e.createBlock(C.default,{key:0,value:o},null,8,["value"])):e.createCommentVNode("",!0)]),_:1},8,["model-value"])])):e.createCommentVNode("",!0)],2)],2))}});exports.default=F;
