{"version":3,"file":"SelectServicePicker.DuV9SV86.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx","__esmMin","window","init_ssg_sandbox_shims","init_npm_react_18_3_1","init_jsx_runtime","oe","c","ce","init_framer_BWFVvmND","DataObserverContext","ServiceLocationController","normalize","val","params","rawServiceParam","serviceParam","LOCATION_SERVICE_MAP","serviceMapEN","serviceMapAR","isArabicPage","serviceInitialized","initServiceOnce","serviceSelect","enLabel","arLabel","match","opt","applyLogic","locationSelect","selectedLocation","allowedServices","firstVisibleIndex","label","option","isAllowed","index","current","tryInit","serviceReady","rafCount","rafLoop","observer","withServiceLocationController","C","props","init_SelectServicePicker"],"sources":["https:/framerusercontent.com/modules/37WK3b7flXJdDG2sllhu/c8iXyJIMNI8OcEC9Z5uT/SelectServicePicker.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function ServiceLocationController(){useEffect(()=>{const normalize=val=>val.trim().toLowerCase().replace(/\\s+/g,\" \");/* ---------------- URL PARAM ---------------- */const params=new URLSearchParams(window.location.search);const rawServiceParam=params.get(\"services\")||params.get(\"service\");// const serviceParam = rawServiceParam.trim().toLowerCase()\nconst serviceParam=rawServiceParam&&rawServiceParam.trim()?rawServiceParam.trim().toLowerCase():null;/* ---------------- MAPS ---------------- */const LOCATION_SERVICE_MAP={\"kafd 3.09\":[\"private office\",\"coworking spaces\",\"meeting and conference room\",\"event spaces\",\"national address\",\"enterprise solutions\",\"managed office\"],\"kafd 2.08\":[\"private office\"]};const serviceMapEN={\"private-office\":\"Private Office\",\"private-offices\":\"Private Office\",\"virtual-office\":\"Virtual Offices\",\"virtual-offices\":\"Virtual Offices \",\"national-address\":\"Virtual Offices\",\"enterprise-solution\":\"Managed Office\",\"enterprise-solutions\":\"Managed Office\",\"managed-offices\":\"Managed Office\",\"managed-office\":\"Managed Office\",\"meeting-rooms\":\"Meeting and Conference Room\",\"meeting-room\":\"Meeting and Conference Room\",\"event-spaces\":\"Event Spaces\",\"event-space\":\"Event Spaces\",coworking:\"Coworking Spaces\",\"coworking-spaces\":\"Coworking Spaces\",\"coworking-space\":\"Coworking Spaces\"};const serviceMapAR={\"Private Office\":\"المكاتب الخاصة\",\"National Address\":\"العنوان الوطني\",\"Managed Office\":\"المكتب المُدار\",\"Managed Offices\":\"المكتب المُدار\",\"Enterprise Solutions\":\"المكتب المُدار\",\"Meeting and Conference Room\":\"قاعة الاجتماعات والمؤتمرات\",\"Event Spaces\":\"قاعات الفعاليات\",\"Coworking Spaces\":\"مساحات العمل المشتركة\"};const isArabicPage=document.documentElement.lang===\"ar\"||window.location.pathname.startsWith(\"/ar\");/* ---------------- SERVICE INIT (ONCE) ---------------- */let serviceInitialized=false;const initServiceOnce=()=>{console.log(serviceInitialized);console.log(serviceParam);console.log(\"serviceParam\");console.log(\"serviceInitialized\");if(serviceInitialized||!serviceParam)return true;const serviceSelect=document.querySelector('select[name=\"Service\"]');if(!serviceSelect||!serviceSelect.options.length)return false;const enLabel=serviceMapEN[serviceParam];const arLabel=enLabel?serviceMapAR[enLabel]:null;const match=Array.from(serviceSelect.options).find(opt=>normalize(opt.text)===normalize(enLabel||\"\")||isArabicPage&&arLabel&&normalize(opt.text)===normalize(arLabel));if(match){serviceSelect.selectedIndex=Array.from(serviceSelect.options).indexOf(match);}serviceInitialized=true;return true;};/* ---------------- FILTER LOGIC ---------------- */const applyLogic=()=>{const locationSelect=document.querySelector('select[name=\"Location\"]');const serviceSelect=document.querySelector('select[name=\"Service\"]');if(!locationSelect||!serviceSelect)return;if(!serviceSelect.options.length)return;console.log(\"applyLogic\");const selectedLocation=normalize(locationSelect.options[locationSelect.selectedIndex]?.text||\"\");const allowedServices=LOCATION_SERVICE_MAP[selectedLocation]||[];let firstVisibleIndex=null;Array.from(serviceSelect.options).forEach((option,index)=>{const label=normalize(option.text);const isAllowed=!allowedServices.length||allowedServices.includes(label);option.hidden=!isAllowed;option.disabled=!isAllowed;if(isAllowed&&firstVisibleIndex===null){firstVisibleIndex=index;}});const current=serviceSelect.options[serviceSelect.selectedIndex];if(!current||current.disabled||current.hidden){serviceSelect.selectedIndex=firstVisibleIndex??0;}serviceSelect.dispatchEvent(new Event(\"change\",{bubbles:true}));};/* ---------------- INIT LOOP ---------------- */const tryInit=()=>{const serviceReady=initServiceOnce();const serviceSelect=document.querySelector('select[name=\"Service\"]');if(serviceReady&&serviceSelect?.options.length){applyLogic();document.querySelector('select[name=\"Location\"]')?.addEventListener(\"change\",applyLogic);return true;}return false;};let rafCount=0;const rafLoop=()=>{if(tryInit()||rafCount>30)return;rafCount++;requestAnimationFrame(rafLoop);};requestAnimationFrame(rafLoop);const observer=new MutationObserver(()=>{if(tryInit())observer.disconnect();});observer.observe(document.body,{childList:true,subtree:true});return()=>observer.disconnect();},[]);return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withServiceLocationController(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ServiceLocationController(props)});};}withServiceLocationController.displayName=\"ServiceLocationController\";\nexport const __FramerMetadata__ = {\"exports\":{\"withServiceLocationController\":{\"type\":\"reactHoc\",\"name\":\"withServiceLocationController\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ServiceLocationController\":{\"type\":\"override\",\"name\":\"ServiceLocationController\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SelectServicePicker.map"],"mappings":"A,yLAAwE,SAAgBY,GAA2B,CACisH,OADhsHH,MAAc,CAAC,IAAMI,EAAU,GAAKC,EAAI,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,OAAO,GAAG,EAAyDC,EAAO,IAAI,gBAAgBZ,EAAO,SAAS,MAAM,EAAQa,EAAgBD,EAAO,IAAI,UAAU,GAAGA,EAAO,IAAI,SAAS,EAC3WE,EAAaD,GAAiBA,EAAgB,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