{"version":3,"file":"AppSelectInput.spLuF3QL.mjs","names":["chroma","AppSelectInput","useState","_Fragment","Select"],"sources":["https:/framerusercontent.com/modules/SoSMQCBgMqJbrfXFheyg/uMRFFQoOEkN6JUd9zwEK/AppSelectInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType,withCSS}from\"framer\";import chroma from\"chroma-js\";import Select from\"react-select\";const colourStyles={control:styles=>({...styles,backgroundColor:\"white\",borderColor:\"#EBECF0\",borderRadius:\"8px\",flexWrap:\"nowrap\"}),option:(styles,{data,isDisabled,isFocused,isSelected})=>{const color=chroma(\"#EDEBF9\");return{...styles,backgroundColor:isDisabled?undefined:isSelected?\"#EDEBF9\":isFocused?\"white\":undefined,color:isDisabled?\"#ccc\":isSelected?chroma.contrast(color,\"white\")>2?\"white\":\"black\":\"#EDEBF9\",cursor:isDisabled?\"not-allowed\":\"default\",\":active\":{...styles[\":active\"],backgroundColor:!isDisabled?isSelected?\"#EDEBF9\":color.alpha(.3).css():undefined}};},valueContainer:(styles,{data})=>{return{...styles,padding:\"8px\",display:\"flex\",flexWrap:\"wrap\",gap:\"4px\"};},noOptionsMessage:(styles,{data})=>{return{...styles,fontSize:\"16px\"};},loadingMessage:(styles,{data})=>{return{...styles,fontSize:\"16px\"};},placeholder:(styles,{data})=>{return{...styles,fontSize:\"16px\"};},input:(styles,{data})=>{return{...styles,fontSize:\"16px\"};}};function replacePlaceholders(str,values){return str.replace(/\\{([^}]+)\\}/g,function(i,match){if(!values.hasOwnProperty(match)||values[match]===null){throw new Error(`Key '${match}' not found or null in values object`);}return values[match];});}/**\n * JOB FORM\n * By Joel Whitaker\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 40\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */const AppSelectInput=withCSS(function AppSelectInput({label,url,multi,defaultImage,onSelect,store,style}){const[colourOptions,setColourOptions]=useState([]);const[isLoading,setLoading]=useState(false);const[reloadOptions,setReloadOptions]=useState(false);useEffect(()=>{var _store_session;if(!(store===null||store===void 0?void 0:store.session))return;let apiEndpoint=\"\";try{apiEndpoint=replacePlaceholders(url,store);}catch(error){// Skip if the value does not exist or is null\nreturn;}const apiOptions={headers:{\"x-test-mode\":store.testMode,authorization:\"Bearer \"+(store===null||store===void 0?void 0:(_store_session=store.session)===null||_store_session===void 0?void 0:_store_session.access_token)}};if(!store){const data=[{id:\"31396\",name:\"Shiny Object Labs\",slug:\"shinyobjectlabs\",image:\"https://eu.ui-avatars.com/api/?name=Shiny+Object+Labs&length=1&background=898FA9&color=fff&size=64&rounded=true\"}];const formattedData=data.map(item=>({value:item.id,label:item.name,image:item.image,color:\"#000\",isFixed:false,isDisabled:false}));setColourOptions(formattedData);}setLoading(true);fetch(apiEndpoint,apiOptions).then(response=>response.json()).then(data=>{// Format the fetched data to match the expected structure\nconst formattedData=data.map(item=>({value:item.id,label:item.name,image:item.image,color:\"#000\",isFixed:false,isDisabled:false}));setColourOptions(formattedData);}).catch(error=>console.error(\"Error:\",error)).finally(()=>{setLoading(false);});},[store,reloadOptions]);const onStoreChange=(data,action)=>{onSelect===null||onSelect===void 0?void 0:onSelect(data.value);};return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsxs(\"div\",{style:labelWrapperStyle,children:[/*#__PURE__*/_jsx(\"p\",{style:labelStyle,children:label}),/*#__PURE__*/_jsx(\"div\",{style:iconWrapperStyle,onClick:()=>setReloadOptions(!reloadOptions),children:/*#__PURE__*/_jsxs(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",width:\"24\",height:\"24\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:'var(--token-3880ffc8-48b5-42cf-af6a-f4adb314eda2, rgb(196, 202, 212)) /* {\"name\":\"Grey 400\"} */',strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:iconStyle,children:[/*#__PURE__*/_jsx(\"polyline\",{points:\"23 4 23 10 17 10\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"1 20 1 14 7 14\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15\"})]})})]}),/*#__PURE__*/_jsx(Select,{closeMenuOnSelect:true,onChange:onStoreChange,isMulti:multi,options:colourOptions,styles:colourStyles,isLoading:isLoading,formatOptionLabel:option=>/*#__PURE__*/_jsxs(\"div\",{style:optionStyle,children:[/*#__PURE__*/_jsx(\"img\",{width:\"24\",height:\"24\",style:optionImageStyle,src:(option===null||option===void 0?void 0:option.image)||defaultImage}),/*#__PURE__*/_jsx(\"span\",{style:optionLabelStyle,children:option.label})]})})]});},[]);addPropertyControls(AppSelectInput,{label:{title:\"Label\",type:ControlType.String,defaultValue:\"Label\"},url:{title:\"Url\",type:ControlType.String,defaultValue:\"http://localhost:54321/functions/v1/dashboard/stores\"},multi:{type:ControlType.Boolean,title:\"Multi\",defaultValue:false}});export default AppSelectInput;const optionStyle={display:\"flex\",gap:\"16px\",alignItems:\"center\"};const optionLabelStyle={fontSize:\"16px\",fontWeight:\"400\",color:\"#000\"};const optionImageStyle={borderRadius:\"7px\"};const labelWrapperStyle={display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",marginBottom:\"1em\"};const labelStyle={fontSize:\"16px\",fontFamily:'\"Inter\", sans-serif',color:\"#606A76\",margin:0};const iconStyle={width:\"100%\",height:\"100%\"};const iconWrapperStyle={width:\"24px\",height:\"24px\",cursor:\"pointer\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AppSelectInput\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"40\",\"framerIntrinsicWidth\":\"200\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerDisableUnlink\":\"*\",\"framerContractVersion\":\"1\",\"framer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