import{c as M}from"./createLucideIcon-PnqOq2iY.js";import{r as c,j as i,s as y}from"./index-C-9v46qO.js";import{e as $,b as P,a as H,h as L,c as q}from"./index-WGdLp8p1.js";import{u as j}from"./button-B-2orO_-.js";import{u as A}from"./index-DCqYjSTn.js";import{c as S}from"./utils-BQHNewu7.js";const z=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],ee=M("upload",z);var b="Switch",[D]=q(b),[O,F]=D(b),E=c.forwardRef((e,o)=>{const{__scopeSwitch:t,name:s,checked:r,defaultChecked:d,required:a,disabled:n,value:u="on",onCheckedChange:g,form:p,...w}=e,[l,f]=c.useState(null),v=j(o,m=>f(m)),k=c.useRef(!1),x=l?p||!!l.closest("form"):!0,[h,T]=$({prop:r,defaultProp:d??!1,onChange:g,caller:b});return i.jsxs(O,{scope:t,checked:h,disabled:n,children:[i.jsx(P.button,{type:"button",role:"switch","aria-checked":h,"aria-required":a,"data-state":U(h),"data-disabled":n?"":void 0,disabled:n,value:u,...w,ref:v,onClick:H(e.onClick,m=>{T(B=>!B),x&&(k.current=m.isPropagationStopped(),k.current||m.stopPropagation())})}),x&&i.jsx(_,{control:l,bubbles:!k.current,name:s,value:u,checked:h,required:a,disabled:n,form:p,style:{transform:"translateX(-100%)"}})]})});E.displayName=b;var N="SwitchThumb",R=c.forwardRef((e,o)=>{const{__scopeSwitch:t,...s}=e,r=F(N,t);return i.jsx(P.span,{"data-state":U(r.checked),"data-disabled":r.disabled?"":void 0,...s,ref:o})});R.displayName=N;var K="SwitchBubbleInput",_=c.forwardRef(({__scopeSwitch:e,control:o,checked:t,bubbles:s=!0,...r},d)=>{const a=c.useRef(null),n=j(a,d),u=A(t),g=L(o);return c.useEffect(()=>{const p=a.current;if(!p)return;const w=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&f){const v=new Event("click",{bubbles:s});f.call(p,t),p.dispatchEvent(v)}},[u,t,s]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:n,style:{...r.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});_.displayName=K;function U(e){return e?"checked":"unchecked"}var I=E,W=R;const X=c.forwardRef(({className:e,...o},t)=>i.jsx(I,{className:S("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...o,ref:t,children:i.jsx(W,{className:S("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));X.displayName=I.displayName;const C="product-images";async function te(e,o="products"){const t=e.name.split(".").pop()?.toLowerCase()||"jpg",s=/^(jpg|jpeg|png|webp|gif|avif|svg|ico)$/.test(t)?t:"jpg",r=`${crypto.randomUUID()}.${s}`,d=`${o}/${r}`,{error:a}=await y.storage.from(C).upload(d,e,{cacheControl:"3600",upsert:!1,contentType:e.type||void 0});if(a)throw new Error(a.message);const{data:n}=y.storage.from(C).getPublicUrl(d);return n.publicUrl}function oe(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}export{X as S,ee as U,oe as s,te as u};
