{"version":3,"file":"AddToCalender.DmbiZ5yY.mjs","names":["__esmMin","init_ssg_sandbox_shims","window","navigator","init_jsx_runtime","c","p","addPropertyControls","init_framer_BisrWwwE","ControlType","AddToCalendar","props","toGoogleUTC","d","dateStr","toICSUTC","generateGoogleCalendarUrl","dates","startDate","endDate","eventName","eventDescription","eventLocation","timeZone","escapeICS","v","generateICSFile","uid","dtstamp","icsLines","blob","url","a","ua","textColor","radius","paddingTop","paddingRight","paddingBottom","paddingLeft","font","style","iconSVG","iconSize","text","init_AddToCalender"],"sources":["https:/framerusercontent.com/modules/fGDajRc8Bcxz9DEZYVaO/vCjrK75WbG4SJCOM9HLa/AddToCalender.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";export default function AddToCalendar(props){const{eventName,eventDescription,eventLocation,startDate,endDate,text,font,backgroundColor,textColor,paddingTop,paddingRight,paddingBottom,paddingLeft,radius,iconSVG,iconSize,timeZone=\"Europe/Rome\",style}=props;// YYYYMMDDTHHMMSSZ (UTC) per Google Calendar\nconst toGoogleUTC=dateStr=>{const d=new Date(dateStr);if(isNaN(d.getTime()))return\"\";return d.toISOString().replace(/[-:]/g,\"\").replace(/\\.\\d{3}Z$/,\"Z\");};// per ICS accetta anche Z; usiamo UTC per semplicità\nconst toICSUTC=dateStr=>toGoogleUTC(dateStr);const generateGoogleCalendarUrl=()=>{const dates=`${toGoogleUTC(startDate)}/${toGoogleUTC(endDate)}`;const params=new URLSearchParams({action:\"TEMPLATE\",text:eventName,details:eventDescription,location:eventLocation,dates,ctz:timeZone});return`https://calendar.google.com/calendar/render?${params.toString()}`;};const escapeICS=v=>(v||\"\").replace(/\\\\/g,\"\\\\\\\\\").replace(/;/g,\"\\\\;\").replace(/,/g,\"\\\\,\").replace(/\\n/g,\"\\\\n\");const generateICSFile=()=>{const uid=`${Date.now()}@apishare.cloud`;const dtstamp=new Date().toISOString().replace(/[-:]/g,\"\").replace(/\\.\\d{3}Z$/,\"Z\");const icsLines=[\"BEGIN:VCALENDAR\",\"VERSION:2.0\",\"PRODID:-//ApiShare//AddToCalendar//EN\",\"CALSCALE:GREGORIAN\",\"METHOD:PUBLISH\",\"BEGIN:VEVENT\",`UID:${uid}`,`DTSTAMP:${dtstamp}`,`DTSTART:${toICSUTC(startDate)}`,`DTEND:${toICSUTC(endDate)}`,`SUMMARY:${escapeICS(eventName)}`,`DESCRIPTION:${escapeICS(eventDescription)}`,`LOCATION:${escapeICS(eventLocation)}`,\"END:VEVENT\",\"END:VCALENDAR\"].join(\"\\r\\n\");const blob=new Blob([icsLines],{type:\"text/calendar;charset=utf-8\"});const url=URL.createObjectURL(blob);const a=document.createElement(\"a\");a.href=url;a.download=\"event.ics\";document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);};const handleClick=()=>{const ua=navigator.userAgent||\"\";const isiOS=/iPhone|iPad|iPod/.test(ua);// su iOS preferiamo .ics (apre Calendario nativo). Su altri apriamo GCal con template\nif(isiOS){generateICSFile();}else{window.open(generateGoogleCalendarUrl(),\"_blank\",\"noopener,noreferrer\");}};return /*#__PURE__*/_jsxs(\"div\",{onClick:handleClick,style:{backgroundColor,color:textColor,borderRadius:radius,padding:`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,cursor:\"pointer\",display:\"flex\",alignItems:\"center\",gap:12,userSelect:\"none\",transition:\"all 0.15s ease\",width:\"fit-content\",...font,...style},onMouseEnter:e=>{e.currentTarget.style.opacity=\"0.9\";e.currentTarget.style.transform=\"translateY(-1px)\";},onMouseLeave:e=>{e.currentTarget.style.opacity=\"1\";e.currentTarget.style.transform=\"translateY(0)\";},children:[iconSVG&&/*#__PURE__*/_jsx(\"div\",{style:{width:iconSize,height:iconSize,color:textColor},dangerouslySetInnerHTML:{__html:iconSVG}}),/*#__PURE__*/_jsx(\"span\",{children:text})]});}addPropertyControls(AddToCalendar,{eventName:{type:ControlType.String,title:\"Event Name\",defaultValue:\"My Event\"},eventDescription:{type:ControlType.String,title:\"Description\",defaultValue:\"Description here...\"},eventLocation:{type:ControlType.String,title:\"Location\",defaultValue:\"123 Main St\"},startDate:{type:ControlType.String,title:\"Start Date\",defaultValue:\"2024-09-10T12:00:00\"},endDate:{type:ControlType.String,title:\"End Date\",defaultValue:\"2024-09-10T13:00:00\"},timeZone:{type:ControlType.String,title:\"Time Zone\",defaultValue:\"Europe/Rome\"},text:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Add to Calendar\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1.4}},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#ffffff\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#222357\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:4,min:0},paddingTop:{type:ControlType.Number,title:\"Padding T\",defaultValue:10,min:0},paddingRight:{type:ControlType.Number,title:\"Padding R\",defaultValue:20,min:0},paddingBottom:{type:ControlType.Number,title:\"Padding B\",defaultValue:10,min:0},paddingLeft:{type:ControlType.Number,title:\"Padding L\",defaultValue:20,min:0},iconSVG:{type:ControlType.String,title:\"Icon SVG\",defaultValue:\"\",display:\"textarea\"},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:24,min:8,max:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AddToCalendar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AddToCalender.map"],"mappings":"A,wLAA6G,SAAwBU,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,mBAAiB,gBAAc,YAAU,UAAQ,OAAK,OAAK,kBAAgB,YAAU,aAAW,eAAa,gBAAc,cAAY,SAAO,UAAQ,WAAS,WAAS,cAAc,SAAOC,EACjWC,EAAY,GAAS,CAAC,IAA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