/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{ref as e,computed as t,onMounted as a,onBeforeUnmount as n,openBlock as o,createElementBlock as r,Fragment as i,createVNode as l,unref as u,withCtx as s,createElementVNode as d,normalizeStyle as c,createTextVNode as f,toDisplayString as p,createBlock as m,createCommentVNode as y,renderSlot as v}from"vue";import{useLocale as g}from"../../../hooks/useLocale.js";import{GscForm as h}from"../../../Form/index.js";import{GscButton as w}from"../../../Button/index.js";import './QueryBar.css';/* empty css             */import x from"../../../_virtual/_plugin-vue_export-helper.js";const b={class:"actions-left"},k={class:"actions-right flex items-center gap-2"},_=/* @__PURE__ */x({__name:"QueryBar",props:{schema:{type:Array,default:()=>[]},modelValue:{type:Object,default:()=>({})},loading:{type:Boolean,default:!1}},emits:["update:modelValue","search","reset"],setup(x,{emit:_}){const B=x,V=_,{t:j}=g(),C=e(!0),K=e(null);const q=t(()=>function(e=[]){return(e||[]).filter(Boolean).map(e=>({key:e.key,label:e.label??e.title??e.key,type:e.type??"text",placeholder:e.placeholder,options:e.options,span:e.span,startKey:e.startKey,endKey:e.endKey,showTime:e.showTime||e.withTime||!1,defaultValue:e.defaultValue})).filter(e=>"dateRange"===e.type||"dateTimeRange"===e.type?!(!e.startKey||!e.endKey):!!e.key)}(B.schema)),R=e("undefined"!=typeof window?window.innerWidth:1200);function T(){"undefined"!=typeof window&&(R.value=window.innerWidth)}a(()=>{"undefined"!=typeof window&&window.addEventListener("resize",T)}),n(()=>{"undefined"!=typeof window&&window.removeEventListener("resize",T)});const I=t(()=>{const e=R.value||1200;return e>=3840?8:e>=2560?7:e>=1920?6:e>=1536?5:e>=1280?4:e>=1024?3:e>=768?2:1});function L(e){if(!e)return 1;if("dateRange"===e.type)return 2;const t=Number(e.span||0);return t>=1?t:1}const M=t(()=>{const e=I.value,t=function(e,t){let a=1,n=0;for(const o of e){const e=Math.min(L(o),t);n+e>t?(a+=1,n=e):n+=e}return a}(q.value,e);return t>2}),z=t(()=>{const e=q.value,t=I.value;if(!M.value)return e;if(!C.value)return e;const a=[];let n=1,o=0;for(const r of e){const e=Math.min(L(r),t);if(o+e>t?(n+=1,o=e):o+=e,n>2)break;a.push(r)}return a}),E=t(()=>{const e=I.value||1;if(e<=2)return{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"8px",alignItems:"center"};return{gridColumn:`${Math.max(1,e-1)} / span 2`,display:"flex",justifyContent:"flex-end",gap:"6px",alignItems:"center"}});function F(){try{K.value?.submit()}catch{}}function Q(){try{K.value?.reset()}catch{}}return(e,t)=>(o(),r(i,null,[l(u(h),{ref_key:"innerForm",ref:K,schema:z.value,"model-value":B.modelValue,"show-actions":!1,"onUpdate:modelValue":t[1]||(t[1]=e=>V("update:modelValue",e)),onSubmit:t[2]||(t[2]=e=>{V("update:modelValue",e),V("search",e)}),onReset:t[3]||(t[3]=e=>{V("update:modelValue",e),V("reset",e)})},{actions:s(()=>[d("div",{class:"gsc-form-actions-unified",style:c(E.value)},[d("div",b,[l(u(w),{variant:"default",disabled:x.loading,onClick:Q},{default:s(()=>[f(p(u(j)("gsc.grid.queryBar.action.reset")),1)]),_:1},8,["disabled"])]),d("div",k,[l(u(w),{variant:"primary",disabled:x.loading,onClick:F},{default:s(()=>[f(p(u(j)("gsc.grid.queryBar.action.search")),1)]),_:1},8,["disabled"]),M.value?(o(),m(u(w),{key:0,variant:"link",onClick:t[0]||(t[0]=e=>C.value=!C.value)},{default:s(()=>[f(p(C.value?u(j)("gsc.grid.queryBar.action.expand"):u(j)("gsc.grid.queryBar.action.collapse")),1)]),_:1})):y("",!0)])],4)]),_:1},8,["schema","model-value"]),v(e.$slots,"extra",{},void 0,!0)],64))}},[["__scopeId","data-v-b9257126"]]);export{_ as default};