@chem-po/react-native 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import Vi,{forwardRef,createContext,useCallback,useMemo,useImperativeHandle,useState,useRef,useEffect,useContext}from'react';import {View,StyleSheet,Animated,Text,TouchableOpacity,TextInput,Switch,Modal,ScrollView,Image,Platform,Pressable,ActivityIndicator,Dimensions,useColorScheme,ImageBackground}from'react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useIconColor,useColorMode,usePlaceholderColor,useTextColor,useBackgroundColor,useBorderColor,useThemeValue,useField,useStandaloneInput,useMounted,useAppAssets,useScreen,useTheme,useColorModeValue,useEditable,DataViewProvider,useSubmitData,useFormSubmit,ChempoFormProvider,ChempoProvider,useAuth,useDocument,useDataView,useObjectUrl,useChempoForm}from'@chem-po/react';import {Ionicons}from'@expo/vector-icons';import ro from'react-native-toast-message';import {Gesture,GestureDetector}from'react-native-gesture-handler';import aa from'lottie-react-native';import qa from'@expo/vector-icons/MaterialCommunityIcons';import {colorValueToHex,gradients,getDateString,getDateTimeString,padZeros,palette,getHandle,isField,isListField,formatField}from'@chem-po/core';import {Controller,useFormContext,useFieldArray,useWatch,useFormState}from'react-hook-form';import Cl from'@react-native-community/slider';import {Portal}from'react-native-paper';import {DatePickerModal,TimePickerModal,registerTranslation,en}from'react-native-paper-dates';import*as dr from'expo-document-picker';import*as ur from'expo-image-picker';import {Notifier,NotifierComponents}from'react-native-notifier';var ue=forwardRef(({style:e,...t},o)=>jsx(View,{ref:o,style:[Wo.center,e],...t})),at=forwardRef(({style:e,...t},o)=>jsx(Animated.View,{ref:o,style:[Wo.center,e],...t})),Wo=StyleSheet.create({center:{flex:1,justifyContent:"center",alignItems:"center"}});var Iu=({width:e,children:t,active:o,duration:n=400,style:r,...i})=>{let a=useRef(new Animated.Value(o?e:0)).current,s=useRef(new Animated.Value(o?1:0)).current;useEffect(()=>{Animated.parallel([Animated.timing(a,{toValue:o?e:0,duration:n,useNativeDriver:false}),Animated.timing(s,{toValue:o?1:0,duration:n,useNativeDriver:true})]).start();},[o,a,s,e,n]);let l=useMemo(()=>({width:a,opacity:s,overflow:"hidden"}),[a,s]);return jsx(at,{style:[l,r],...i,children:t})};var fi=(e,t)=>jsx(View,{ref:t,style:[gi.container,e.style],...e}),gi=StyleSheet.create({container:{backgroundColor:"#FFFFFF",padding:12,borderRadius:6,shadowColor:"#000000",shadowOffset:{width:1,height:1},shadowOpacity:.4,shadowRadius:4,elevation:4}}),Ou=forwardRef(fi);var jt=({children:e,style:t})=>jsx(View,{style:[{...Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84},android:{elevation:5}})},t],children:e});var G=({children:e,...t})=>{let o=useTextColor();return jsx(Text,{...t,style:[{color:o},t.style],children:e})};var Yt=({header:e,children:t,initExpanded:o=false,nested:n,alwaysExpanded:r,iconColor:i="#000",footer:a,isOpen:s,onClose:l,onOpen:p,style:c})=>{let[d,u]=Vi.useState(r??o),f=useRef(new Animated.Value(0)).current,h=useRef(new Animated.Value(0)).current;useEffect(()=>{typeof s<"u"&&u(s);},[s]);let m=useCallback(()=>{u(false),l?.();},[l]),g=useCallback(()=>{u(true),p?.();},[p]),y=useCallback(()=>{r||(d?m():g());},[r,g,m,d]);useEffect(()=>{Animated.parallel([Animated.timing(f,{toValue:d?1:0,duration:300,useNativeDriver:false}),Animated.timing(h,{toValue:d?1:0,duration:300,useNativeDriver:true})]).start();},[d,f,h]);let V=h.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]});return jsxs(View,{style:[pe.container,c],children:[jsxs(Pressable,{onPress:y,style:pe.header,children:[jsx(View,{style:pe.headerContent,children:typeof e=="string"?jsx(G,{style:pe.headerText,children:e}):e({isOpen:d,onClose:m})}),!r&&jsx(Animated.Text,{style:[pe.arrow,{transform:[{rotate:V}],color:i}],children:"\u25BC"})]}),jsx(at,{style:[pe.content,n&&pe.nested,{maxHeight:f.interpolate({inputRange:[0,1],outputRange:[0,1e3]})}],children:t}),a?.({isOpen:d,onClose:m})]})},pe=StyleSheet.create({container:{width:"100%"},header:{flexDirection:"row",padding:8,alignItems:"center"},headerContent:{flex:1},headerText:{fontWeight:"600",color:"#666"},arrow:{fontSize:12,marginLeft:8},content:{width:"100%",overflow:"hidden"},nested:{borderLeftWidth:4,borderLeftColor:"rgba(0,0,0,0.2)"}});var np=({animateOpacity:e,duration:t=300,children:o,in:n=true,onExited:r,style:i,...a})=>{let[s,l]=useState(false);useEffect(()=>{l(true);},[]);let[p,c]=useState(0),d=useRef(null),u=useMemo(()=>s&&n,[n,s]),f=useRef(new Animated.Value(0)).current,h=useRef(new Animated.Value(0)).current;return useEffect(()=>{d.current&&d.current.measure((m,g,y,V)=>{c(V);});},[o]),useEffect(()=>{let m=[Animated.timing(f,{toValue:u?p:0,duration:t,useNativeDriver:false})];e&&m.push(Animated.timing(h,{toValue:u?1:0,duration:t,delay:u?t:0,useNativeDriver:true})),Animated.parallel(m).start(()=>{!u&&r&&r();});},[u,p,t,f,h,e,r]),jsx(Animated.View,{style:[{overflow:"hidden",width:"100%",height:f},i],...a,children:jsx(View,{ref:d,style:[{width:"100%"},e&&{opacity:h},i],...a,children:o})})};var dp=({children:e,...t})=>{let[o,n]=useState(0),[r,i]=useState(0),a=useRef(null),s=useCallback(l=>{let{width:p,height:c}=l.nativeEvent.layout;n(p),i(c);},[]);return jsx(View,{ref:a,...t,style:[{width:"100%",height:"100%"},t.style],onLayout:s,children:e({width:o,height:r})})},Zo=createContext({width:0,height:0}),up=({children:e,...t})=>{let[o,n]=useState(0),[r,i]=useState(0),a=useRef(null),s=useCallback(p=>{let{width:c,height:d}=p.nativeEvent.layout;n(c),i(d);},[]),l=useMemo(()=>({width:o,height:r}),[o,r]);return jsx(View,{ref:a,...t,style:[{width:"100%",height:"100%"},t.style],onLayout:s,children:jsx(Zo.Provider,{value:l,children:e})})},pp=()=>useContext(Zo);var Bi="Are you sure? You can't undo this action afterwards.",Ei=({confirmActive:e,onCancel:t,onConfirm:o,body:n=Bi,actionName:r="Delete",actionLoading:i,itemName:a})=>jsx(Modal,{transparent:true,visible:e,onRequestClose:t,animationType:"fade",children:jsx(View,{style:O.overlay,children:jsxs(View,{style:O.alertContainer,children:[jsxs(G,{style:O.alertTitle,children:[r," ",a,"?"]}),typeof n=="string"?jsx(G,{style:O.alertBody,children:n}):n,jsxs(View,{style:O.buttonContainer,children:[jsx(TouchableOpacity,{style:O.cancelButton,onPress:t,children:jsx(G,{style:O.cancelText,children:"Cancel"})}),jsx(TouchableOpacity,{style:O.confirmButton,onPress:o,disabled:i,children:i?jsx(ActivityIndicator,{color:"#fff"}):jsx(G,{style:[O.buttonText,O.confirmButtonText],children:r})})]})]})})}),Xt=({onDelete:e,itemName:t,noConfirm:o,alertBody:n,text:r,actionName:i="Delete",style:a})=>{let[s,l]=useState(false),[p,c]=useState(false),d=useRef(),u=useRef(true),f=useRef(new Animated.Value(1)).current,h=useRef(new Animated.Value(0)).current;useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let m=useCallback(y=>{Animated.parallel([Animated.timing(f,{toValue:y?0:1,duration:200,useNativeDriver:true}),Animated.timing(h,{toValue:y?1:0,duration:200,useNativeDriver:true})]).start();},[f,h]),g=useCallback(async()=>{if(d.current&&clearTimeout(d.current),c(false),e){l(true),m(true);try{await e();}catch(y){console.error(y),ro.show({text1:y.message??"An error occurred",type:"error"});}u.current&&(l(false),m(false));}else console.error("No delete function");},[e,m]);return jsxs(Fragment,{children:[r?jsx(TouchableOpacity,{style:[O.button,a],onPress:y=>{y.stopPropagation(),o?g():c(true);},disabled:s,children:jsxs(View,{style:O.buttonContent,children:[jsxs(Animated.View,{style:[O.contentContainer,{opacity:f}],children:[jsx(Ionicons,{name:"trash",size:20,color:"red"}),jsx(Text,{style:O.buttonText,children:r})]}),jsx(Animated.View,{style:[O.loaderContainer,{opacity:h}],children:jsx(ActivityIndicator,{color:"#ff0000",size:"small"})})]})}):jsx(TouchableOpacity,{style:[O.iconButton,a],onPress:y=>{y.stopPropagation(),o?g():c(true);},disabled:s,children:jsxs(View,{style:O.buttonContent,children:[jsx(Animated.View,{style:[O.contentContainer,{opacity:f}],children:jsx(Ionicons,{name:"trash",size:24,color:"#ee0000"})}),jsx(Animated.View,{style:[O.loaderContainer,{opacity:h}],children:jsx(ActivityIndicator,{color:"#ff0000",size:"small"})})]})}),o?null:jsx(Ei,{confirmActive:p,onCancel:()=>c(false),actionLoading:s,onConfirm:()=>{g();},actionName:i,body:n,itemName:t})]})},O=StyleSheet.create({overlay:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)"},alertContainer:{width:"80%",maxWidth:400,backgroundColor:"white",borderRadius:10,padding:20,alignItems:"center"},alertTitle:{fontSize:18,fontWeight:"bold",marginBottom:10},alertBody:{fontSize:16,marginBottom:20},buttonContainer:{flexDirection:"row",justifyContent:"space-between",width:"100%"},cancelButton:{padding:10,borderColor:"gray",borderWidth:1,borderRadius:5,flex:1,marginRight:5,alignItems:"center"},cancelText:{color:"gray",fontWeight:"bold"},confirmButton:{padding:10,backgroundColor:"red",borderRadius:5,flex:1,marginLeft:5,alignItems:"center"},buttonText:{color:"red",fontWeight:"bold"},confirmButtonText:{color:"white",textShadowColor:"rgba(0, 0, 0, 0.5)",textShadowOffset:{width:1,height:1},textShadowRadius:3},button:{flexDirection:"row",alignItems:"center",padding:10,backgroundColor:"transparent"},buttonContent:{flexDirection:"row",gap:3,borderWidth:1,borderColor:"red",paddingHorizontal:13,paddingVertical:5,borderRadius:4,alignItems:"center",justifyContent:"center",minHeight:34,position:"relative"},contentContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:3},loaderContainer:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},iconButton:{padding:10,backgroundColor:"transparent"},loading:{position:"absolute",top:0,left:0,justifyContent:"center",alignItems:"center",height:24,width:24}});var kp=({onPress:e,children:t,style:o,textStyle:n,color:r,icon:i,disabled:a=false})=>{let[s,l]=useState(false),p=useRef(true),c=useRef(new Animated.Value(1)).current,d=useRef(new Animated.Value(0)).current;useEffect(()=>(p.current=true,()=>{p.current=false;}),[]);let u=useCallback(g=>{Animated.parallel([Animated.timing(c,{toValue:g?0:1,duration:200,useNativeDriver:true}),Animated.timing(d,{toValue:g?1:0,duration:200,useNativeDriver:true})]).start();},[c,d]),f=useCallback(async()=>{if(e){l(true),u(true);try{await e();}catch(g){console.error(g),ro.show({text1:g.message??"An error occurred",type:"error"});}p.current&&(l(false),u(false));}},[e,u]),h=useTextColor(),m=useMemo(()=>r??h,[r,h]);return jsx(TouchableOpacity,{style:[Ne.button,{borderColor:m,backgroundColor:a?"#f0f0f0":"transparent"},o],onPress:g=>{g.stopPropagation(),f();},disabled:s||a,children:jsxs(View,{style:[Ne.buttonContent,{borderColor:a?"#ccc":m}],children:[jsxs(Animated.View,{style:[Ne.contentContainer,{opacity:c}],children:[i&&jsx(Ionicons,{name:i.name,size:i.size??20,color:a?"#ccc":m}),typeof t=="string"?jsx(Text,{style:[Ne.buttonText,{color:a?"#ccc":m},n],children:t}):t]}),jsx(Animated.View,{style:[Ne.loaderContainer,{opacity:d}],children:jsx(ActivityIndicator,{color:m,size:"small"})})]})})},Ne=StyleSheet.create({button:{flexDirection:"row",alignItems:"center",backgroundColor:"transparent"},buttonContent:{flexDirection:"row",gap:8,borderWidth:1,paddingHorizontal:16,paddingVertical:8,borderRadius:4,alignItems:"center",justifyContent:"center",minHeight:40,position:"relative"},contentContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},loaderContainer:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},buttonText:{fontWeight:"bold"}});var Zi=({selected:e,option:{Render:t,disabledMessage:o},size:n,onPress:r})=>{let i=useCallback(()=>{o?ro.show({type:"error",text1:o}):r();},[r,o]);return jsx(View,{style:[Zt.buttonContainer,{width:n,height:n,opacity:o?.6:1}],children:jsx(TouchableOpacity,{style:[Zt.button,{backgroundColor:e?"rgba(255, 255, 255, 0.5)":"rgba(0, 0, 0, 0.1)",pointerEvents:e?"none":"auto"}],onPress:i,disabled:!!o,children:t(e)})})},Wp=({value:e,onChange:t,size:o=28,options:n})=>{let{theme:{colors:{background:r}}}=useTheme();return jsx(View,{style:[Zt.container,{borderColor:r[300]}],children:n.map(i=>jsx(Zi,{onPress:()=>{t(i.id);},option:i,size:o,selected:i.id===e},i.id))})},Zt=StyleSheet.create({container:{flexDirection:"row",borderWidth:1,borderRadius:3},buttonContainer:{justifyContent:"center",alignItems:"center"},button:{justifyContent:"center",alignItems:"center",borderRadius:3}});var cn=createContext({}),dn=({curr:e,children:t})=>{let o=useMemo(()=>({curr:e}),[e]);return jsx(cn.Provider,{value:o,children:t})},na=()=>useContext(cn);var un={top:0,left:0,right:0,bottom:0,display:"flex"},ae=StyleSheet.create({absolute:{...un,position:"absolute"},relative:{...un,position:"relative"}});var fn=({size:e=30,isLoading:t,speed:o=2,inFeed:n,asset:r})=>{let{colorMode:i}=useTheme(),a=useMemo(()=>n||i==="dark"?r.dark??r.default:r.default,[r,n,i]),s=useMemo(()=>({width:e,height:e,opacity:t?.85:0}),[e,t]);return jsx(aa,{source:a,autoPlay:t,loop:true,speed:o,style:s})},gn=({size:e=30,isLoading:t,asset:o,inFeed:n})=>{let{colorMode:r}=useTheme(),i=useMemo(()=>n||r==="dark"?o.dark??o.default:o.default,[o,n,r]),a=useMemo(()=>({width:e,height:e,opacity:t?.85:0}),[e,t]);return jsx(Image,{source:{uri:i},style:a})},ca=({isLoading:e,size:t})=>{let{loading:o}=useAppAssets();return o.lottieJson?jsx(fn,{isLoading:e,size:t,asset:o.lottieJson}):o.svg?jsx(gn,{isLoading:e,size:t,asset:o.svg}):null},ge=({isLoading:e,size:t,inFeed:o})=>{let{loading:n}=useAppAssets();return n.lottieJson?jsx(fn,{inFeed:o,isLoading:e,size:t,asset:n.lottieJson}):n.svg?jsx(gn,{inFeed:o,isLoading:e,size:t,asset:n.svg}):jsx(Text,{style:Ue.errorText,children:"ERROR: No loading animation found"})},oo=({text:e="Loading...",inBox:t,containerStyle:o})=>{let n=jsxs(View,{style:[Ue.loadingContainer,o],children:[jsx(ca,{isLoading:true}),jsx(Text,{style:Ue.loadingText,children:e})]});return t?jsx(View,{style:Ue.boxContainer,children:n}):n},mt=({isLoading:e,text:t,inFeed:o,style:n})=>{let{colorMode:r}=useTheme(),i=r==="dark"?"rgba(0, 0, 0, 0.53)":"rgba(255, 255, 255, 0.67)";return jsx(View,{style:[Ue.overlay,{backgroundColor:i},{opacity:e?1:0},n],children:t?jsx(oo,{text:t}):jsx(ge,{inFeed:o,size:100,isLoading:e})})},Ue=StyleSheet.create({loadingContainer:{flexDirection:"row",alignItems:"center",padding:8},loadingText:{opacity:.8,fontSize:14,marginLeft:8},boxContainer:{padding:16,borderRadius:8,backgroundColor:"rgba(0, 0, 0, 0.05)"},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center"},errorText:{color:"red"}});var fa=e=>e==="current"?1:0,wn=(e,t)=>{let{height:o}=t;return e==="current"?0:e==="next"?o*1.1:e==="prev"?-o*1.1:0},bn=({id:e,collectionPath:t,onItemLoad:o,RenderItem:n,status:r,offsetY:i,enterStatus:a})=>{let{height:s,width:l}=useScreen(),p=useMemo(()=>({height:s,width:l}),[s,l]),c=useRef(new Animated.Value(0)).current,d=useRef(new Animated.Value(wn(a??"next",p))).current,u=Animated.add(d,i),f=useMemo(()=>`${t}/${e}`,[t,e]),{data:h}=useDocument(f,o);return useEffect(()=>{let m=fa(r),g=wn(r,p);d.setValue(g),c.setValue(m);},[r,d,c,p]),jsx(Animated.View,{style:{position:"absolute",top:0,left:0,transform:[{translateY:u},{scale:c}],display:"flex",alignItems:"center",justifyContent:"center",height:"100%",opacity:c,width:"100%"},children:h?n(h):null})};var wa=10,xn=(e,t,o=wa,n=false)=>{let[r,i]=useState([null,null,null]),[a,s]=useState(0),l=useAuth(x=>x.user),[p,c]=useState(false),[d,u]=useState(false),[f,h]=useState(null),[m,g]=useState(false),[y,V]=useState(null),S=useRef(null),b=useRef({prev:null,curr:null,next:null}),v=useCallback(x=>{x&&(b.current.prev===x&&(b.current.prev=null),b.current.next===x&&(b.current.next=null)),b.current.curr=x,t({...b.current});},[t]),T=useCallback(x=>{x&&(b.current.prev===x&&(b.current.prev=null),b.current.curr===x&&(b.current.curr=null)),b.current.next=x,t({...b.current});},[t]),D=useCallback(x=>{x&&(b.current.curr===x&&(b.current.curr=null),b.current.next===x&&(b.current.next=null)),b.current.prev=x,t({...b.current});},[t]),k=useCallback(async(x,M,B)=>{if(!l&&n)return [];B||c(true);try{let C=await e({limit:o,startAfter:M,startBefore:x});if(B)M?i(P=>[P[0],P[1],C.ids]):x&&i(P=>[C.ids,P[1],P[2]]);else {let P=C.ids[0],re=C.ids[1]||null;v(P),T(re),D(M),i(M?j=>[j[1],C.ids,null]:x?j=>[null,C.ids,j[1]]:[null,C.ids,null]);let F=C.ids[C.ids.length-1];F&&k(null,F,!0);}return c(!1),C.ids||[]}catch(C){h(C.message),ro.show({text1:"Error fetching feed",text2:C.message,type:"error",visibilityTime:5e3});}return c(false),[]},[e,l,n,v,T,D,o]),_=useCallback(async(x,M)=>{let B=r[1]??[],C=r[2]??[],P=x+1;if(P<B.length)return {id:B[P],idx:P};if(C[0]){let j=C[C.length-1];return M||(i(ie=>[ie[1],ie[2],null]),k(null,j,true)),{id:C[0],idx:0}}let F=(await k(null,B[B.length-1],M))[0];return F?{id:F,idx:0}:null},[r,k]),H=useCallback(async(x,M)=>{let B=r[1]??[],C=r[0]??[],P=x-1;if(P>=0)return {id:B[P],idx:P};if(C[C.length-1]){let j=C[0];return M||(i([null,r[0],r[1]]),k(j,null,true)),{id:C[C.length-1],idx:C.length-1}}let re=await k(B[0],null,M),F=re[re.length-1];return F?{id:F,idx:re.length-1}:null},[r,k]),I=useCallback(async()=>{if(m)return;let x=b.current.curr;g(true);let M=await _(a,false);if(V("next"),M){let{id:B,idx:C}=M;S.current=B,s(C),v(B),T(null),D(x),_(C,true).then(P=>T(P?.id??null));}else ro.show({text1:"No more items",type:"info",visibilityTime:3e3});g(false);},[a,_,v,T,D,m]),E=useCallback(async()=>{if(m)return;let x=b.current.curr;V("prev"),g(true);let M=await H(a,false);if(M){let{id:B,idx:C}=M;S.current=B,s(C),v(B),D(null),T(x),H(C,true).then(P=>D(P?.id??null));}else ro.show({text1:"No more items",type:"info",visibilityTime:3e3});g(false);},[a,H,v,T,D,m]),L=useCallback(async()=>{c(true),u(true),i([null,null,null]),v(null),T(null),D(null),V(null),s(0),await k(null,null,false),u(false);},[k,v,T,D]),[q]=useState(()=>k);useEffect(()=>{q(null,null,false);},[q]);let Se=useMemo(()=>a>0&&!!r[1]?.length||!!r[0]?.length,[r,a]),Ve=useMemo(()=>(r[1]&&a<r[1].length)??!!r[2]?.length,[r,a]);return useMemo(()=>({ids:r,goNext:I,goPrev:E,error:f,refresh:L,refreshing:d,loading:p,canGoNext:Ve,direction:y,canGoPrev:Se,itemLoading:m}),[r,I,E,p,f,m,Ve,Se,L,d,y])};var In=({color:e,trackColor:t,animating:o,visible:n=true,viewStyle:r,...i})=>{let a=useColorModeValue("#959595","#575757"),s=useRef(new Animated.Value(n?1:0)).current;return useEffect(()=>{Animated.timing(s,{toValue:n?1:0,duration:300,useNativeDriver:true}).start();},[n,s]),jsxs(Animated.View,{style:[Sa.container,{opacity:s},r],children:[jsx(ActivityIndicator,{color:t??a,style:StyleSheet.absoluteFill,animating:false,...i}),jsx(ActivityIndicator,{animating:o,color:e??"#575757",...i})]})},Sa=StyleSheet.create({container:{alignItems:"center",justifyContent:"center"}});var An=({src:e,onClose:t})=>{let[o,n]=useState(true),r=useScreen(u=>u.width),i=useScreen(u=>u.height),[a,s]=useState({width:r/2,height:i/2}),{height:l,width:p}=useMemo(()=>{if(o)return a;let u=a.width/a.height,f=Math.min(a.height,i*.9),h=f*u;return h>r*.9&&(h=Math.min(a.width,r*.9),f=h/u),{height:f,width:h}},[i,r,a,o]),c=useCallback(()=>n(true),[]),d=useCallback(u=>{let{width:f,height:h}=u.nativeEvent.source;s({width:f,height:h}),n(false);},[]);return jsx(Modal,{visible:true,transparent:true,animationType:"fade",onRequestClose:t,children:jsx(View,{style:Pe.modalOverlay,children:jsxs(View,{style:Pe.contentContainer,children:[jsx(View,{style:[Pe.imageContainer,{width:p,height:l,opacity:o?0:1}],children:jsx(Image,{source:{uri:e},style:Pe.image,onLoadStart:c,onLoad:d,resizeMode:"contain"})}),jsx(TouchableOpacity,{style:Pe.closeButton,onPress:t,children:jsx(Ionicons,{name:"close",size:24,color:"white"})}),o&&jsx(View,{style:Pe.loadingContainer,children:jsx(ge,{isLoading:o,size:70})})]})})})},Pe=StyleSheet.create({modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.7)"},contentContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:16},imageContainer:{overflow:"hidden",borderRadius:4},image:{width:"100%",height:"100%"},closeButton:{position:"absolute",top:16,right:16,width:40,height:40,borderRadius:20,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center"},loadingContainer:{...StyleSheet.absoluteFillObject,justifyContent:"center",alignItems:"center"}});var Mn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAv/lxKUAAAAASUVORK5CYII=",Bn=({src:e,loadingOverride:t,onLoad:o,width:n,height:r,noFullView:i,buttonFullView:a,style:s})=>{let[l,p]=useState(!!e),c=useRef(null),[d,u]=useState(false),f=useMounted(100),h=useCallback(S=>{o&&o(S);},[o]),[m,g]=useState(e);useEffect(()=>{e&&g(e);},[e,m]);let y=useMemo(()=>l||!!t,[l,t]),V=jsx(Image,{ref:c,source:{uri:e??Mn},style:[ve.image,{opacity:e&&!y?1:0}],onLoadEnd:()=>p(false),onLoad:h,resizeMode:e?"cover":"contain"});return jsxs(View,{style:[ve.container,{width:n??"100%",height:r??"100%",opacity:f?1:0},s],children:[i||a?V:jsx(TouchableOpacity,{activeOpacity:.9,onPress:()=>u(true),style:ve.imageContainer,children:V}),a&&jsx(TouchableOpacity,{style:ve.fullViewButton,onPress:()=>u(true),activeOpacity:.7,children:jsx(Ionicons,{name:"expand",size:20,color:"white",style:ve.fullViewIcon})}),jsx(View,{style:[ve.loadingContainer,{opacity:y?1:0}],children:jsx(ge,{isLoading:y,size:10})}),d&&jsx(An,{src:e??Mn,onClose:()=>u(false)})]})},ve=StyleSheet.create({container:{overflow:"hidden",position:"relative"},imageContainer:{width:"100%",height:"100%"},image:{width:"100%",height:"100%"},loadingContainer:{...StyleSheet.absoluteFillObject,justifyContent:"center",alignItems:"center"},fullViewButton:{position:"absolute",top:8,right:8,width:28,height:28,borderRadius:14,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center"},fullViewIcon:{opacity:.8}});var Ym=({value:e,label:t,onChange:o})=>{let[n,r]=useState(false),i=useState(new Animated.Value(1))[0],a=useCallback(l=>{let p=Math.max(0,1e3-(Date.now()-l));setTimeout(()=>{r(false),Animated.timing(i,{toValue:1,duration:300,useNativeDriver:true}).start();},p);},[i]),s=l=>{r(true),Animated.timing(i,{toValue:0,duration:300,useNativeDriver:true}).start();let p=Date.now();o(l).catch(c=>{console.error(c);}),a(p);};return jsxs(View,{style:yt.container,children:[jsxs(Animated.View,{style:[yt.content,{opacity:i}],children:[jsx(Text,{style:yt.label,children:t}),jsx(Switch,{value:e,onValueChange:s})]}),n&&jsx(View,{style:yt.loadingContainer,children:jsx(oo,{})})]})},yt=StyleSheet.create({container:{paddingVertical:4,paddingHorizontal:12,backgroundColor:"#2D3748",borderRadius:12,shadowColor:"#000",shadowOffset:{width:0,height:0},shadowOpacity:.25,shadowRadius:4,elevation:5,position:"relative",flexDirection:"row",alignItems:"center"},content:{flexDirection:"row",alignItems:"center",gap:8},label:{fontSize:20,height:24,color:"#FFFFFF"},loadingContainer:{position:"absolute",top:"-10%",left:"-10%",width:"120%",height:"120%",borderRadius:8,padding:4,justifyContent:"center",alignItems:"center"}});var Ya="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAv/lxKUAAAAASUVORK5CYII=",_a=StyleSheet.create({imageBackground:{flex:1,transform:[{scale:1.075}]}}),bt=({background:e,opacity:t=.7,style:o,...n})=>jsx(View,{style:[ae.absolute,o],...n,children:jsx(ImageBackground,{source:{uri:e??Ya},style:[_a.imageBackground,{opacity:t}],resizeMode:"cover"})}),Ja=({getBackgroundValue:e,item:t})=>{let o=useMemo(()=>t?e(t):null,[e,t]),{loading:n,url:r}=useObjectUrl(o),i=useRef(0),[a,s]=useState(0),[l,p]=useState(null),[c,d]=useState(null);return useEffect(()=>{i.current===0?(p(r),i.current=1,s(0)):(d(r),i.current=0,s(1));},[r]),jsxs(ue,{style:ae.absolute,children:[jsx(bt,{opacity:a===0?1:0,background:l}),jsx(bt,{opacity:a===1?1:0,background:c}),jsx(ge,{isLoading:n})]})},Ka=({getBackgroundUrl:e,item:t})=>{let o=useMemo(()=>t?e(t):null,[e,t]),n=useRef(0),[r,i]=useState(0),[a,s]=useState(null),[l,p]=useState(null);return useEffect(()=>{o&&(n.current===0?(s(o),n.current=1,i(0)):(p(o),n.current=0,i(1)));},[o]),jsxs(ue,{style:ae.absolute,children:[jsx(bt,{opacity:r===0?1:0,background:a}),jsx(bt,{opacity:r===1?1:0,background:l})]})},Un=({getBackgroundValue:e,getBackgroundUrl:t,...o})=>e?jsx(Ja,{getBackgroundValue:e,...o}):t?jsx(Ka,{getBackgroundUrl:t,...o}):null;var Za=25,_n=({offsetY:e,refreshing:t,canRefresh:o})=>{let n=useRef(new Animated.Value(0)).current,r=useRef(new Animated.Value(0)).current,i=Animated.subtract(e,75),a=Animated.divide(i,Za),s=Animated.diffClamp(a,0,1);useEffect(()=>{Animated.spring(n,{toValue:t?50:0,useNativeDriver:true}).start();},[t,n]),useEffect(()=>{Animated.spring(r,{toValue:o?1:0,useNativeDriver:true}).start();},[o,r]);let l=s.interpolate({inputRange:[0,1],outputRange:[0,Math.sqrt(1)*20]}),c=Animated.add(n,l).interpolate({inputRange:[0,20],outputRange:[0,20],extrapolate:"clamp"}),d=Animated.multiply(r,c),u=d.interpolate({inputRange:[0,30],outputRange:[0,1],extrapolate:"clamp"}),f=Animated.multiply(r,u),h=s.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]});return jsx(Animated.View,{style:[Yn.container,{opacity:f,transform:[{translateY:d},{scale:f},{rotate:h}]}],children:jsxs(View,{style:Yn.centerContainer,children:[jsx(jt,{style:[{opacity:t?0:1}],children:jsx(qa,{name:"refresh",size:32,color:"white"})}),jsx(jt,{style:{opacity:t?1:0},children:jsx(In,{animating:true,size:"large",color:"white"})})]})})},Yn=StyleSheet.create({container:{position:"absolute",top:0,left:0,right:0,pointerEvents:"none"},centerContainer:{alignItems:"center",justifyContent:"center",width:"100%"}});var sl=e=>useCallback(t=>{let o=[];t.prev&&o.push({status:"prev",id:t.prev}),t.curr&&o.push({status:"current",id:t.curr}),t.next&&o.push({status:"next",id:t.next}),e(o);},[e]),Hf=({fetch:e,collection:t,RenderItem:o,authRequired:n,getBackgroundUrl:r,getBackgroundValue:i,limit:a,defaultBackground:s,swipeDisabled:l,children:p})=>{let{width:c,height:d}=useScreen(),{theme:u}=useTheme(),f=useRef(null),h=useRef(null),[m,g]=useState(null),[y,V]=useState([]),S=useRef(new Animated.Value(0)).current,b=sl(V),v=useRef(null),{goNext:T,goPrev:D,loading:k,canGoNext:_,canGoPrev:H,refresh:I,refreshing:E}=xn(e,b,a,n),L=useRef(false),q=useRef({x:0,y:0}),Se=useCallback(F=>{l||(L.current=true,q.current={x:F.x,y:F.y});},[l]),Ve=useCallback(F=>{if(!L.current)return;let j=H?75:100,ie=_?-75:-100,Te=Math.max(ie,Math.min(j,F.y-q.current.y));_&&Te<-65?(g("next"),T()):H&&Te>65?(g("prev"),D()):(Te>90||Te<-90)&&(I(),v.current&&v.current.onNewData(null)),S.setValue(0),L.current=false;},[S,T,D,_,H,I]),x=useCallback(F=>{if(!L.current)return;let j=Math.max(-10,Math.min(10,F.x-q.current.x)),ie=H?75:100,Te=_?-75:-100,Ho=Math.max(Te,Math.min(ie,F.y-q.current.y));Math.sqrt(j**2+Ho**2)>10&&f.current,S.setValue(Ho);},[S,_,H]),M=Gesture.Pan().onStart(Se).onUpdate(x).onEnd(Ve),B=useMemo(()=>({height:`${d}px`,width:`${c}px`,overflow:"hidden",pointerEvents:l?"none":"auto"}),[c,d,l]),[C,P]=useState(null),re=useCallback(F=>{y.find(ie=>ie.status==="current")?.id===F?._id&&P(F);},[y]);return jsx(dn,{curr:C,children:jsx(GestureDetector,{gesture:M,children:jsxs(ue,{style:[cl.container,{backgroundColor:s??u.colors.background[100]}],children:[jsx(Un,{item:C,getBackgroundValue:i,getBackgroundUrl:r}),jsx("div",{ref:h,style:B,children:jsx(ue,{style:ae.relative,ref:f,children:y.map(F=>jsx(bn,{id:F.id,collectionPath:t,RenderItem:o,onItemLoad:re,status:F.status,enterStatus:m,offsetY:S},F.id))})}),jsx(_n,{canRefresh:!H,refreshing:E,offsetY:S}),jsx(mt,{inFeed:true,isLoading:k}),p?jsx(ue,{style:[ae.absolute,{zIndex:3}],children:p}):null]})})})},cl=StyleSheet.create({container:{...ae.relative,overflow:"hidden"}});var Ct=({path:e,condition:t,children:o})=>{let n=useWatch({exact:true,name:e});return useMemo(()=>t(n),[n,t])?jsx(Animated.View,{style:{paddingVertical:3,opacity:1},children:o}):null};var gl=({field:e,input:{onChange:t,value:o,...n}},r)=>{let{placeholder:i}=e;return useImperativeHandle(r,()=>({focus:()=>{},blur:()=>{}})),jsxs(View,{style:{flexDirection:"row",alignItems:"center"},children:[jsx(Switch,{value:o,onValueChange:t,...n}),jsx(Text,{style:{marginLeft:8,fontWeight:"600",opacity:o?.9:.6},children:i})]})},hl=forwardRef(gl),yl=({field:e,input:{onChange:t,value:o,...n}},r)=>{let{placeholder:i}=e;return useImperativeHandle(r,()=>({focus:()=>{},blur:()=>{}})),jsxs(View,{style:{flexDirection:"row",alignItems:"center"},children:[jsx(Switch,{value:o,onValueChange:t,...n}),jsx(Text,{style:{marginLeft:8,fontWeight:"600",opacity:o?.9:.6},children:i})]})},wl=forwardRef(yl),bl=(e,t)=>e.field.type==="switch"?jsx(wl,{ref:t,...e}):jsx(hl,{ref:t,...e}),Qn=forwardRef(bl);var St=({label:e,gradient:t,value:o,minimumValue:n,maximumValue:r,...i})=>jsx(View,{style:[we.container,{opacity:o!==void 0?1:.5}],children:jsxs(View,{style:we.sliderContainer,children:[n!==void 0?jsx(Text,{style:[we.label,t?we.gradientText:null],children:typeof n=="number"?n.toFixed((i?.step??1)<1?2:0):""}):null,jsx(Cl,{style:we.slider,minimumValue:n,maximumValue:r,step:1,...i}),r!==void 0?jsx(Text,{style:[we.label,t?we.gradientText:null],children:typeof r=="number"?r.toFixed((i?.step??1)<1?2:0):""}):null]})}),we=StyleSheet.create({container:{width:"100%",paddingVertical:8},sliderContainer:{flexDirection:"row",alignItems:"center",width:"100%"},slider:{flex:1,height:40},label:{fontSize:14,marginHorizontal:8},gradientText:{color:"#007AFF"}});var Vt=e=>{let t=useRef(null);return useImperativeHandle(e,()=>({focus:()=>{t.current?.focus();},blur:()=>{t.current?.blur();}}),[]),t};var It=({label:e,gradient:t,value:o,...n})=>jsx(St,{label:e,value:o,minimumValue:0,maximumValue:255,step:1,gradient:t,...n}),rr=forwardRef(({input:{onChange:e,value:t},field:o,meta:n},r)=>{let{withAlpha:i,defaultValue:a}=o,{active:s}=n||{};Vt(r);let l=useCallback((d,u)=>{e(i?{r:0,g:0,b:0,a:1,...t,[d]:u}:{r:0,g:0,b:0,...t,[d]:u});},[t,e,i]),p=useMemo(()=>({...a,...t}),[a,t]),c=useMemo(()=>colorValueToHex(!!i,p),[p,i]);return jsxs(View,{style:Ge.container,children:[jsx(View,{style:[Ge.colorPreview,{backgroundColor:c}],children:jsx(Text,{style:Ge.hexText,children:c})}),jsxs(View,{style:[Ge.slidersContainer,s&&Ge.activeContainer],children:[jsx(It,{label:"R",gradient:gradients.red,value:t?.r,onValueChange:d=>l("r",d)}),jsx(It,{label:"G",gradient:gradients.green,value:t?.g,onValueChange:d=>l("g",d)}),jsx(It,{label:"B",gradient:gradients.blue,value:t?.b,onValueChange:d=>l("b",d)}),i?jsx(It,{label:"A",gradient:gradients.midnight,value:t?.a,onValueChange:d=>l("a",d)}):null]})]})}),Ge=StyleSheet.create({container:{width:"100%",flexDirection:"row",alignItems:"center",gap:8},colorPreview:{width:80,height:80,borderRadius:40,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5},hexText:{fontSize:16,color:"#fff",textShadowColor:"rgba(0, 0, 0, 0.75)",textShadowOffset:{width:0,height:1},textShadowRadius:2},slidersContainer:{flex:1,padding:8,borderRadius:6},activeContainer:{shadowColor:"#fff",shadowOffset:{width:0,height:0},shadowOpacity:.5,shadowRadius:5,elevation:5}});var po=({onPress:e,isActive:t,marginRight:o})=>{let n=useIconColor(),r=useBorderColor();return jsx(TouchableOpacity,{onPress:e,style:[Bl.closeButton,{opacity:t?1:0,marginRight:o,borderColor:r}],hitSlop:{top:10,bottom:10,left:10,right:10},disabled:!t,children:jsx(Ionicons,{name:"close",size:14,color:n,style:{alignSelf:"center"}})})},ke=({onPress:e,isActive:t})=>jsx(po,{marginRight:0,onPress:e,isActive:t}),Bl=StyleSheet.create({closeButton:{padding:3,borderRadius:100,display:"flex",alignItems:"center",justifyContent:"center",borderWidth:1}});var Me=e=>{let t=useTextColor(),o=usePlaceholderColor();return e!=null&&e!==""?t:o};var mo=forwardRef(({input:{onChange:e,value:t,onFocus:o,onBlur:n},field:{placeholder:r,minDate:i,maxDate:a,optional:s},meta:{active:l}},p)=>{let c=useMemo(()=>t?new Date(`${t}T00:00:00.000`):void 0,[t]);useImperativeHandle(p,()=>({focus:()=>{o();},blur:()=>{n();}}));let d=()=>{o();},u=useIconColor(),f=Me(t),h=i==="now"?new Date:i?new Date(i):void 0,m=a==="now"?new Date:a?new Date(a):void 0;return jsxs(View,{style:Ft.container,children:[jsxs(TouchableOpacity,{style:Ft.button,onPress:d,children:[jsx(Text,{style:[Ft.text,{color:f}],children:t?getDateString(t,"short"):r}),jsx(Ionicons,{name:"calendar",size:20,color:u,style:Ft.icon}),s&&t?jsx(ke,{onPress:()=>e(null),isActive:!!t}):null]}),jsx(Portal,{children:jsx(DatePickerModal,{locale:"en",label:"Date",date:c,startYear:h?.getFullYear(),endYear:m?.getFullYear(),mode:"single",onConfirm:g=>{e(g?.date?.toISOString()?.split("T")[0]??null),n();},onDismiss:n,visible:l})})]})});mo.displayName="DateInput";var Ft=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var ho=forwardRef(({input:{value:e,onBlur:t,onChange:o,onFocus:n},field:r,meta:{active:i}},a)=>{let{placeholder:s,optional:l}=r,[p,c]=useState(true),[d,u]=useState(false),f=useMemo(()=>e?new Date(e):new Date,[e]);useImperativeHandle(a,()=>({focus:()=>{n();},blur:()=>{t();}}));let h=useCallback(T=>{if(T){let D=new Date(T);o(D.toISOString()),u(true);}else t();c(false);},[o,t]),m=useCallback(({hours:T,minutes:D})=>{let k=f?new Date(f):new Date;k.setHours(T),k.setMinutes(D),o(k.toISOString()),u(false),t();},[o,t,f]),g=useCallback(()=>{c(true),u(false),t();},[t]),y=useMemo(()=>e?new Date(e):void 0,[e]),V=useMemo(()=>e?getDateTimeString(e):null,[e]),S=useMemo(()=>y?{hours:y.getHours(),minutes:y.getMinutes()}:{hours:0,minutes:0},[y]),b=useIconColor(),v=Me(e);return jsxs(View,{style:_e.container,children:[jsxs(TouchableOpacity,{style:_e.button,onPress:()=>{c(true),n();},children:[jsx(Text,{style:[_e.text,{color:v}],children:V??s}),jsx(Ionicons,{name:"calendar",size:20,color:b,style:_e.icon}),jsx(Ionicons,{name:"time",size:20,color:b,style:_e.icon}),l&&e?jsx(ke,{onPress:()=>o(null),isActive:!!e}):null]}),jsxs(Portal,{children:[p&&jsx(DatePickerModal,{locale:"en",label:"Date",date:y,mode:"single",onConfirm:T=>{h(T?.date?.toISOString()?.split("T")[0]??null);},onDismiss:g,visible:i&&p}),d&&jsx(TimePickerModal,{visible:i&&d,onDismiss:g,locale:"en-US",onConfirm:m,hours:S.hours,minutes:S.minutes})]})]})});ho.displayName="DateTimeInput";var _e=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var ms=e=>{if(!e.accept)return;let t=[];return e.accept.includes("image")&&t.push("image/jpg","image/jpeg","image/png","image/svg","image/gif"),e.accept.includes("pdf")&&t.push("application/pdf"),e.accept.includes("audio")&&t.push("audio/mp3","audio/wav","audio/x-wav","audio/webm","audio/ogg"),t.join(",")},fs=({hasUpload:e})=>jsxs(View,{style:ce.noFileContainer,children:[jsx(Text,{style:ce.noFileText,children:e?"Tap to upload file":"No file uploaded"}),jsx(Ionicons,{name:"cloud-upload",size:24,color:"#666"})]}),vt=({value:e,hasUpload:t,imageOptions:o})=>{let{storagePath:n,dataUrl:r}=e??{};return !e||!r&&!n?jsx(fs,{hasUpload:t}):e.type?.startsWith("image/")?jsx(Bn,{src:r,width:o?.width??120,height:o?.height??120,style:ce.image}):jsxs(View,{style:ce.fileContainer,children:[jsx(Ionicons,{name:"document",size:24,color:"#666"}),jsx(Text,{style:ce.filename,children:e.filename})]})},bo=forwardRef(({input:{value:e,onChange:t},field:o},n)=>{let[r,i]=useState(false),{imageOptions:a}=o||{},s=useCallback(async()=>{try{i(!0);let c;if(o.accept?.includes("image")){if(c=await ur.launchImageLibraryAsync({mediaTypes:["images"],allowsEditing:!0,quality:1,base64:!0}),!c.canceled&&c.assets[0]){let d=c.assets[0],u=d.uri.split(".").pop()??"jpeg",f=d.uri.split("/").pop()??"image";t({...e,dataUrl:d.uri,type:`image/${u}`,filename:f});}}else c=await dr.getDocumentAsync({type:ms(o)}),c.canceled||t({...e,dataUrl:c.assets[0].uri,type:c.assets[0].mimeType,filename:c.assets[0].name});}catch(c){c instanceof Error&&console.error("Error picking file:",c.message);}finally{i(false);}},[o,t,e]);useImperativeHandle(n,()=>({focus:()=>{s();},blur:()=>{}}));let l=useMemo(()=>o.accept&&o.accept.length===1&&o.accept[0]==="image",[o]),p=useMemo(()=>l||e?.type?.startsWith("image/")?{height:120,...a}:void 0,[a,l,e]);return jsxs(View,{style:ce.container,children:[jsx(Text,{style:ce.placeholder,children:o.placeholder}),jsx(TouchableOpacity,{style:ce.contentContainer,onPress:()=>void s(),disabled:r,children:jsx(vt,{hasUpload:true,imageOptions:p,value:e})})]})});bo.displayName="FileComponent";var ce=StyleSheet.create({container:{width:"100%",alignItems:"center",justifyContent:"center"},placeholder:{fontSize:14,opacity:.8,marginBottom:4},contentContainer:{width:"100%",position:"relative",alignItems:"center",justifyContent:"center",padding:8,overflow:"hidden"},noFileContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",padding:16,borderWidth:1,borderColor:"#e2e8f0",borderRadius:4,borderStyle:"dashed"},noFileText:{fontSize:14,textAlign:"center",opacity:.8,marginRight:8},fileContainer:{flexDirection:"row",alignItems:"center",padding:8,borderWidth:1,borderColor:"#e2e8f0",borderRadius:4},filename:{fontSize:14,marginLeft:8},image:{borderRadius:4,overflow:"hidden"}});var mr=forwardRef(({field:e,input:t,inEditable:o},n)=>{let{options:r,renderOption:i,getOptionKey:a}=e,{onChange:s,value:l,onFocus:p,onBlur:c}=t,d=useColorMode(),u=usePlaceholderColor();useImperativeHandle(n,()=>({focus:()=>{p();},blur:()=>{c();}}));let f=m=>{s(l?.includes(m)?l.filter(g=>g!==m):[...l??[],m]);},h=jsx(View,{style:Je.container,children:r.map(m=>jsx(TouchableOpacity,{style:[Je.option,l?.includes(m)&&Je.selectedOption],onPress:()=>f(m),children:i(m,d,!!l?.includes(m))},a?a(m):m))});return o?jsxs(View,{style:Je.editableContainer,children:[jsx(Text,{style:[Je.placeholder,{color:u}],children:e.placeholder}),h]}):h}),Je=StyleSheet.create({container:{width:"100%",flexDirection:"row",flexWrap:"wrap",gap:4},editableContainer:{width:"100%",paddingVertical:2},placeholder:{fontSize:14,fontWeight:"600",opacity:.8,paddingHorizontal:8,marginBottom:4},option:{padding:4,opacity:.7},selectedOption:{opacity:1}});var Is={xs:4,sm:6,md:8,lg:8,xl:8},Fs={xs:8,sm:12,md:12,lg:12,xl:12},Ps={xs:12,sm:14,md:16,lg:18,xl:20},fr=e=>useMemo(()=>StyleSheet.create({style:{paddingVertical:Is[e??"md"],paddingHorizontal:Fs[e??"md"],fontSize:Ps[e??"md"]}}),[e]);var Vo=forwardRef(({input:{onChange:e,value:t,...o},field:n,size:r,prefix:i,inEditable:a,...s},l)=>{let{type:p,defaultValue:c,placeholder:d}=n,u=useTextColor(),{style:f}=fr(r),h=Vt(l),[m,g]=useState(""),y=typeof t=="number"&&!Number.isNaN(t)?`${t}${m}`:"",V=usePlaceholderColor();return p==="slider"?jsx(St,{label:d,onValueChange:e,value:t,minimumValue:c}):jsxs(View,{style:So.container,children:[i&&jsx(Text,{style:So.prefix,children:i}),jsx(TextInput,{ref:h,style:[So.input,f,{color:u}],placeholder:n.placeholder,placeholderTextColor:V,keyboardType:"numeric",value:y,onChangeText:S=>{S.endsWith(".")?g("."):S.includes(".")&&S.endsWith("0")?g("0"):g("");let b=parseFloat(S);e(isNaN(b)?void 0:b);},...o})]})}),zs=({field:e,...t},o)=>{let n=useRef(null);return useImperativeHandle(o,()=>({focus:()=>{n.current?.focus();},blur:()=>{n.current?.blur();}})),jsx(Vo,{prefix:"$",field:{...e,_type:"number"},...t})},hr=forwardRef(zs),So=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",width:"100%"},input:{flex:1,height:40,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent"},prefix:{marginRight:4,fontSize:16}});var Qs=({field:e,input:t,meta:o},n)=>{let{placeholder:r,options:i,renderOption:a,getOptionKey:s,optional:l}=e,{onChange:p,value:c,onFocus:d,onBlur:u}=t,{active:f}=o,[h,m]=useState({x:0,y:0,width:0,height:0}),g=useRef(null),y=useMemo(()=>{if(c)return i.find(I=>{if(s){let E=s(I),L=s(c);return E===L}return I===c})},[c,i,s]);useImperativeHandle(n,()=>({focus:()=>{d();},blur:()=>{u();}}));let V=()=>{g.current?.measure((I,E,L,q,Se,Ve)=>{m({x:Se,y:Ve,width:L,height:q});});},S=(I,E)=>typeof a=="function"?a(I,"light",E):typeof I=="object"?jsx(G,{children:JSON.stringify(I)}):jsx(G,{children:String(I)}),b=I=>{if(s){let E=s(I);return typeof E=="object"?JSON.stringify(E):String(E)}return typeof I=="object"?JSON.stringify(I):String(I)},v=I=>{p(I),u();},T=useIconColor(),D=usePlaceholderColor(),k=useBackgroundColor(200),_=useBackgroundColor(300),H=useBorderColor();return jsxs(View,{style:oe.wrapper,children:[jsx(View,{ref:g,onLayout:V,style:oe.container,children:jsxs(TouchableOpacity,{style:[oe.button],onPress:()=>{f?u():d();},children:[jsx(View,{children:y?S(y,true):jsx(Text,{style:[oe.placeholder,{color:D}],children:r})}),jsxs(View,{style:oe.iconsContainer,children:[l?jsx(po,{onPress:()=>p(null),isActive:!!c}):null,jsx(Ionicons,{name:f?"chevron-up":"chevron-down",size:20,color:T})]})]})}),jsx(Modal,{visible:f,transparent:true,animationType:"fade",onRequestClose:()=>u(),children:jsx(TouchableOpacity,{style:oe.modalOverlay,activeOpacity:1,onPress:()=>u(),children:jsx(View,{style:[oe.dropdownContainer,{position:"absolute",top:h.y+h.height+4,left:h.x,width:h.width,backgroundColor:k,borderColor:H}],children:jsx(ScrollView,{style:oe.dropdown,children:i.map(I=>{let E=b(I),L=I===y;return jsx(TouchableOpacity,{style:[oe.option,{borderColor:H},L&&{backgroundColor:_}],onPress:()=>v(I),children:jsx(View,{children:S(I,L)})},E)})})})})})]})},wr=forwardRef(Qs),oe=StyleSheet.create({wrapper:{width:"100%"},container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderRadius:4},buttonText:{fontSize:16,flex:1},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)"},dropdownContainer:{backgroundColor:"white",borderWidth:1,borderColor:"#ddd",borderRadius:4,maxHeight:200,elevation:3,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:2,padding:0},dropdown:{maxHeight:200},option:{paddingVertical:12,paddingHorizontal:16,borderBottomWidth:1},optionText:{fontSize:16},iconsContainer:{flexDirection:"row",alignItems:"center",gap:8},placeholder:{color:"#666"}});var lc={facebook:"facebook",instagram:"instagram",twitter:"twitter",youtube:"youtube",soundcloud:"soundcloud"},Ke=({site:e,value:t,onChange:o,isModalVisible:n,onModalClose:r})=>{let{handle:i,error:a}=useMemo(()=>{try{return {handle:getHandle(e,t)}}catch(l){return {error:l?.message??"Error parsing handle"}}},[t,e]),s=useMemo(()=>i?`${e.toUpperCase()}: ${i}`:e.toUpperCase(),[e,i]);return jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:[U.iconButton,!i&&U.iconButtonInactive],onPress:()=>r(),children:jsx(Text,{style:U.iconText,children:lc[e]})}),jsx(Modal,{visible:n,transparent:true,animationType:"slide",onRequestClose:r,children:jsx(View,{style:U.modalContainer,children:jsxs(View,{style:U.modalContent,children:[jsx(Text,{style:U.modalTitle,children:s}),a&&jsx(Text,{style:U.errorText,children:a}),jsx(TextInput,{style:U.modalInput,onChangeText:o,placeholder:"Handle or URL",value:t,autoCapitalize:"none",autoCorrect:false}),jsx(TouchableOpacity,{style:U.closeButton,onPress:r,children:jsx(Text,{style:U.closeButtonText,children:"Close"})})]})})})]})},xr=forwardRef((e,t)=>{let{input:{value:o,onChange:n},field:{sites:r}}=e,[i,a]=useState(null),s=useCallback((l,p)=>{let{[l]:c,...d}=o??{};!p&&Object.keys(d).length===0&&n({target:{value:void 0}}),p||n(d),n({...d,[l]:p});},[n,o]);return useImperativeHandle(t,()=>({blur:()=>{},focus:()=>{}})),jsxs(View,{style:U.container,children:[jsx(Text,{style:U.title,children:"Links"}),jsxs(View,{style:U.iconsContainer,children:[(!r||r.facebook)&&jsx(Ke,{onChange:l=>s("facebook",l),site:"facebook",value:o?.facebook,isModalVisible:i==="facebook",onModalClose:()=>a(null)}),(!r||r.instagram)&&jsx(Ke,{onChange:l=>s("instagram",l),site:"instagram",value:o?.instagram,isModalVisible:i==="instagram",onModalClose:()=>a(null)}),(!r||r.twitter)&&jsx(Ke,{onChange:l=>s("twitter",l),site:"twitter",value:o?.twitter,isModalVisible:i==="twitter",onModalClose:()=>a(null)}),(!r||r.youtube)&&jsx(Ke,{onChange:l=>s("youtube",l),site:"youtube",value:o?.youtube,isModalVisible:i==="youtube",onModalClose:()=>a(null)}),(!r||r.soundcloud)&&jsx(Ke,{onChange:l=>s("soundcloud",l),site:"soundcloud",value:o?.soundcloud,isModalVisible:i==="soundcloud",onModalClose:()=>a(null)})]})]})}),U=StyleSheet.create({container:{flex:1,padding:8},title:{fontSize:16,fontWeight:"bold",marginBottom:8,color:"#1A202C"},iconsContainer:{flexDirection:"row",flexWrap:"wrap",gap:8},iconButton:{width:34,height:34,borderRadius:17,backgroundColor:"#EDF2F7",justifyContent:"center",alignItems:"center"},iconButtonInactive:{opacity:.6},iconText:{fontSize:12,color:"#1A202C"},modalContainer:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)"},modalContent:{backgroundColor:"white",borderRadius:8,padding:16,width:"80%",maxWidth:300},modalTitle:{fontSize:16,fontWeight:"bold",marginBottom:8,color:"#1A202C"},errorText:{color:"#E53E3E",fontSize:14,marginBottom:8,padding:4,backgroundColor:"#FFF5F5"},modalInput:{borderWidth:1,borderColor:"#E2E8F0",borderRadius:4,padding:8,marginBottom:16,fontSize:16},closeButton:{backgroundColor:"#EDF2F7",padding:8,borderRadius:4,alignItems:"center"},closeButtonText:{color:"#1A202C",fontSize:16}});var Fo=forwardRef(({input:e,field:t,inEditable:o},n)=>{let r=useRef(null),{value:i,onChange:a,...s}=e;useImperativeHandle(n,()=>({focus:()=>{r.current?.focus();},blur:()=>{r.current?.blur();}}));let l=usePlaceholderColor(),p=useTextColor();return jsx(TextInput,{ref:r,style:[Sr.textarea,o&&Sr.inEditable,{color:p}],placeholder:t.placeholder,placeholderTextColor:l,multiline:true,numberOfLines:2,maxLength:200,textAlignVertical:"top",value:i??"",onChangeText:a,...s})});Fo.displayName="TextAreaComponent";var Sr=StyleSheet.create({textarea:{width:"100%",minHeight:80,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",textAlignVertical:"top"},inEditable:{paddingHorizontal:0,paddingVertical:0}});var Po=forwardRef(({input:e,inEditable:t,meta:o,field:n},r)=>{let{placeholder:i,type:a}=n,[s,l]=useState(a==="password"),{value:p,onChange:c,...d}=e,u=useRef(null);useImperativeHandle(r,()=>({focus:()=>{u.current?.focus();},blur:()=>{u.current?.blur();}}));let f=usePlaceholderColor(),h=useTextColor(),m=a==="textarea"?jsx(Fo,{inEditable:t,field:n,input:e,meta:o}):jsx(TextInput,{ref:u,style:[Xe.input,t&&Xe.inEditable,a==="password"&&Xe.passwordInput,{color:h}],secureTextEntry:s,placeholderTextColor:f,placeholder:i,value:p??"",onChangeText:c,...d});return a==="password"?jsxs(View,{style:Xe.passwordContainer,children:[m,jsx(TouchableOpacity,{style:Xe.eyeIcon,onPress:()=>l(!s),children:jsx(Ionicons,{name:s?"eye":"eye-off",size:20,color:"#666"})})]}):m});Po.displayName="TextComponent";var Xe=StyleSheet.create({input:{width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},inEditable:{paddingHorizontal:0,paddingVertical:0,height:"auto"},passwordInput:{paddingRight:40},passwordContainer:{width:"100%",flexDirection:"row",alignItems:"center",position:"relative"},eyeIcon:{position:"absolute",right:12,padding:4}});var Ro=forwardRef(({input:{onChange:e,value:t,onFocus:o,onBlur:n},field:{placeholder:r,optional:i}},a)=>{let[s,l]=useState(false);useImperativeHandle(a,()=>({focus:()=>{l(true),o();},blur:()=>{l(false),n();}}));let p=({hours:g,minutes:y})=>{l(false);let V=`${padZeros(g)}:${padZeros(y)}`;e(V),n();},c=()=>{l(false),n();},d=useMemo(()=>{if(!t)return null;let[g,y]=t.split(":").map(Number),V=g>=12?"PM":"AM";return `${g%12===0?12:g%12}:${padZeros(y)} ${V}`},[t]),{hours:u,minutes:f}=useMemo(()=>{if(!t)return {hours:0,minutes:0};let[g,y]=t.split(":").map(Number);return {hours:g,minutes:y}},[t]),h=useIconColor(),m=Me(t);return jsxs(View,{style:kt.container,children:[jsxs(TouchableOpacity,{style:kt.button,onPress:()=>{l(true),o();},children:[jsx(Text,{style:[kt.text,{color:m}],children:d??r}),jsx(Ionicons,{name:"time",size:20,color:h,style:kt.icon}),i&&t?jsx(ke,{onPress:()=>e(null),isActive:!!t}):null]}),jsx(Portal,{children:jsx(TimePickerModal,{visible:s,onDismiss:c,onConfirm:p,hours:u,minutes:f})})]})});Ro.displayName="TimeInput";var kt=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var Gc={text:Po,file:bo,boolean:Qn,select:wr,multipleSelect:mr,currency:hr,number:Vo,date:mo,datetime:ho,time:Ro,socialMedia:xr,color:rr},Yc=(e,t)=>{let{field:o,meta:{error:n,active:r,touched:i},input:a,inEditable:s}=e,{value:l}=a,p=useThemeValue("colors.text.500"),c=useThemeValue("colors.accent.400"),d=useThemeValue("colors.error.200"),u=useMemo(()=>new Animated.Value(0),[]),f=useMemo(()=>n&&i?n:null,[n,i]),h=useMemo(()=>f?"#ff7777":c,[f,c]);useEffect(()=>{Animated.timing(u,{toValue:r||f?1:0,duration:300,useNativeDriver:false}).start();},[r,f,u]);let m=u.interpolate({inputRange:[0,1],outputRange:[p,h]}),{_type:g,label:y}=o,V=useMemo(()=>g==="multipleSelect"||!!l&&g!=="file"&&g!=="boolean",[l,g]),S=useBackgroundColor(150),b=useMemo(()=>{if(s)return {};switch(g){case "text":case "number":case "currency":case "select":case "datetime":case "date":case "time":return {shadowColor:m,shadowOffset:{width:0,height:0},shadowOpacity:1,shadowRadius:7,elevation:10,backgroundColor:S};default:return {}}},[g,m,s,S]),v=useMemo(()=>Gc[g],[g]),T=useMemo(()=>s?0:n&&i?24:8,[s,n,i]);return jsxs(View,{style:[Ze.container,{paddingBottom:T}],children:[y&&!s?jsx(Text,{style:Ze.label,children:y}):null,jsx(Animated.View,{style:[Ze.inputContainer,b],children:jsx(v,{ref:t,...e})}),!s&&jsxs(Fragment,{children:[jsx(Text,{style:[Ze.errorText,{opacity:n&&i?1:0,color:d}],children:n}),jsx(Text,{style:[Ze.placeholder,{opacity:V?1:0}],children:o.placeholder??""})]})]})},Ze=StyleSheet.create({container:{position:"relative",width:"100%",paddingVertical:4,paddingHorizontal:4},label:{color:"#1A202C",fontSize:14,paddingHorizontal:8},inputContainer:{width:"100%",borderRadius:4,paddingVertical:1,overflow:"hidden"},errorText:{position:"absolute",bottom:0,fontSize:14,paddingHorizontal:4,color:"#E53E3E"},placeholder:{position:"absolute",top:-16,fontSize:14,paddingHorizontal:4,color:"rgba(0,0,0,0.6)"}}),Mt=forwardRef(Yc);var Xc=({field:e,name:t},o)=>{let{control:n,getOnChange:r,meta:i,onFocus:a,onBlur:s}=useField(t,e);return jsx(Controller,{control:n,name:t,render:({field:{name:l,ref:p,onBlur:c,...d}})=>jsx(Mt,{ref:o,field:e,input:{...d,onFocus:a,onBlur:()=>{s(),c();},onChange:r(d.onChange)},meta:i})})},Pr=forwardRef(Xc);var tt=StyleSheet.create({container:{width:"100%",flexDirection:"column"},progressContainer:{paddingHorizontal:8,height:26,width:"100%",justifyContent:"center",alignItems:"center"},progressBar:{height:"100%",width:"100%",borderRadius:13,backgroundColor:"rgba(0, 0, 0, 0.1)",overflow:"hidden"},progressFill:{height:"100%",backgroundColor:"#3182CE"},label:{position:"absolute",color:"white",fontSize:12,fontWeight:"500",textTransform:"uppercase",textShadowColor:"rgba(0, 0, 0, 0.67)",textShadowOffset:{width:1,height:1},textShadowRadius:3}}),Et=({uploads:e})=>{let t=useMemo(()=>Object.values(e),[e]);return jsx(View,{style:tt.container,children:t.map(o=>jsxs(Animated.View,{style:tt.progressContainer,children:[jsx(View,{style:tt.progressBar,children:jsx(Animated.View,{style:[tt.progressFill,{width:`${o.percent*100}%`}]})}),jsx(Text,{style:tt.label,children:o.label})]},o.label))})};var ne=StyleSheet.create({container:{width:"100%"},progressContainer:{height:5,width:"100%"},footerContainer:{flexDirection:"row",paddingVertical:8,borderTopWidth:1,borderTopColor:palette.gray.light,paddingHorizontal:12,width:"100%"},cancelButton:{flex:1,paddingVertical:8,paddingHorizontal:16,borderWidth:1,borderColor:"#cdcdcd",borderRadius:4,marginRight:8},cancelButtonText:{color:"#777",textAlign:"center"},submitButton:{flex:1,paddingVertical:8,paddingHorizontal:16,borderRadius:4,backgroundColor:palette.cyan.light},submitButtonText:{color:"#fff",textAlign:"center"},errorText:{color:"red",paddingHorizontal:12,paddingVertical:4},disabledButton:{opacity:.5}}),id=({onBack:e,children:t})=>jsx(TouchableOpacity,{style:ne.cancelButton,onPress:e,children:jsx(Text,{style:ne.cancelButtonText,children:t})}),ad=({onSubmitClick:e,submitting:t,children:o})=>jsx(TouchableOpacity,{style:[ne.submitButton,t&&ne.disabledButton],onPress:e,disabled:t,children:t?jsx(ActivityIndicator,{color:"#fff"}):jsx(Text,{style:ne.submitButtonText,children:o})}),ld=()=>{let{formError:e}=useChempoForm();return e?jsx(Text,{style:ne.errorText,children:e}):null},Mr=({isLoading:e,uploads:t,onSubmit:o,renderFooter:n,onBack:r,buttonText:i})=>{let{isSubmitting:a,isValid:s}=useFormState();return jsxs(View,{style:ne.container,children:[e&&jsx(View,{style:ne.progressContainer,children:jsx(ActivityIndicator,{})}),jsx(Et,{uploads:t}),jsx(ld,{}),n?n({}):jsxs(View,{style:ne.footerContainer,children:[r&&jsx(id,{onBack:r,children:"Cancel"}),jsx(ad,{onSubmitClick:o,submitting:a||!s,children:i})]})]})};var ot=StyleSheet.create({container:{flexDirection:"column"},rowContainer:{flexDirection:"row"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},emptyText:{opacity:.7},fileContainer:{padding:4}}),zr=({field:e,value:t,noLabel:o,style:n})=>{let{imageOptions:r,placeholder:i}=e,a=useMemo(()=>({height:150,...r}),[r]);return jsxs(View,{style:[t?ot.container:ot.rowContainer,n],children:[!o&&jsx(Text,{style:ot.label,children:i}),t?jsx(View,{style:ot.fileContainer,children:jsx(vt,{imageOptions:a,value:t})}):jsx(Text,{style:ot.emptyText,children:"None"})]})};var Lt=StyleSheet.create({container:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",maxWidth:"100%"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},optionContainer:{padding:2},emptyText:{opacity:.6}}),Nr=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r,renderOption:i,getOptionKey:a}=e,s=useColorScheme()??"light";return jsxs(View,{style:[Lt.container,n],children:[!o&&jsx(Text,{style:Lt.label,children:r}),t?t.map(l=>jsx(View,{style:Lt.optionContainer,children:i(l,s,true)},a?a(l):l)):jsx(Text,{style:Lt.emptyText,children:"None"})]})};var Wr=StyleSheet.create({container:{flexDirection:"row",alignItems:"center"},label:{paddingRight:8,opacity:.7,fontWeight:"600"}}),bd=e=>jsx(G,{children:typeof e=="string"?e:JSON.stringify(e)}),Ur=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r,renderOption:i}=e,a=useColorScheme()??"light",s=usePlaceholderColor(),l=i??bd;return jsxs(View,{style:[Wr.container,n],children:[!o&&jsx(Text,{style:[Wr.label,{color:s}],children:r}),t?l(t,a,true):"None"]})};var Ht=StyleSheet.create({container:{flexDirection:"row",alignItems:"center"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},value:{opacity:1},valueEmpty:{opacity:.6}}),Id=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r}=e,i=useMemo(()=>{let a=formatField[e._type];return a?a(e,t):t},[t,e]);return jsxs(View,{style:[Ht.container,n],children:[!o&&jsx(Text,{style:Ht.label,children:r}),jsx(Text,{style:t!=null?Ht.value:Ht.valueEmpty,children:i??"None"})]})},Nt=({field:e,value:t,noLabel:o,style:n})=>{switch(e._type){case "select":return jsx(Ur,{style:n,field:e,value:t,noLabel:o});case "multipleSelect":return jsx(Nr,{style:n,field:e,value:t,noLabel:o});case "file":return jsx(zr,{style:n,field:e,value:t,noLabel:o});default:return jsx(Id,{style:n,field:e,value:t,noLabel:o})}};var Rd=({onChange:e,value:t,field:o,onBlur:n,inEditable:r,onFocus:i,style:a},s)=>{let{inputProps:l,meta:p}=useStandaloneInput(o,t,e,i,n);return jsx(Mt,{ref:s,field:o,inEditable:r,style:a,input:l,meta:p})},Gr=forwardRef(Rd);var Kr=({value:e,field:t,onSubmit:o,storagePath:n,style:r,onEditClose:i,onEditOpen:a})=>{let{formattedValue:s,inputRef:l,setValue:p,isLoading:c,uploads:d,editHovered:u,handleEditOpen:f,handleEditClose:h,isEditing:m,value:g,setEditHovered:y,submit:V,parse:S}=useEditable({value:e,field:t,onSubmit:o,storagePath:n,onEditOpen:a,onEditClose:i}),b=useMemo(()=>t._type==="file"||t._type==="boolean",[t]);useEffect(()=>{m&&l.current?.focus();},[m,l]);let v=useColorModeValue("#00000055","#ffffff55");return jsxs(View,{style:[xe.container,{borderColor:u&&!m?v:"transparent"},r],children:[jsxs(View,{style:xe.contentContainer,children:[jsx(View,{style:[xe.inputContainer,{opacity:c?0:1,borderColor:m?v:"transparent"}],children:m||b?jsx(Gr,{ref:l,value:s,inEditable:true,field:t,style:[xe.input,r],onChange:b?T=>V(S(T)):T=>p(S(T))}):jsx(Nt,{style:r,field:t,value:g})}),!b&&jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:xe.editButton,onPress:()=>{m?(p(g),h()):f();},onPressIn:()=>y(true),onPressOut:()=>y(false),children:jsx(Ionicons,{name:m?"close":"create-outline",size:20,color:palette.gray.medium})}),jsx(View,{style:[xe.submitButtonContainer,{width:m?30:0,opacity:m?1:0}],children:jsx(TouchableOpacity,{style:[xe.submitButton,{backgroundColor:palette.cyan.light}],onPress:()=>void V(g),children:jsx(Ionicons,{name:"checkmark",size:20,color:"#fff"})})})]}),jsx(mt,{isLoading:c})]}),jsx(Et,{uploads:d})]})},xe=StyleSheet.create({container:{borderRadius:4,borderWidth:1,borderStyle:"dashed",width:"100%"},contentContainer:{flexDirection:"row",alignItems:"center",paddingHorizontal:4,position:"relative",width:"100%"},inputContainer:{flex:1,minWidth:0,borderWidth:1,borderStyle:"dashed"},input:{padding:0},editButton:{padding:4,marginLeft:4},submitButtonContainer:{justifyContent:"flex-end",overflow:"hidden"},submitButton:{padding:4,borderRadius:4}});var R=StyleSheet.create({container:{width:"100%"},listContainer:{width:"100%",paddingHorizontal:8,paddingVertical:4,gap:8},listHeader:{fontSize:14,opacity:.7,lineHeight:1},listContent:{gap:8,paddingVertical:4,minHeight:30},listItem:{paddingTop:8,paddingHorizontal:8,borderWidth:1,borderColor:"#e2e8f0",borderRadius:4},listItemContent:{flexDirection:"row",alignItems:"center",gap:4,width:"100%"},listItemInput:{flex:1,minWidth:0},emptyListText:{fontSize:14,opacity:.7,paddingVertical:4,paddingHorizontal:8},newButton:{alignSelf:"flex-start",paddingVertical:4,paddingHorizontal:8,borderRadius:4,backgroundColor:"#f7fafc"},newButtonText:{fontSize:14,color:"#4a5568"},formElementContainer:{width:"100%",gap:4},dataViewHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,width:"100%"},dataViewTitle:{fontSize:18,fontFamily:"System",paddingVertical:8},dataViewActions:{flexDirection:"row",alignItems:"center",gap:8,marginLeft:"auto"},dataViewContent:{paddingHorizontal:16,paddingVertical:8}}),Yd=({field:e,name:t})=>{let o=useMemo(()=>isField(e.itemField)?"":isListField(e.itemField)?[]:{},[e]),{control:n}=useFormContext(),{fields:r,append:i,remove:a}=useFieldArray({control:n,name:t});return jsxs(View,{style:R.listContainer,children:[jsx(Text,{style:R.listHeader,children:e.placeholder}),jsx(View,{style:R.listContent,children:r.length?r.map((s,l)=>jsx(View,{style:R.listItem,children:jsxs(View,{style:R.listItemContent,children:[jsx(View,{style:R.listItemInput,children:jsx(Lo,{name:s.id,field:e.itemField})}),jsx(Xt,{onDelete:()=>a(l),itemName:`${e.placeholder} ${l+1}`})]})},s.id)):jsx(Text,{style:R.emptyListText,children:"No items"})}),jsx(TouchableOpacity,{style:R.newButton,onPress:()=>i(o),children:jsx(Text,{style:R.newButtonText,children:"+ NEW"})})]})},Lo=({field:e,name:t})=>{let o=useMemo(()=>isField(e)||isListField(e)?[{name:"value",field:e}]:Object.entries(e.children).map(([n,r])=>({name:`${t?`${t}.`:""}${n}`,field:r})),[e,t]);return jsx(View,{style:R.formElementContainer,children:o.map(n=>{if(isListField(n.field)){let i=jsx(Yd,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(Ct,{path:t,condition:n.field.condition,children:i},n.name):i}if(isField(n.field)){let i=jsx(Pr,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(Ct,{path:t,condition:n.field.condition,children:i},n.name):i}let r=jsx(Lo,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(Ct,{path:t,condition:n.field.condition,children:r},n.name):r})})},_d=({field:e,value:t,path:o})=>{let{itemField:n,placeholder:r}=e;return jsx(View,{style:R.listContainer,children:jsx(Yt,{header:()=>jsx(Text,{style:R.listHeader,children:r}),initExpanded:true,children:jsx(View,{style:R.listContent,children:t?.length?t.map((i,a)=>jsx(View,{style:R.listItem,children:jsx(qr,{path:`${o}.${a}`,field:{...n,placeholder:`${r} ${a+1}`},value:i})},`${o}.${a}`)):jsx(Text,{style:R.emptyListText,children:"No items"})})})})},qr=({field:e,value:t,path:o,storagePath:n})=>{let{updateField:r}=useDataView();return isField(e)?r?jsx(Kr,{storagePath:n,field:e,value:t,onSubmit:i=>r(o,i)}):jsx(Nt,{field:e,value:t}):isListField(e)?jsx(_d,{path:o,field:e,value:t}):jsx(Jd,{storagePath:n?`${n}.${o}`:void 0,path:o,field:e})},Jd=({field:e,value:t,onClose:o,onDelete:n,onSubmit:r,itemName:i,storagePath:a,path:s=""})=>{let{name:l,children:p}=e,[c,d]=useState(false);return jsx(DataViewProvider,{value:t,onSubmit:r,children:jsx(Yt,{alwaysExpanded:true,header:()=>jsxs(View,{style:R.dataViewHeader,children:[jsx(Text,{style:R.dataViewTitle,children:l}),jsxs(View,{style:R.dataViewActions,children:[n&&jsx(Xt,{onDelete:n,itemName:i??"item"}),r&&jsx(TouchableOpacity,{onPress:()=>d(true),children:jsx(Text,{children:"Edit"})}),o&&jsx(TouchableOpacity,{onPress:o,children:jsx(Text,{children:"Close"})})]})]}),children:c&&r?jsx(qd,{storagePath:a,field:e,value:t,onSubmit:r,onBack:()=>d(false)}):jsx(View,{style:R.dataViewContent,children:Object.entries(p).map(([u,f])=>jsx(qr,{storagePath:a?`${a}/${u}`:void 0,path:s?`${s}.${u}`:u,field:f,value:t?.[u]},u))})})})},Xr=({onSubmit:e,onBack:t,field:o,value:n,buttonText:r="SUBMIT",renderFooter:i,storagePath:a})=>{let s=useMemo(()=>({field:o,value:n,onSubmit:e,storagePath:a}),[o,n,e,a]),{submit:l,uploads:p,isLoading:c}=useSubmitData(s),d=useFormSubmit(o,l);return jsxs(View,{style:R.container,children:[jsx(Lo,{name:"",field:o}),jsx(Mr,{isLoading:c,uploads:p,onSubmit:d,renderFooter:i,onBack:t,buttonText:r})]})},Kd=({onSubmit:e,field:t,value:o,...n})=>{let r=useMemo(()=>({children:{value:t}}),[t]);return jsx(Xr,{field:r,value:{value:o},onSubmit:i=>e(i),...n})},qd=({field:e,...t})=>{let o=isField(e)||isListField(e)?jsx(Kd,{field:e,...t}):jsx(Xr,{field:e,...t});return jsx(ChempoFormProvider,{children:o})};var ru=()=>{let{colorMode:e,toggleColorMode:t}=useTheme(),o=e==="dark",n=useIconColor(),r=o?"moon":"sunny",i=useBackgroundColor(100);return jsx(TouchableOpacity,{onPress:t,style:[Qr.button,{backgroundColor:i}],children:jsx(Ionicons,{name:r,size:16,color:n})})},vw=()=>jsx(View,{style:Qr.container,children:jsx(ru,{})}),Qr=StyleSheet.create({container:{position:"absolute",bottom:12,right:12},button:{width:25,height:25,borderRadius:16,justifyContent:"center",alignItems:"center"}});var ti={closeMessage:()=>Notifier.hideNotification(),showMessage:({title:e,type:t,duration:o,message:n})=>{let r=t==="info"?NotifierComponents.Notification:NotifierComponents.Alert,i={alertType:t==="error"?"error":"success"};return Notifier.showNotification({title:e,description:n,duration:o,Component:r,componentProps:i}),"root"}};var oi=e=>{let{initialColorMode:t,theme:o}=e??{},[n,r]=useState(t??"light");return useMemo(()=>({colorMode:n,setColorMode:r,theme:o}),[n,r,o])};var ri=()=>{let e=()=>{let{width:o,height:n}=Dimensions.get("window");useScreen.setState({width:o,height:n,isMobile:true,isPortrait:o<n});};e();let t=Dimensions.addEventListener("change",e);return ()=>{t.remove();}};registerTranslation("en",en);var Yw=({theme:e,initialColorMode:t,...o})=>{let n=useMemo(()=>({theme:e,initialColorMode:t}),[e,t]),r=oi(n);return jsx(ChempoProvider,{toast:ti,theme:r,initializeScreen:ri,...o})};export{vw as AbsoluteDarkModeToggle,at as AnimatedCenter,ue as Center,Yw as ChempoNativeProvider,In as CircularProgress,Iu as CollapseHorizontal,Ou as ContentBox,ru as DarkModeToggle,Jd as DataView,Xt as DeleteButton,Ei as DeleteConfirmAlert,jt as DropShadow,Kr as Editable,np as ExpandOnMount,Yt as Expandable,Kd as FieldForm,Xr as FieldMapForm,vt as FileView,qd as Form,Lo as FormElement,dp as FullSizeContainer,up as FullSizeProvider,An as ImageViewOverlay,Yd as ListFieldInput,oo as Loading,kp as LoadingButton,Bn as LoadingImage,ge as LoadingLogo,mt as LoadingOverlay,Ym as LoadingSwitch,fn as LottieLoadingLogo,Hf as MediaFeed,Gr as StandaloneInput,Wp as Toggle,G as Txt,ri as initializeScreen,ti as nativeToast,pp as useFullSize,na as useMediaFeed,oi as useThemeState};//# sourceMappingURL=index.mjs.map
1
+ import Pi,{forwardRef,createContext,useCallback,useMemo,useImperativeHandle,useState,useRef,useEffect,useContext}from'react';import {View,StyleSheet,Animated,Text,TouchableOpacity,TextInput,Switch,Modal,ScrollView,Image,Platform,Pressable,ActivityIndicator,Dimensions,useColorScheme,ImageBackground}from'react-native';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useIconColor,usePlaceholderColor,useBorderColor,useColorMode,useTextColor,useBackgroundColor,useThemeValue,useField,useStandaloneInput,useMounted,useAppAssets,useScreen,useTheme,useToast,useColorModeValue,useEditable,useButtonColor,DataViewProvider,useFormSubmit,ChempoFormProvider,ChempoProvider,useAuth,useDocument,useDataView,useObjectUrl}from'@chem-po/react';import {Ionicons}from'@expo/vector-icons';import {Gesture,GestureDetector}from'react-native-gesture-handler';import da from'lottie-react-native';import tl from'@expo/vector-icons/MaterialCommunityIcons';import {colorValueToHex,gradients,getDateString,getDateTimeString,padZeros,getHandle,getFieldValidate,palette,isField,isListField,formatField}from'@chem-po/core';import {Controller,useFormContext,useFieldArray,useWatch,useFormState}from'react-hook-form';import Ol from'@react-native-community/slider';import {Portal}from'react-native-paper';import {DatePickerModal,TimePickerModal,registerTranslation,en}from'react-native-paper-dates';import*as fr from'expo-document-picker';import*as gr from'expo-image-picker';import {Notifier,NotifierComponents,NotifierWrapper}from'react-native-notifier';var de=forwardRef(({style:e,...t},o)=>jsx(View,{ref:o,style:[$o.center,e],...t})),lt=forwardRef(({style:e,...t},o)=>jsx(Animated.View,{ref:o,style:[$o.center,e],...t})),$o=StyleSheet.create({center:{flex:1,justifyContent:"center",alignItems:"center"}});var _u=({width:e,children:t,active:o,duration:n=400,style:r,...i})=>{let a=useRef(new Animated.Value(o?e:0)).current,s=useRef(new Animated.Value(o?1:0)).current;useEffect(()=>{Animated.parallel([Animated.timing(a,{toValue:o?e:0,duration:n,useNativeDriver:false}),Animated.timing(s,{toValue:o?1:0,duration:n,useNativeDriver:true})]).start();},[o,a,s,e,n]);let l=useMemo(()=>({width:a,opacity:s,overflow:"hidden"}),[a,s]);return jsx(lt,{style:[l,r],...i,children:t})};var wi=(e,t)=>jsx(View,{ref:t,style:[bi.container,e.style],...e}),bi=StyleSheet.create({container:{backgroundColor:"#FFFFFF",padding:12,borderRadius:6,shadowColor:"#000000",shadowOffset:{width:1,height:1},shadowOpacity:.4,shadowRadius:4,elevation:4}}),Zu=forwardRef(wi);var Gt=({children:e,style:t})=>jsx(View,{style:[{...Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84},android:{elevation:5}})},t],children:e});var Y=({children:e,...t})=>{let o=useTextColor();return jsx(Text,{...t,style:[{color:o},t.style],children:e})};var _t=({header:e,children:t,initExpanded:o=false,nested:n,alwaysExpanded:r,iconColor:i="#000",footer:a,isOpen:s,onClose:l,onOpen:u,style:p})=>{let[d,c]=Pi.useState(r??o),f=useRef(new Animated.Value(0)).current,h=useRef(new Animated.Value(0)).current;useEffect(()=>{typeof s<"u"&&c(s);},[s]);let m=useCallback(()=>{c(false),l?.();},[l]),g=useCallback(()=>{c(true),u?.();},[u]),y=useCallback(()=>{r||(d?m():g());},[r,g,m,d]);useEffect(()=>{Animated.parallel([Animated.timing(f,{toValue:d?1:0,duration:300,useNativeDriver:false}),Animated.timing(h,{toValue:d?1:0,duration:300,useNativeDriver:true})]).start();},[d,f,h]);let b=h.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]});return jsxs(View,{style:[ue.container,p],children:[jsxs(Pressable,{onPress:y,style:ue.header,children:[jsx(View,{style:ue.headerContent,children:typeof e=="string"?jsx(Y,{style:ue.headerText,children:e}):e({isOpen:d,onClose:m})}),!r&&jsx(Animated.Text,{style:[ue.arrow,{transform:[{rotate:b}],color:i}],children:"\u25BC"})]}),jsx(lt,{style:[ue.content,n&&ue.nested,{maxHeight:f.interpolate({inputRange:[0,1],outputRange:[0,1e3]})}],children:t}),a?.({isOpen:d,onClose:m})]})},ue=StyleSheet.create({container:{width:"100%"},header:{flexDirection:"row",padding:8,alignItems:"center"},headerContent:{flex:1},headerText:{fontWeight:"600",color:"#666"},arrow:{fontSize:12,marginLeft:8},content:{width:"100%",overflow:"hidden"},nested:{borderLeftWidth:4,borderLeftColor:"rgba(0,0,0,0.2)"}});var Fp=({animateOpacity:e,duration:t=300,children:o,in:n=true,onExited:r,style:i,...a})=>{let[s,l]=useState(false);useEffect(()=>{l(true);},[]);let[u,p]=useState(0),d=useRef(null),c=useMemo(()=>s&&n,[n,s]),f=useRef(new Animated.Value(0)).current,h=useRef(new Animated.Value(0)).current;return useEffect(()=>{d.current&&d.current.measure((m,g,y,b)=>{p(b);});},[o]),useEffect(()=>{let m=[Animated.timing(f,{toValue:c?u:0,duration:t,useNativeDriver:false})];e&&m.push(Animated.timing(h,{toValue:c?1:0,duration:t,delay:c?t:0,useNativeDriver:true})),Animated.parallel(m).start(()=>{!c&&r&&r();});},[c,u,t,f,h,e,r]),jsx(Animated.View,{style:[{overflow:"hidden",width:"100%",height:f},i],...a,children:jsx(View,{ref:d,style:[{width:"100%"},e&&{opacity:h},i],...a,children:o})})};var kp=({children:e,...t})=>{let[o,n]=useState(0),[r,i]=useState(0),a=useRef(null),s=useCallback(l=>{let{width:u,height:p}=l.nativeEvent.layout;n(u),i(p);},[]);return jsx(View,{ref:a,...t,style:[{width:"100%",height:"100%"},t.style],onLayout:s,children:e({width:o,height:r})})},tn=createContext({width:0,height:0}),Dp=({children:e,...t})=>{let[o,n]=useState(0),[r,i]=useState(0),a=useRef(null),s=useCallback(u=>{let{width:p,height:d}=u.nativeEvent.layout;n(p),i(d);},[]),l=useMemo(()=>({width:o,height:r}),[o,r]);return jsx(View,{ref:a,...t,style:[{width:"100%",height:"100%"},t.style],onLayout:s,children:jsx(tn.Provider,{value:l,children:e})})},Bp=()=>useContext(tn);var Hi="Are you sure? You can't undo this action afterwards.",Ni=({confirmActive:e,onCancel:t,onConfirm:o,body:n=Hi,actionName:r="Delete",actionLoading:i,itemName:a})=>jsx(Modal,{transparent:true,visible:e,onRequestClose:t,animationType:"fade",children:jsx(View,{style:O.overlay,children:jsxs(View,{style:O.alertContainer,children:[jsxs(Y,{style:O.alertTitle,children:[r," ",a,"?"]}),typeof n=="string"?jsx(Y,{style:O.alertBody,children:n}):n,jsxs(View,{style:O.buttonContainer,children:[jsx(TouchableOpacity,{style:O.cancelButton,onPress:t,children:jsx(Y,{style:O.cancelText,children:"Cancel"})}),jsx(TouchableOpacity,{style:O.confirmButton,onPress:o,disabled:i,children:i?jsx(ActivityIndicator,{color:"#fff"}):jsx(Y,{style:[O.buttonText,O.confirmButtonText],children:r})})]})]})})}),Qt=({onDelete:e,itemName:t,noConfirm:o,alertBody:n,text:r,actionName:i="Delete",style:a})=>{let{showError:s}=useToast(),[l,u]=useState(false),[p,d]=useState(false),c=useRef(),f=useRef(true),h=useRef(new Animated.Value(1)).current,m=useRef(new Animated.Value(0)).current;useEffect(()=>(f.current=true,()=>{f.current=false;}),[]);let g=useCallback(b=>{Animated.parallel([Animated.timing(h,{toValue:b?0:1,duration:200,useNativeDriver:true}),Animated.timing(m,{toValue:b?1:0,duration:200,useNativeDriver:true})]).start();},[h,m]),y=useCallback(async()=>{if(c.current&&clearTimeout(c.current),d(false),e){u(true),g(true);try{await e();}catch(b){console.error(b),s(b.message??"An error occurred");}f.current&&(u(false),g(false));}else console.error("No delete function");},[e,g]);return jsxs(Fragment,{children:[r?jsx(TouchableOpacity,{style:[O.button,a],onPress:b=>{b.stopPropagation(),o?y():d(true);},disabled:l,children:jsxs(View,{style:O.buttonContent,children:[jsxs(Animated.View,{style:[O.contentContainer,{opacity:h}],children:[jsx(Ionicons,{name:"trash",size:20,color:"red"}),jsx(Text,{style:O.buttonText,children:r})]}),jsx(Animated.View,{style:[O.loaderContainer,{opacity:m}],children:jsx(ActivityIndicator,{color:"#ff0000",size:"small"})})]})}):jsx(TouchableOpacity,{style:[O.iconButton,a],onPress:b=>{b.stopPropagation(),o?y():d(true);},disabled:l,children:jsxs(View,{style:O.buttonContent,children:[jsx(Animated.View,{style:[O.contentContainer,{opacity:h}],children:jsx(Ionicons,{name:"trash",size:24,color:"#ee0000"})}),jsx(Animated.View,{style:[O.loaderContainer,{opacity:m}],children:jsx(ActivityIndicator,{color:"#ff0000",size:"small"})})]})}),o?null:jsx(Ni,{confirmActive:p,onCancel:()=>d(false),actionLoading:l,onConfirm:()=>{y();},actionName:i,body:n,itemName:t})]})},O=StyleSheet.create({overlay:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)"},alertContainer:{width:"80%",maxWidth:400,backgroundColor:"white",borderRadius:10,padding:20,alignItems:"center"},alertTitle:{fontSize:18,fontWeight:"bold",marginBottom:10},alertBody:{fontSize:16,marginBottom:20},buttonContainer:{flexDirection:"row",justifyContent:"space-between",width:"100%"},cancelButton:{padding:10,borderColor:"gray",borderWidth:1,borderRadius:5,flex:1,marginRight:5,alignItems:"center"},cancelText:{color:"gray",fontWeight:"bold"},confirmButton:{padding:10,backgroundColor:"red",borderRadius:5,flex:1,marginLeft:5,alignItems:"center"},buttonText:{color:"red",fontWeight:"bold"},confirmButtonText:{color:"white",textShadowColor:"rgba(0, 0, 0, 0.5)",textShadowOffset:{width:1,height:1},textShadowRadius:3},button:{flexDirection:"row",alignItems:"center",padding:10,backgroundColor:"transparent"},buttonContent:{flexDirection:"row",gap:3,borderWidth:1,borderColor:"red",paddingHorizontal:13,paddingVertical:5,borderRadius:4,alignItems:"center",justifyContent:"center",minHeight:34,position:"relative"},contentContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:3},loaderContainer:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},iconButton:{padding:10,backgroundColor:"transparent"},loading:{position:"absolute",top:0,left:0,justifyContent:"center",alignItems:"center",height:24,width:24}});var tm=({onPress:e,children:t,style:o,textStyle:n,color:r,icon:i,disabled:a=false})=>{let[s,l]=useState(false),u=useRef(true),p=useRef(new Animated.Value(1)).current,d=useRef(new Animated.Value(0)).current,{showError:c}=useToast();useEffect(()=>(u.current=true,()=>{u.current=false;}),[]);let f=useCallback(y=>{Animated.parallel([Animated.timing(p,{toValue:y?0:1,duration:200,useNativeDriver:true}),Animated.timing(d,{toValue:y?1:0,duration:200,useNativeDriver:true})]).start();},[p,d]),h=useCallback(async()=>{if(e){l(true),f(true);try{await e();}catch(y){console.error(y),c(y.message??"An error occurred");}u.current&&(l(false),f(false));}},[e,f,c]),m=useTextColor(),g=useMemo(()=>r??m,[r,m]);return jsx(TouchableOpacity,{style:[Le.button,{borderColor:g,backgroundColor:a?"#f0f0f0":"transparent"},o],onPress:y=>{y.stopPropagation(),h();},disabled:s||a,children:jsxs(View,{style:[Le.buttonContent,{borderColor:a?"#ccc":g}],children:[jsxs(Animated.View,{style:[Le.contentContainer,{opacity:p}],children:[i&&jsx(Ionicons,{name:i.name,size:i.size??20,color:a?"#ccc":g}),typeof t=="string"?jsx(Text,{style:[Le.buttonText,{color:a?"#ccc":g},n],children:t}):t]}),jsx(Animated.View,{style:[Le.loaderContainer,{opacity:d}],children:jsx(ActivityIndicator,{color:g,size:"small"})})]})})},Le=StyleSheet.create({button:{flexDirection:"row",alignItems:"center",backgroundColor:"transparent"},buttonContent:{flexDirection:"row",gap:8,borderWidth:1,paddingHorizontal:16,paddingVertical:8,borderRadius:4,alignItems:"center",justifyContent:"center",minHeight:40,position:"relative"},contentContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},loaderContainer:{...StyleSheet.absoluteFillObject,alignItems:"center",justifyContent:"center"},buttonText:{fontWeight:"bold"}});var na=({selected:e,option:{Render:t,disabledMessage:o},size:n,onPress:r})=>{let{showError:i}=useToast(),a=useCallback(()=>{o?i(o):r();},[r,o,i]);return jsx(View,{style:[eo.buttonContainer,{width:n,height:n,opacity:o?.6:1}],children:jsx(TouchableOpacity,{style:[eo.button,{backgroundColor:e?"rgba(255, 255, 255, 0.5)":"rgba(0, 0, 0, 0.1)",pointerEvents:e?"none":"auto"}],onPress:a,disabled:!!o,children:t(e)})})},sm=({value:e,onChange:t,size:o=28,options:n})=>{let{theme:{colors:{background:r}}}=useTheme();return jsx(View,{style:[eo.container,{borderColor:r[300]}],children:n.map(i=>jsx(na,{onPress:()=>{t(i.id);},option:i,size:o,selected:i.id===e},i.id))})},eo=StyleSheet.create({container:{flexDirection:"row",borderWidth:1,borderRadius:3},buttonContainer:{justifyContent:"center",alignItems:"center"},button:{justifyContent:"center",alignItems:"center",borderRadius:3}});var un=createContext({}),pn=({curr:e,children:t})=>{let o=useMemo(()=>({curr:e}),[e]);return jsx(un.Provider,{value:o,children:t})},la=()=>useContext(un);var mn={top:0,left:0,right:0,bottom:0,display:"flex"},ie=StyleSheet.create({absolute:{...mn,position:"absolute"},relative:{...mn,position:"relative"}});var hn=({size:e=30,isLoading:t,speed:o=2,inFeed:n,asset:r})=>{let{colorMode:i}=useTheme(),a=useMemo(()=>n||i==="dark"?r.dark??r.default:r.default,[r,n,i]),s=useMemo(()=>({width:e,height:e,opacity:t?.85:0}),[e,t]);return jsx(da,{source:a,autoPlay:t,loop:true,speed:o,style:s})},yn=({size:e=30,isLoading:t,asset:o,inFeed:n})=>{let{colorMode:r}=useTheme(),i=useMemo(()=>n||r==="dark"?o.dark??o.default:o.default,[o,n,r]),a=useMemo(()=>({width:e,height:e,opacity:t?.85:0}),[e,t]);return jsx(Image,{source:{uri:i},style:a})},ma=({isLoading:e,size:t})=>{let{loading:o}=useAppAssets();return o.lottieJson?jsx(hn,{isLoading:e,size:t,asset:o.lottieJson}):o.svg?jsx(yn,{isLoading:e,size:t,asset:o.svg}):null},fe=({isLoading:e,size:t,inFeed:o})=>{let{loading:n}=useAppAssets();return n.lottieJson?jsx(hn,{inFeed:o,isLoading:e,size:t,asset:n.lottieJson}):n.svg?jsx(yn,{inFeed:o,isLoading:e,size:t,asset:n.svg}):jsx(Text,{style:Ne.errorText,children:"ERROR: No loading animation found"})},no=({text:e="Loading...",inBox:t,containerStyle:o})=>{let n=jsxs(View,{style:[Ne.loadingContainer,o],children:[jsx(ma,{isLoading:true}),jsx(Text,{style:Ne.loadingText,children:e})]});return t?jsx(View,{style:Ne.boxContainer,children:n}):n},ft=({isLoading:e,text:t,inFeed:o,style:n})=>{let{colorMode:r}=useTheme(),i=r==="dark"?"rgba(0, 0, 0, 0.53)":"rgba(255, 255, 255, 0.67)";return jsx(View,{style:[Ne.overlay,{backgroundColor:i},{opacity:e?1:0},n],children:t?jsx(no,{text:t}):jsx(fe,{inFeed:o,size:100,isLoading:e})})},Ne=StyleSheet.create({loadingContainer:{flexDirection:"row",alignItems:"center",padding:8},loadingText:{opacity:.8,fontSize:14,marginLeft:8},boxContainer:{padding:16,borderRadius:8,backgroundColor:"rgba(0, 0, 0, 0.05)"},overlay:{position:"absolute",top:0,left:0,right:0,bottom:0,justifyContent:"center",alignItems:"center"},errorText:{color:"red"}});var wa=e=>e==="current"?1:0,Cn=(e,t)=>{let{height:o}=t;return e==="current"?0:e==="next"?o*1.1:e==="prev"?-o*1.1:0},xn=({id:e,collectionPath:t,onItemLoad:o,RenderItem:n,status:r,offsetY:i,enterStatus:a})=>{let{height:s,width:l}=useScreen(),u=useMemo(()=>({height:s,width:l}),[s,l]),p=useRef(new Animated.Value(0)).current,d=useRef(new Animated.Value(Cn(a??"next",u))).current,c=Animated.add(d,i),f=useMemo(()=>`${t}/${e}`,[t,e]),{data:h}=useDocument(f,o);return useEffect(()=>{let m=wa(r),g=Cn(r,u);d.setValue(g),p.setValue(m);},[r,d,p,u]),jsx(Animated.View,{style:{position:"absolute",top:0,left:0,transform:[{translateY:c},{scale:p}],display:"flex",alignItems:"center",justifyContent:"center",height:"100%",opacity:p,width:"100%"},children:h?n(h):null})};var Va=10,Vn=(e,t,o=Va,n=false)=>{let[r,i]=useState([null,null,null]),[a,s]=useState(0),l=useAuth(V=>V.user),[u,p]=useState(false),[d,c]=useState(false),[f,h]=useState(null),[m,g]=useState(false),[y,b]=useState(null),T=useRef(null),C=useRef({prev:null,curr:null,next:null}),{showInfo:D,showError:B}=useToast(),I=useCallback(V=>{V&&(C.current.prev===V&&(C.current.prev=null),C.current.next===V&&(C.current.next=null)),C.current.curr=V,t({...C.current});},[t]),M=useCallback(V=>{V&&(C.current.prev===V&&(C.current.prev=null),C.current.curr===V&&(C.current.curr=null)),C.current.next=V,t({...C.current});},[t]),E=useCallback(V=>{V&&(C.current.curr===V&&(C.current.curr=null),C.current.next===V&&(C.current.next=null)),C.current.prev=V,t({...C.current});},[t]),P=useCallback(async(V,v,k)=>{if(!l&&n)return [];k||p(true);try{let S=await e({limit:o,startAfter:v,startBefore:V});if(k)v?i(x=>[x[0],x[1],S.ids]):V&&i(x=>[S.ids,x[1],x[2]]);else {let x=S.ids[0],_=S.ids[1]||null;I(x),M(_),E(v),i(v?W=>[W[1],S.ids,null]:V?W=>[null,S.ids,W[1]]:[null,S.ids,null]);let N=S.ids[S.ids.length-1];N&&P(null,N,!0);}return p(!1),S.ids||[]}catch(S){h(S.message),B("Error fetching feed");}return p(false),[]},[e,l,n,I,M,E,o,B]),F=useCallback(async(V,v)=>{let k=r[1]??[],S=r[2]??[],x=V+1;if(x<k.length)return {id:k[x],idx:x};if(S[0]){let W=S[S.length-1];return v||(i(Me=>[Me[1],Me[2],null]),P(null,W,true)),{id:S[0],idx:0}}let N=(await P(null,k[k.length-1],v))[0];return N?{id:N,idx:0}:null},[r,P]),z=useCallback(async(V,v)=>{let k=r[1]??[],S=r[0]??[],x=V-1;if(x>=0)return {id:k[x],idx:x};if(S[S.length-1]){let W=S[0];return v||(i([null,r[0],r[1]]),P(W,null,true)),{id:S[S.length-1],idx:S.length-1}}let _=await P(k[0],null,v),N=_[_.length-1];return N?{id:N,idx:_.length-1}:null},[r,P]),H=useCallback(async()=>{if(m)return;let V=C.current.curr;g(true);let v=await F(a,false);if(b("next"),v){let{id:k,idx:S}=v;T.current=k,s(S),I(k),M(null),E(V),F(S,true).then(x=>M(x?.id??null));}else D("No more items");g(false);},[a,F,I,M,E,m,D]),Q=useCallback(async()=>{if(m)return;let V=C.current.curr;b("prev"),g(true);let v=await z(a,false);if(v){let{id:k,idx:S}=v;T.current=k,s(S),I(k),E(null),M(V),z(S,true).then(x=>E(x?.id??null));}else D("No more items");g(false);},[a,z,I,M,E,m,D]),Ce=useCallback(async()=>{p(true),c(true),i([null,null,null]),I(null),M(null),E(null),b(null),s(0),await P(null,null,false),c(false);},[P,I,M,E]),[xe]=useState(()=>P);useEffect(()=>{xe(null,null,false);},[xe]);let it=useMemo(()=>a>0&&!!r[1]?.length||!!r[0]?.length,[r,a]),at=useMemo(()=>(r[1]&&a<r[1].length)??!!r[2]?.length,[r,a]);return useMemo(()=>({ids:r,goNext:H,goPrev:Q,error:f,refresh:Ce,refreshing:d,loading:u,canGoNext:at,direction:y,canGoPrev:it,itemLoading:m}),[r,H,Q,u,f,m,at,it,Ce,d,y])};var Pn=({color:e,trackColor:t,animating:o,visible:n=true,viewStyle:r,...i})=>{let a=useColorModeValue("#959595","#575757"),s=useRef(new Animated.Value(n?1:0)).current;return useEffect(()=>{Animated.timing(s,{toValue:n?1:0,duration:300,useNativeDriver:true}).start();},[n,s]),jsxs(Animated.View,{style:[Pa.container,{opacity:s},r],children:[jsx(ActivityIndicator,{color:t??a,style:StyleSheet.absoluteFill,animating:false,...i}),jsx(ActivityIndicator,{animating:o,color:e??"#575757",...i})]})},Pa=StyleSheet.create({container:{alignItems:"center",justifyContent:"center"}});var kn=({src:e,onClose:t})=>{let[o,n]=useState(true),r=useScreen(c=>c.width),i=useScreen(c=>c.height),[a,s]=useState({width:r/2,height:i/2}),{height:l,width:u}=useMemo(()=>{if(o)return a;let c=a.width/a.height,f=Math.min(a.height,i*.9),h=f*c;return h>r*.9&&(h=Math.min(a.width,r*.9),f=h/c),{height:f,width:h}},[i,r,a,o]),p=useCallback(()=>n(true),[]),d=useCallback(c=>{let{width:f,height:h}=c.nativeEvent.source;s({width:f,height:h}),n(false);},[]);return jsx(Modal,{visible:true,transparent:true,animationType:"fade",onRequestClose:t,children:jsx(View,{style:Te.modalOverlay,children:jsxs(View,{style:Te.contentContainer,children:[jsx(View,{style:[Te.imageContainer,{width:u,height:l,opacity:o?0:1}],children:jsx(Image,{source:{uri:e},style:Te.image,onLoadStart:p,onLoad:d,resizeMode:"contain"})}),jsx(TouchableOpacity,{style:Te.closeButton,onPress:t,children:jsx(Ionicons,{name:"close",size:24,color:"white"})}),o&&jsx(View,{style:Te.loadingContainer,children:jsx(fe,{isLoading:o,size:70})})]})})})},Te=StyleSheet.create({modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.7)"},contentContainer:{flex:1,justifyContent:"center",alignItems:"center",padding:16},imageContainer:{overflow:"hidden",borderRadius:4},image:{width:"100%",height:"100%"},closeButton:{position:"absolute",top:16,right:16,width:40,height:40,borderRadius:20,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center"},loadingContainer:{...StyleSheet.absoluteFillObject,justifyContent:"center",alignItems:"center"}});var En="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAv/lxKUAAAAASUVORK5CYII=",zn=({src:e,loadingOverride:t,onLoad:o,width:n,height:r,noFullView:i,buttonFullView:a,style:s})=>{let[l,u]=useState(!!e),p=useRef(null),[d,c]=useState(false),f=useMounted(100),h=useCallback(T=>{o&&o(T);},[o]),[m,g]=useState(e);useEffect(()=>{e&&g(e);},[e,m]);let y=useMemo(()=>l||!!t,[l,t]),b=jsx(Image,{ref:p,source:{uri:e??En},style:[Fe.image,{opacity:e&&!y?1:0}],onLoadEnd:()=>u(false),onLoad:h,resizeMode:e?"cover":"contain"});return jsxs(View,{style:[Fe.container,{width:n??"100%",height:r??"100%",opacity:f?1:0},s],children:[i||a?b:jsx(TouchableOpacity,{activeOpacity:.9,onPress:()=>c(true),style:Fe.imageContainer,children:b}),a&&jsx(TouchableOpacity,{style:Fe.fullViewButton,onPress:()=>c(true),activeOpacity:.7,children:jsx(Ionicons,{name:"expand",size:20,color:"white",style:Fe.fullViewIcon})}),jsx(View,{style:[Fe.loadingContainer,{opacity:y?1:0}],children:jsx(fe,{isLoading:y,size:10})}),d&&jsx(kn,{src:e??En,onClose:()=>c(false)})]})},Fe=StyleSheet.create({container:{overflow:"hidden",position:"relative"},imageContainer:{width:"100%",height:"100%"},image:{width:"100%",height:"100%"},loadingContainer:{...StyleSheet.absoluteFillObject,justifyContent:"center",alignItems:"center"},fullViewButton:{position:"absolute",top:8,right:8,width:28,height:28,borderRadius:14,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center"},fullViewIcon:{opacity:.8}});var mf=({value:e,label:t,onChange:o})=>{let[n,r]=useState(false),i=useState(new Animated.Value(1))[0],a=useCallback(l=>{let u=Math.max(0,1e3-(Date.now()-l));setTimeout(()=>{r(false),Animated.timing(i,{toValue:1,duration:300,useNativeDriver:true}).start();},u);},[i]),s=l=>{r(true),Animated.timing(i,{toValue:0,duration:300,useNativeDriver:true}).start();let u=Date.now();o(l).catch(p=>{console.error(p);}),a(u);};return jsxs(View,{style:wt.container,children:[jsxs(Animated.View,{style:[wt.content,{opacity:i}],children:[jsx(Text,{style:wt.label,children:t}),jsx(Switch,{value:e,onValueChange:s})]}),n&&jsx(View,{style:wt.loadingContainer,children:jsx(no,{})})]})},wt=StyleSheet.create({container:{paddingVertical:4,paddingHorizontal:12,backgroundColor:"#2D3748",borderRadius:12,shadowColor:"#000",shadowOffset:{width:0,height:0},shadowOpacity:.25,shadowRadius:4,elevation:5,position:"relative",flexDirection:"row",alignItems:"center"},content:{flexDirection:"row",alignItems:"center",gap:8},label:{fontSize:20,height:24,color:"#FFFFFF"},loadingContainer:{position:"absolute",top:"-10%",left:"-10%",width:"120%",height:"120%",borderRadius:8,padding:4,justifyContent:"center",alignItems:"center"}});var Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAv/lxKUAAAAASUVORK5CYII=",Qa=StyleSheet.create({imageBackground:{flex:1,transform:[{scale:1.075}]}}),Ct=({background:e,opacity:t=.7,style:o,...n})=>jsx(View,{style:[ie.absolute,o],...n,children:jsx(ImageBackground,{source:{uri:e??Xa},style:[Qa.imageBackground,{opacity:t}],resizeMode:"cover"})}),Za=({getBackgroundValue:e,item:t})=>{let o=useMemo(()=>t?e(t):null,[e,t]),{loading:n,url:r}=useObjectUrl(o),i=useRef(0),[a,s]=useState(0),[l,u]=useState(null),[p,d]=useState(null);return useEffect(()=>{i.current===0?(u(r),i.current=1,s(0)):(d(r),i.current=0,s(1));},[r]),jsxs(de,{style:ie.absolute,children:[jsx(Ct,{opacity:a===0?1:0,background:l}),jsx(Ct,{opacity:a===1?1:0,background:p}),jsx(fe,{isLoading:n})]})},el=({getBackgroundUrl:e,item:t})=>{let o=useMemo(()=>t?e(t):null,[e,t]),n=useRef(0),[r,i]=useState(0),[a,s]=useState(null),[l,u]=useState(null);return useEffect(()=>{o&&(n.current===0?(s(o),n.current=1,i(0)):(u(o),n.current=0,i(1)));},[o]),jsxs(de,{style:ie.absolute,children:[jsx(Ct,{opacity:r===0?1:0,background:a}),jsx(Ct,{opacity:r===1?1:0,background:l})]})},jn=({getBackgroundValue:e,getBackgroundUrl:t,...o})=>e?jsx(Za,{getBackgroundValue:e,...o}):t?jsx(el,{getBackgroundUrl:t,...o}):null;var rl=25,Kn=({offsetY:e,refreshing:t,canRefresh:o})=>{let n=useRef(new Animated.Value(0)).current,r=useRef(new Animated.Value(0)).current,i=Animated.subtract(e,75),a=Animated.divide(i,rl),s=Animated.diffClamp(a,0,1);useEffect(()=>{Animated.spring(n,{toValue:t?50:0,useNativeDriver:true}).start();},[t,n]),useEffect(()=>{Animated.spring(r,{toValue:o?1:0,useNativeDriver:true}).start();},[o,r]);let l=s.interpolate({inputRange:[0,1],outputRange:[0,Math.sqrt(1)*20]}),p=Animated.add(n,l).interpolate({inputRange:[0,20],outputRange:[0,20],extrapolate:"clamp"}),d=Animated.multiply(r,p),c=d.interpolate({inputRange:[0,30],outputRange:[0,1],extrapolate:"clamp"}),f=Animated.multiply(r,c),h=s.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]});return jsx(Animated.View,{style:[Jn.container,{opacity:f,transform:[{translateY:d},{scale:f},{rotate:h}]}],children:jsxs(View,{style:Jn.centerContainer,children:[jsx(Gt,{style:[{opacity:t?0:1}],children:jsx(tl,{name:"refresh",size:32,color:"white"})}),jsx(Gt,{style:{opacity:t?1:0},children:jsx(Pn,{animating:true,size:"large",color:"white"})})]})})},Jn=StyleSheet.create({container:{position:"absolute",top:0,left:0,right:0,pointerEvents:"none"},centerContainer:{alignItems:"center",justifyContent:"center",width:"100%"}});var fl=e=>useCallback(t=>{let o=[];t.prev&&o.push({status:"prev",id:t.prev}),t.curr&&o.push({status:"current",id:t.curr}),t.next&&o.push({status:"next",id:t.next}),e(o);},[e]),rg=({fetch:e,collection:t,RenderItem:o,authRequired:n,getBackgroundUrl:r,getBackgroundValue:i,limit:a,defaultBackground:s,swipeDisabled:l,children:u})=>{let{width:p,height:d}=useScreen(),{theme:c}=useTheme(),f=useRef(null),h=useRef(null),[m,g]=useState(null),[y,b]=useState([]),T=useRef(new Animated.Value(0)).current,C=fl(b),D=useRef(null),{goNext:B,goPrev:I,loading:M,canGoNext:E,canGoPrev:P,refresh:F,refreshing:z}=Vn(e,C,a,n),H=useRef(false),Q=useRef({x:0,y:0}),Ce=useCallback(x=>{l||(H.current=true,Q.current={x:x.x,y:x.y});},[l]),xe=useCallback(x=>{if(!H.current)return;let _=P?75:100,N=E?-75:-100,W=Math.max(N,Math.min(_,x.y-Q.current.y));E&&W<-65?(g("next"),B()):P&&W>65?(g("prev"),I()):(W>90||W<-90)&&(F(),D.current&&D.current.onNewData(null)),T.setValue(0),H.current=false;},[T,B,I,E,P,F]),it=useCallback(x=>{if(!H.current)return;let _=Math.max(-10,Math.min(10,x.x-Q.current.x)),N=P?75:100,W=E?-75:-100,Me=Math.max(W,Math.min(N,x.y-Q.current.y));Math.sqrt(_**2+Me**2)>10&&f.current,T.setValue(Me);},[T,E,P]),at=Gesture.Pan().onStart(Ce).onUpdate(it).onEnd(xe),V=useMemo(()=>({height:d,width:p,overflow:"hidden",pointerEvents:l?"none":"auto"}),[p,d,l]),[v,k]=useState(null),S=useCallback(x=>{y.find(N=>N.status==="current")?.id===x?._id&&k(x);},[y]);return jsx(pn,{curr:v,children:jsx(GestureDetector,{gesture:at,children:jsxs(de,{style:[gl.container,{backgroundColor:s??c.colors.background[100]}],children:[jsx(jn,{item:v,getBackgroundValue:i,getBackgroundUrl:r}),jsx(View,{style:V,ref:h,children:jsx(de,{style:ie.relative,ref:f,children:y.map(x=>jsx(xn,{id:x.id,collectionPath:t,RenderItem:o,onItemLoad:S,status:x.status,enterStatus:m,offsetY:T},x.id))})}),jsx(Kn,{canRefresh:!P,refreshing:z,offsetY:T}),jsx(ft,{inFeed:true,isLoading:M}),u?jsx(de,{style:[ie.absolute,{zIndex:3}],children:u}):null]})})})},gl=StyleSheet.create({container:{...ie.relative,overflow:"hidden"}});var xt=({path:e,condition:t,children:o})=>{let n=useWatch({exact:true,name:e});return useMemo(()=>t(n),[n,t])?jsx(Animated.View,{style:{paddingVertical:3,opacity:1},children:o}):null};var Tl=(e,t,o,n)=>{let r=useRef(new Animated.Value(0)).current;return useEffect(()=>{Animated.timing(r,{toValue:e?1:0,duration:200,useNativeDriver:false}).start();},[e,r]),useMemo(()=>({opacity:r,color:t,transform:[{scale:r.interpolate({inputRange:[0,1],outputRange:[.8,1]})}],height:r.interpolate({inputRange:[0,1],outputRange:[0,o]}),marginBottom:r.interpolate({inputRange:[0,1],outputRange:[0,n]})}),[t,o,n,r])},co=({show:e,color:t,height:o,marginBottom:n,style:r,children:i})=>{let{opacity:a,color:s,transform:l,height:u,marginBottom:p}=Tl(e,t,o,n);return jsx(Animated.Text,{style:[r,{opacity:a,color:s,transform:l,height:u,marginBottom:p}],children:i})};var Il=({field:e,input:{onChange:t,value:o,...n}},r)=>{let{placeholder:i}=e;return useImperativeHandle(r,()=>({focus:()=>{},blur:()=>{}})),jsxs(View,{style:{flexDirection:"row",alignItems:"center"},children:[jsx(Switch,{value:o,onValueChange:t,...n}),jsx(Text,{style:{marginLeft:8,fontWeight:"600",opacity:o?.9:.6},children:i})]})},Pl=forwardRef(Il),Rl=({field:e,input:{onChange:t,value:o,...n}},r)=>{let{placeholder:i}=e;return useImperativeHandle(r,()=>({focus:()=>{},blur:()=>{}})),jsxs(View,{style:{flexDirection:"row",alignItems:"center"},children:[jsx(Switch,{value:o,onValueChange:t,...n}),jsx(Text,{style:{marginLeft:8,fontWeight:"600",opacity:o?.9:.6},children:i})]})},vl=forwardRef(Rl),Al=(e,t)=>e.field.type==="switch"?jsx(vl,{ref:t,...e}):jsx(Pl,{ref:t,...e}),er=forwardRef(Al);var Vt=({gradient:e,value:t,minimumValue:o,maximumValue:n,...r})=>jsx(View,{style:[ye.container,{opacity:t!==void 0?1:.5}],children:jsxs(View,{style:ye.sliderContainer,children:[o!==void 0?jsx(Text,{style:[ye.label,e?ye.gradientText:null],children:typeof o=="number"?o.toFixed((r?.step??1)<1?2:0):""}):null,jsx(Ol,{style:ye.slider,minimumValue:o,maximumValue:n,step:1,...r}),n!==void 0?jsx(Text,{style:[ye.label,e?ye.gradientText:null],children:typeof n=="number"?n.toFixed((r?.step??1)<1?2:0):""}):null]})}),ye=StyleSheet.create({container:{width:"100%",paddingVertical:8},sliderContainer:{flexDirection:"row",alignItems:"center",width:"100%"},slider:{flex:1,height:40},label:{fontSize:14,marginHorizontal:8},gradientText:{color:"#007AFF"}});var Tt=e=>{let t=useRef(null);return useImperativeHandle(e,()=>({focus:()=>{t.current?.focus();},blur:()=>{t.current?.blur();}}),[]),t};var It=({label:e,gradient:t,value:o,...n})=>jsx(Vt,{label:e,value:o,minimumValue:0,maximumValue:255,step:1,gradient:t,...n}),ar=forwardRef(({input:{onChange:e,value:t},field:o,meta:n},r)=>{let{withAlpha:i,defaultValue:a}=o,{active:s}=n||{};Tt(r);let l=useCallback((d,c)=>{e(i?{r:0,g:0,b:0,a:1,...t,[d]:c}:{r:0,g:0,b:0,...t,[d]:c});},[t,e,i]),u=useMemo(()=>({...a,...t}),[a,t]),p=useMemo(()=>colorValueToHex(!!i,u),[u,i]);return jsxs(View,{style:$e.container,children:[jsx(View,{style:[$e.colorPreview,{backgroundColor:p}],children:jsx(Text,{style:$e.hexText,children:p})}),jsxs(View,{style:[$e.slidersContainer,s&&$e.activeContainer],children:[jsx(It,{label:"R",gradient:gradients.red,value:t?.r,onValueChange:d=>l("r",d)}),jsx(It,{label:"G",gradient:gradients.green,value:t?.g,onValueChange:d=>l("g",d)}),jsx(It,{label:"B",gradient:gradients.blue,value:t?.b,onValueChange:d=>l("b",d)}),i?jsx(It,{label:"A",gradient:gradients.midnight,value:t?.a,onValueChange:d=>l("a",d)}):null]})]})}),$e=StyleSheet.create({container:{width:"100%",flexDirection:"row",alignItems:"center",gap:8},colorPreview:{width:80,height:80,borderRadius:40,justifyContent:"center",alignItems:"center",shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.25,shadowRadius:3.84,elevation:5},hexText:{fontSize:16,color:"#fff",textShadowColor:"rgba(0, 0, 0, 0.75)",textShadowOffset:{width:0,height:1},textShadowRadius:2},slidersContainer:{flex:1,padding:8,borderRadius:6},activeContainer:{shadowColor:"#fff",shadowOffset:{width:0,height:0},shadowOpacity:.5,shadowRadius:5,elevation:5}});var fo=({onPress:e,isActive:t,marginRight:o})=>{let n=useIconColor(),r=useBorderColor();return jsx(TouchableOpacity,{onPress:e,style:[Yl.closeButton,{opacity:t?1:0,marginRight:o,borderColor:r}],hitSlop:{top:10,bottom:10,left:10,right:10},disabled:!t,children:jsx(Ionicons,{name:"close",size:14,color:n,style:{alignSelf:"center"}})})},Ae=({onPress:e,isActive:t})=>jsx(fo,{marginRight:0,onPress:e,isActive:t}),Yl=StyleSheet.create({closeButton:{padding:3,borderRadius:100,display:"flex",alignItems:"center",justifyContent:"center",borderWidth:1}});var Oe=e=>{let t=useTextColor(),o=usePlaceholderColor();return e!=null&&e!==""?t:o};var go=forwardRef(({input:{onChange:e,value:t,onFocus:o,onBlur:n},field:{placeholder:r,minDate:i,maxDate:a,optional:s},meta:{active:l}},u)=>{let p=useMemo(()=>t?new Date(`${t}T00:00:00.000`):void 0,[t]);useImperativeHandle(u,()=>({focus:()=>{o();},blur:()=>{n();}}));let d=()=>{o();},c=useIconColor(),f=Oe(t),h=i==="now"?new Date:i?new Date(i):void 0,m=a==="now"?new Date:a?new Date(a):void 0;return jsxs(View,{style:Pt.container,children:[jsxs(TouchableOpacity,{style:Pt.button,onPress:d,children:[jsx(Text,{style:[Pt.text,{color:f}],children:t?getDateString(t,"short"):r}),jsx(Ionicons,{name:"calendar",size:20,color:c,style:Pt.icon}),s&&t?jsx(Ae,{onPress:()=>e(null),isActive:true}):null]}),jsx(Portal,{children:jsx(DatePickerModal,{locale:"en",label:"Date",date:p,startYear:h?.getFullYear(),endYear:m?.getFullYear(),mode:"single",onConfirm:g=>{e(g?.date?.toISOString()?.split("T")[0]??null),n();},onDismiss:n,visible:l})})]})});go.displayName="DateInput";var Pt=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var wo=forwardRef(({input:{value:e,onBlur:t,onChange:o,onFocus:n},field:r,meta:{active:i}},a)=>{let{placeholder:s,optional:l}=r,[u,p]=useState(true),[d,c]=useState(false),f=useMemo(()=>e?new Date(e):new Date,[e]);useImperativeHandle(a,()=>({focus:()=>{n();},blur:()=>{t();}}));let h=useCallback(B=>{if(B){let I=new Date(B);o(I.toISOString()),c(true);}else t();p(false);},[o,t]),m=useCallback(({hours:B,minutes:I})=>{let M=f?new Date(f):new Date;M.setHours(B),M.setMinutes(I),o(M.toISOString()),c(false),t();},[o,t,f]),g=useCallback(()=>{p(true),c(false),t();},[t]),y=useMemo(()=>e?new Date(e):void 0,[e]),b=useMemo(()=>e?getDateTimeString(e):null,[e]),T=useMemo(()=>y?{hours:y.getHours(),minutes:y.getMinutes()}:{hours:0,minutes:0},[y]),C=useIconColor(),D=Oe(e);return jsxs(View,{style:Ge.container,children:[jsxs(TouchableOpacity,{style:Ge.button,onPress:()=>{p(true),n();},children:[jsx(Text,{style:[Ge.text,{color:D}],children:b??s}),jsx(Ionicons,{name:"calendar",size:20,color:C,style:Ge.icon}),jsx(Ionicons,{name:"time",size:20,color:C,style:Ge.icon}),l&&e?jsx(Ae,{onPress:()=>o(null),isActive:!!e}):null]}),jsxs(Portal,{children:[u&&jsx(DatePickerModal,{locale:"en",label:"Date",date:y,mode:"single",onConfirm:B=>{h(B?.date?.toISOString()?.split("T")[0]??null);},onDismiss:g,visible:i&&u}),d&&jsx(TimePickerModal,{visible:i&&d,onDismiss:g,locale:"en-US",onConfirm:m,hours:T.hours,minutes:T.minutes})]})]})});wo.displayName="DateTimeInput";var Ge=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var Fs=e=>{if(!e.accept)return;let t=[];return e.accept.includes("image")&&t.push("image/jpg","image/jpeg","image/png","image/svg","image/gif"),e.accept.includes("pdf")&&t.push("application/pdf"),e.accept.includes("audio")&&t.push("audio/mp3","audio/wav","audio/x-wav","audio/webm","audio/ogg"),t.join(",")},Is=({hasUpload:e})=>{let t=useTextColor(),o=useIconColor(),n=useBorderColor();return jsxs(View,{style:[se.noFileContainer,{borderColor:n}],children:[jsx(Text,{style:[se.noFileText,{color:t}],children:e?"Tap to upload file":"No file uploaded"}),jsx(Ionicons,{name:"cloud-upload",size:24,color:o})]})},vt=({value:e,hasUpload:t,imageOptions:o})=>{let{storagePath:n,dataUrl:r}=e??{},i=!r&&!n,a=useIconColor(),s=useTextColor(),l=useBorderColor();return !e||i?jsx(Is,{hasUpload:t}):e.type?.startsWith("image/")?jsx(zn,{src:r,width:o?.width??120,height:o?.height??120,style:se.image}):jsxs(View,{style:[se.fileContainer,{borderColor:l}],children:[jsx(Ionicons,{name:"document",size:24,color:a}),jsx(Text,{style:[se.filename,{color:s}],children:e.filename})]})},So=forwardRef(({input:{value:e,onChange:t},field:o},n)=>{let[r,i]=useState(false),{imageOptions:a}=o||{},s=useCallback(async()=>{try{i(!0);let c;if(o.accept?.includes("image")){if(c=await gr.launchImageLibraryAsync({mediaTypes:["images"],allowsEditing:!0,quality:1,base64:!0}),!c.canceled&&c.assets[0]){let f=c.assets[0],h=f.uri.split(".").pop()??"jpeg",m=f.uri.split("/").pop()??"image";t({...e,dataUrl:f.uri,type:`image/${h}`,filename:m});}}else c=await fr.getDocumentAsync({type:Fs(o)}),c.canceled||t({...e,dataUrl:c.assets[0].uri,type:c.assets[0].mimeType,filename:c.assets[0].name});}catch(c){c instanceof Error&&console.error("Error picking file:",c.message);}finally{i(false);}},[o,t,e]);useImperativeHandle(n,()=>({focus:()=>{s();},blur:()=>{}}));let l=useMemo(()=>o.accept&&o.accept.length===1&&o.accept[0]==="image",[o]),u=useMemo(()=>l||e?.type?.startsWith("image/")?{height:120,...a}:void 0,[a,l,e]),p=usePlaceholderColor(),d=useBorderColor();return jsxs(View,{style:[se.container,{borderColor:d}],children:[jsx(Text,{style:[se.placeholder,{color:p}],children:o.placeholder}),jsx(TouchableOpacity,{style:se.contentContainer,onPress:()=>void s(),disabled:r,children:jsx(vt,{hasUpload:true,imageOptions:u,value:e})})]})});So.displayName="FileComponent";var se=StyleSheet.create({container:{width:"100%",alignItems:"center",justifyContent:"center"},placeholder:{fontSize:14,opacity:.8,marginBottom:4},contentContainer:{width:"100%",position:"relative",alignItems:"center",justifyContent:"center",padding:8,overflow:"hidden"},noFileContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",padding:16,borderWidth:1,borderRadius:4,borderStyle:"dashed"},noFileText:{fontSize:14,textAlign:"center",opacity:.8,marginRight:10},fileContainer:{flexDirection:"row",alignItems:"center",padding:8,borderWidth:1,borderRadius:4},filename:{fontSize:14,marginLeft:8},image:{borderRadius:4,overflow:"hidden"}});var yr=forwardRef(({field:e,input:t,inEditable:o},n)=>{let{options:r,renderOption:i,getOptionKey:a}=e,{onChange:s,value:l,onFocus:u,onBlur:p}=t,d=useColorMode(),c=usePlaceholderColor();useImperativeHandle(n,()=>({focus:()=>{u();},blur:()=>{p();}}));let f=m=>{s(l?.includes(m)?l.filter(g=>g!==m):[...l??[],m]);},h=jsx(View,{style:Ye.container,children:r.map(m=>jsx(TouchableOpacity,{style:[Ye.option,l?.includes(m)&&Ye.selectedOption],onPress:()=>f(m),children:i(m,d,!!l?.includes(m))},a?a(m):m))});return o?jsxs(View,{style:Ye.editableContainer,children:[jsx(Text,{style:[Ye.placeholder,{color:c}],children:e.placeholder}),h]}):h}),Ye=StyleSheet.create({container:{width:"100%",flexDirection:"row",flexWrap:"wrap",gap:4},editableContainer:{width:"100%",paddingVertical:2},placeholder:{fontSize:14,fontWeight:"600",opacity:.8,paddingHorizontal:8,marginBottom:4},option:{padding:4,opacity:.7},selectedOption:{opacity:1}});var zs={xs:4,sm:6,md:8,lg:8,xl:8},Ls={xs:8,sm:12,md:12,lg:12,xl:12},Hs={xs:12,sm:14,md:16,lg:18,xl:20},wr=e=>useMemo(()=>StyleSheet.create({style:{paddingVertical:zs[e??"md"],paddingHorizontal:Ls[e??"md"],fontSize:Hs[e??"md"]}}),[e]);var Io=forwardRef(({input:{onChange:e,value:t,...o},field:n,size:r,prefix:i,inEditable:a,...s},l)=>{let{type:u,defaultValue:p,placeholder:d}=n,c=useTextColor(),{style:f}=wr(r),h=Tt(l),[m,g]=useState(""),y=typeof t=="number"&&!Number.isNaN(t)?`${t}${m}`:"",b=usePlaceholderColor();return u==="slider"?jsx(Vt,{label:d,onValueChange:e,value:t,minimumValue:p}):jsxs(View,{style:Fo.container,children:[i&&jsx(Text,{style:Fo.prefix,children:i}),jsx(TextInput,{ref:h,style:[Fo.input,f,{color:c}],placeholder:n.placeholder,placeholderTextColor:b,keyboardType:"numeric",value:y,onChangeText:T=>{T.endsWith(".")?g("."):T.includes(".")&&T.endsWith("0")?g("0"):g("");let C=parseFloat(T);e(isNaN(C)?void 0:C);},...o})]})}),Ks=({field:e,...t},o)=>{let n=useRef(null);return useImperativeHandle(o,()=>({focus:()=>{n.current?.focus();},blur:()=>{n.current?.blur();}})),jsx(Io,{prefix:"$",field:{...e,_type:"number"},...t})},Cr=forwardRef(Ks),Fo=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",width:"100%"},input:{flex:1,height:40,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent"},prefix:{marginRight:4,fontSize:16}});var dc=({field:e,input:t,meta:o},n)=>{let{placeholder:r,options:i,renderOption:a,getOptionKey:s,optional:l}=e,{onChange:u,value:p,onFocus:d,onBlur:c}=t,{active:f}=o,[h,m]=useState({x:0,y:0,width:0,height:0}),g=useRef(null),y=useMemo(()=>{if(p)return i.find(F=>{if(s){let z=s(F),H=s(p);return z===H}return F===p})},[p,i,s]);useImperativeHandle(n,()=>({focus:()=>{d();},blur:()=>{c();}}));let b=()=>{g.current?.measure((F,z,H,Q,Ce,xe)=>{m({x:Ce,y:xe,width:H,height:Q});});},T=(F,z)=>typeof a=="function"?a(F,"light",z):typeof F=="object"?jsx(Y,{children:JSON.stringify(F)}):jsx(Y,{children:String(F)}),C=F=>{if(s){let z=s(F);return typeof z=="object"?JSON.stringify(z):String(z)}return typeof F=="object"?JSON.stringify(F):String(F)},D=F=>{u(F),c();},B=useIconColor(),I=usePlaceholderColor(),M=useBackgroundColor(100),E=useBackgroundColor(50),P=useBorderColor();return jsxs(View,{style:q.wrapper,children:[jsx(View,{ref:g,onLayout:b,style:q.container,children:jsxs(TouchableOpacity,{style:[q.button],onPress:()=>{f?c():d();},children:[jsx(View,{style:q.buttonTextContainer,children:y?T(y,true):jsx(Text,{style:[q.placeholder,{color:I}],children:r})}),jsx(Ionicons,{name:f?"chevron-up":"chevron-down",size:20,color:B,style:q.icon}),l&&p?jsx(fo,{onPress:()=>u(null),isActive:!!p}):null]})}),jsx(Modal,{visible:f,transparent:true,animationType:"fade",onRequestClose:()=>c(),children:jsx(TouchableOpacity,{style:q.modalOverlay,activeOpacity:1,onPress:()=>c(),children:jsx(View,{style:[q.dropdownContainer,{position:"absolute",top:h.y+h.height+4,left:h.x,width:h.width,backgroundColor:M,borderColor:P}],children:jsx(ScrollView,{style:q.dropdown,children:i.map(F=>{let z=C(F),H=F===y;return jsx(TouchableOpacity,{style:[q.option,{borderColor:P},H&&{backgroundColor:E}],onPress:()=>D(F),children:jsx(View,{children:T(F,H)})},z)})})})})})]})},Vr=forwardRef(dc),q=StyleSheet.create({wrapper:{width:"100%"},container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",borderRadius:4},buttonTextContainer:{flex:1},buttonText:{fontSize:16},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)"},dropdownContainer:{backgroundColor:"white",borderWidth:1,borderColor:"#ddd",borderRadius:4,maxHeight:200,elevation:3,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:2,padding:0},dropdown:{maxHeight:200},option:{paddingVertical:12,paddingHorizontal:16,borderBottomWidth:1},optionText:{fontSize:16},placeholder:{color:"#666"},icon:{marginRight:10}});var bc={facebook:"facebook",instagram:"instagram",twitter:"twitter",youtube:"youtube",soundcloud:"soundcloud"},Je=({site:e,value:t,onChange:o,isModalVisible:n,onModalClose:r})=>{let{handle:i,error:a}=useMemo(()=>{try{return {handle:getHandle(e,t)}}catch(l){return {error:l?.message??"Error parsing handle"}}},[t,e]),s=useMemo(()=>i?`${e.toUpperCase()}: ${i}`:e.toUpperCase(),[e,i]);return jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:[j.iconButton,!i&&j.iconButtonInactive],onPress:()=>r(),children:jsx(Text,{style:j.iconText,children:bc[e]})}),jsx(Modal,{visible:n,transparent:true,animationType:"slide",onRequestClose:r,children:jsx(View,{style:j.modalContainer,children:jsxs(View,{style:j.modalContent,children:[jsx(Text,{style:j.modalTitle,children:s}),a&&jsx(Text,{style:j.errorText,children:a}),jsx(TextInput,{style:j.modalInput,onChangeText:o,placeholder:"Handle or URL",value:t,autoCapitalize:"none",autoCorrect:false}),jsx(TouchableOpacity,{style:j.closeButton,onPress:r,children:jsx(Text,{style:j.closeButtonText,children:"Close"})})]})})})]})},Ir=forwardRef((e,t)=>{let{input:{value:o,onChange:n},field:{sites:r}}=e,[i,a]=useState(null),s=useCallback((l,u)=>{let{[l]:p,...d}=o??{};!u&&Object.keys(d).length===0&&n({target:{value:void 0}}),u||n(d),n({...d,[l]:u});},[n,o]);return useImperativeHandle(t,()=>({blur:()=>{},focus:()=>{}})),jsxs(View,{style:j.container,children:[jsx(Text,{style:j.title,children:"Links"}),jsxs(View,{style:j.iconsContainer,children:[(!r||r.facebook)&&jsx(Je,{onChange:l=>s("facebook",l),site:"facebook",value:o?.facebook,isModalVisible:i==="facebook",onModalClose:()=>a(null)}),(!r||r.instagram)&&jsx(Je,{onChange:l=>s("instagram",l),site:"instagram",value:o?.instagram,isModalVisible:i==="instagram",onModalClose:()=>a(null)}),(!r||r.twitter)&&jsx(Je,{onChange:l=>s("twitter",l),site:"twitter",value:o?.twitter,isModalVisible:i==="twitter",onModalClose:()=>a(null)}),(!r||r.youtube)&&jsx(Je,{onChange:l=>s("youtube",l),site:"youtube",value:o?.youtube,isModalVisible:i==="youtube",onModalClose:()=>a(null)}),(!r||r.soundcloud)&&jsx(Je,{onChange:l=>s("soundcloud",l),site:"soundcloud",value:o?.soundcloud,isModalVisible:i==="soundcloud",onModalClose:()=>a(null)})]})]})}),j=StyleSheet.create({container:{flex:1,padding:8},title:{fontSize:16,fontWeight:"bold",marginBottom:8,color:"#1A202C"},iconsContainer:{flexDirection:"row",flexWrap:"wrap",gap:8},iconButton:{width:34,height:34,borderRadius:17,backgroundColor:"#EDF2F7",justifyContent:"center",alignItems:"center"},iconButtonInactive:{opacity:.6},iconText:{fontSize:12,color:"#1A202C"},modalContainer:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)"},modalContent:{backgroundColor:"white",borderRadius:8,padding:16,width:"80%",maxWidth:300},modalTitle:{fontSize:16,fontWeight:"bold",marginBottom:8,color:"#1A202C"},errorText:{color:"#E53E3E",fontSize:14,marginBottom:8,padding:4,backgroundColor:"#FFF5F5"},modalInput:{borderWidth:1,borderColor:"#E2E8F0",borderRadius:4,padding:8,marginBottom:16,fontSize:16},closeButton:{backgroundColor:"#EDF2F7",padding:8,borderRadius:4,alignItems:"center"},closeButtonText:{color:"#1A202C",fontSize:16}});var Ro=forwardRef(({input:e,field:t,inEditable:o},n)=>{let r=useRef(null),{value:i,onChange:a,...s}=e;useImperativeHandle(n,()=>({focus:()=>{r.current?.focus();},blur:()=>{r.current?.blur();}}));let l=usePlaceholderColor(),u=useTextColor();return jsx(TextInput,{ref:r,style:[Pr.textarea,o&&Pr.inEditable,{color:u}],placeholder:t.placeholder,placeholderTextColor:l,multiline:true,maxLength:200,textAlignVertical:"top",value:i??"",onChangeText:a,...s})});Ro.displayName="TextAreaComponent";var Pr=StyleSheet.create({textarea:{width:"100%",minHeight:80,paddingHorizontal:12,paddingVertical:8,backgroundColor:"transparent",textAlignVertical:"top"},inEditable:{paddingHorizontal:0,paddingVertical:0}});var vo=forwardRef(({input:e,inEditable:t,meta:o,field:n},r)=>{let{placeholder:i,type:a}=n,[s,l]=useState(a==="password"),{value:u,onChange:p,...d}=e,c=useRef(null);useImperativeHandle(r,()=>({focus:()=>{c.current?.focus();},blur:()=>{c.current?.blur();}}));let f=usePlaceholderColor(),h=useTextColor(),m=a==="textarea"?jsx(Ro,{inEditable:t,field:n,input:e,meta:o}):jsx(TextInput,{ref:c,style:[qe.input,t&&qe.inEditable,a==="password"&&qe.passwordInput,{color:h}],secureTextEntry:s,placeholderTextColor:f,placeholder:i,value:u??"",onChangeText:p,...d});return a==="password"?jsxs(View,{style:qe.passwordContainer,children:[m,jsx(TouchableOpacity,{style:qe.eyeIcon,onPress:()=>l(!s),children:jsx(Ionicons,{name:s?"eye":"eye-off",size:20,color:"#666"})})]}):m});vo.displayName="TextComponent";var qe=StyleSheet.create({input:{width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},inEditable:{paddingHorizontal:0,paddingVertical:0,height:"auto"},passwordInput:{paddingRight:40},passwordContainer:{width:"100%",flexDirection:"row",alignItems:"center",position:"relative"},eyeIcon:{position:"absolute",right:12,padding:4}});var Oo=forwardRef(({input:{onChange:e,value:t,onFocus:o,onBlur:n},field:{placeholder:r,optional:i}},a)=>{let[s,l]=useState(false);useImperativeHandle(a,()=>({focus:()=>{l(true),o();},blur:()=>{l(false),n();}}));let u=({hours:g,minutes:y})=>{l(false);let b=`${padZeros(g)}:${padZeros(y)}`;e(b),n();},p=()=>{l(false),n();},d=useMemo(()=>{if(!t)return null;let[g,y]=t.split(":").map(Number),b=g>=12?"PM":"AM";return `${g%12===0?12:g%12}:${padZeros(y)} ${b}`},[t]),{hours:c,minutes:f}=useMemo(()=>{if(!t)return {hours:0,minutes:0};let[g,y]=t.split(":").map(Number);return {hours:g,minutes:y}},[t]),h=useIconColor(),m=Oe(t);return jsxs(View,{style:Bt.container,children:[jsxs(TouchableOpacity,{style:Bt.button,onPress:()=>{l(true),o();},children:[jsx(Text,{style:[Bt.text,{color:m}],children:d??r}),jsx(Ionicons,{name:"time",size:20,color:h,style:Bt.icon}),i&&t?jsx(Ae,{onPress:()=>e(null),isActive:!!t}):null]}),jsx(Portal,{children:jsx(TimePickerModal,{visible:s,onDismiss:p,onConfirm:u,hours:c,minutes:f})})]})});Oo.displayName="TimeInput";var Bt=StyleSheet.create({container:{width:"100%"},button:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",height:40,paddingHorizontal:12,paddingVertical:8},text:{fontSize:16,flex:1},icon:{marginRight:10}});var id={text:vo,file:So,boolean:er,select:Vr,multipleSelect:yr,currency:Cr,number:Io,date:go,datetime:wo,time:Oo,socialMedia:Ir,color:ar},ad=(e,t)=>{let{field:o,meta:{error:n,active:r,touched:i},input:a,inEditable:s}=e,{value:l}=a,u=usePlaceholderColor(),p=useThemeValue("colors.accent.400"),d=useThemeValue("colors.error.400"),c=useMemo(()=>new Animated.Value(0),[]),f=useMemo(()=>n&&i?n:null,[n,i]),h=useMemo(()=>f?d:p,[f,p,d]);useEffect(()=>{Animated.timing(c,{toValue:r||f?1:0,duration:300,useNativeDriver:false}).start();},[r,f,c]);let m=c.interpolate({inputRange:[0,1],outputRange:[u,h]}),{_type:g,label:y}=o,b=useMemo(()=>g==="multipleSelect"||!!l&&g!=="file"&&g!=="boolean",[l,g]),T=useBackgroundColor(150),C=useMemo(()=>{if(s)return {};switch(g){case "text":case "number":case "currency":case "select":case "datetime":case "date":case "time":return {shadowColor:m,shadowOffset:{width:0,height:0},shadowOpacity:1,shadowRadius:4,elevation:5,backgroundColor:T};default:return {}}},[g,m,s,T]),D=useMemo(()=>id[g],[g]);return jsxs(View,{style:[Qe.container],children:[y&&!s?jsx(Text,{style:Qe.label,children:y}):null,jsx(co,{style:Qe.placeholder,show:b,color:u,height:16,marginBottom:6,children:o.placeholder??""}),jsx(Animated.View,{style:[Qe.inputContainer,C],children:jsx(D,{ref:t,...e})}),!s&&jsx(co,{style:Qe.errorText,show:!!f,color:d,height:18,marginBottom:0,children:f})]})},Qe=StyleSheet.create({container:{position:"relative",width:"100%",paddingHorizontal:4},label:{color:"#1A202C",fontSize:14,paddingHorizontal:8},inputContainer:{width:"100%",borderRadius:4,paddingVertical:1,overflow:"hidden"},errorText:{fontSize:14,paddingHorizontal:4,fontWeight:500},placeholder:{fontSize:14,paddingHorizontal:4,overflow:"hidden"}}),Mt=forwardRef(ad);var md=({field:e,name:t},o)=>{let{control:n,getOnChange:r,meta:i,onFocus:a,onBlur:s}=useField(t,e),l=useMemo(()=>e.validate??getFieldValidate(e),[e]);return jsx(Controller,{control:n,rules:{validate:l},name:t,render:({field:{name:u,ref:p,onBlur:d,...c}})=>jsx(Mt,{ref:o,field:e,input:{...c,onFocus:a,onBlur:()=>{s(),d();},onChange:r(c.onChange)},meta:i})})},kr=forwardRef(md);var et=StyleSheet.create({container:{width:"100%",flexDirection:"column"},progressContainer:{paddingHorizontal:8,height:26,width:"100%",justifyContent:"center",alignItems:"center"},progressBar:{height:"100%",width:"100%",borderRadius:13,backgroundColor:"rgba(0, 0, 0, 0.1)",overflow:"hidden"},progressFill:{height:"100%",backgroundColor:"#3182CE"},label:{position:"absolute",color:"white",fontSize:12,fontWeight:"500",textTransform:"uppercase",textShadowColor:"rgba(0, 0, 0, 0.67)",textShadowOffset:{width:1,height:1},textShadowRadius:3}}),zt=({uploads:e})=>{let t=useMemo(()=>Object.values(e),[e]);return jsx(View,{style:et.container,children:t.map(o=>jsxs(Animated.View,{style:et.progressContainer,children:[jsx(View,{style:et.progressBar,children:jsx(Animated.View,{style:[et.progressFill,{width:`${o.percent*100}%`}]})}),jsx(Text,{style:et.label,children:o.label})]},o.label))})};var Eo="#ffffff",re=StyleSheet.create({container:{width:"100%"},progressContainer:{height:5,width:"100%"},footerContainer:{flexDirection:"column",paddingVertical:8,gap:5,borderTopWidth:1,paddingHorizontal:12,width:"100%"},buttonsContainer:{flexDirection:"row",justifyContent:"space-between",gap:10},cancelButton:{flex:1,paddingVertical:6,borderRadius:4,borderWidth:1},cancelButtonText:{color:Eo,fontSize:16,fontWeight:"500",textAlign:"center"},submitButtonContainer:{flex:1,borderRadius:4},submitButton:{paddingVertical:6},submitButtonText:{color:Eo,fontSize:16,fontWeight:"500",textShadowOffset:{width:.5,height:.5},textShadowRadius:5,textAlign:"center"},errorText:{color:"red",fontSize:16,paddingVertical:4}}),Pd=({onBack:e,children:t,submitting:o})=>{let n=usePlaceholderColor(),r=useBorderColor();return jsx(TouchableOpacity,{disabled:o,style:[re.cancelButton,{borderColor:r}],onPress:e,children:jsx(Text,{style:[re.cancelButtonText,{color:n}],children:t})})},Rd=({onSubmitClick:e,submitting:t,children:o,valid:n})=>{let r=useRef(new Animated.Value(1)).current,i=useMemo(()=>t||!n?"rgba(0, 0, 0, 0.0)":"rgba(0, 0, 0, 0.5)",[t,n]);useEffect(()=>{Animated.timing(r,{toValue:t||!n?.5:1,duration:200,useNativeDriver:true}).start();},[t,n,r]);let a=useButtonColor();return jsx(Animated.View,{style:[re.submitButtonContainer,{opacity:r,backgroundColor:a}],children:jsx(TouchableOpacity,{style:re.submitButton,onPress:()=>{e();},disabled:t,children:t?jsx(ActivityIndicator,{color:Eo}):jsx(Text,{style:[re.submitButtonText,{textShadowColor:i}],children:o})})})},vd=()=>{let{formState:e}=useFormContext();return e.errors.root?jsx(Text,{style:re.errorText,children:e.errors.root.message}):null},zr=({renderFooter:e,...t})=>{let{uploads:o,onSubmit:n,onBack:r,buttonText:i}=t,a=useBorderColor(),{isSubmitting:s,isValid:l}=useFormState();return jsxs(View,{style:re.container,children:[jsx(zt,{uploads:o}),e?e(t):jsxs(View,{style:[re.footerContainer,{borderColor:a}],children:[jsx(vd,{}),jsxs(View,{style:re.buttonsContainer,children:[r&&jsx(Pd,{submitting:s,onBack:r,children:"Cancel"}),jsx(Rd,{onSubmitClick:n,submitting:s,valid:l,children:i})]})]})]})};var tt=StyleSheet.create({container:{flexDirection:"column"},rowContainer:{flexDirection:"row"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},emptyText:{opacity:.7},fileContainer:{padding:4}}),Nr=({field:e,value:t,noLabel:o,style:n})=>{let{imageOptions:r,placeholder:i}=e,a=useMemo(()=>({height:150,...r}),[r]);return jsxs(View,{style:[t?tt.container:tt.rowContainer,n],children:[!o&&jsx(Text,{style:tt.label,children:i}),t?jsx(View,{style:tt.fileContainer,children:jsx(vt,{imageOptions:a,value:t})}):jsx(Text,{style:tt.emptyText,children:"None"})]})};var Ht=StyleSheet.create({container:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",maxWidth:"100%"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},optionContainer:{padding:2},emptyText:{opacity:.6}}),$r=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r,renderOption:i,getOptionKey:a}=e,s=useColorScheme()??"light";return jsxs(View,{style:[Ht.container,n],children:[!o&&jsx(Text,{style:Ht.label,children:r}),t?t.map(l=>jsx(View,{style:Ht.optionContainer,children:i(l,s,true)},a?a(l):l)):jsx(Text,{style:Ht.emptyText,children:"None"})]})};var jr=StyleSheet.create({container:{flexDirection:"row",alignItems:"center"},label:{paddingRight:10,fontWeight:"600"}}),Wd=e=>jsx(Y,{children:typeof e=="string"?e:JSON.stringify(e)}),Gr=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r,renderOption:i}=e,a=useColorScheme()??"light",s=usePlaceholderColor(),l=i??Wd;return jsxs(View,{style:[jr.container,n],children:[!o&&jsx(Text,{style:[jr.label,{color:s}],children:r}),t?l(t,a,true):"None"]})};var Nt=StyleSheet.create({container:{flexDirection:"row",alignItems:"center"},label:{paddingRight:8,opacity:.7,fontWeight:"600"},value:{opacity:1},valueEmpty:{opacity:.6}}),_d=({field:e,value:t,noLabel:o,style:n})=>{let{placeholder:r}=e,i=useMemo(()=>{let a=formatField[e._type];return a?a(e,t):t},[t,e]);return jsxs(View,{style:[Nt.container,n],children:[!o&&jsx(Text,{style:Nt.label,children:r}),jsx(Text,{style:t!=null?Nt.value:Nt.valueEmpty,children:i??"None"})]})},Wt=({field:e,value:t,noLabel:o,style:n})=>{switch(e._type){case "select":return jsx(Gr,{style:n,field:e,value:t,noLabel:o});case "multipleSelect":return jsx($r,{style:n,field:e,value:t,noLabel:o});case "file":return jsx(Nr,{style:n,field:e,value:t,noLabel:o});default:return jsx(_d,{style:n,field:e,value:t,noLabel:o})}};var Xd=({onChange:e,value:t,field:o,onBlur:n,inEditable:r,onFocus:i,style:a},s)=>{let{inputProps:l,meta:u}=useStandaloneInput(o,t,e,i,n);return jsx(Mt,{ref:s,field:o,inEditable:r,style:a,input:l,meta:u})},Jr=forwardRef(Xd);var Qr=({value:e,field:t,onSubmit:o,storagePath:n,style:r,onEditClose:i,onEditOpen:a})=>{let{formattedValue:s,inputRef:l,setValue:u,isLoading:p,uploads:d,editHovered:c,handleEditOpen:f,handleEditClose:h,isEditing:m,value:g,setEditHovered:y,submitValue:b,submit:T,parse:C}=useEditable({value:e,field:t,onSubmit:o,storagePath:n,onEditOpen:a,onEditClose:i}),D=useMemo(()=>t._type==="file"||t._type==="boolean",[t]);useEffect(()=>{m&&l.current?.focus();},[m,l]);let B=useColorModeValue("#00000055","#ffffff55");return jsxs(View,{style:[be.container,{borderColor:c&&!m?B:"transparent"},r],children:[jsxs(View,{style:be.contentContainer,children:[jsx(View,{style:[be.inputContainer,{opacity:p?0:1,borderColor:m?B:"transparent"}],children:m||D?jsx(Jr,{ref:l,value:s,inEditable:true,field:t,style:[be.input,r],onChange:D?I=>b(C(I)):I=>u(C(I))}):jsx(Wt,{style:r,field:t,value:g})}),!D&&jsxs(Fragment,{children:[jsx(TouchableOpacity,{style:be.editButton,onPress:()=>{m?(u(g),h()):f();},onPressIn:()=>y(true),onPressOut:()=>y(false),children:jsx(Ionicons,{name:m?"close":"create-outline",size:20,color:palette.gray.medium})}),jsx(View,{style:[be.submitButtonContainer,{width:m?30:0,opacity:m?1:0}],children:jsx(TouchableOpacity,{style:[be.submitButton,{backgroundColor:palette.cyan.light}],onPress:()=>{T();},children:jsx(Ionicons,{name:"checkmark",size:20,color:"#fff"})})})]}),jsx(ft,{isLoading:p})]}),jsx(zt,{uploads:d})]})},be=StyleSheet.create({container:{borderRadius:4,borderWidth:1,borderStyle:"dashed",width:"100%"},contentContainer:{flexDirection:"row",alignItems:"center",paddingHorizontal:4,position:"relative",width:"100%"},inputContainer:{flex:1,minWidth:0,borderWidth:1,borderStyle:"dashed"},input:{padding:0},editButton:{padding:4,marginLeft:4},submitButtonContainer:{justifyContent:"flex-end",overflow:"hidden"},submitButton:{padding:4,borderRadius:4}});var R=StyleSheet.create({container:{width:"100%"},listContainer:{width:"100%",paddingHorizontal:8,paddingVertical:4,gap:8},listHeader:{fontSize:14,opacity:.7,lineHeight:1},listContent:{gap:8,paddingVertical:4,minHeight:30},listItem:{paddingTop:8,paddingHorizontal:8,borderWidth:1,borderColor:"#e2e8f0",borderRadius:4},listItemContent:{flexDirection:"row",alignItems:"center",gap:4,width:"100%"},listItemInput:{flex:1,minWidth:0},emptyListText:{fontSize:14,opacity:.7,paddingVertical:4,paddingHorizontal:8},newButton:{alignSelf:"flex-start",paddingVertical:4,paddingHorizontal:8,borderRadius:4},newButtonText:{fontSize:14,color:"#4a5568"},formElementContainer:{width:"100%",gap:5},dataViewHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,width:"100%"},dataViewTitle:{fontSize:18,fontFamily:"System",paddingVertical:8},dataViewActions:{flexDirection:"row",alignItems:"center",gap:8,marginLeft:"auto"},dataViewContent:{paddingHorizontal:16,paddingVertical:8}}),fu=({field:e,name:t})=>{let o=useMemo(()=>isField(e.itemField)?"":isListField(e.itemField)?[]:{},[e]),n=useButtonColor(),{control:r}=useFormContext(),{fields:i,append:a,remove:s}=useFieldArray({control:r,name:t});return jsxs(View,{style:R.listContainer,children:[jsx(Text,{style:R.listHeader,children:e.placeholder}),jsx(View,{style:R.listContent,children:i.length?i.map((l,u)=>jsx(View,{style:R.listItem,children:jsxs(View,{style:R.listItemContent,children:[jsx(View,{style:R.listItemInput,children:jsx(Wo,{name:l.id,field:e.itemField})}),jsx(Qt,{onDelete:()=>s(u),itemName:`${e.placeholder} ${u+1}`})]})},l.id)):jsx(Text,{style:R.emptyListText,children:"No items"})}),jsx(TouchableOpacity,{style:[R.newButton,{backgroundColor:n}],onPress:()=>a(o),children:jsx(Text,{style:R.newButtonText,children:"+ NEW"})})]})},Wo=({field:e,name:t})=>{let o=useMemo(()=>isField(e)||isListField(e)?[{name:"value",field:e}]:Object.entries(e.children).map(([n,r])=>({name:`${t?`${t}.`:""}${n}`,field:r})),[e,t]);return jsx(View,{style:R.formElementContainer,children:o.map(n=>{if(isListField(n.field)){let i=jsx(fu,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(xt,{path:t,condition:n.field.condition,children:i},n.name):i}if(isField(n.field)){let i=jsx(kr,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(xt,{path:t,condition:n.field.condition,children:i},n.name):i}let r=jsx(Wo,{name:n.name,field:n.field},n.name);return n.field.condition?jsx(xt,{path:t,condition:n.field.condition,children:r},n.name):r})})},gu=({field:e,value:t,path:o})=>{let{itemField:n,placeholder:r}=e;return jsx(View,{style:R.listContainer,children:jsx(_t,{header:()=>jsx(Text,{style:R.listHeader,children:r}),initExpanded:true,children:jsx(View,{style:R.listContent,children:t?.length?t.map((i,a)=>jsx(View,{style:R.listItem,children:jsx(Zr,{path:`${o}.${a}`,field:{...n,placeholder:`${r} ${a+1}`},value:i})},`${o}.${a}`)):jsx(Text,{style:R.emptyListText,children:"No items"})})})})},Zr=({field:e,value:t,path:o,storagePath:n})=>{let{updateField:r}=useDataView();return isField(e)?r?jsx(Qr,{storagePath:n,field:e,value:t,onSubmit:i=>r(o,i)}):jsx(Wt,{field:e,value:t}):isListField(e)?jsx(gu,{path:o,field:e,value:t}):jsx(hu,{storagePath:n?`${n}.${o}`:void 0,path:o,field:e})},hu=({field:e,value:t,onClose:o,onDelete:n,onSubmit:r,itemName:i,storagePath:a,path:s=""})=>{let{name:l,children:u}=e,[p,d]=useState(false);return jsx(DataViewProvider,{value:t,onSubmit:r,children:jsx(_t,{alwaysExpanded:true,header:()=>jsxs(View,{style:R.dataViewHeader,children:[jsx(Text,{style:R.dataViewTitle,children:l}),jsxs(View,{style:R.dataViewActions,children:[n&&jsx(Qt,{onDelete:n,itemName:i??"item"}),r&&jsx(TouchableOpacity,{onPress:()=>d(true),children:jsx(Text,{children:"Edit"})}),o&&jsx(TouchableOpacity,{onPress:o,children:jsx(Text,{children:"Close"})})]})]}),children:p&&r?jsx(wu,{storagePath:a,field:e,value:t,onSubmit:r,onBack:()=>d(false)}):jsx(View,{style:R.dataViewContent,children:Object.entries(u).map(([c,f])=>jsx(Zr,{storagePath:a?`${a}/${c}`:void 0,path:s?`${s}.${c}`:c,field:f,value:t?.[c]},c))})})})},ei=({onSubmit:e,onBack:t,field:o,value:n,buttonText:r="SUBMIT",renderFooter:i,storagePath:a})=>{let s=useMemo(()=>({field:o,value:n,submit:e,storagePath:a}),[o,n,e,a]),{onSubmit:l,uploads:u}=useFormSubmit(s);return jsxs(View,{style:R.container,children:[jsx(Wo,{name:"",field:o}),jsx(zr,{uploads:u,onSubmit:l,renderFooter:i,onBack:t,buttonText:r})]})},yu=({onSubmit:e,field:t,value:o,...n})=>{let r=useMemo(()=>({children:{value:t}}),[t]);return jsx(ei,{field:r,value:{value:o},onSubmit:i=>e(i?.value),...n})},wu=({field:e,...t})=>{let o=isField(e)||isListField(e)?jsx(yu,{field:e,...t}):jsx(ei,{field:e,...t});return jsx(ChempoFormProvider,{children:o})};var Iu=()=>{let{colorMode:e,toggleColorMode:t}=useTheme(),o=e==="dark",n=useIconColor(),r=o?"moon":"sunny",i=useBackgroundColor(100);return jsx(TouchableOpacity,{onPress:t,style:[ti.button,{backgroundColor:i}],children:jsx(Ionicons,{name:r,size:16,color:n})})},lb=()=>jsx(View,{style:ti.container,children:jsx(Iu,{})}),ti=StyleSheet.create({container:{position:"absolute",bottom:12,right:12},button:{width:25,height:25,borderRadius:16,justifyContent:"center",alignItems:"center"}});var ri={closeMessage:()=>Notifier.hideNotification(),showMessage:({title:e,type:t,duration:o,message:n})=>{let r=t==="info"?NotifierComponents.Notification:NotifierComponents.Alert,i={alertType:t==="error"?"error":"success"};return Notifier.showNotification({title:e,description:n,duration:o,Component:r,componentProps:i}),"root"}};var ii=e=>{let{initialColorMode:t,theme:o}=e??{},[n,r]=useState(t??"light");return useMemo(()=>({colorMode:n,setColorMode:r,theme:o}),[n,r,o])};var li=()=>{let e=()=>{let{width:o,height:n}=Dimensions.get("window");useScreen.setState({width:o,height:n,isMobile:true,isPortrait:o<n});};e();let t=Dimensions.addEventListener("change",e);return ()=>{t.remove();}};registerTranslation("en",en);var Ib=({theme:e,initialColorMode:t,...o})=>{let n=useMemo(()=>({theme:e,initialColorMode:t}),[e,t]),r=ii(n);return jsx(NotifierWrapper,{children:jsx(ChempoProvider,{toast:ri,theme:r,initializeScreen:li,...o})})};export{lb as AbsoluteDarkModeToggle,lt as AnimatedCenter,de as Center,Ib as ChempoNativeProvider,Pn as CircularProgress,_u as CollapseHorizontal,Zu as ContentBox,Iu as DarkModeToggle,hu as DataView,Qt as DeleteButton,Ni as DeleteConfirmAlert,Gt as DropShadow,Qr as Editable,Fp as ExpandOnMount,_t as Expandable,yu as FieldForm,ei as FieldMapForm,vt as FileView,wu as Form,Wo as FormElement,kp as FullSizeContainer,Dp as FullSizeProvider,kn as ImageViewOverlay,fu as ListFieldInput,no as Loading,tm as LoadingButton,zn as LoadingImage,fe as LoadingLogo,ft as LoadingOverlay,mf as LoadingSwitch,hn as LottieLoadingLogo,rg as MediaFeed,Jr as StandaloneInput,sm as Toggle,Y as Txt,li as initializeScreen,ri as nativeToast,Bp as useFullSize,la as useMediaFeed,ii as useThemeState};//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map