@momentco-ai/moment-sdk 0.5.0-dev.30 → 0.5.0-dev.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/moment-sdk.js +2 -2
- package/dist/moment-sdk.mjs +56 -42
- package/dist/types/sdk/brand-assets.d.ts +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [0.
|
|
8
|
+
## [0.5.0] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **"Powered by" wordmark is now bundled** as an inlined SVG data URI (`src/sdk/brand-assets.ts`) instead of an `<img src="${liveBaseUrl}/brand/moment-text-white.png">` fetched at modal-open time. The logo used to drop in a beat after the "Powered by" text on a cold cache; it now paints with the rest of the tray, needs no request to the Live origin, and stays crisp at any DPR. Bundle cost is ~3.4 kB gzipped, against a ~21 kB PNG request removed.
|
|
13
|
+
- **Powered-by tray is a fixed 32px** (Figma 1396:2538), with a 6px gap and an explicitly-sized 67×11.83 wordmark box. It previously derived its height from the padded PNG's intrinsic aspect ratio (~48px) and could be squeezed by the flex column.
|
|
14
|
+
- **Modal frame carries a subtle hairline** (`rgba(255, 255, 255, 0.216)`, an inset shadow so it adds no layout box) and uses `#0d0d0d` rather than pure black, so the bottom tray still reads as its own surface on a dark host page whose background is close to the frame's own colour.
|
|
15
|
+
- **Desktop version introduced** — the SDK now opens a desktop-optimized modal on >=1024px viewports. The modal still opens in a mobile-optimized version on <1024px, but the modal frame and content now have different styles and layout.
|
|
16
|
+
|
|
17
|
+
## [0.4.0] - 2026-07-08
|
|
9
18
|
|
|
10
19
|
### Added
|
|
11
20
|
|
package/dist/moment-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(b){"use strict";class P{popup=null;pollTimer=null;messageHandler=null;resultReceived=!1;opts;constructor(e){this.opts=e}open(e){this.cleanup(),this.resultReceived=!1;const t=this.buildPopupUrl(e),i=Math.round(window.screenX+(window.outerWidth-500)/2),o=Math.round(window.screenY+(window.outerHeight-700)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=500,height=700,left=${i},top=${o},menubar=no,toolbar=no,location=yes,status=no`),!this.popup||this.popup.closed){this.sendStatusToIframe("popup-blocked"),this.opts.onPopupBlocked();return}this.sendStatusToIframe("popup-opened"),this.startPolling(),this.messageHandler=n=>{if(n.origin!==this.opts.liveOrigin||n.source!==this.popup)return;const r=n.data;!r||typeof r!="object"||r.source!=="moment-live-embed"||r.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(r,this.opts.liveOrigin),this.opts.onResult(r),this.cleanup())},window.addEventListener("message",this.messageHandler)}cleanup(){if(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.popup&&!this.popup.closed)try{this.popup.close()}catch{}this.popup=null}buildPopupUrl(e){const t=window.location.origin,i=new URLSearchParams({provider:e.provider,teamSlug:e.teamSlug,ids:e.ids.join(","),triggerType:e.triggerType,returnOrigin:t});return e.subscriptionType&&i.set("subscriptionType",e.subscriptionType),e.scheduleMomentIds?.length&&i.set("scheduleMomentIds",e.scheduleMomentIds.join(",")),e.schedulePlaylistIds?.length&&i.set("schedulePlaylistIds",e.schedulePlaylistIds.join(",")),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${i.toString()}`}startPolling(){this.pollTimer=setInterval(()=>{(!this.popup||this.popup.closed)&&(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.resultReceived||(this.sendStatusToIframe("popup-closed"),this.opts.onPopupClosed()),this.cleanup())},500)}sendStatusToIframe(e){if(!this.opts.iframeWindow)return;const t={source:"moment-sdk",type:"moment.embed.oauth.status",status:e};this.opts.iframeWindow.postMessage(t,this.opts.liveOrigin)}}function k(s,e,t=typeof window<"u"?window.location.origin:""){if(e.triggerType==="schedule"){const o=new URLSearchParams;return o.set("teamSlug",e.teamSlug),o.set("returnOrigin",t),o.set("embed","1"),`${s}/en/embed/schedule?${o.toString()}`}const i=new URLSearchParams;return i.set("teamSlug",e.teamSlug),e.momentSlug&&i.set("momentSlug",e.momentSlug),e.listSlug&&i.set("listSlug",e.listSlug),i.set("triggerType",e.triggerType),e.ids?.length&&i.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&i.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&i.set("calendar",e.calendar),e.apiSourceId&&i.set("subscriptionId",e.apiSourceId),e.externalEventId&&i.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&i.set("externalIdPrefix",e.externalEventIdPrefix),i.set("returnOrigin",t),i.set("embed","1"),`${s}/en/embed/sync?${i.toString()}`}const y="moment-sdk-trigger-styles",A=`
|
|
1
|
+
(function(v){"use strict";const M="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='15.55 11.94 120.52 21.28'%3E%3Cpath d='M16.59 33.04L17.42 29.54C18.62 24.54 19.22 21.32 19.22 19.89C19.22 19.68 19.19 19.54 19.12 19.47C19.05 19.4 18.91 19.38 18.7 19.4C18.4 19.47 17.97 19.65 17.42 19.94C16.86 20.23 16.32 20.62 15.79 21.1C15.63 20.9 15.55 20.69 15.55 20.48C15.55 20.27 15.65 20.03 15.86 19.75C16.16 19.38 16.65 18.95 17.33 18.45C18.02 17.95 18.74 17.53 19.5 17.2C20.27 16.86 20.92 16.7 21.48 16.7C21.78 16.7 22 16.79 22.14 16.99C22.28 17.19 22.35 17.5 22.35 17.94C22.35 18.55 22.24 19.42 22.04 20.56C21.83 21.71 21.55 22.88 21.2 24.09C22.34 21.96 23.59 20.19 24.95 18.79C26.32 17.4 27.7 16.7 29.12 16.7C29.79 16.7 30.27 16.87 30.57 17.23C30.87 17.59 31.02 18.14 31.02 18.88C31.02 19.97 30.69 21.7 30.02 24.09C31.13 22.01 32.44 20.25 33.94 18.83C35.44 17.41 36.94 16.7 38.42 16.7C39.11 16.7 39.63 16.88 39.98 17.25C40.33 17.62 40.5 18.16 40.5 18.88C40.5 19.18 40.45 19.62 40.34 20.18C40.24 20.75 40.1 21.37 39.91 22.04L38.42 27.7C38.09 28.92 37.93 29.77 37.93 30.23C37.93 30.48 37.97 30.67 38.05 30.8C38.13 30.93 38.27 30.99 38.45 30.99C38.89 30.99 39.47 30.69 40.17 30.09C40.88 29.49 41.46 28.85 41.92 28.18C42.25 28.44 42.41 28.72 42.41 29.05C42.41 29.26 42.34 29.48 42.2 29.71C41.74 30.5 40.98 31.28 39.93 32.05C38.87 32.82 37.82 33.21 36.75 33.21C36.08 33.21 35.56 33.02 35.17 32.62C34.79 32.23 34.6 31.66 34.6 30.92C34.6 30.3 34.8 29.22 35.19 27.7L36.79 21.55C37 20.74 37.1 20.13 37.1 19.71C37.1 19.2 36.89 18.95 36.48 18.95C35.97 18.95 35.3 19.33 34.46 20.08C33.63 20.83 32.79 21.94 31.93 23.41C31.07 24.88 30.33 26.62 29.71 28.63L28.91 31.27C28.77 31.73 28.59 32.09 28.37 32.33C28.15 32.57 27.82 32.73 27.38 32.8L25.54 33.22L25.37 33.04L26.13 29.67C26.73 27.11 27.19 25.03 27.49 23.44C27.79 21.86 27.94 20.72 27.94 20.03C27.94 19.33 27.72 19.02 27.28 19.02C26.79 19.02 26.17 19.4 25.42 20.15C24.67 20.9 23.89 22 23.1 23.46C22.3 24.92 21.6 26.65 21 28.67L20.2 31.27C20.06 31.71 19.87 32.05 19.63 32.29C19.38 32.54 19.02 32.71 18.53 32.8L16.76 33.22L16.59 33.04L16.59 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M57.66 17.94C57 17.13 55.99 16.73 54.62 16.73C52.93 16.73 51.31 17.3 49.75 18.43C49.51 18.6 49.28 18.78 49.06 18.97C49.24 19.85 49.39 20.78 49.48 21.74C49.86 21.01 50.3 20.37 50.79 19.82C51.63 18.87 52.5 18.39 53.41 18.39C54.08 18.39 54.55 18.68 54.81 19.24C55.08 19.81 55.21 20.58 55.21 21.55C55.21 23.08 54.97 24.63 54.48 26.19C54 27.75 53.35 29.03 52.54 30.04C51.73 31.04 50.86 31.55 49.94 31.55C49.53 31.55 49.19 31.44 48.9 31.22C48.74 31.9 48.54 32.55 48.31 33.19C48.5 33.2 48.7 33.21 48.9 33.21C50.54 33.21 52.11 32.63 53.61 31.48C55.12 30.32 56.33 28.82 57.26 26.98C58.18 25.14 58.65 23.28 58.65 21.38C58.65 19.9 58.32 18.75 57.66 17.94L57.66 17.94Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M61.84 33.04L62.67 29.54C63.88 24.54 64.48 21.32 64.48 19.89C64.48 19.68 64.44 19.54 64.37 19.47C64.3 19.4 64.17 19.38 63.96 19.4C63.66 19.47 63.23 19.65 62.67 19.94C62.12 20.23 61.57 20.62 61.04 21.1C60.88 20.9 60.8 20.69 60.8 20.48C60.8 20.27 60.9 20.03 61.11 19.75C61.41 19.38 61.9 18.95 62.59 18.45C63.27 17.95 63.99 17.53 64.76 17.2C65.52 16.86 66.18 16.7 66.73 16.7C67.04 16.7 67.26 16.79 67.39 16.99C67.53 17.19 67.6 17.5 67.6 17.94C67.6 18.55 67.5 19.42 67.29 20.56C67.08 21.71 66.8 22.88 66.46 24.09C67.59 21.96 68.84 20.19 70.2 18.79C71.57 17.4 72.96 16.7 74.37 16.7C75.04 16.7 75.53 16.87 75.83 17.23C76.13 17.59 76.28 18.14 76.28 18.88C76.28 19.97 75.94 21.7 75.27 24.09C76.38 22.01 77.69 20.25 79.19 18.83C80.7 17.41 82.19 16.7 83.67 16.7C84.36 16.7 84.89 16.88 85.23 17.25C85.58 17.62 85.75 18.16 85.75 18.88C85.75 19.18 85.7 19.62 85.6 20.18C85.49 20.75 85.35 21.37 85.16 22.04L83.67 27.7C83.35 28.92 83.19 29.77 83.19 30.23C83.19 30.48 83.23 30.67 83.31 30.8C83.39 30.93 83.52 30.99 83.71 30.99C84.15 30.99 84.72 30.69 85.42 30.09C86.13 29.49 86.71 28.85 87.18 28.18C87.5 28.44 87.66 28.72 87.66 29.05C87.66 29.26 87.59 29.48 87.46 29.71C86.99 30.5 86.24 31.28 85.18 32.05C84.13 32.82 83.07 33.21 82.01 33.21C81.34 33.21 80.81 33.02 80.43 32.62C80.05 32.23 79.86 31.66 79.86 30.92C79.86 30.3 80.05 29.22 80.44 27.7L82.04 21.55C82.25 20.74 82.35 20.13 82.35 19.71C82.35 19.2 82.15 18.95 81.73 18.95C81.22 18.95 80.55 19.33 79.72 20.08C78.88 20.83 78.04 21.94 77.18 23.41C76.33 24.88 75.59 26.62 74.96 28.63L74.16 31.27C74.02 31.73 73.85 32.09 73.63 32.33C73.41 32.57 73.08 32.73 72.64 32.8L70.8 33.22L70.62 33.04L71.39 29.67C71.99 27.11 72.44 25.03 72.74 23.44C73.04 21.86 73.19 20.72 73.19 20.03C73.19 19.33 72.97 19.02 72.53 19.02C72.05 19.02 71.43 19.4 70.68 20.15C69.92 20.9 69.15 22 68.35 23.46C67.55 24.92 66.85 26.65 66.25 28.67L65.45 31.27C65.31 31.71 65.12 32.05 64.88 32.29C64.64 32.54 64.27 32.71 63.79 32.8L62.02 33.22L61.84 33.04L61.84 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M91.01 31.91C90.19 31.04 89.78 29.85 89.78 28.32C89.78 26.47 90.32 24.64 91.41 22.84C92.49 21.03 93.87 19.56 95.54 18.41C97.2 17.27 98.82 16.69 100.4 16.69C101.23 16.69 101.87 16.9 102.31 17.3C102.75 17.71 102.97 18.25 102.97 18.95C102.97 20.08 102.55 21.13 101.72 22.09C100.88 23.05 99.77 23.81 98.37 24.38C96.97 24.95 95.47 25.23 93.87 25.23H93.52C93.25 26.16 93.11 27.05 93.11 27.9C93.11 28.97 93.32 29.79 93.75 30.37C94.18 30.95 94.8 31.24 95.61 31.24C96.51 31.24 97.4 30.91 98.28 30.26C99.16 29.62 99.99 28.69 100.78 27.49C100.96 27.72 101.1 27.91 101.18 28.06C101.26 28.21 101.3 28.39 101.3 28.6C101.3 28.81 101.22 29.06 101.06 29.36C100.78 29.89 100.32 30.46 99.67 31.05C99.02 31.63 98.24 32.14 97.33 32.57C96.41 33 95.43 33.21 94.39 33.21C92.96 33.21 91.83 32.78 91.01 31.91V31.91ZM94.32 23.81C95.43 23.81 96.43 23.58 97.33 23.12C98.22 22.65 98.92 22.08 99.42 21.4C99.93 20.71 100.19 20.05 100.19 19.4C100.19 18.69 99.85 18.33 99.18 18.33C98.3 18.33 97.37 18.85 96.39 19.91C95.41 20.96 94.61 22.25 94.01 23.78C94.08 23.8 94.19 23.81 94.32 23.81L94.32 23.81Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M105.91 33.04L106.78 29.12C107.96 24.08 108.55 21.04 108.55 20.03C108.55 19.82 108.5 19.66 108.4 19.56C108.29 19.45 108.15 19.4 107.96 19.4C107.68 19.4 107.3 19.54 106.82 19.82C106.33 20.1 105.75 20.51 105.08 21.07C105.01 21 104.95 20.89 104.91 20.75C104.86 20.62 104.84 20.5 104.84 20.41C104.84 20.27 104.86 20.13 104.89 19.99C104.93 19.85 105.01 19.7 105.15 19.54C105.43 19.17 105.88 18.76 106.52 18.31C107.16 17.86 107.83 17.47 108.55 17.16C109.27 16.85 109.89 16.69 110.43 16.69C110.79 16.69 111.06 16.79 111.21 16.97C111.36 17.16 111.43 17.47 111.43 17.91C111.43 19.09 111.05 21.2 110.29 24.26C111.42 22.08 112.72 20.28 114.19 18.84C115.66 17.41 117.14 16.69 118.65 16.69C119.37 16.69 119.92 16.88 120.3 17.25C120.68 17.62 120.87 18.14 120.87 18.81C120.87 19.48 120.67 20.57 120.28 22.07L118.72 27.97C118.44 28.99 118.3 29.74 118.3 30.23C118.3 30.71 118.48 30.99 118.82 30.99C119.26 30.99 119.84 30.69 120.54 30.09C121.25 29.49 121.83 28.85 122.29 28.18C122.62 28.43 122.78 28.72 122.78 29.05C122.78 29.26 122.71 29.48 122.57 29.71C122.32 30.17 121.91 30.67 121.34 31.22C120.77 31.76 120.12 32.23 119.39 32.62C118.67 33.02 117.92 33.21 117.16 33.21C116.46 33.21 115.92 33.02 115.54 32.62C115.16 32.23 114.97 31.63 114.97 30.82C114.97 30.15 115.18 29.04 115.59 27.49L117.09 22.14C117.36 21.05 117.5 20.24 117.5 19.71C117.5 19.18 117.32 18.95 116.95 18.95C116.37 18.95 115.65 19.35 114.8 20.15C113.94 20.95 113.08 22.09 112.21 23.58C111.34 25.07 110.63 26.84 110.08 28.87L109.45 31.06C109.31 31.59 109.13 31.98 108.9 32.22C108.67 32.47 108.33 32.65 107.89 32.76L106.09 33.21L105.91 33.04L105.91 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M126.29 32.28C125.82 31.65 125.59 30.84 125.59 29.85C125.59 29.27 125.7 28.37 125.9 27.16C126.11 25.94 126.47 24.18 126.98 21.87L127.6 18.88H124.52L124.76 17.49L127.99 17.15L130.03 13.12C130.24 12.75 130.43 12.48 130.59 12.32C130.75 12.16 130.95 12.06 131.18 12.01C131.41 11.96 131.76 11.94 132.22 11.94L132.36 12.11L131.28 17.15H136.07L135.9 18.01C135.85 18.36 135.75 18.59 135.6 18.71C135.45 18.82 135.18 18.88 134.79 18.88H130.9L130.24 21.94C129.73 24.34 129.37 26.11 129.17 27.23C128.96 28.35 128.85 29.14 128.85 29.61C128.85 30 128.93 30.29 129.08 30.47C129.23 30.66 129.48 30.75 129.82 30.75C130.42 30.75 131.14 30.5 131.98 30.01C132.81 29.51 133.55 28.89 134.2 28.15C134.57 28.43 134.75 28.69 134.75 28.95C134.75 29.39 134.42 29.95 133.75 30.63C133.07 31.31 132.25 31.91 131.26 32.43C130.28 32.96 129.34 33.22 128.44 33.22C127.47 33.22 126.75 32.9 126.28 32.28L126.29 32.28Z' fill='%23FAFAF9'%3E%3C/path%3E%3C/svg%3E",k=5.663533834586466,b=500,y=700,H=500;class O{popup=null;pollTimer=null;messageHandler=null;resultReceived=!1;opts;constructor(e){this.opts=e}open(e){this.cleanup(),this.resultReceived=!1;const t=this.buildPopupUrl(e),i=Math.round(window.screenX+(window.outerWidth-b)/2),o=Math.round(window.screenY+(window.outerHeight-y)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=${b},height=${y},left=${i},top=${o},menubar=no,toolbar=no,location=yes,status=no`),!this.popup||this.popup.closed){this.sendStatusToIframe("popup-blocked"),this.opts.onPopupBlocked();return}this.sendStatusToIframe("popup-opened"),this.startPolling(),this.messageHandler=n=>{if(n.origin!==this.opts.liveOrigin||n.source!==this.popup)return;const r=n.data;!r||typeof r!="object"||r.source!=="moment-live-embed"||r.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(r,this.opts.liveOrigin),this.opts.onResult(r),this.cleanup())},window.addEventListener("message",this.messageHandler)}cleanup(){if(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.popup&&!this.popup.closed)try{this.popup.close()}catch{}this.popup=null}buildPopupUrl(e){const t=window.location.origin,i=new URLSearchParams({provider:e.provider,teamSlug:e.teamSlug,ids:e.ids.join(","),triggerType:e.triggerType,returnOrigin:t});return e.subscriptionType&&i.set("subscriptionType",e.subscriptionType),e.scheduleMomentIds?.length&&i.set("scheduleMomentIds",e.scheduleMomentIds.join(",")),e.schedulePlaylistIds?.length&&i.set("schedulePlaylistIds",e.schedulePlaylistIds.join(",")),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${i.toString()}`}startPolling(){this.pollTimer=setInterval(()=>{(!this.popup||this.popup.closed)&&(this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.resultReceived||(this.sendStatusToIframe("popup-closed"),this.opts.onPopupClosed()),this.cleanup())},H)}sendStatusToIframe(e){if(!this.opts.iframeWindow)return;const t={source:"moment-sdk",type:"moment.embed.oauth.status",status:e};this.opts.iframeWindow.postMessage(t,this.opts.liveOrigin)}}function P(s,e,t=typeof window<"u"?window.location.origin:""){if(e.triggerType==="schedule"){const o=new URLSearchParams;return o.set("teamSlug",e.teamSlug),o.set("returnOrigin",t),o.set("embed","1"),`${s}/en/embed/schedule?${o.toString()}`}const i=new URLSearchParams;return i.set("teamSlug",e.teamSlug),e.momentSlug&&i.set("momentSlug",e.momentSlug),e.listSlug&&i.set("listSlug",e.listSlug),i.set("triggerType",e.triggerType),e.ids?.length&&i.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&i.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&i.set("calendar",e.calendar),e.apiSourceId&&i.set("subscriptionId",e.apiSourceId),e.externalEventId&&i.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&i.set("externalIdPrefix",e.externalEventIdPrefix),i.set("returnOrigin",t),i.set("embed","1"),`${s}/en/embed/sync?${i.toString()}`}const w="moment-sdk-trigger-styles",R=`
|
|
2
2
|
:where(.moment-sync-trigger) {
|
|
3
3
|
background-color: #1c1917;
|
|
4
4
|
color: #ffffff;
|
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
outline: 2px solid #1c1917;
|
|
23
23
|
outline-offset: 2px;
|
|
24
24
|
}
|
|
25
|
-
`;function H(){if(typeof document>"u"||document.getElementById(y))return;const s=document.createElement("style");s.id=y,s.textContent=A,document.head.appendChild(s)}const M=".moment-sync-trigger",w=1024,x=380,T=600,S=400,f=80,L="https://live.dev.momentco.ai";class E{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;isDesktopViewport=!1;viewportResizeHandler=null;constructor(e){this.opts={triggerSelector:M,...e},this.liveBaseUrl=L;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}H(),this.bindTriggers(),this.emitAnalytics("embed.init")}open(e){e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const t=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:t.teamSlug,triggerType:t.triggerType}),this.createModal(t)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const i=n=>{n.preventDefault(),this.handleTriggerClick(t)},o=this.boundClickHandlers.get(t);o&&t.removeEventListener("click",o),t.addEventListener("click",i),this.boundClickHandlers.set(t,i)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",i=e.getAttribute("data-moment-slug")??void 0,o=e.getAttribute("data-moment-list-slug")??void 0,n=e.getAttribute("data-moment-trigger-type");let r="moment";n!=null&&n!==""&&(n==="moment"||n==="list"||n==="team"||n==="brand-playlist"||n==="playlist"||n==="schedule"?r=n:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",n));const g=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",u=g?g.split(",").filter(Boolean):[],m=e.getAttribute("data-moment-playlist-slugs")??"",p=m?m.split(",").map(O=>O.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let l;a!=null&&a!==""&&(a==="google"||a==="outlook"?l=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const d=e.getAttribute("data-api-source-id")??void 0,c=e.getAttribute("data-external-event-id")??void 0,h=e.getAttribute("data-external-event-id-prefix")??void 0;if(c&&h&&console.warn("[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."),!t){console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");return}const v=r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:r,momentIds:v?[]:u}),this.open({teamSlug:t,momentSlug:i,listSlug:o,triggerType:r,ids:u,playlistSlugs:p,calendar:l??void 0,apiSourceId:d,externalEventId:h&&!c?void 0:c,externalEventIdPrefix:c?void 0:h})}scopeOpenPayload(e){return e.triggerType==="schedule"?{teamSlug:e.teamSlug,triggerType:e.triggerType}:e.triggerType==="playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,playlistSlugs:e.playlistSlugs,calendar:e.calendar}:e.triggerType==="team"||e.triggerType==="brand-playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,calendar:e.calendar}:e}createModal(e){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e,this.isDesktopViewport=window.innerWidth>=w;const t=this.buildIframeUrl(e);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:"999999",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",padding:"16px"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const o=document.createElement("div");Object.assign(o.style,{position:"relative",width:"100%",maxWidth:`${this.isDesktopViewport?T:x}px`,minWidth:this.isDesktopViewport?`${S}px`:"0",borderRadius:"16px",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:"#000000",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const n=document.createElement("div");n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label","Calendar sync modal"),n.tabIndex=-1,Object.assign(n.style,{position:"relative",width:"100%",maxHeight:this.isDesktopViewport?`calc(100vh - ${f}px)`:"80vh",borderRadius:"12px",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:"#ffffff"});const r=document.createElement("button");r.type="button",r.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1l12 12M13 1L1 13" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',r.setAttribute("aria-label","Close"),Object.assign(r.style,{position:"absolute",top:"10px",right:"10px",zIndex:"10",border:"none",backgroundColor:"transparent",color:"#999",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:"0"}),r.addEventListener("mouseenter",()=>{r.style.color="#666"}),r.addEventListener("mouseleave",()=>{r.style.color="#999"}),r.addEventListener("click",()=>this.handleCancel());const g=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.setAttribute("allow",""),this.iframe.setAttribute("sandbox","allow-scripts allow-same-origin allow-popups allow-forms"),this.iframe.setAttribute("scrolling","no"),Object.assign(this.iframe.style,{width:"100%",border:"none",display:"block",height:this.isDesktopViewport?"520px":"420px",overflow:"hidden",transition:"height 0.15s ease"}),g&&n.appendChild(r),n.appendChild(this.iframe);const u=document.createElement("div");Object.assign(u.style,{display:"flex",alignItems:"center",justifyContent:"center",padding:"12px 0"});const m=document.createElement("span");m.textContent="Powered by",Object.assign(m.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const p=document.createElement("img");p.alt="Moment",p.src=`${this.liveBaseUrl}/brand/moment-text-white.png`,Object.assign(p.style,{height:"auto",width:"67px",paddingTop:"2px"}),u.appendChild(m),u.appendChild(p),this.wrapper=o,this.container=n,o.appendChild(n),o.appendChild(u),this.overlay.appendChild(o),document.body.appendChild(this.overlay),this.viewportResizeHandler=()=>{const l=window.innerWidth>=w;if(this.isDesktopViewport=l,this.wrapper&&(this.wrapper.style.maxWidth=`${l?T:x}px`,this.wrapper.style.minWidth=l?`${S}px`:"0"),this.container&&(this.container.style.maxHeight=l?`calc(100vh - ${f}px)`:"80vh"),this.iframe){const d=l?window.innerHeight-f:Math.round(window.innerHeight*.8);(Number.parseFloat(this.iframe.style.height)||0)>d&&(this.iframe.style.height=`${d}px`)}},window.addEventListener("resize",this.viewportResizeHandler);const a=l=>{if(l.key!=="Tab")return;const d=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(d.length===0){l.preventDefault(),n.focus();return}const c=d[0],h=d[d.length-1],v=document.activeElement;l.shiftKey&&v===c?(l.preventDefault(),h.focus()):!l.shiftKey&&v===h&&(l.preventDefault(),c.focus())};n.addEventListener("keydown",a),g?r.focus():n.focus(),this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0,this.setupMessageListener(),this.overlay._escHandler=i,this.overlay._focusTrapHandler=a}buildIframeUrl(e){return k(this.liveBaseUrl,e)}setupMessageListener(){this.messageHandler=e=>{if(e.origin!==this.liveOrigin||e.source!==this.iframe?.contentWindow)return;const t=e.data;if(!(!t||typeof t!="object")){if(t.source==="moment-live-embed"&&t.type==="moment.embed.oauth.start"){const i=t;this.emitAnalytics("oauth.start",{provider:i.provider,teamSlug:i.teamSlug}),this.handleOAuthStart(i);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const i=typeof t.height=="number"?t.height:0;if(i>0&&this.iframe){const o=this.isDesktopViewport?window.innerHeight-f:Math.round(window.innerHeight*.8);this.iframe.style.height=`${Math.min(i,o)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const{borderRadius:i}=t;if(typeof i=="number"&&Number.isFinite(i)){const o=Math.max(0,Math.min(i,32));this.container&&(this.container.style.borderRadius=`${o}px`),this.wrapper&&(this.wrapper.style.borderRadius=o===0?"0px":`${o+4}px`)}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;i&&typeof i=="string"&&i.startsWith("webcal://")&&window.open(i,"_blank");return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.close"){this.handleCancel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const i=t;this.handleResult(i)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new P({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,onResult:t=>{this.handleResult(t)},onPopupBlocked:()=>{this.emitAnalytics("oauth.popup.blocked",{provider:e.provider})},onPopupClosed:()=>{this.emitAnalytics("oauth.popup.closed",{provider:e.provider})}}),this.popupBridge.open(e)}handleResult(e){if(e.result==="success"||e.result==="partial")this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e);else if(e.result==="error")this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e);else if(e.result==="cancelled")return;this.opts.onClose?.(e),this.emitAnalytics("embed.close"),e.triggerType!=="schedule"&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500))}handleCancel(){this.emitAnalytics("embed.close");const t={source:"moment-live-embed",type:"moment.embed.result",result:"cancelled",triggerType:this.activePayload?.triggerType??"moment",momentIds:this.activePayload?.ids??[]};this.opts.onClose?.(t),this.cleanup()}cleanup(){if(this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:e,_focusTrapHandler:t}=this.overlay;e&&document.removeEventListener("keydown",e);const i=this.overlay.firstElementChild;i&&t&&i.removeEventListener("keydown",t),this.overlay.remove(),this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.activePayload=null,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.previousFocusedElement&&typeof this.previousFocusedElement.focus=="function"&&this.previousFocusedElement.focus(),this.previousFocusedElement=null}emitAnalytics(e,t){this.opts.onAnalytics?.({event:e,timestamp:Date.now(),...t})}}function I(s){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),s.className&&s.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",s.teamSlug),s.momentSlug&&e.setAttribute("data-moment-slug",s.momentSlug),s.listSlug&&e.setAttribute("data-moment-list-slug",s.listSlug),s.triggerType&&e.setAttribute("data-moment-trigger-type",s.triggerType),s.ids?.length&&e.setAttribute("data-moment-ids",s.ids.join(",")),s.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",s.playlistSlugs.join(",")),s.calendar&&e.setAttribute("data-moment-calendar",s.calendar),s.apiSourceId&&e.setAttribute("data-api-source-id",s.apiSourceId),s.externalEventId&&e.setAttribute("data-external-event-id",s.externalEventId),s.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",s.externalEventIdPrefix),e.textContent=s.label??"Add to Calendar",e}if(typeof window<"u"){const s=window;s.MomentSdk=E,s.createMomentButton=I}b.MomentSdk=E,b.createMomentButton=I,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
|
25
|
+
`;function B(){if(typeof document>"u"||document.getElementById(w))return;const s=document.createElement("style");s.id=w,s.textContent=R,document.head.appendChild(s)}const _=".moment-sync-trigger",E=1024,x=380,T=600,S=400,C=80,D=32,F=6,L=67,$="#0d0d0d",U="rgba(255, 255, 255, 0.216)",W="https://live.dev.momentco.ai";class I{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;closeTimer=null;isDesktopViewport=!1;viewportResizeHandler=null;constructor(e){this.opts={triggerSelector:_,...e},this.liveBaseUrl=W;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}B(),this.bindTriggers(),this.emitAnalytics("embed.init")}open(e){e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const t=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:t.teamSlug,triggerType:t.triggerType}),this.createModal(t)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const i=n=>{n.preventDefault(),this.handleTriggerClick(t)},o=this.boundClickHandlers.get(t);o&&t.removeEventListener("click",o),t.addEventListener("click",i),this.boundClickHandlers.set(t,i)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",i=e.getAttribute("data-moment-slug")??void 0,o=e.getAttribute("data-moment-list-slug")??void 0,n=e.getAttribute("data-moment-trigger-type");let r="moment";n!=null&&n!==""&&(n==="moment"||n==="list"||n==="team"||n==="brand-playlist"||n==="playlist"||n==="schedule"?r=n:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",n));const g=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",u=g?g.split(",").filter(Boolean):[],m=e.getAttribute("data-moment-playlist-slugs")??"",p=m?m.split(",").map(j=>j.trim()).filter(Boolean):[],a=e.getAttribute("data-moment-calendar");let l;a!=null&&a!==""&&(a==="google"||a==="outlook"?l=a:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",a));const d=e.getAttribute("data-api-source-id")??void 0,c=e.getAttribute("data-external-event-id")??void 0,h=e.getAttribute("data-external-event-id-prefix")??void 0;if(c&&h&&console.warn("[MomentSdk] Both data-external-event-id and data-external-event-id-prefix are set; using data-external-event-id only."),!t){console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");return}const f=r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:r,momentIds:f?[]:u}),this.open({teamSlug:t,momentSlug:i,listSlug:o,triggerType:r,ids:u,playlistSlugs:p,calendar:l??void 0,apiSourceId:d,externalEventId:h&&!c?void 0:c,externalEventIdPrefix:c?void 0:h})}scopeOpenPayload(e){return e.triggerType==="schedule"?{teamSlug:e.teamSlug,triggerType:e.triggerType}:e.triggerType==="playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,playlistSlugs:e.playlistSlugs,calendar:e.calendar}:e.triggerType==="team"||e.triggerType==="brand-playlist"?{teamSlug:e.teamSlug,triggerType:e.triggerType,calendar:e.calendar}:e}createModal(e){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e,this.isDesktopViewport=window.innerWidth>=E;const t=this.buildIframeUrl(e);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:"999999",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",padding:"16px"}),this.overlay.addEventListener("click",l=>{l.target===this.overlay&&this.handleCancel()});const i=l=>{l.key==="Escape"&&this.handleCancel()};document.addEventListener("keydown",i);const o=document.createElement("div");Object.assign(o.style,{position:"relative",width:"100%",maxWidth:`${this.isDesktopViewport?T:x}px`,minWidth:this.isDesktopViewport?`${S}px`:"0",borderRadius:"16px",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:$,boxShadow:`0 25px 50px -12px rgba(0, 0, 0, 0.25), inset 0 0 0 1px ${U}`,display:"flex",flexDirection:"column"});const n=document.createElement("div");n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label","Calendar sync modal"),n.tabIndex=-1,Object.assign(n.style,{position:"relative",width:"100%",maxHeight:this.isDesktopViewport?`calc(100vh - ${C}px)`:"80vh",borderRadius:"12px",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:"#ffffff"});const r=document.createElement("button");r.type="button",r.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1l12 12M13 1L1 13" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',r.setAttribute("aria-label","Close"),Object.assign(r.style,{position:"absolute",top:"10px",right:"10px",zIndex:"10",border:"none",backgroundColor:"transparent",color:"#999",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",padding:"0"}),r.addEventListener("mouseenter",()=>{r.style.color="#666"}),r.addEventListener("mouseleave",()=>{r.style.color="#999"}),r.addEventListener("click",()=>this.handleCancel());const g=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.setAttribute("allow",""),this.iframe.setAttribute("sandbox","allow-scripts allow-same-origin allow-popups allow-forms"),this.iframe.setAttribute("scrolling","no"),Object.assign(this.iframe.style,{width:"100%",border:"none",display:"block",height:this.isDesktopViewport?"520px":"420px",overflow:"hidden",transition:"height 0.15s ease"}),g&&n.appendChild(r),n.appendChild(this.iframe);const u=document.createElement("div");Object.assign(u.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:`${F}px`,height:`${D}px`,flexShrink:"0",boxSizing:"border-box",padding:"0"});const m=document.createElement("span");m.textContent="Powered by",Object.assign(m.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const p=document.createElement("img");p.alt="Moment",p.src=M,Object.assign(p.style,{display:"block",width:`${L}px`,height:`${(L/k).toFixed(2)}px`}),u.appendChild(m),u.appendChild(p),this.wrapper=o,this.container=n,o.appendChild(n),o.appendChild(u),this.overlay.appendChild(o),document.body.appendChild(this.overlay),this.viewportResizeHandler=()=>{const l=window.innerWidth>=E;if(this.isDesktopViewport=l,this.wrapper&&(this.wrapper.style.maxWidth=`${l?T:x}px`,this.wrapper.style.minWidth=l?`${S}px`:"0"),this.container&&(this.container.style.maxHeight=l?`calc(100vh - ${C}px)`:"80vh"),this.iframe){const d=l?window.innerHeight-C:Math.round(window.innerHeight*.8);(Number.parseFloat(this.iframe.style.height)||0)>d&&(this.iframe.style.height=`${d}px`)}},window.addEventListener("resize",this.viewportResizeHandler);const a=l=>{if(l.key!=="Tab")return;const d=n.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(d.length===0){l.preventDefault(),n.focus();return}const c=d[0],h=d[d.length-1],f=document.activeElement;l.shiftKey&&f===c?(l.preventDefault(),h.focus()):!l.shiftKey&&f===h&&(l.preventDefault(),c.focus())};n.addEventListener("keydown",a),g?r.focus():n.focus(),this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0,this.setupMessageListener(),this.overlay._escHandler=i,this.overlay._focusTrapHandler=a}buildIframeUrl(e){return P(this.liveBaseUrl,e)}setupMessageListener(){this.messageHandler=e=>{if(e.origin!==this.liveOrigin||e.source!==this.iframe?.contentWindow)return;const t=e.data;if(!(!t||typeof t!="object")){if(t.source==="moment-live-embed"&&t.type==="moment.embed.oauth.start"){const i=t;this.emitAnalytics("oauth.start",{provider:i.provider,teamSlug:i.teamSlug}),this.handleOAuthStart(i);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const i=typeof t.height=="number"?t.height:0;if(i>0&&this.iframe){const o=this.isDesktopViewport?window.innerHeight-C:Math.round(window.innerHeight*.8);this.iframe.style.height=`${Math.min(i,o)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const{borderRadius:i}=t;if(typeof i=="number"&&Number.isFinite(i)){const o=Math.max(0,Math.min(i,32));this.container&&(this.container.style.borderRadius=`${o}px`),this.wrapper&&(this.wrapper.style.borderRadius=o===0?"0px":`${o+4}px`)}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:i}=t;i&&typeof i=="string"&&i.startsWith("webcal://")&&window.open(i,"_blank");return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.close"){this.handleCancel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const i=t;this.handleResult(i)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new O({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,onResult:t=>{this.handleResult(t)},onPopupBlocked:()=>{this.emitAnalytics("oauth.popup.blocked",{provider:e.provider})},onPopupClosed:()=>{this.emitAnalytics("oauth.popup.closed",{provider:e.provider})}}),this.popupBridge.open(e)}handleResult(e){if(e.result==="success"||e.result==="partial")this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e);else if(e.result==="error")this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e);else if(e.result==="cancelled")return;this.opts.onClose?.(e),this.emitAnalytics("embed.close"),e.triggerType!=="schedule"&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500))}handleCancel(){this.emitAnalytics("embed.close");const t={source:"moment-live-embed",type:"moment.embed.result",result:"cancelled",triggerType:this.activePayload?.triggerType??"moment",momentIds:this.activePayload?.ids??[]};this.opts.onClose?.(t),this.cleanup()}cleanup(){if(this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:e,_focusTrapHandler:t}=this.overlay;e&&document.removeEventListener("keydown",e);const i=this.overlay.firstElementChild;i&&t&&i.removeEventListener("keydown",t),this.overlay.remove(),this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.activePayload=null,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.previousFocusedElement&&typeof this.previousFocusedElement.focus=="function"&&this.previousFocusedElement.focus(),this.previousFocusedElement=null}emitAnalytics(e,t){this.opts.onAnalytics?.({event:e,timestamp:Date.now(),...t})}}function A(s){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),s.className&&s.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",s.teamSlug),s.momentSlug&&e.setAttribute("data-moment-slug",s.momentSlug),s.listSlug&&e.setAttribute("data-moment-list-slug",s.listSlug),s.triggerType&&e.setAttribute("data-moment-trigger-type",s.triggerType),s.ids?.length&&e.setAttribute("data-moment-ids",s.ids.join(",")),s.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",s.playlistSlugs.join(",")),s.calendar&&e.setAttribute("data-moment-calendar",s.calendar),s.apiSourceId&&e.setAttribute("data-api-source-id",s.apiSourceId),s.externalEventId&&e.setAttribute("data-external-event-id",s.externalEventId),s.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",s.externalEventIdPrefix),e.textContent=s.label??"Add to Calendar",e}if(typeof window<"u"){const s=window;s.MomentSdk=I,s.createMomentButton=A}v.MomentSdk=I,v.createMomentButton=A,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
package/dist/moment-sdk.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const I = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='15.55 11.94 120.52 21.28'%3E%3Cpath d='M16.59 33.04L17.42 29.54C18.62 24.54 19.22 21.32 19.22 19.89C19.22 19.68 19.19 19.54 19.12 19.47C19.05 19.4 18.91 19.38 18.7 19.4C18.4 19.47 17.97 19.65 17.42 19.94C16.86 20.23 16.32 20.62 15.79 21.1C15.63 20.9 15.55 20.69 15.55 20.48C15.55 20.27 15.65 20.03 15.86 19.75C16.16 19.38 16.65 18.95 17.33 18.45C18.02 17.95 18.74 17.53 19.5 17.2C20.27 16.86 20.92 16.7 21.48 16.7C21.78 16.7 22 16.79 22.14 16.99C22.28 17.19 22.35 17.5 22.35 17.94C22.35 18.55 22.24 19.42 22.04 20.56C21.83 21.71 21.55 22.88 21.2 24.09C22.34 21.96 23.59 20.19 24.95 18.79C26.32 17.4 27.7 16.7 29.12 16.7C29.79 16.7 30.27 16.87 30.57 17.23C30.87 17.59 31.02 18.14 31.02 18.88C31.02 19.97 30.69 21.7 30.02 24.09C31.13 22.01 32.44 20.25 33.94 18.83C35.44 17.41 36.94 16.7 38.42 16.7C39.11 16.7 39.63 16.88 39.98 17.25C40.33 17.62 40.5 18.16 40.5 18.88C40.5 19.18 40.45 19.62 40.34 20.18C40.24 20.75 40.1 21.37 39.91 22.04L38.42 27.7C38.09 28.92 37.93 29.77 37.93 30.23C37.93 30.48 37.97 30.67 38.05 30.8C38.13 30.93 38.27 30.99 38.45 30.99C38.89 30.99 39.47 30.69 40.17 30.09C40.88 29.49 41.46 28.85 41.92 28.18C42.25 28.44 42.41 28.72 42.41 29.05C42.41 29.26 42.34 29.48 42.2 29.71C41.74 30.5 40.98 31.28 39.93 32.05C38.87 32.82 37.82 33.21 36.75 33.21C36.08 33.21 35.56 33.02 35.17 32.62C34.79 32.23 34.6 31.66 34.6 30.92C34.6 30.3 34.8 29.22 35.19 27.7L36.79 21.55C37 20.74 37.1 20.13 37.1 19.71C37.1 19.2 36.89 18.95 36.48 18.95C35.97 18.95 35.3 19.33 34.46 20.08C33.63 20.83 32.79 21.94 31.93 23.41C31.07 24.88 30.33 26.62 29.71 28.63L28.91 31.27C28.77 31.73 28.59 32.09 28.37 32.33C28.15 32.57 27.82 32.73 27.38 32.8L25.54 33.22L25.37 33.04L26.13 29.67C26.73 27.11 27.19 25.03 27.49 23.44C27.79 21.86 27.94 20.72 27.94 20.03C27.94 19.33 27.72 19.02 27.28 19.02C26.79 19.02 26.17 19.4 25.42 20.15C24.67 20.9 23.89 22 23.1 23.46C22.3 24.92 21.6 26.65 21 28.67L20.2 31.27C20.06 31.71 19.87 32.05 19.63 32.29C19.38 32.54 19.02 32.71 18.53 32.8L16.76 33.22L16.59 33.04L16.59 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M57.66 17.94C57 17.13 55.99 16.73 54.62 16.73C52.93 16.73 51.31 17.3 49.75 18.43C49.51 18.6 49.28 18.78 49.06 18.97C49.24 19.85 49.39 20.78 49.48 21.74C49.86 21.01 50.3 20.37 50.79 19.82C51.63 18.87 52.5 18.39 53.41 18.39C54.08 18.39 54.55 18.68 54.81 19.24C55.08 19.81 55.21 20.58 55.21 21.55C55.21 23.08 54.97 24.63 54.48 26.19C54 27.75 53.35 29.03 52.54 30.04C51.73 31.04 50.86 31.55 49.94 31.55C49.53 31.55 49.19 31.44 48.9 31.22C48.74 31.9 48.54 32.55 48.31 33.19C48.5 33.2 48.7 33.21 48.9 33.21C50.54 33.21 52.11 32.63 53.61 31.48C55.12 30.32 56.33 28.82 57.26 26.98C58.18 25.14 58.65 23.28 58.65 21.38C58.65 19.9 58.32 18.75 57.66 17.94L57.66 17.94Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M61.84 33.04L62.67 29.54C63.88 24.54 64.48 21.32 64.48 19.89C64.48 19.68 64.44 19.54 64.37 19.47C64.3 19.4 64.17 19.38 63.96 19.4C63.66 19.47 63.23 19.65 62.67 19.94C62.12 20.23 61.57 20.62 61.04 21.1C60.88 20.9 60.8 20.69 60.8 20.48C60.8 20.27 60.9 20.03 61.11 19.75C61.41 19.38 61.9 18.95 62.59 18.45C63.27 17.95 63.99 17.53 64.76 17.2C65.52 16.86 66.18 16.7 66.73 16.7C67.04 16.7 67.26 16.79 67.39 16.99C67.53 17.19 67.6 17.5 67.6 17.94C67.6 18.55 67.5 19.42 67.29 20.56C67.08 21.71 66.8 22.88 66.46 24.09C67.59 21.96 68.84 20.19 70.2 18.79C71.57 17.4 72.96 16.7 74.37 16.7C75.04 16.7 75.53 16.87 75.83 17.23C76.13 17.59 76.28 18.14 76.28 18.88C76.28 19.97 75.94 21.7 75.27 24.09C76.38 22.01 77.69 20.25 79.19 18.83C80.7 17.41 82.19 16.7 83.67 16.7C84.36 16.7 84.89 16.88 85.23 17.25C85.58 17.62 85.75 18.16 85.75 18.88C85.75 19.18 85.7 19.62 85.6 20.18C85.49 20.75 85.35 21.37 85.16 22.04L83.67 27.7C83.35 28.92 83.19 29.77 83.19 30.23C83.19 30.48 83.23 30.67 83.31 30.8C83.39 30.93 83.52 30.99 83.71 30.99C84.15 30.99 84.72 30.69 85.42 30.09C86.13 29.49 86.71 28.85 87.18 28.18C87.5 28.44 87.66 28.72 87.66 29.05C87.66 29.26 87.59 29.48 87.46 29.71C86.99 30.5 86.24 31.28 85.18 32.05C84.13 32.82 83.07 33.21 82.01 33.21C81.34 33.21 80.81 33.02 80.43 32.62C80.05 32.23 79.86 31.66 79.86 30.92C79.86 30.3 80.05 29.22 80.44 27.7L82.04 21.55C82.25 20.74 82.35 20.13 82.35 19.71C82.35 19.2 82.15 18.95 81.73 18.95C81.22 18.95 80.55 19.33 79.72 20.08C78.88 20.83 78.04 21.94 77.18 23.41C76.33 24.88 75.59 26.62 74.96 28.63L74.16 31.27C74.02 31.73 73.85 32.09 73.63 32.33C73.41 32.57 73.08 32.73 72.64 32.8L70.8 33.22L70.62 33.04L71.39 29.67C71.99 27.11 72.44 25.03 72.74 23.44C73.04 21.86 73.19 20.72 73.19 20.03C73.19 19.33 72.97 19.02 72.53 19.02C72.05 19.02 71.43 19.4 70.68 20.15C69.92 20.9 69.15 22 68.35 23.46C67.55 24.92 66.85 26.65 66.25 28.67L65.45 31.27C65.31 31.71 65.12 32.05 64.88 32.29C64.64 32.54 64.27 32.71 63.79 32.8L62.02 33.22L61.84 33.04L61.84 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M91.01 31.91C90.19 31.04 89.78 29.85 89.78 28.32C89.78 26.47 90.32 24.64 91.41 22.84C92.49 21.03 93.87 19.56 95.54 18.41C97.2 17.27 98.82 16.69 100.4 16.69C101.23 16.69 101.87 16.9 102.31 17.3C102.75 17.71 102.97 18.25 102.97 18.95C102.97 20.08 102.55 21.13 101.72 22.09C100.88 23.05 99.77 23.81 98.37 24.38C96.97 24.95 95.47 25.23 93.87 25.23H93.52C93.25 26.16 93.11 27.05 93.11 27.9C93.11 28.97 93.32 29.79 93.75 30.37C94.18 30.95 94.8 31.24 95.61 31.24C96.51 31.24 97.4 30.91 98.28 30.26C99.16 29.62 99.99 28.69 100.78 27.49C100.96 27.72 101.1 27.91 101.18 28.06C101.26 28.21 101.3 28.39 101.3 28.6C101.3 28.81 101.22 29.06 101.06 29.36C100.78 29.89 100.32 30.46 99.67 31.05C99.02 31.63 98.24 32.14 97.33 32.57C96.41 33 95.43 33.21 94.39 33.21C92.96 33.21 91.83 32.78 91.01 31.91V31.91ZM94.32 23.81C95.43 23.81 96.43 23.58 97.33 23.12C98.22 22.65 98.92 22.08 99.42 21.4C99.93 20.71 100.19 20.05 100.19 19.4C100.19 18.69 99.85 18.33 99.18 18.33C98.3 18.33 97.37 18.85 96.39 19.91C95.41 20.96 94.61 22.25 94.01 23.78C94.08 23.8 94.19 23.81 94.32 23.81L94.32 23.81Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M105.91 33.04L106.78 29.12C107.96 24.08 108.55 21.04 108.55 20.03C108.55 19.82 108.5 19.66 108.4 19.56C108.29 19.45 108.15 19.4 107.96 19.4C107.68 19.4 107.3 19.54 106.82 19.82C106.33 20.1 105.75 20.51 105.08 21.07C105.01 21 104.95 20.89 104.91 20.75C104.86 20.62 104.84 20.5 104.84 20.41C104.84 20.27 104.86 20.13 104.89 19.99C104.93 19.85 105.01 19.7 105.15 19.54C105.43 19.17 105.88 18.76 106.52 18.31C107.16 17.86 107.83 17.47 108.55 17.16C109.27 16.85 109.89 16.69 110.43 16.69C110.79 16.69 111.06 16.79 111.21 16.97C111.36 17.16 111.43 17.47 111.43 17.91C111.43 19.09 111.05 21.2 110.29 24.26C111.42 22.08 112.72 20.28 114.19 18.84C115.66 17.41 117.14 16.69 118.65 16.69C119.37 16.69 119.92 16.88 120.3 17.25C120.68 17.62 120.87 18.14 120.87 18.81C120.87 19.48 120.67 20.57 120.28 22.07L118.72 27.97C118.44 28.99 118.3 29.74 118.3 30.23C118.3 30.71 118.48 30.99 118.82 30.99C119.26 30.99 119.84 30.69 120.54 30.09C121.25 29.49 121.83 28.85 122.29 28.18C122.62 28.43 122.78 28.72 122.78 29.05C122.78 29.26 122.71 29.48 122.57 29.71C122.32 30.17 121.91 30.67 121.34 31.22C120.77 31.76 120.12 32.23 119.39 32.62C118.67 33.02 117.92 33.21 117.16 33.21C116.46 33.21 115.92 33.02 115.54 32.62C115.16 32.23 114.97 31.63 114.97 30.82C114.97 30.15 115.18 29.04 115.59 27.49L117.09 22.14C117.36 21.05 117.5 20.24 117.5 19.71C117.5 19.18 117.32 18.95 116.95 18.95C116.37 18.95 115.65 19.35 114.8 20.15C113.94 20.95 113.08 22.09 112.21 23.58C111.34 25.07 110.63 26.84 110.08 28.87L109.45 31.06C109.31 31.59 109.13 31.98 108.9 32.22C108.67 32.47 108.33 32.65 107.89 32.76L106.09 33.21L105.91 33.04L105.91 33.04Z' fill='%23FAFAF9'%3E%3C/path%3E%3Cpath d='M126.29 32.28C125.82 31.65 125.59 30.84 125.59 29.85C125.59 29.27 125.7 28.37 125.9 27.16C126.11 25.94 126.47 24.18 126.98 21.87L127.6 18.88H124.52L124.76 17.49L127.99 17.15L130.03 13.12C130.24 12.75 130.43 12.48 130.59 12.32C130.75 12.16 130.95 12.06 131.18 12.01C131.41 11.96 131.76 11.94 132.22 11.94L132.36 12.11L131.28 17.15H136.07L135.9 18.01C135.85 18.36 135.75 18.59 135.6 18.71C135.45 18.82 135.18 18.88 134.79 18.88H130.9L130.24 21.94C129.73 24.34 129.37 26.11 129.17 27.23C128.96 28.35 128.85 29.14 128.85 29.61C128.85 30 128.93 30.29 129.08 30.47C129.23 30.66 129.48 30.75 129.82 30.75C130.42 30.75 131.14 30.5 131.98 30.01C132.81 29.51 133.55 28.89 134.2 28.15C134.57 28.43 134.75 28.69 134.75 28.95C134.75 29.39 134.42 29.95 133.75 30.63C133.07 31.31 132.25 31.91 131.26 32.43C130.28 32.96 129.34 33.22 128.44 33.22C127.47 33.22 126.75 32.9 126.28 32.28L126.29 32.28Z' fill='%23FAFAF9'%3E%3C/path%3E%3C/svg%3E", A = 5.663533834586466, v = 500, b = 700, M = 500;
|
|
2
|
+
class k {
|
|
2
3
|
popup = null;
|
|
3
4
|
pollTimer = null;
|
|
4
5
|
messageHandler = null;
|
|
@@ -12,11 +13,11 @@ class S {
|
|
|
12
13
|
*/
|
|
13
14
|
open(e) {
|
|
14
15
|
this.cleanup(), this.resultReceived = !1;
|
|
15
|
-
const t = this.buildPopupUrl(e), i = Math.round(window.screenX + (window.outerWidth -
|
|
16
|
+
const t = this.buildPopupUrl(e), i = Math.round(window.screenX + (window.outerWidth - v) / 2), o = Math.round(window.screenY + (window.outerHeight - b) / 2);
|
|
16
17
|
if (this.popup = window.open(
|
|
17
18
|
t,
|
|
18
19
|
"moment-oauth-popup",
|
|
19
|
-
`width
|
|
20
|
+
`width=${v},height=${b},left=${i},top=${o},menubar=no,toolbar=no,location=yes,status=no`
|
|
20
21
|
), !this.popup || this.popup.closed) {
|
|
21
22
|
this.sendStatusToIframe("popup-blocked"), this.opts.onPopupBlocked();
|
|
22
23
|
return;
|
|
@@ -51,7 +52,7 @@ class S {
|
|
|
51
52
|
startPolling() {
|
|
52
53
|
this.pollTimer = setInterval(() => {
|
|
53
54
|
(!this.popup || this.popup.closed) && (this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null), this.resultReceived || (this.sendStatusToIframe("popup-closed"), this.opts.onPopupClosed()), this.cleanup());
|
|
54
|
-
},
|
|
55
|
+
}, M);
|
|
55
56
|
}
|
|
56
57
|
sendStatusToIframe(e) {
|
|
57
58
|
if (!this.opts.iframeWindow) return;
|
|
@@ -63,7 +64,7 @@ class S {
|
|
|
63
64
|
this.opts.iframeWindow.postMessage(t, this.opts.liveOrigin);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function H(s, e, t = typeof window < "u" ? window.location.origin : "") {
|
|
67
68
|
if (e.triggerType === "schedule") {
|
|
68
69
|
const o = new URLSearchParams();
|
|
69
70
|
return o.set("teamSlug", e.teamSlug), o.set("returnOrigin", t), o.set("embed", "1"), `${s}/en/embed/schedule?${o.toString()}`;
|
|
@@ -71,7 +72,7 @@ function I(s, e, t = typeof window < "u" ? window.location.origin : "") {
|
|
|
71
72
|
const i = new URLSearchParams();
|
|
72
73
|
return i.set("teamSlug", e.teamSlug), e.momentSlug && i.set("momentSlug", e.momentSlug), e.listSlug && i.set("listSlug", e.listSlug), i.set("triggerType", e.triggerType), e.ids?.length && i.set("ids", e.ids.join(",")), e.playlistSlugs?.length && i.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && i.set("calendar", e.calendar), e.apiSourceId && i.set("subscriptionId", e.apiSourceId), e.externalEventId && i.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && i.set("externalIdPrefix", e.externalEventIdPrefix), i.set("returnOrigin", t), i.set("embed", "1"), `${s}/en/embed/sync?${i.toString()}`;
|
|
73
74
|
}
|
|
74
|
-
const
|
|
75
|
+
const w = "moment-sdk-trigger-styles", O = `
|
|
75
76
|
:where(.moment-sync-trigger) {
|
|
76
77
|
background-color: #1c1917;
|
|
77
78
|
color: #ffffff;
|
|
@@ -96,13 +97,13 @@ const b = "moment-sdk-trigger-styles", P = `
|
|
|
96
97
|
outline-offset: 2px;
|
|
97
98
|
}
|
|
98
99
|
`;
|
|
99
|
-
function
|
|
100
|
-
if (typeof document > "u" || document.getElementById(
|
|
100
|
+
function P() {
|
|
101
|
+
if (typeof document > "u" || document.getElementById(w)) return;
|
|
101
102
|
const s = document.createElement("style");
|
|
102
|
-
s.id =
|
|
103
|
+
s.id = w, s.textContent = O, document.head.appendChild(s);
|
|
103
104
|
}
|
|
104
|
-
const
|
|
105
|
-
class
|
|
105
|
+
const R = ".moment-sync-trigger", y = 1024, x = 380, E = 600, T = 400, f = 80, B = 32, _ = 6, L = 67, D = "#0d0d0d", F = "rgba(255, 255, 255, 0.216)", $ = "https://live.dev.momentco.ai";
|
|
106
|
+
class U {
|
|
106
107
|
opts;
|
|
107
108
|
liveBaseUrl;
|
|
108
109
|
liveOrigin;
|
|
@@ -126,15 +127,15 @@ class L {
|
|
|
126
127
|
viewportResizeHandler = null;
|
|
127
128
|
constructor(e) {
|
|
128
129
|
this.opts = {
|
|
129
|
-
triggerSelector:
|
|
130
|
+
triggerSelector: R,
|
|
130
131
|
...e
|
|
131
|
-
}, this.liveBaseUrl =
|
|
132
|
+
}, this.liveBaseUrl = $;
|
|
132
133
|
try {
|
|
133
134
|
this.liveOrigin = new URL(this.liveBaseUrl).origin;
|
|
134
135
|
} catch {
|
|
135
136
|
throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`);
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
P(), this.bindTriggers(), this.emitAnalytics("embed.init");
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
140
141
|
* Programmatically open the sync modal.
|
|
@@ -188,7 +189,7 @@ class L {
|
|
|
188
189
|
"[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",
|
|
189
190
|
n
|
|
190
191
|
));
|
|
191
|
-
const g = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", u = g ? g.split(",").filter(Boolean) : [],
|
|
192
|
+
const g = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", u = g ? g.split(",").filter(Boolean) : [], p = e.getAttribute("data-moment-playlist-slugs") ?? "", m = p ? p.split(",").map((S) => S.trim()).filter(Boolean) : [], a = e.getAttribute("data-moment-calendar");
|
|
192
193
|
let l;
|
|
193
194
|
a != null && a !== "" && (a === "google" || a === "outlook" ? l = a : console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:", a));
|
|
194
195
|
const d = e.getAttribute("data-api-source-id") ?? void 0, c = e.getAttribute("data-external-event-id") ?? void 0, h = e.getAttribute("data-external-event-id-prefix") ?? void 0;
|
|
@@ -198,18 +199,18 @@ class L {
|
|
|
198
199
|
console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");
|
|
199
200
|
return;
|
|
200
201
|
}
|
|
201
|
-
const
|
|
202
|
+
const C = r === "team" || r === "brand-playlist" || r === "playlist" || r === "schedule";
|
|
202
203
|
this.emitAnalytics("embed.trigger.click", {
|
|
203
204
|
teamSlug: t,
|
|
204
205
|
triggerType: r,
|
|
205
|
-
momentIds:
|
|
206
|
+
momentIds: C ? [] : u
|
|
206
207
|
}), this.open({
|
|
207
208
|
teamSlug: t,
|
|
208
209
|
momentSlug: i,
|
|
209
210
|
listSlug: o,
|
|
210
211
|
triggerType: r,
|
|
211
212
|
ids: u,
|
|
212
|
-
playlistSlugs:
|
|
213
|
+
playlistSlugs: m,
|
|
213
214
|
calendar: l ?? void 0,
|
|
214
215
|
apiSourceId: d,
|
|
215
216
|
externalEventId: h && !c ? void 0 : c,
|
|
@@ -257,7 +258,7 @@ class L {
|
|
|
257
258
|
Object.assign(o.style, {
|
|
258
259
|
position: "relative",
|
|
259
260
|
width: "100%",
|
|
260
|
-
maxWidth: `${this.isDesktopViewport ?
|
|
261
|
+
maxWidth: `${this.isDesktopViewport ? E : x}px`,
|
|
261
262
|
minWidth: this.isDesktopViewport ? `${T}px` : "0",
|
|
262
263
|
borderRadius: "16px",
|
|
263
264
|
// Ease radius changes so a brand's configured radius (arriving via
|
|
@@ -265,8 +266,12 @@ class L {
|
|
|
265
266
|
// smoothly instead of snapping.
|
|
266
267
|
transition: "border-radius 0.3s ease",
|
|
267
268
|
overflow: "hidden",
|
|
268
|
-
backgroundColor:
|
|
269
|
-
|
|
269
|
+
backgroundColor: D,
|
|
270
|
+
// The hairline is an *inset* shadow rather than a border so it adds no
|
|
271
|
+
// layout box: a real border would depend on the host page's box-sizing
|
|
272
|
+
// and shift the iframe by a pixel. It follows the frame's radius and is
|
|
273
|
+
// only visible where the frame itself is — chiefly the bottom tray.
|
|
274
|
+
boxShadow: `0 25px 50px -12px rgba(0, 0, 0, 0.25), inset 0 0 0 1px ${F}`,
|
|
270
275
|
display: "flex",
|
|
271
276
|
flexDirection: "column"
|
|
272
277
|
});
|
|
@@ -274,7 +279,7 @@ class L {
|
|
|
274
279
|
n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), n.setAttribute("aria-label", "Calendar sync modal"), n.tabIndex = -1, Object.assign(n.style, {
|
|
275
280
|
position: "relative",
|
|
276
281
|
width: "100%",
|
|
277
|
-
maxHeight: this.isDesktopViewport ? `calc(100vh - ${
|
|
282
|
+
maxHeight: this.isDesktopViewport ? `calc(100vh - ${f}px)` : "80vh",
|
|
278
283
|
borderRadius: "12px",
|
|
279
284
|
transition: "border-radius 0.3s ease",
|
|
280
285
|
overflow: "auto",
|
|
@@ -315,24 +320,33 @@ class L {
|
|
|
315
320
|
display: "flex",
|
|
316
321
|
alignItems: "center",
|
|
317
322
|
justifyContent: "center",
|
|
318
|
-
|
|
323
|
+
gap: `${_}px`,
|
|
324
|
+
height: `${B}px`,
|
|
325
|
+
// The wrapper is a flex column, so without this the tray would be the
|
|
326
|
+
// first thing squeezed when the card hits its max height.
|
|
327
|
+
flexShrink: "0",
|
|
328
|
+
// Host pages set box-sizing globally; pin it so the height is the height.
|
|
329
|
+
boxSizing: "border-box",
|
|
330
|
+
padding: "0"
|
|
319
331
|
});
|
|
320
|
-
const
|
|
321
|
-
|
|
332
|
+
const p = document.createElement("span");
|
|
333
|
+
p.textContent = "Powered by", Object.assign(p.style, {
|
|
322
334
|
fontFamily: "Inter, system-ui, -apple-system, sans-serif",
|
|
323
335
|
fontSize: "12px",
|
|
324
336
|
lineHeight: "16px",
|
|
325
337
|
color: "#ffffff"
|
|
326
338
|
});
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
339
|
+
const m = document.createElement("img");
|
|
340
|
+
m.alt = "Moment", m.src = I, Object.assign(m.style, {
|
|
341
|
+
display: "block",
|
|
342
|
+
// Both dimensions are explicit so the tray has no reflow to do, even if
|
|
343
|
+
// the image is ever swapped for one that has to decode.
|
|
344
|
+
width: `${L}px`,
|
|
345
|
+
height: `${(L / A).toFixed(2)}px`
|
|
346
|
+
}), u.appendChild(p), u.appendChild(m), this.wrapper = o, this.container = n, o.appendChild(n), o.appendChild(u), this.overlay.appendChild(o), document.body.appendChild(this.overlay), this.viewportResizeHandler = () => {
|
|
333
347
|
const l = window.innerWidth >= y;
|
|
334
|
-
if (this.isDesktopViewport = l, this.wrapper && (this.wrapper.style.maxWidth = `${l ?
|
|
335
|
-
const d = l ? window.innerHeight -
|
|
348
|
+
if (this.isDesktopViewport = l, this.wrapper && (this.wrapper.style.maxWidth = `${l ? E : x}px`, this.wrapper.style.minWidth = l ? `${T}px` : "0"), this.container && (this.container.style.maxHeight = l ? `calc(100vh - ${f}px)` : "80vh"), this.iframe) {
|
|
349
|
+
const d = l ? window.innerHeight - f : Math.round(window.innerHeight * 0.8);
|
|
336
350
|
(Number.parseFloat(this.iframe.style.height) || 0) > d && (this.iframe.style.height = `${d}px`);
|
|
337
351
|
}
|
|
338
352
|
}, window.addEventListener("resize", this.viewportResizeHandler);
|
|
@@ -345,13 +359,13 @@ class L {
|
|
|
345
359
|
l.preventDefault(), n.focus();
|
|
346
360
|
return;
|
|
347
361
|
}
|
|
348
|
-
const c = d[0], h = d[d.length - 1],
|
|
349
|
-
l.shiftKey &&
|
|
362
|
+
const c = d[0], h = d[d.length - 1], C = document.activeElement;
|
|
363
|
+
l.shiftKey && C === c ? (l.preventDefault(), h.focus()) : !l.shiftKey && C === h && (l.preventDefault(), c.focus());
|
|
350
364
|
};
|
|
351
365
|
n.addEventListener("keydown", a), g ? r.focus() : n.focus(), this.previousBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this.didManageBodyOverflow = !0, this.setupMessageListener(), this.overlay._escHandler = i, this.overlay._focusTrapHandler = a;
|
|
352
366
|
}
|
|
353
367
|
buildIframeUrl(e) {
|
|
354
|
-
return
|
|
368
|
+
return H(this.liveBaseUrl, e);
|
|
355
369
|
}
|
|
356
370
|
// ── Private: message handling ─────────────────────────────────────
|
|
357
371
|
setupMessageListener() {
|
|
@@ -370,7 +384,7 @@ class L {
|
|
|
370
384
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.resize") {
|
|
371
385
|
const i = typeof t.height == "number" ? t.height : 0;
|
|
372
386
|
if (i > 0 && this.iframe) {
|
|
373
|
-
const o = this.isDesktopViewport ? window.innerHeight -
|
|
387
|
+
const o = this.isDesktopViewport ? window.innerHeight - f : Math.round(window.innerHeight * 0.8);
|
|
374
388
|
this.iframe.style.height = `${Math.min(i, o)}px`;
|
|
375
389
|
}
|
|
376
390
|
return;
|
|
@@ -400,7 +414,7 @@ class L {
|
|
|
400
414
|
}, window.addEventListener("message", this.messageHandler);
|
|
401
415
|
}
|
|
402
416
|
handleOAuthStart(e) {
|
|
403
|
-
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new
|
|
417
|
+
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new k({
|
|
404
418
|
liveBaseUrl: this.liveBaseUrl,
|
|
405
419
|
liveOrigin: this.liveOrigin,
|
|
406
420
|
iframeWindow: this.iframe?.contentWindow ?? null,
|
|
@@ -466,7 +480,7 @@ class L {
|
|
|
466
480
|
});
|
|
467
481
|
}
|
|
468
482
|
}
|
|
469
|
-
function
|
|
483
|
+
function W(s) {
|
|
470
484
|
const e = document.createElement("button");
|
|
471
485
|
return e.type = "button", e.classList.add("moment-sync-trigger"), s.className && s.className.split(" ").forEach((t) => {
|
|
472
486
|
t && e.classList.add(t);
|
|
@@ -474,9 +488,9 @@ function O(s) {
|
|
|
474
488
|
}
|
|
475
489
|
if (typeof window < "u") {
|
|
476
490
|
const s = window;
|
|
477
|
-
s.MomentSdk =
|
|
491
|
+
s.MomentSdk = U, s.createMomentButton = W;
|
|
478
492
|
}
|
|
479
493
|
export {
|
|
480
|
-
|
|
481
|
-
|
|
494
|
+
U as MomentSdk,
|
|
495
|
+
W as createMomentButton
|
|
482
496
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brand assets bundled into the SDK.
|
|
3
|
+
*
|
|
4
|
+
* The "Powered by" wordmark used to be fetched from the Live origin at modal
|
|
5
|
+
* open time (`<img src="${liveBaseUrl}/brand/moment-text-white.png">`), which
|
|
6
|
+
* meant the text rendered first and the logo dropped in a beat later on a cold
|
|
7
|
+
* cache. Inlining it as a data URI paints it with the first frame, and also
|
|
8
|
+
* keeps the modal chrome working on hosts with a strict image CSP.
|
|
9
|
+
*
|
|
10
|
+
* Source: the official white "moment" logotype (vector). The `viewBox` is
|
|
11
|
+
* cropped to the glyph's bounding box, so the <img> box IS the wordmark box —
|
|
12
|
+
* size it directly (`width: 67px`) with no transparent padding to compensate
|
|
13
|
+
* for. Path coordinates are rounded to 2dp, which is well below a pixel at the
|
|
14
|
+
* sizes this renders at.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MOMENT_WORDMARK_WHITE: string;
|
|
17
|
+
/** Intrinsic aspect ratio (width / height) of the cropped wordmark. */
|
|
18
|
+
export declare const MOMENT_WORDMARK_ASPECT: number;
|
package/package.json
CHANGED