import{a as e}from"./vendor-CSmrTISS.js";const t=e=>e.trim();function r(e){return"function"==typeof e?e():e??""}function a(a={}){const[o,i]=e(!1),[n,l]=e(r(a.initialValue)),[u,s]=e("");return{open:o,setOpen:i,value:n,setValue:l,error:u,setError:s,openWith:e=>{l("string"==typeof e?e:r(a.initialValue)),s(""),i(!0)},close:()=>{i(!1),s("")},reset:()=>{l(r(a.initialValue)),s("")},getValidValue:()=>{const e=a.formatter??t,r=a.requireValue??!0,o=e(n());let i;return a.validate&&(i=a.validate(o)),i||!r||o||(i=a.emptyMessage??""),i?(s(i),{ok:!1,error:i}):(s(""),{ok:!0,value:o})}}}export{a as c};
