"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"),_=require("lodash-unified");require("../../../config-provider/index.js");require("../../../hooks/index.js");const w=require("../utils.js"),A=require("../../../hooks/useControllableValue.js"),O=require("../../../config-provider/hooks/use-locale.js"),d=require("../../../config-provider/hooks/use-namespace.js"),k=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,{emit:v}){const a=l,m=v,{value:g,updateValue:h}=A.useControllableValue(a,m),s=e.ref(!1),c=e.ref(),i=e.ref(),u=e.ref({left:0,right:0}),C=t=>a._parent||t,{t:b}=O.useLocale();function x(t){const o=t.target.value||"";let n=w.splitValue(o,`
,`,`
`,a.maxNum);if(n=n.replace(/\\n/g,`
`),n!==o){const r=c.value?.$el||c.value;r&&(r.value=n)}h(n)}const y=()=>{if(a.getPopupContainer){const t=a._parent,o=a.getPopupContainer(),n=t?.getBoundingClientRect(),r=o?.getBoundingClientRect();i.value=t?.offsetWidth,u.value.left=(n?.left||0)-(r.left||0),u.value.right=(n?.right||0)-(r.right||0)}};function N(t){y(),a.disabled?s.value=!1:s.value=t,!t&&a.onClose?.()}const{b:p,e:V,em:q,bm:P}=d.useNamespace("batch-input-group-popover-input"),{cssVar:I}=d.useNamespace("batch-input-group-popover"),$=e.computed(()=>{const t=a.placement,o=_.isNumber(t)?`${t}px`:t==="left"?`${u.value.left}px`:"unset",n=t==="right"?`${-u.value.right}px`:"unset";return{left:o,right:n}}),R=e.computed(()=>I({...$.value,width:i.value?`${i.value}px`:"100%"}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(p)())},[e.createVNode(e.unref(f.Popover),{"overlay-class-name":`${e.unref(V)("popover")} ${t.$attrs.class}`,"get-popup-container":l.getPopupContainer??C,trigger:"click",placement:"bottomLeft",open:s.value,"overlay-style":R.value,onOpenChange:N},{content:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(q)("popover","content"))},[e.createVNode(e.unref(f.Textarea),{ref_key:"textAreaRef",ref:c,placeholder:e.unref(b)("ap.batchInputGroup.popoverInputPlaceholder",{maxNum:l.maxNum+""}),bordered:!1,rows:10,value:e.unref(g),"allow-clear":!1,"auto-size":!1,onInput:x},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(P)("trigger-icon","disabled"):null])},null,8,["class"])]),_:1},8,["overlay-class-name","get-popup-container","open","overlay-style"])],2))}});exports.default=k;
