{"version":3,"file":"SelectServicePicker.BN3sltE-.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx"],"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":"yLAAwE,SAAgB,GAA2B,CACisH,OADhsH,MAAc,CAAC,IAAM,EAAU,GAAK,EAAI,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,OAAO,GAAG,EAAyD,EAAO,IAAI,gBAAgB,EAAO,SAAS,MAAM,EAAQ,EAAgB,EAAO,IAAI,UAAU,GAAG,EAAO,IAAI,SAAS,EAC3W,EAAa,GAAiB,EAAgB,KAAK,EAAE,EAAgB,KAAK,CAAC,CAAC,YAAY,EAAE,KAAuD,EAAqB,CAAC,YAAY,CAAC,iBAAiB,mBAAmB,8BAA8B,eAAe,mBAAmB,uBAAuB,gBAAgB,EAAE,YAAY,CAAC,gBAAgB,CAAC,EAAQ,EAAa,CAAC,iBAAiB,iBAAiB,kBAAkB,iBAAiB,iBAAiB,kBAAkB,kBAAkB,mBAAmB,mBAAmB,kBAAkB,sBAAsB,iBAAiB,uBAAuB,iBAAiB,kBAAkB,iBAAiB,iBAAiB,iBAAiB,gBAAgB,8BA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