UNPKG

flexium

Version:

A lightweight, signals-based UI framework with cross-platform renderers

2 lines 23.8 kB
import {d,b,c,e}from'./chunk-Z7JNAX53.mjs';function ne(e){let t={},n=[];return e.x!==void 0&&n.push(`translateX(${e.x}px)`),e.y!==void 0&&n.push(`translateY(${e.y}px)`),e.scale!==void 0?n.push(`scale(${e.scale})`):(e.scaleX!==void 0&&n.push(`scaleX(${e.scaleX})`),e.scaleY!==void 0&&n.push(`scaleY(${e.scaleY})`)),e.rotate!==void 0&&n.push(`rotate(${e.rotate}deg)`),n.length>0&&(t.transform=n.join(" ")),e.opacity!==void 0&&(t.opacity=e.opacity.toString()),e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height!==void 0&&(t.height=typeof e.height=="number"?`${e.height}px`:e.height),t}function me(e){let t=e.tension??170,n=e.friction??26,s=e.mass??1,u=t,o=n,l=s,d=Math.sqrt(u/l),f=o/(2*Math.sqrt(u*l)),h=4.6/(f*d)*1e3;return f<1?{duration:h,easing:"cubic-bezier(0.34, 1.56, 0.64, 1)"}:{duration:h,easing:"cubic-bezier(0.22, 1, 0.36, 1)"}}var Q=class{constructor(t){this.animation=null;this.resizeObserver=null;this.previousSize=null;this.element=t;}animate(t){let{initial:n,animate:s,duration:u=300,spring:o,easing:l="ease-out",delay:d=0}=t;if(!s)return;if(this.cancel(),n){let A=ne(n);Object.assign(this.element.style,{transform:A.transform||"",opacity:A.opacity||"",width:A.width||"",height:A.height||""});}let f=n?ne(n):{},h=ne(s),b=u,E=l;if(o){let A=me(o);b=A.duration,E=A.easing;}this.animation=this.element.animate([f,h],{duration:b,easing:E,delay:d,fill:"forwards"}),t.onAnimationStart&&t.onAnimationStart(),this.animation.onfinish=()=>{t.onAnimationComplete&&t.onAnimationComplete();};}async animateExit(t,n=300,s="ease-in"){this.cancel();let u=ne(t);this.animation=this.element.animate([{},u],{duration:n,easing:s,fill:"forwards"}),await this.animation.finished;}enableLayoutAnimation(t=300,n="ease-out"){let s=this.element.getBoundingClientRect();this.previousSize={width:s.width,height:s.height},this.resizeObserver=new ResizeObserver(u=>{for(let o of u){if(!this.previousSize){this.previousSize={width:o.contentRect.width,height:o.contentRect.height};return}let l=o.contentRect.width,d=o.contentRect.height;(l!==this.previousSize.width||d!==this.previousSize.height)&&(this.cancel(),this.animation=this.element.animate([{width:`${this.previousSize.width}px`,height:`${this.previousSize.height}px`},{width:`${l}px`,height:`${d}px`}],{duration:t,easing:n,fill:"forwards"}),this.previousSize={width:l,height:d});}}),this.resizeObserver.observe(this.element);}disableLayoutAnimation(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null,this.previousSize=null);}cancel(){this.animation&&(this.animation.cancel(),this.animation=null);}dispose(){this.cancel(),this.disableLayoutAnimation();}};function ge(e){let t=e.element||document.createElement(e.tagName||"div"),n=new Q(t);return n.animate(e),{element:t,controller:n,update:s=>{n.animate(s);},dispose:()=>{n.dispose();}}}function he(e,t){let n=new Q(e),s=d(()=>{let u=t.value;n.animate(u);});return {controller:n,dispose:()=>{s(),n.dispose();}}}function be(e$1={}){let{initialValues:t={},validation:n={},validateOnChange:s=true,validateOnBlur:u=true,onSubmit:o}=e$1,l=b(t),d=b(false),f=b(new Set),h=b(new Set),b$1=new Map,E=c(()=>{let c={};for(let[y,m]of b$1)c[y]=m.error.value;return c}),A=c(()=>Object.values(E.value).every(y=>y===null)),H=c(()=>h.value.size>0);async function V(c){let y=n[c];if(!y)return null;let m=l.value[c],i=Array.isArray(y)?y:[y];for(let T of i)try{let C=await T(m,l.value);if(C===!1||typeof C=="string")return typeof C=="string"?C:"Invalid value"}catch(C){return console.error(`Validation error for field ${c}:`,C),"Validation error"}return null}async function L(){let c=Object.keys(n).map(async m=>{let i=await V(m);return b$1.get(m)&&F(m),i===null});return (await Promise.all(c)).every(m=>m)}function D(c$1){if(b$1.has(c$1))return b$1.get(c$1);let y=b(l.value[c$1]),m=b(f.value.has(c$1)),i=b(h.value.has(c$1)),T=b(false),C=c(()=>{if(!m.value)return null;let k=n[c$1];if(!k)return null;let z=y.value,r=Array.isArray(k)?k:[k];for(let $ of r)try{let B=$(z,l.value);if(B instanceof Promise)continue;if(B===!1||typeof B=="string")return typeof B=="string"?B:"Invalid value"}catch(B){return console.error(`Validation error for field ${c$1}:`,B),"Validation error"}return null}),w={value:y,error:C,touched:m,dirty:i,validating:T};return b$1.set(c$1,w),w}function O(c,y){e(()=>{l.set({...l.value,[c]:y});let m=D(c);m.value.set(y),m.dirty.set(true);let i=new Set(h.value);i.add(c),h.set(i),s&&m.touched.value&&V(c).then(T=>{F(c);});});}function F(c,y){let m=b$1.get(c);m&&m.touched.set(true);}function R(c,y){D(c).touched.set(y);let i=new Set(f.value);y?i.add(c):i.delete(c),f.set(i),y&&u&&V(c).then(T=>{F(c);});}async function X(c){if(c&&c.preventDefault(),e(()=>{let m=new Set(Object.keys(n));for(let i of m)R(i,true);}),!!await L()&&o){d.set(true);try{await o(l.value);}catch(m){console.error("Form submission error:",m);}finally{d.set(false);}}}function j(c){e(()=>{l.set(c||t),f.set(new Set),h.set(new Set),d.set(false);for(let[y,m]of b$1)m.value.set(l.value[y]),m.touched.set(false),m.dirty.set(false),m.validating.set(false);});}function K(){b$1.clear();}return {state:{data:l,errors:E,isValid:A,isSubmitting:d,isDirty:H,touchedFields:f,dirtyFields:h},fields:b$1,getField:D,setFieldValue:O,setFieldError:F,setFieldTouched:R,validateField:V,validateForm:L,handleSubmit:X,reset:j,dispose:K}}function re(e){let{type:t="text",name:n,value:s,placeholder:u,disabled:o=false,required:l=false,readonly:d$1=false,autoComplete:f,autoFocus:h=false,maxLength:b,minLength:E,min:A,max:H,step:V,pattern:L,multiple:D=false,accept:O,error:F,touched:R,className:X="",style:j,id:K,ariaLabel:c,ariaDescribedby:y,ariaInvalid:m,onInput:i,onChange:T,onBlur:C,onFocus:w,onKeyDown:k,onKeyUp:z}=e,r=document.createElement("input");r.type=t,n&&(r.name=n),K&&(r.id=K),u&&(r.placeholder=u),f&&(r.autocomplete=f),L&&(r.pattern=L),O&&(r.accept=O),r.disabled=o,r.required=l,r.readOnly=d$1,r.autofocus=h,r.multiple=D,b!==void 0&&(r.maxLength=b),E!==void 0&&(r.minLength=E),A!==void 0&&(r.min=String(A)),H!==void 0&&(r.max=String(H)),V!==void 0&&(r.step=String(V)),X&&(r.className=X),j&&Object.assign(r.style,j),c&&r.setAttribute("aria-label",c),y&&r.setAttribute("aria-describedby",y);let $=[];if(s){let g=d(()=>{let P=s.value;r.value!==String(P)&&(r.value=String(P));});$.push(g);let W=P=>{let v=t==="number"?parseFloat(r.value)||0:r.value;s.set(v),i&&i(r.value,P);},a=P=>{T&&T(r.value,P);};r.addEventListener("input",W),r.addEventListener("change",a),$.push(()=>{r.removeEventListener("input",W),r.removeEventListener("change",a);});}else {if(i){let g=W=>i(r.value,W);r.addEventListener("input",g),$.push(()=>r.removeEventListener("input",g));}if(T){let g=W=>T(r.value,W);r.addEventListener("change",g),$.push(()=>r.removeEventListener("change",g));}}if(F&&R){let g=d(()=>{F.value&&R.value?(r.setAttribute("aria-invalid","true"),r.classList.add("input-error")):(r.removeAttribute("aria-invalid"),r.classList.remove("input-error"));});$.push(g);}else m!==void 0&&r.setAttribute("aria-invalid",String(m));if(C||R){let g=W=>{R&&R.set(true),C&&C(W);};r.addEventListener("blur",g),$.push(()=>r.removeEventListener("blur",g));}w&&(r.addEventListener("focus",w),$.push(()=>r.removeEventListener("focus",w))),k&&(r.addEventListener("keydown",k),$.push(()=>r.removeEventListener("keydown",k))),z&&(r.addEventListener("keyup",z),$.push(()=>r.removeEventListener("keyup",z)));function B(g){g.type!==void 0&&(r.type=g.type),g.name!==void 0&&(r.name=g.name),g.placeholder!==void 0&&(r.placeholder=g.placeholder),g.disabled!==void 0&&(r.disabled=g.disabled),g.required!==void 0&&(r.required=g.required),g.readonly!==void 0&&(r.readOnly=g.readonly),g.className!==void 0&&(r.className=g.className),g.style&&Object.assign(r.style,g.style),g.ariaLabel!==void 0&&r.setAttribute("aria-label",g.ariaLabel);}function U(){$.forEach(g=>g());}return {element:r,update:B,dispose:U}}function ve(e){let{label:t,helperText:n,error:s,showError:u=true,id:o,...l}=e,d$1=o||`input-${Math.random().toString(36).substr(2,9)}`,f=`${d$1}-error`,h=`${d$1}-helper`,b=document.createElement("div");b.className="input-field";let E=null;t&&(E=document.createElement("label"),E.htmlFor=d$1,E.textContent=t,E.className="input-label",b.appendChild(E));let{element:A,dispose:H}=re({...l,id:d$1,error:s,ariaDescribedby:n?h:f});b.appendChild(A);let V=null;n&&(V=document.createElement("div"),V.id=h,V.className="input-helper",V.textContent=n,b.appendChild(V));let L=null,D=[H];if(s&&u){L=document.createElement("div"),L.id=f,L.className="input-error-message",L.setAttribute("role","alert"),L.setAttribute("aria-live","polite"),b.appendChild(L);let F=d(()=>{let R=s.value;R&&L?(L.textContent=R,L.style.display="block"):L&&(L.textContent="",L.style.display="none");});D.push(F);}function O(){D.forEach(F=>F());}return {element:b,input:A,dispose:O}}function oe(e){let{type:t="button",variant:n="primary",size:s="md",disabled:u=false,loading:o=false,fullWidth:l=false,children:d$1,leftIcon:f,rightIcon:h,loadingText:b$1="Loading...",className:E="",style:A,id:H,role:V,ariaLabel:L,ariaDescribedby:D,ariaExpanded:O,ariaPressed:F,ariaControls:R,onPress:X,onPressStart:j,onPressEnd:K,onFocus:c,onBlur:y,onKeyDown:m}=e,i=document.createElement("button");i.type=t,H&&(i.id=H),V&&i.setAttribute("role",V);let T=["button",`button-${n}`,`button-${s}`];l&&T.push("button-full-width"),E&&T.push(E),i.className=T.join(" "),A&&Object.assign(i.style,A),L&&i.setAttribute("aria-label",L),D&&i.setAttribute("aria-describedby",D),O!==void 0&&i.setAttribute("aria-expanded",String(O)),F!==void 0&&i.setAttribute("aria-pressed",String(F)),R&&i.setAttribute("aria-controls",R);let C=[],w=document.createElement("span");w.className="button-content";let k=document.createElement("span");k.className="button-spinner",k.setAttribute("aria-hidden","true"),k.style.display="none",i.appendChild(k),f&&(f.className="button-icon button-icon-left",w.appendChild(f));let z=document.createElement("span");z.className="button-text",typeof d$1=="string"?z.textContent=d$1:d$1 instanceof HTMLElement?z.appendChild(d$1):Array.isArray(d$1)&&d$1.forEach(a=>z.appendChild(a)),w.appendChild(z),h&&(h.className="button-icon button-icon-right",w.appendChild(h)),i.appendChild(w);let r=typeof u=="boolean"?b(u):u,$=d(()=>{i.disabled=r.value,r.value?i.setAttribute("aria-disabled","true"):i.removeAttribute("aria-disabled");});C.push($);let B=typeof o=="boolean"?b(o):o,U=d(()=>{B.value?(k.style.display="inline-block",w.style.visibility="hidden",b$1&&(z.textContent=b$1),i.disabled=true,i.setAttribute("aria-busy","true")):(k.style.display="none",w.style.visibility="visible",typeof d$1=="string"&&(z.textContent=d$1),i.removeAttribute("aria-busy"));});if(C.push(U),X){let a=false,P=x=>{i.disabled||(a=true,i.classList.add("button-pressed"),j&&j(x));},v=x=>{a&&(a=false,i.classList.remove("button-pressed"),K&&K(x));},Y=async x=>{if(i.disabled){x.preventDefault();return}try{await X(x);}catch(_){console.error("Button press handler error:",_);}},ee=x=>{i.disabled||((x.key==="Enter"||x.key===" ")&&(x.preventDefault(),a=true,i.classList.add("button-pressed"),j&&j(x)),m&&m(x));},te=x=>{i.disabled||(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),a=false,i.classList.remove("button-pressed"),K&&K(x),Y(x));},S=()=>{a=false,i.classList.remove("button-pressed");};i.addEventListener("pointerdown",P),i.addEventListener("pointerup",v),i.addEventListener("click",Y),i.addEventListener("keydown",ee),i.addEventListener("keyup",te),i.addEventListener("pointercancel",S),C.push(()=>{i.removeEventListener("pointerdown",P),i.removeEventListener("pointerup",v),i.removeEventListener("click",Y),i.removeEventListener("keydown",ee),i.removeEventListener("keyup",te),i.removeEventListener("pointercancel",S);});}c&&(i.addEventListener("focus",c),C.push(()=>i.removeEventListener("focus",c))),y&&(i.addEventListener("blur",y),C.push(()=>i.removeEventListener("blur",y)));function g(a){if(a.type!==void 0&&(i.type=a.type),a.className!==void 0){let P=["button",`button-${n}`,`button-${s}`];l&&P.push("button-full-width"),a.className&&P.push(a.className),i.className=P.join(" ");}if(a.style&&Object.assign(i.style,a.style),a.ariaLabel!==void 0&&i.setAttribute("aria-label",a.ariaLabel),a.disabled!==void 0){let P=typeof a.disabled=="boolean"?b(a.disabled):a.disabled;r.set(P.value);}if(a.loading!==void 0){let P=typeof a.loading=="boolean"?b(a.loading):a.loading;B.set(P.value);}}function W(){C.forEach(a=>a());}return {element:i,update:g,dispose:W}}function ye(e){let{icon:t,ariaLabel:n,...s}=e;n||console.warn("IconButton should have an aria-label for accessibility");let{element:u,dispose:o}=oe({...s,children:t,ariaLabel:n,className:`icon-button ${s.className||""}`});return {element:u,dispose:o}}function N(e){if(e!==void 0)return typeof e=="number"?`${e}px`:e}function Z(e){let{as:t="p",children:n,fontSize:s,fontWeight:u,fontFamily:o,lineHeight:l,letterSpacing:d$1,textAlign:f,textDecoration:h,textTransform:b,color:E,whiteSpace:A,fontSizeBase:H,display:V,margin:L,marginTop:D,marginRight:O,marginBottom:F,marginLeft:R,padding:X,paddingTop:j,paddingRight:K,paddingBottom:c,paddingLeft:y,maxWidth:m,truncate:i=false,lineClamp:T,className:C="",style:w,id:k,role:z,ariaLabel:r,ariaDescribedby:$,ariaLive:B,onClick:U,onMouseEnter:g,onMouseLeave:W}=e,a=document.createElement(t);k&&(a.id=k),z&&a.setAttribute("role",z);let P=["text",`text-${t}`];i&&P.push("text-truncate"),T&&P.push("text-line-clamp"),C&&P.push(C),a.className=P.join(" ");let v={};s&&(v.fontSize=N(s)),u&&(v.fontWeight=String(u)),o&&(v.fontFamily=o),l&&(v.lineHeight=N(l)),d$1&&(v.letterSpacing=N(d$1)),f&&(v.textAlign=f),h&&(v.textDecoration=h),b&&(v.textTransform=b),E&&(v.color=E),A&&(v.whiteSpace=A),V&&(v.display=V),m&&(v.maxWidth=N(m)),L&&(v.margin=N(L)),D&&(v.marginTop=N(D)),O&&(v.marginRight=N(O)),F&&(v.marginBottom=N(F)),R&&(v.marginLeft=N(R)),X&&(v.padding=N(X)),j&&(v.paddingTop=N(j)),K&&(v.paddingRight=N(K)),c&&(v.paddingBottom=N(c)),y&&(v.paddingLeft=N(y)),i&&(v.overflow="hidden",v.textOverflow="ellipsis",v.whiteSpace="nowrap"),T&&(v.display="-webkit-box",v.webkitLineClamp=String(T),v.webkitBoxOrient="vertical",v.overflow="hidden"),H&&(v.fontSize=N(H)),Object.assign(a.style,v),w&&Object.assign(a.style,w),r&&a.setAttribute("aria-label",r),$&&a.setAttribute("aria-describedby",$),B&&a.setAttribute("aria-live",B);let Y=[];if(n!==void 0){if(typeof n=="string"||typeof n=="number")a.textContent=String(n);else if(n instanceof HTMLElement)a.appendChild(n);else if(Array.isArray(n))n.forEach(S=>a.appendChild(S));else if(typeof n.value<"u"){let S=n,x=d(()=>{a.textContent=String(S.value);});Y.push(x);}}if(U){let S=U;if(a.addEventListener("click",S),Y.push(()=>a.removeEventListener("click",S)),t==="span"||t==="p"){a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.style.cursor="pointer";let x=_=>{let ie=_;(ie.key==="Enter"||ie.key===" ")&&(_.preventDefault(),U(_));};a.addEventListener("keypress",x),Y.push(()=>a.removeEventListener("keypress",x));}}if(g){let S=g;a.addEventListener("mouseenter",S),Y.push(()=>a.removeEventListener("mouseenter",S));}if(W){let S=W;a.addEventListener("mouseleave",S),Y.push(()=>a.removeEventListener("mouseleave",S));}function ee(S){if(S.children!==void 0){let x=S.children;(typeof x=="string"||typeof x=="number")&&(a.textContent=String(x));}if(S.fontSize!==void 0&&(a.style.fontSize=N(S.fontSize)),S.fontWeight!==void 0&&(a.style.fontWeight=String(S.fontWeight)),S.color!==void 0&&(a.style.color=S.color),S.className!==void 0){let x=["text",`text-${t}`];i&&x.push("text-truncate"),T&&x.push("text-line-clamp"),S.className&&x.push(S.className),a.className=x.join(" ");}S.style&&Object.assign(a.style,S.style);}function te(){Y.forEach(S=>S());}return {element:a,update:ee,dispose:te}}function xe(e,t){return Z({...t,as:`h${e}`})}function Se(e){return Z({...e,as:"p"})}function Ee(e){return Z({...e,as:"label"})}function Le(e){return Z({...e,as:"code",fontFamily:e.fontFamily||"monospace"})}function I(e){if(!e)return {};let t={};e.display&&(t.display=e.display),e.flex!==void 0&&(t.flex=e.flex),e.flexDirection&&(t.flexDirection=e.flexDirection),e.flexWrap&&(t.flexWrap=e.flexWrap),e.justifyContent&&(t.justifyContent=e.justifyContent),e.alignItems&&(t.alignItems=e.alignItems),e.alignSelf&&(t.alignSelf=e.alignSelf),e.gap!==void 0&&(t.gap=`${e.gap}px`),e.padding!==void 0&&(t.padding=`${e.padding}px`),e.paddingTop!==void 0&&(t.paddingTop=`${e.paddingTop}px`),e.paddingRight!==void 0&&(t.paddingRight=`${e.paddingRight}px`),e.paddingBottom!==void 0&&(t.paddingBottom=`${e.paddingBottom}px`),e.paddingLeft!==void 0&&(t.paddingLeft=`${e.paddingLeft}px`),e.paddingHorizontal!==void 0&&(t.paddingLeft=`${e.paddingHorizontal}px`,t.paddingRight=`${e.paddingHorizontal}px`),e.paddingVertical!==void 0&&(t.paddingTop=`${e.paddingVertical}px`,t.paddingBottom=`${e.paddingVertical}px`),e.margin!==void 0&&(t.margin=`${e.margin}px`),e.marginTop!==void 0&&(t.marginTop=`${e.marginTop}px`),e.marginRight!==void 0&&(t.marginRight=`${e.marginRight}px`),e.marginBottom!==void 0&&(t.marginBottom=`${e.marginBottom}px`),e.marginLeft!==void 0&&(t.marginLeft=`${e.marginLeft}px`),e.marginHorizontal!==void 0&&(t.marginLeft=`${e.marginHorizontal}px`,t.marginRight=`${e.marginHorizontal}px`),e.marginVertical!==void 0&&(t.marginTop=`${e.marginVertical}px`,t.marginBottom=`${e.marginVertical}px`),e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.height!==void 0&&(t.height=typeof e.height=="number"?`${e.height}px`:e.height),e.minWidth!==void 0&&(t.minWidth=`${e.minWidth}px`),e.maxWidth!==void 0&&(t.maxWidth=`${e.maxWidth}px`),e.minHeight!==void 0&&(t.minHeight=`${e.minHeight}px`),e.maxHeight!==void 0&&(t.maxHeight=`${e.maxHeight}px`),e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.borderRadius!==void 0&&(t.borderRadius=`${e.borderRadius}px`),e.borderTopLeftRadius!==void 0&&(t.borderTopLeftRadius=`${e.borderTopLeftRadius}px`),e.borderTopRightRadius!==void 0&&(t.borderTopRightRadius=`${e.borderTopRightRadius}px`),e.borderBottomLeftRadius!==void 0&&(t.borderBottomLeftRadius=`${e.borderBottomLeftRadius}px`),e.borderBottomRightRadius!==void 0&&(t.borderBottomRightRadius=`${e.borderBottomRightRadius}px`),e.opacity!==void 0&&(t.opacity=e.opacity),e.borderWidth!==void 0&&(t.borderWidth=`${e.borderWidth}px`),e.borderColor&&(t.borderColor=e.borderColor),e.borderTopWidth!==void 0&&(t.borderTopWidth=`${e.borderTopWidth}px`),e.borderRightWidth!==void 0&&(t.borderRightWidth=`${e.borderRightWidth}px`),e.borderBottomWidth!==void 0&&(t.borderBottomWidth=`${e.borderBottomWidth}px`),e.borderLeftWidth!==void 0&&(t.borderLeftWidth=`${e.borderLeftWidth}px`),e.position&&(t.position=e.position),e.top!==void 0&&(t.top=`${e.top}px`),e.right!==void 0&&(t.right=`${e.right}px`),e.bottom!==void 0&&(t.bottom=`${e.bottom}px`),e.left!==void 0&&(t.left=`${e.left}px`),e.zIndex!==void 0&&(t.zIndex=e.zIndex),e.transform&&(t.transform=e.transform);let n=e;return n.color&&(t.color=n.color),n.fontSize!==void 0&&(t.fontSize=`${n.fontSize}px`),n.fontWeight&&(t.fontWeight=n.fontWeight),n.fontFamily&&(t.fontFamily=n.fontFamily),n.fontStyle&&(t.fontStyle=n.fontStyle),n.textAlign&&(t.textAlign=n.textAlign),n.textDecoration&&(t.textDecoration=n.textDecoration),n.lineHeight!==void 0&&(t.lineHeight=`${n.lineHeight}px`),n.letterSpacing!==void 0&&(t.letterSpacing=`${n.letterSpacing}px`),t}function Te(e){let{children:t,style:n,onClick:s,onPress:u,class:o,className:l,id:d,...f}=e;return {type:"div",props:{...f,id:d,class:o||l,style:I(n),onclick:s||u},children:Array.isArray(t)?t:t?[t]:[]}}function Ce(e){let{children:t,style:n,onClick:s,onPress:u,class:o,className:l,...d}=e;return {type:"span",props:{...d,class:o||l,style:I(n),onclick:s||u},children:Array.isArray(t)?t:t?[t]:[]}}function Pe(e){let{src:t,alt:n,width:s,height:u,style:o,onLoad:l,onError:d,...f}=e,h={...o,width:s||o?.width,height:u||o?.height};return {type:"img",props:{...f,src:t,alt:n||"",style:I(h),onload:l,onerror:d},children:[]}}function Ae(e){let{children:t,onPress:n,onPressIn:s,onPressOut:u,disabled:o,style:l,activeOpacity:d=.7,...f}=e,h={...l,opacity:o?.5:l?.opacity,padding:0};return {type:"button",props:{...f,disabled:o,style:I(h),onclick:o?void 0:n,onmousedown:s,onmouseup:u,ontouchstart:s,ontouchend:u},children:Array.isArray(t)?t:t?[t]:[]}}function Ve(e){let{children:t,style:n,horizontal:s,showsHorizontalScrollIndicator:u=true,showsVerticalScrollIndicator:o=true,...l}=e,d={...n},f={};return (!u||!o)&&(f.scrollbarWidth="none",f.msOverflowStyle="none"),{type:"div",props:{...l,style:{...I(d),...f}},children:Array.isArray(t)?t:t?[t]:[]}}function ke(e){return e&&typeof e=="object"&&"value"in e&&"peek"in e&&"set"in e}function p(e){return ke(e)?e.value:e}function ae(e,t,n,s){if(!t)return;let u=Array.isArray(t)?t:[t];for(let o of u)if(!(!o||!o.type))switch(o.type){case "canvas-rect":Fe(e,o.props);break;case "canvas-circle":Re(e,o.props);break;case "canvas-path":we(e,o.props);break;case "canvas-text":$e(e,o.props);break;case "canvas-line":ze(e,o.props);break;case "canvas-arc":Ne(e,o.props);break}}function Fe(e,t){let n=p(t.x),s=p(t.y),u=p(t.width),o=p(t.height),l=p(t.fill),d=p(t.stroke),f=p(t.strokeWidth),h=p(t.opacity);e.save(),h!==void 0&&(e.globalAlpha=h),l&&(e.fillStyle=l,e.fillRect(n,s,u,o)),d&&(e.strokeStyle=d,e.lineWidth=f||1,e.strokeRect(n,s,u,o)),e.restore();}function Re(e,t){let n=p(t.x),s=p(t.y),u=p(t.radius),o=p(t.fill),l=p(t.stroke),d=p(t.strokeWidth),f=p(t.opacity);e.save(),f!==void 0&&(e.globalAlpha=f),e.beginPath(),e.arc(n,s,u,0,2*Math.PI),o&&(e.fillStyle=o,e.fill()),l&&(e.strokeStyle=l,e.lineWidth=d||1,e.stroke()),e.restore();}function we(e,t){let n=p(t.d),s=p(t.fill),u=p(t.stroke),o=p(t.strokeWidth),l=p(t.opacity);e.save(),l!==void 0&&(e.globalAlpha=l);let d=new Path2D(n);s&&(e.fillStyle=s,e.fill(d)),u&&(e.strokeStyle=u,e.lineWidth=o||1,e.stroke(d)),e.restore();}function $e(e,t){let n=p(t.x),s=p(t.y),u=p(t.text),o=p(t.fill),l=p(t.fontSize)||12,d=t.fontFamily||"sans-serif",f=t.fontWeight||"normal",h=t.textAlign||"left",b=t.textBaseline||"alphabetic";e.save(),e.font=`${f} ${l}px ${d}`,e.textAlign=h,e.textBaseline=b,o&&(e.fillStyle=o,e.fillText(u,n,s)),e.restore();}function ze(e,t){let n=p(t.x1),s=p(t.y1),u=p(t.x2),o=p(t.y2),l=p(t.stroke)||"black",d=p(t.strokeWidth)||1,f=p(t.opacity);e.save(),f!==void 0&&(e.globalAlpha=f),e.beginPath(),e.moveTo(n,s),e.lineTo(u,o),e.strokeStyle=l,e.lineWidth=d,e.stroke(),e.restore();}function Ne(e,t){let n=p(t.x),s=p(t.y),u=p(t.radius),o=p(t.startAngle),l=p(t.endAngle),d=t.counterclockwise||false,f=p(t.fill),h=p(t.stroke),b=p(t.strokeWidth),E=p(t.opacity);e.save(),E!==void 0&&(e.globalAlpha=E),e.beginPath(),e.arc(n,s,u,o,l,d),f&&(e.fillStyle=f,e.fill()),h&&(e.strokeStyle=h,e.lineWidth=b||1,e.stroke()),e.restore();}function se(e){let{width:t,height:n,children:s,style:u,id:o,...l}=e;return {type:"canvas",props:{...l,id:o,width:t,height:n,style:I(u),ref:d=>{if(!d)return;let f=d.getContext("2d");f&&import('./index.mjs').then(({effect:h})=>{let b;h(()=>{b&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{f.clearRect(0,0,t,n),ae(f,s);});});});}},children:[]}}function le(e){return {type:"canvas-rect",props:e,children:[]}}function de(e){return {type:"canvas-circle",props:e,children:[]}}function ue(e){return {type:"canvas-path",props:e,children:[]}}function fe(e){return {type:"canvas-text",props:e,children:[]}}function ce(e){return {type:"canvas-line",props:e,children:[]}}function pe(e){return {type:"canvas-arc",props:e,children:[]}}export{Q as a,ge as b,he as c,be as d,re as e,ve as f,oe as g,ye as h,Z as i,xe as j,Se as k,Ee as l,Le as m,I as n,Te as o,Ce as p,Pe as q,Ae as r,Ve as s,se as t,le as u,de as v,ue as w,fe as x,ce as y,pe as z};//# sourceMappingURL=chunk-PJGVD25I.mjs.map //# sourceMappingURL=chunk-PJGVD25I.mjs.map