import{like as l,or as f,sql as c}from"drizzle-orm";import{transformToSnakeCase as d}from"./utils/transform-to-snake-case.js";const h=["title","summary","tags","key","type"];function p(t,n=h,o={}){if(!t||!t.trim()||!n.length)return;let e=t.trim();return(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1)),{searchableFields:n.map(r=>o[r]||d(r)),value:e}}function C(t,n){if(!n.search)return{sqlBuilder:t,whereCondition:null};const{searchableFields:o,value:e}=n.search,i=o.map(s=>{const a=c.identifier(s);return l(a,`%${e}%`)});let r=null;return i.length===1?r=i[0]:i.length>1&&(r=f(...i)),{sqlBuilder:t,whereCondition:r}}export{h as SEARCHABLE_FIELDS,C as applySearch,p as parseSearch};
