"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),f=require("@aplus-frontend/antdv"),B=require("@aplus-frontend/icon"),O=require("lodash-unified");require("../../../config-provider/index.js");require("../../../hooks/index.js");const A=require("../utils.js"),k=require("../../../hooks/useControllableValue.js"),z=require("../../../config-provider/hooks/use-locale.js"),d=require("../../../config-provider/hooks/use-namespace.js"),E=e.defineComponent({name:"BatchInputGroupPopoverInput",inheritAttrs:!1,__name:"index",props:{_parent:{},onClose:{type:Function},disabled:{type:Boolean},maxNum:{},getPopupContainer:{type:Function},placement:{},value:{},"onUpdate:value":{type:Function}},emits:["update:value"],setup(l,{expose:v,emit:m}){const o=l,g=m,{value:h,updateValue:C}=k.useControllableValue(o,g),u=e.ref(!1),s=e.ref(),i=e.ref(),c=e.ref({left:0,right:0}),b=t=>o._parent||t,{t:x}=z.useLocale();function y(t){const a=t.target.value||"";let n=A.splitValue(a,`
,`,`
`,o.maxNum);if(n=n.replace(/\\n/g,`
`),n!==a){const r=s.value?.$el||s.value;r&&(r.value=n)}C(n)}const N=()=>{if(o.getPopupContainer){const t=o._parent,a=o.getPopupContainer(),n=t?.getBoundingClientRect(),r=a?.getBoundingClientRect();i.value=t?.offsetWidth,c.value.left=(n?.left||0)-(r.left||0),c.value.right=(n?.right||0)-(r.right||0)}};function V(t){N(),o.disabled?u.value=!1:(u.value=t,t&&setTimeout(()=>{s.value?.focus()},200)),!t&&o.onClose?.()}const{b:p,e:q,em:P,bm:I}=d.useNamespace("batch-input-group-popover-input"),{cssVar:$}=d.useNamespace("batch-input-group-popover"),w=e.computed(()=>{const t=o.placement,a=O.isNumber(t)?`${t}px`:t==="left"?`${c.value.left}px`:"unset",n=t==="right"?`${-c.value.right}px`:"unset";return{left:a,right:n}}),R=e.computed(()=>$({...w.value,width:i.value?`${i.value}px`:"100%"}));return v({getOpen:()=>u.value}),(t,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(p)())},[e.createVNode(e.unref(f.Popover),{"overlay-class-name":`${e.unref(q)("popover")} ${t.$attrs.class}`,"get-popup-container":l.getPopupContainer??b,trigger:"click",placement:"bottomLeft",open:u.value,"overlay-style":R.value,onOpenChange:V},{content:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(P)("popover","content"))},[e.createVNode(e.unref(f.Textarea),{ref_key:"textAreaRef",ref:s,placeholder:e.unref(x)("ap.batchInputGroup.popoverInputPlaceholder",{maxNum:l.maxNum+""}),bordered:!1,rows:10,value:e.unref(h),"allow-clear":!1,"auto-size":!1,onInput:y},null,8,["placeholder","value"])],2)]),default:e.withCtx(()=>[e.createVNode(e.unref(B.IconApAdLineScreen),{class:e.normalizeClass([e.unref(p)("trigger-icon"),l.disabled?e.unref(I)("trigger-icon","disabled"):null]),onMousedown:a[0]||(a[0]=e.withModifiers(()=>{},["stop","prevent"]))},null,8,["class"])]),_:1},8,["overlay-class-name","get-popup-container","open","overlay-style"])],2))}});exports.default=E;
