{"version":3,"file":"LocalTime.VaOg0kGb.mjs","names":["React.useState","React.useRef","React.useMemo"],"sources":["https:/framerusercontent.com/modules/HXIRE3raLuPfoCEkiWJz/ZWF4wu702zovtZRoE2bw/LocalTime.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// ─── Constants ───────────────────────────────────────────────────────────────\nconst TIME_ZONE=\"Europe/Istanbul\";const LOCALE=\"en-GB\";// ─── Formatter cache ─────────────────────────────────────────────────────────\nconst timeFormatterCache=new Map;let dateFormatter=null;function getTimeFormatter(hourCycle,withSeconds){const key=`${hourCycle}|${withSeconds?1:0}`;let f=timeFormatterCache.get(key);if(!f){f=new Intl.DateTimeFormat(LOCALE,{timeZone:TIME_ZONE,hour:\"2-digit\",minute:\"2-digit\",...withSeconds?{second:\"2-digit\"}:{},hourCycle});timeFormatterCache.set(key,f);}return f;}function getDateFormatter(){if(!dateFormatter){dateFormatter=new Intl.DateTimeFormat(LOCALE,{timeZone:TIME_ZONE,month:\"long\",day:\"numeric\",year:\"numeric\"});}return dateFormatter;}// ─── SSR-safe placeholder ────────────────────────────────────────────────────\n// Server and client both render the same placeholder string on initial paint.\n// Real time is filled in by useEffect (client-only). This avoids React\n// hydration error #425 (server/client text mismatch). Without this guard,\n// React discards the SSR DOM and re-mounts the entire root - which kills any\n// in-flight <video autoplay> element from the SSR HTML.\nfunction makeTimePlaceholder(format,withSeconds){if(format===\"12h\")return withSeconds?\"00:00:00 am\":\"00:00 am\";return withSeconds?\"00:00:00\":\"00:00\";}// ─── Component ───────────────────────────────────────────────────────────────\nexport function IstanbulTime({format,showSeconds,showDate,font,color,style}){const isCanvas=RenderTarget.current()===RenderTarget.canvas;const timeFormatter=getTimeFormatter(format===\"12h\"?\"h12\":\"h23\",showSeconds);const dateFmt=showDate?getDateFormatter():null;// SSR-safe initial state - same on server and client.\nconst[display,setDisplay]=React.useState({time:makeTimePlaceholder(format,showSeconds),date:\"\"});const timeFormatterRef=React.useRef(timeFormatter);const dateFormatterRef=React.useRef(dateFmt);timeFormatterRef.current=timeFormatter;dateFormatterRef.current=dateFmt;// Re-format immediately when format/seconds/date toggles change.\nReact.useEffect(()=>{const now=new Date;setDisplay({time:timeFormatter.format(now),date:dateFmt?dateFmt.format(now):\"\"});},[timeFormatter,dateFmt]);// Ticking effect — runs once on mount in published mode.\nReact.useEffect(()=>{if(isCanvas)return;if(typeof window===\"undefined\")return;let timeoutId=null;let intervalId=null;const tick=()=>{const now=new Date;const df=dateFormatterRef.current;setDisplay({time:timeFormatterRef.current.format(now),date:df?df.format(now):\"\"});};const start=()=>{if(intervalId!=null)return;const msToNextSecond=1e3-Date.now()%1e3;timeoutId=setTimeout(()=>{timeoutId=null;tick();intervalId=setInterval(tick,1e3);},msToNextSecond);};const stop=()=>{if(timeoutId!=null){clearTimeout(timeoutId);timeoutId=null;}if(intervalId!=null){clearInterval(intervalId);intervalId=null;}};const handleVisibility=()=>{if(document.hidden){stop();}else{tick();start();}};// Tick once immediately so placeholder is replaced as fast as possible.\ntick();start();document.addEventListener(\"visibilitychange\",handleVisibility);return()=>{stop();document.removeEventListener(\"visibilitychange\",handleVisibility);};},[isCanvas]);const containerStyle=React.useMemo(()=>{const f=font||{};const textAlign=f.textAlign||\"left\";const justifyContent=textAlign===\"center\"?\"center\":textAlign===\"right\"?\"flex-end\":\"flex-start\";return{display:\"flex\",flexDirection:showDate?\"column\":\"row\",justifyContent,alignItems:showDate?justifyContent:\"baseline\",width:\"100%\",height:\"100%\",...f,color,textTransform:\"uppercase\",...style||{}};},[font,color,showDate,style]);return /*#__PURE__*/_jsxs(\"div\",{style:containerStyle,role:\"timer\",\"aria-live\":\"polite\",\"aria-label\":`Local time in Istanbul${showDate?`, ${display.date}`:\"\"}`,children:[/*#__PURE__*/_jsx(\"span\",{suppressHydrationWarning:true,children:display.time}),showDate&&/*#__PURE__*/_jsx(\"span\",{suppressHydrationWarning:true,style:{fontSize:\"0.7em\",opacity:.65},children:display.date})]});}IstanbulTime.displayName=\"text-local-time\";IstanbulTime.defaultProps={format:\"24h\",showSeconds:false,showDate:false,color:\"#000000\",font:{fontSize:16,fontWeight:400,lineHeight:\"1.2em\"}};// ─── Property Controls ───────────────────────────────────────────────────────\naddPropertyControls(IstanbulTime,{format:{type:ControlType.Enum,title:\"Format\",options:[\"24h\",\"12h\"],optionTitles:[\"24-hour\",\"12-hour\"],defaultValue:\"24h\",displaySegmentedControl:true},showSeconds:{type:ControlType.Boolean,title:\"Seconds\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showDate:{type:ControlType.Boolean,title:\"Date\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},font:{// @ts-expect-error — ControlType.Font is valid at runtime in Framer\ntype:\"font\",title:\"Font\",controls:\"extended\",displayTextAlignment:true,defaultValue:{fontSize:16,fontWeight:400,lineHeight:\"1.2em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"IstanbulTime\":{\"type\":\"reactComponent\",\"name\":\"IstanbulTime\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LocalTime.map"],"mappings":"kNAEwD,SAAS,EAAiB,EAAU,EAAY,CAAC,IAAM,EAAI,GAAG,EAAU,GAAG,OAAsB,EAAE,EAAmB,IAAI,CAAG,EAA8K,OAAxK,IAAG,EAAE,IAAI,KAAK,eAAe,EAAO,CAAC,SAAS,EAAU,KAAK,UAAU,OAAO,UAAU,GAAG,EAAY,CAAC,OAAO,SAAS,EAAE,CAAC,EAAE,WAAS,CAAC,EAAE,EAAmB,IAAI,EAAI,CAAC,GAAU,CAAE,CAAC,SAAS,GAAkB,CAAkI,MAAjI,CAAmB,IAAc,IAAI,KAAK,eAAe,EAAO,CAAC,SAAS,EAAU,MAAM,OAAO,IAAI,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