@momentco-ai/moment-sdk 0.9.0-dev.53 → 0.9.0-dev.54
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 +2 -0
- package/dist/moment-sdk.js +5 -5
- package/dist/moment-sdk.mjs +207 -160
- package/dist/types/sdk/__tests__/fake-dom.d.ts +6 -0
- package/dist/types/sdk/modal-frame.d.ts +12 -2
- package/dist/types/sdk/moment-sdk.d.ts +4 -0
- package/dist/types/sdk/types.d.ts +13 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
19
|
- **Confetti and toasts over the page.** Two new embed messages, drawn on a click-through layer over the host page instead of clipped inside the iframe. `moment.embed.celebrate` launches confetti once the sheet's height has settled, and is skipped when the visitor prefers reduced motion. `moment.embed.toast` (`text`, optional `variant`: `success`, `info`, `warning` or `error`) shows Roman's light toast 56px below the top of the screen for 4 s, replacing any current one. It is announced by a status region inside the dialog, the same message again included, and its text is drawn as text, never HTML.
|
|
20
20
|
- **The embed can own a tap outside the sheet.** A v2 `moment.embed.theme` with `dismiss: "embed"` makes a tap on the dim, or Escape on the page, post `moment.sdk.dismiss` to the embed instead of closing, so it does exactly what the sheet's own ✕ does: return to where the sync started, or ask before dropping a selection. The embed answers each `moment.sdk.dismiss` with `moment.embed.dismiss.ack` at once; without it within 0.5 s the SDK closes the sheet itself, so an embed that stops listening (an error page) never leaves the fan behind a dim that does nothing. The sheet closes on the embed's `moment.embed.close`, as before.
|
|
21
21
|
- **The phone's back steps back inside the sheet.** A swipe back (or the back button) used to leave the partner's page with the sheet still open. A v2 `moment.embed.theme` with `back: "embed"` makes the shown sheet push one history entry at the page's own URL, with the page's history state copied into it, and one more for each `moment.embed.history.push` the embed sends when the fan taps one level deeper. Each back pops one: the SDK posts `moment.sdk.back` to the embed, which does what its own ‹ does (its ✕ on a screen with none, so a back on the first screen closes the sheet). Nothing is pushed on a back, because Chrome and Safari skip a later back past an entry pushed without a tap. The embed answers each `moment.sdk.back` with `moment.embed.back.ack`; without it within 0.5 s the SDK closes the sheet. On a `design: "v1"` step a back closes the sheet. Closing the sheet gives back the entries it still holds, unless the page is already navigating away, which that traversal would cancel.
|
|
22
|
+
- **The embed can cover the page.** `moment.embed.presentation` with `presentation: "cover"` makes a v2 frame step aside: the iframe fills the screen edge to edge with no dim, glass, radius, shadow or strip, so the embed paints the whole screen itself (Roman's sync progress, a 90% black overlay over the page). `presentation: "sheet"` gives the sheet back at the height the embed last asked for, including a resize sent while it covered. Both switch at once, without the height's ease. A cover counts only while the frame is v2: `design: "v1"` ends it, and every sheet opens uncovered.
|
|
22
23
|
|
|
23
24
|
### Fixed
|
|
24
25
|
|
|
@@ -41,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
41
42
|
- Behaviour: 0.8.0 called `onClose` a second time (`cancelled`) when a `keepOpen` sheet closed; 0.9.0 doesn't, except after a `schedule` result.
|
|
42
43
|
- Behaviour: the sheet now appears when the embed first reports its look (Moment Live sends it on its first render) instead of on the tap, at most 2 s later. A second tap or `open()` while it is still hidden is ignored, so the sheet that is loading isn't restarted. An embed that never sends `design: "v2"` still gets the 0.8.0 frame.
|
|
43
44
|
- Additive: `dismiss` is optional and counts only while the frame is v2. Without it, or once the embed sends `design: "v1"`, a tap outside closes the sheet as in 0.8.0.
|
|
45
|
+
- Additive: older SDKs ignore `moment.embed.presentation`, and Moment Live keeps its sync progress inside the sheet for them.
|
|
44
46
|
|
|
45
47
|
## [0.8.0] - Unreleased
|
|
46
48
|
|
package/dist/moment-sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O){"use strict";const F="moment_sync",P="moment_campaign",le=/^(?:schedule|(moment|list):([a-z0-9-]+)|playlist:([a-z0-9-]+(?:,[a-z0-9-]+)*))$/,de=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function ce(i,e){if(!e)return null;const t=new URL(i),s=t.searchParams.get(F);if(s===null||s.length>200)return null;const n=le.exec(s);if(!n)return null;const[,r,o,a]=n;let u;r==="moment"?u={teamSlug:e,triggerType:"moment",momentSlug:o}:r==="list"?u={teamSlug:e,triggerType:"list",listSlug:o}:a?u={teamSlug:e,triggerType:"playlist",playlistSlugs:a.split(",")}:u={teamSlug:e,triggerType:"schedule"};const m=t.searchParams.get(P);return t.search=t.search.slice(1).split("&").filter(g=>{const d=g.split("=",1)[0];return d!==F&&d!==P}).join("&"),{payload:u,...m&&de.test(m)?{campaignId:m}:{},cleanUrl:t.href}}let N=!1;function ue(){return N?!1:(N=!0,!0)}function me(i,e){i.body?e():i.addEventListener("DOMContentLoaded",e,{once:!0})}const he="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",pe=120.52/21.28,fe=4e3,ge=80,D=["#f04a34","#041abe","#041139","#1cd4ed","#b8e070"],Ce=260,U={x:.5,y:.7},ye=[{share:.25,spread:26,velocity:55,decay:.91,scalar:1},{share:.2,spread:60,velocity:45,decay:.91,scalar:1},{share:.35,spread:100,velocity:45,decay:.91,scalar:.8},{share:.1,spread:120,velocity:25,decay:.92,scalar:1.2},{share:.1,spread:120,velocity:45,decay:.91,scalar:1}],be=3,ve=.2,Te=200,Ee=1e3/60,we=4,Ae=.75,$={success:{fill:"#1c1d22",glyph:"#fafafc",path:"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"},info:{fill:"#146eaa",glyph:"#ffffff",path:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"},warning:{fill:"#aa4e19",glyph:"#ffffff",path:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"},error:{fill:"#c62734",glyph:"#ffffff",path:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}},xe={position:"absolute",top:"calc(56px + env(safe-area-inset-top, 0px))",left:"0",right:"0",margin:"0 auto",width:"max-content",maxWidth:"min(320px, calc(100% - 32px))",boxSizing:"border-box",display:"flex",alignItems:"center",gap:"8px",padding:"4px 16px 4px 4px",borderRadius:"20px",backgroundColor:"#ffffff",color:"#1c1d22",boxShadow:"0 4px 8px 0 #0000000a, 0 12px 32px 0 #0000001f",fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"14px",lineHeight:"20px",fontWeight:"400",overflowWrap:"anywhere"},Se={display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",width:"28px",height:"28px",margin:"2px",borderRadius:"50%"},Ie={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",border:"0",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"};function E(i,e){const t=document.createElement(i);return Object.assign(t.style,e),t}function Le(i,e){const t=E("div",{position:"absolute",inset:"0",overflow:"hidden",pointerEvents:"none",zIndex:"1"});t.setAttribute("aria-hidden","true"),i.appendChild(t);const s=E("span",Ie);s.setAttribute("role","status"),(e.querySelector('[role="dialog"]')??e).appendChild(s);let n=null,r=null,o=null,a=null;const u=()=>{r&&clearTimeout(r),r=null,a?.(),a=null,n?.remove(),n=null,s.textContent=""},m=c=>{const h=()=>{a=null,s.textContent=c};if(typeof requestAnimationFrame=="function"){const l=requestAnimationFrame(h);a=()=>cancelAnimationFrame(l)}else{const l=setTimeout(h,0);a=()=>clearTimeout(l)}},g=({spread:c,velocity:h,decay:l,scalar:f},C,w,p)=>{const y=(4+Math.random()*6)*f,b=E("span",{position:"absolute",left:`${w}px`,top:`${p}px`,width:`${y}px`,height:`${y*(.5+Math.random())}px`,borderRadius:Math.random()<.5?"50%":"1px",backgroundColor:C});b.setAttribute("data-moment-confetti",""),t.appendChild(b);const x=-Math.PI/2+(Math.random()-.5)*c*Math.PI/180;let T=h*(.5+Math.random());const rt=(Math.random()*2-1)*ve,at=(.25+Math.random()*.5)*Math.PI,lt=Math.random()<.5?.1:-.1,dt=Math.random()*10,ct=Math.min(.11,.05+Math.random()*.1),M=[{tick:0,x:0,y:0}];let[v,B,_]=[0,0,0];do B+=Math.cos(x)*T+rt,_+=Math.sin(x)*T+be,T*=l,v++,v%we===0&&M.push({tick:v,x:B,y:_});while(v<Te||_<1);M.at(-1).tick!==v&&M.push({tick:v,x:B,y:_}),b.animate(M.map(S=>{const ae=S.tick/v,ut=(at+S.tick*lt)*180/Math.PI,mt=Math.cos(dt+S.tick*ct);return{offset:ae,transform:`translate(${S.x.toFixed(1)}px, ${S.y.toFixed(1)}px) rotate(${ut.toFixed(0)}deg) scaleY(${mt.toFixed(2)})`,opacity:Math.min(1,(1-ae)/(1-Ae))}}),{duration:v*Ee,fill:"both"}).onfinish=()=>b.remove()},d=()=>{o=null;const c=window.innerWidth*U.x,h=window.innerHeight*U.y;let l=0;for(const f of ye)for(let C=Math.floor(ge*f.share);C>0;C--)g(f,D[l++%D.length],c,h)};return{celebrate(){window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||typeof t.animate!="function"||o||(o=setTimeout(d,Ce))},toast(c,h="success"){u();const l=$[Object.hasOwn($,h)?h:"success"],f=E("span",{...Se,backgroundColor:l.fill,color:l.glyph});f.innerHTML=`<svg width="16" height="16" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="${l.path}"/></svg>`;const C=E("span",{minWidth:"0"});C.textContent=c,n=E("div",xe),n.setAttribute("data-moment-toast",""),n.appendChild(f),n.appendChild(C),t.appendChild(n),m(c),r=setTimeout(u,fe)},destroy(){o&&clearTimeout(o),o=null,u(),t.remove(),s.remove()}}}function W(){if(typeof window>"u")return"";const i=window.location.origin,e=i==="null"?self.origin:i;return e==="null"&&console.error('[MomentSdk] This page has an opaque origin ("null"), so Moment Live cannot message it and calendar sync will not work. Serve the page over http(s), and give a sandboxed iframe allow-same-origin.'),e}function ke(i,e,t=W(),s){if(e.triggerType==="schedule"){const r=new URLSearchParams;return r.set("teamSlug",e.teamSlug),r.set("returnOrigin",t),r.set("embed","1"),r.set("sdkVersion","0.9.0-dev.53"),s&&(r.set("entry","link"),s.campaignId&&r.set("campaignId",s.campaignId)),`${i}/en/embed/schedule?${r.toString()}`}const n=new URLSearchParams;return n.set("teamSlug",e.teamSlug),e.momentSlug&&n.set("momentSlug",e.momentSlug),e.listSlug&&n.set("listSlug",e.listSlug),n.set("triggerType",e.triggerType),e.ids?.length&&n.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&n.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&n.set("calendar",e.calendar),e.apiSourceId&&n.set("subscriptionId",e.apiSourceId),e.externalEventId&&n.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&n.set("externalIdPrefix",e.externalEventIdPrefix),n.set("returnOrigin",t),n.set("embed","1"),n.set("sdkVersion","0.9.0-dev.53"),s&&(n.set("entry","link"),s.campaignId&&n.set("campaignId",s.campaignId)),`${i}/en/embed/sync?${n.toString()}`}const j=500,G=700,Me=500;class _e{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),s=Math.round(window.screenX+(window.outerWidth-j)/2),n=Math.round(window.screenY+(window.outerHeight-G)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=${j},height=${G},left=${s},top=${n},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=r=>{if(r.origin!==this.opts.liveOrigin||r.source!==this.popup)return;const o=r.data;!o||typeof o!="object"||o.source!=="moment-live-embed"||o.type!=="moment.embed.result"||(this.resultReceived=!0,this.sendStatusToIframe("completed"),this.opts.iframeWindow&&this.opts.iframeWindow.postMessage(o,this.opts.liveOrigin),e.intent!=="connect"&&this.opts.onResult(o),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=Oe(e,W());return this.opts.campaignId&&t.set("campaignId",this.opts.campaignId),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${t.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())},Me)}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 Oe(i,e){const t=new URLSearchParams({provider:i.provider,teamSlug:i.teamSlug,ids:i.ids.join(","),triggerType:i.triggerType,returnOrigin:e});i.subscriptionType&&t.set("subscriptionType",i.subscriptionType);const s={scheduleMomentIds:i.scheduleMomentIds,schedulePlaylistIds:i.schedulePlaylistIds,scheduleListIds:i.scheduleListIds};for(const[n,r]of Object.entries(s))r?.length&&t.set(n,r.join(","));return i.addons?.length&&t.set("addons",i.addons.join(",")),i.intent==="connect"&&t.set("intent","connect"),t}const K="moment-sdk-styles",Y="moment-sdk-close",R="moment-sdk-tray",I="moment-sdk-closing",Re=`
|
|
1
|
+
(function(O){"use strict";const F="moment_sync",P="moment_campaign",de=/^(?:schedule|(moment|list):([a-z0-9-]+)|playlist:([a-z0-9-]+(?:,[a-z0-9-]+)*))$/,ce=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function me(i,e){if(!e)return null;const t=new URL(i),s=t.searchParams.get(F);if(s===null||s.length>200)return null;const n=de.exec(s);if(!n)return null;const[,o,r,a]=n;let m;o==="moment"?m={teamSlug:e,triggerType:"moment",momentSlug:r}:o==="list"?m={teamSlug:e,triggerType:"list",listSlug:r}:a?m={teamSlug:e,triggerType:"playlist",playlistSlugs:a.split(",")}:m={teamSlug:e,triggerType:"schedule"};const u=t.searchParams.get(P);return t.search=t.search.slice(1).split("&").filter(g=>{const d=g.split("=",1)[0];return d!==F&&d!==P}).join("&"),{payload:m,...u&&ce.test(u)?{campaignId:u}:{},cleanUrl:t.href}}let N=!1;function ue(){return N?!1:(N=!0,!0)}function he(i,e){i.body?e():i.addEventListener("DOMContentLoaded",e,{once:!0})}const pe="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",fe=120.52/21.28,ge=4e3,Ce=80,D=["#f04a34","#041abe","#041139","#1cd4ed","#b8e070"],ye=260,U={x:.5,y:.7},be=[{share:.25,spread:26,velocity:55,decay:.91,scalar:1},{share:.2,spread:60,velocity:45,decay:.91,scalar:1},{share:.35,spread:100,velocity:45,decay:.91,scalar:.8},{share:.1,spread:120,velocity:25,decay:.92,scalar:1.2},{share:.1,spread:120,velocity:45,decay:.91,scalar:1}],ve=3,Te=.2,we=200,Ee=1e3/60,xe=4,Ae=.75,$={success:{fill:"#1c1d22",glyph:"#fafafc",path:"M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z"},info:{fill:"#146eaa",glyph:"#ffffff",path:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"},warning:{fill:"#aa4e19",glyph:"#ffffff",path:"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z"},error:{fill:"#c62734",glyph:"#ffffff",path:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}},Se={position:"absolute",top:"calc(56px + env(safe-area-inset-top, 0px))",left:"0",right:"0",margin:"0 auto",width:"max-content",maxWidth:"min(320px, calc(100% - 32px))",boxSizing:"border-box",display:"flex",alignItems:"center",gap:"8px",padding:"4px 16px 4px 4px",borderRadius:"20px",backgroundColor:"#ffffff",color:"#1c1d22",boxShadow:"0 4px 8px 0 #0000000a, 0 12px 32px 0 #0000001f",fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"14px",lineHeight:"20px",fontWeight:"400",overflowWrap:"anywhere"},Le={display:"flex",alignItems:"center",justifyContent:"center",flexShrink:"0",width:"28px",height:"28px",margin:"2px",borderRadius:"50%"},Ie={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",border:"0",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"};function w(i,e){const t=document.createElement(i);return Object.assign(t.style,e),t}function ke(i,e){const t=w("div",{position:"absolute",inset:"0",overflow:"hidden",pointerEvents:"none",zIndex:"1"});t.setAttribute("aria-hidden","true"),i.appendChild(t);const s=w("span",Ie);s.setAttribute("role","status"),(e.querySelector('[role="dialog"]')??e).appendChild(s);let n=null,o=null,r=null,a=null;const m=()=>{o&&clearTimeout(o),o=null,a?.(),a=null,n?.remove(),n=null,s.textContent=""},u=c=>{const h=()=>{a=null,s.textContent=c};if(typeof requestAnimationFrame=="function"){const l=requestAnimationFrame(h);a=()=>cancelAnimationFrame(l)}else{const l=setTimeout(h,0);a=()=>clearTimeout(l)}},g=({spread:c,velocity:h,decay:l,scalar:f},C,E,p)=>{const y=(4+Math.random()*6)*f,b=w("span",{position:"absolute",left:`${E}px`,top:`${p}px`,width:`${y}px`,height:`${y*(.5+Math.random())}px`,borderRadius:Math.random()<.5?"50%":"1px",backgroundColor:C});b.setAttribute("data-moment-confetti",""),t.appendChild(b);const A=-Math.PI/2+(Math.random()-.5)*c*Math.PI/180;let T=h*(.5+Math.random());const at=(Math.random()*2-1)*Te,lt=(.25+Math.random()*.5)*Math.PI,dt=Math.random()<.5?.1:-.1,ct=Math.random()*10,mt=Math.min(.11,.05+Math.random()*.1),M=[{tick:0,x:0,y:0}];let[v,B,_]=[0,0,0];do B+=Math.cos(A)*T+at,_+=Math.sin(A)*T+ve,T*=l,v++,v%xe===0&&M.push({tick:v,x:B,y:_});while(v<we||_<1);M.at(-1).tick!==v&&M.push({tick:v,x:B,y:_}),b.animate(M.map(S=>{const le=S.tick/v,ut=(lt+S.tick*dt)*180/Math.PI,ht=Math.cos(ct+S.tick*mt);return{offset:le,transform:`translate(${S.x.toFixed(1)}px, ${S.y.toFixed(1)}px) rotate(${ut.toFixed(0)}deg) scaleY(${ht.toFixed(2)})`,opacity:Math.min(1,(1-le)/(1-Ae))}}),{duration:v*Ee,fill:"both"}).onfinish=()=>b.remove()},d=()=>{r=null;const c=window.innerWidth*U.x,h=window.innerHeight*U.y;let l=0;for(const f of be)for(let C=Math.floor(Ce*f.share);C>0;C--)g(f,D[l++%D.length],c,h)};return{celebrate(){window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||typeof t.animate!="function"||r||(r=setTimeout(d,ye))},toast(c,h="success"){m();const l=$[Object.hasOwn($,h)?h:"success"],f=w("span",{...Le,backgroundColor:l.fill,color:l.glyph});f.innerHTML=`<svg width="16" height="16" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="${l.path}"/></svg>`;const C=w("span",{minWidth:"0"});C.textContent=c,n=w("div",Se),n.setAttribute("data-moment-toast",""),n.appendChild(f),n.appendChild(C),t.appendChild(n),u(c),o=setTimeout(m,ge)},destroy(){r&&clearTimeout(r),r=null,m(),t.remove(),s.remove()}}}function W(){if(typeof window>"u")return"";const i=window.location.origin,e=i==="null"?self.origin:i;return e==="null"&&console.error('[MomentSdk] This page has an opaque origin ("null"), so Moment Live cannot message it and calendar sync will not work. Serve the page over http(s), and give a sandboxed iframe allow-same-origin.'),e}function Me(i,e,t=W(),s){if(e.triggerType==="schedule"){const o=new URLSearchParams;return o.set("teamSlug",e.teamSlug),o.set("returnOrigin",t),o.set("embed","1"),o.set("sdkVersion","0.9.0-dev.54"),s&&(o.set("entry","link"),s.campaignId&&o.set("campaignId",s.campaignId)),`${i}/en/embed/schedule?${o.toString()}`}const n=new URLSearchParams;return n.set("teamSlug",e.teamSlug),e.momentSlug&&n.set("momentSlug",e.momentSlug),e.listSlug&&n.set("listSlug",e.listSlug),n.set("triggerType",e.triggerType),e.ids?.length&&n.set("ids",e.ids.join(",")),e.playlistSlugs?.length&&n.set("playlistSlugs",e.playlistSlugs.join(",")),e.calendar&&n.set("calendar",e.calendar),e.apiSourceId&&n.set("subscriptionId",e.apiSourceId),e.externalEventId&&n.set("externalId",e.externalEventId),e.externalEventIdPrefix&&!e.externalEventId&&n.set("externalIdPrefix",e.externalEventIdPrefix),n.set("returnOrigin",t),n.set("embed","1"),n.set("sdkVersion","0.9.0-dev.54"),s&&(n.set("entry","link"),s.campaignId&&n.set("campaignId",s.campaignId)),`${i}/en/embed/sync?${n.toString()}`}const j=500,G=700,_e=500;class Oe{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),s=Math.round(window.screenX+(window.outerWidth-j)/2),n=Math.round(window.screenY+(window.outerHeight-G)/2);if(this.popup=window.open(t,"moment-oauth-popup",`width=${j},height=${G},left=${s},top=${n},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=o=>{if(o.origin!==this.opts.liveOrigin||o.source!==this.popup)return;const r=o.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),e.intent!=="connect"&&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=Re(e,W());return this.opts.campaignId&&t.set("campaignId",this.opts.campaignId),`${this.opts.liveBaseUrl}/en/embed/oauth-popup?${t.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())},_e)}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 Re(i,e){const t=new URLSearchParams({provider:i.provider,teamSlug:i.teamSlug,ids:i.ids.join(","),triggerType:i.triggerType,returnOrigin:e});i.subscriptionType&&t.set("subscriptionType",i.subscriptionType);const s={scheduleMomentIds:i.scheduleMomentIds,schedulePlaylistIds:i.schedulePlaylistIds,scheduleListIds:i.scheduleListIds};for(const[n,o]of Object.entries(s))o?.length&&t.set(n,o.join(","));return i.addons?.length&&t.set("addons",i.addons.join(",")),i.intent==="connect"&&t.set("intent","connect"),t}const K="moment-sdk-styles",Y="moment-sdk-close",R="moment-sdk-tray",L="moment-sdk-closing",He=`
|
|
2
2
|
:where(.moment-sync-trigger) {
|
|
3
3
|
background-color: #1c1917;
|
|
4
4
|
color: #ffffff;
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
animation: moment-sdk-tray-in 0.35s cubic-bezier(0.32, 0.72, 0, 1);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.${
|
|
57
|
+
.${L} {
|
|
58
58
|
animation: moment-sdk-dim-out 0.25s ease-in forwards;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.${
|
|
61
|
+
.${L} > * {
|
|
62
62
|
animation: moment-sdk-fade-out 0.25s ease-in forwards;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
.${
|
|
65
|
+
.${L} .${R} {
|
|
66
66
|
animation: moment-sdk-tray-out 0.25s cubic-bezier(0.32, 0.72, 0, 1) forwards;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
`;function He(){if(typeof document>"u"||document.getElementById(K))return;const i=document.createElement("style");i.id=K,i.textContent=Re,document.head.appendChild(i)}function Be(i){return typeof i=="string"&&i.startsWith("webcal://")}function Fe(i){return!i||i.closed?"blocked":"opened"}const Pe=1024,H=600,Ne=400,De=40,z=80,V=90,Ue=420,$e=520,Z=48,q="#0d0d0d",L="#121316",We={backgroundColor:q,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"none",webkitBackdropFilter:"none"},X="inset 0 0.5px 0.75px rgb(255 255 255 / 0.6)",je="inset 0 -0.5px 0.75px rgb(255 255 255 / 0.3)",Q=["0 0 0 0.5px #9c9c9c","0 4px 8px 0 #0000001f","0 12px 32px 0 #00000047"],J={backgroundColor:"rgb(19 19 19 / 0.812)",backdropFilter:"blur(14px)",webkitBackdropFilter:"blur(14px)",boxShadow:[X,je,...Q].join(", ")},Ge={...J,boxShadow:[X,...Q].join(", ")},A=32,ee="height 0.25s cubic-bezier(0.32, 0.72, 0, 1)",Ke=2e3,Ye=500,ze=400,k=12,Ve="2147483647",Ze='button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])',te="#38393B",qe="#4B4B4E",Xe={position:"absolute",top:"16px",right:"16px",zIndex:"10",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:te,color:"#F5F5F5",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};function Qe(i,e,t=k,s="v1",n=0,r=L){const o=s==="v2",a=i<Pe,m={showFooter:!o,material:o?"glass":"solid",wrapperMaterial:o?a?Ge:J:We,card:{backgroundColor:o?"transparent":r},iframe:o?{background:"transparent",colorScheme:"dark"}:{background:"",colorScheme:""}},g=o?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.5)",d=o?k:t,c=`${d}px ${d}px 0px 0px`;if(a){const l=o?e-Z-n:Math.floor(e*V/100)-A;return{isTray:!0,overlay:{alignItems:"flex-end",padding:"0",backdropFilter:"none",backgroundColor:g},wrapper:{maxWidth:i<H+2*De?"none":`${H}px`,minWidth:"0",borderRadius:c,paddingBottom:"env(safe-area-inset-bottom, 0px)"},container:{maxHeight:o?`calc(100dvh - ${Z}px - env(safe-area-inset-bottom, 0px))`:`calc(${V}dvh - ${A}px)`,borderRadius:c},iframeMaxHeight:l,iframeOpeningHeight:Math.min(Ue,l),...m}}const h=e-z;return{isTray:!1,overlay:{alignItems:"center",padding:"16px",backdropFilter:o?"none":"blur(2px)",backgroundColor:g},wrapper:{maxWidth:`${H}px`,minWidth:`${Ne}px`,borderRadius:`${d}px`,paddingBottom:"0"},container:{maxHeight:`calc(100vh - ${z}px)`,borderRadius:c},iframeMaxHeight:h,iframeOpeningHeight:Math.min($e,h),...m}}function ie(i,e){return Math.min(i,e)}function Je(i){return i.triggerType!=="schedule"&&i.keepOpen!==!0}const et=32;function tt(i){const e={hideCloseButton:i.closeControl==="embed",dismissByEmbed:i.dismiss==="embed",backByEmbed:i.back==="embed"};return typeof i.borderRadius=="number"&&Number.isFinite(i.borderRadius)&&(e.cardRadius=Math.max(0,Math.min(i.borderRadius,et))),typeof i.surface=="string"&&i.surface!==""&&(e.surface=i.surface),(i.design==="v1"||i.design==="v2")&&(e.design=i.design),e}const it=".moment-sync-trigger",se="momentSdkSheet",st=6,ne=60,nt="rgba(255, 255, 255, 0.216)",ot="https://live.dev.momentco.ai";class oe{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;closeButton=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;activeCampaignId;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;previousBodyPaddingRight="";didManageBodyPadding=!1;closeTimer=null;revealed=!1;revealTimer=null;dismissAckTimer=null;cardRadius=k;design="v1";surface=L;dismissByEmbed=!1;backByEmbed=!1;historyToken=null;historyLevel=-1;pageUnloading=!1;lastRequestedHeight=null;footer=null;hairline=null;viewportResizeHandler=null;feedback=null;closeReported=!1;constructor(e){this.opts={triggerSelector:it,...e},this.liveBaseUrl=ot;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}He(),this.bindTriggers(),this.emitAnalytics("embed.init"),this.opts.autoOpen&&this.autoOpenFromUrl(this.opts.autoOpen.teamSlug)}open(e){this.openWith(e)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}openWith(e,t){if(this.overlay&&!this.revealed)return;e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const s=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:s.teamSlug,triggerType:s.triggerType,...t?{triggerSource:"url"}:{}}),this.createModal(s,t)}autoOpenFromUrl(e){if(!ue())return;const t=ce(window.location.href,e);t&&me(document,()=>{this.openWith(t.payload,t),history.replaceState(history.state,"",t.cleanUrl)})}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const s=r=>{r.preventDefault(),this.handleTriggerClick(t)},n=this.boundClickHandlers.get(t);n&&t.removeEventListener("click",n),t.addEventListener("click",s),this.boundClickHandlers.set(t,s)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",s=e.getAttribute("data-moment-slug")??void 0,n=e.getAttribute("data-moment-list-slug")??void 0,r=e.getAttribute("data-moment-trigger-type");let o="moment";r!=null&&r!==""&&(r==="moment"||r==="list"||r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule"?o=r:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",r));const a=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",u=a?a.split(",").filter(Boolean):[],m=e.getAttribute("data-moment-playlist-slugs")??"",g=m?m.split(",").map(w=>w.trim()).filter(Boolean):[],d=e.getAttribute("data-moment-calendar");let c;d!=null&&d!==""&&(d==="google"||d==="outlook"?c=d:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",d));const h=e.getAttribute("data-api-source-id")??void 0,l=e.getAttribute("data-external-event-id")??void 0,f=e.getAttribute("data-external-event-id-prefix")??void 0;if(l&&f&&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 C=o==="team"||o==="brand-playlist"||o==="playlist"||o==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:o,momentIds:C?[]:u}),this.open({teamSlug:t,momentSlug:s,listSlug:n,triggerType:o,ids:u,playlistSlugs:g,calendar:c??void 0,apiSourceId:h,externalEventId:f&&!l?void 0:l,externalEventIdPrefix:l?void 0:f})}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,t){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e,this.activeCampaignId=t?.campaignId;const s=this.buildIframeUrl(e,t);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:Ve,display:"flex",justifyContent:"center",visibility:"hidden"}),this.overlay.addEventListener("click",p=>{p.target===this.overlay&&this.requestDismiss()});const n=p=>{p.key==="Escape"&&this.requestDismiss()};document.addEventListener("keydown",n),window.addEventListener("popstate",this.onPopState),window.addEventListener("beforeunload",this.onBeforeUnload);const r=document.createElement("div");Object.assign(r.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:q,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const o=document.createElement("div");o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-label","Calendar sync modal"),o.tabIndex=-1,Object.assign(o.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:L,outline:"none"});const a=document.createElement("button");a.type="button",a.className=Y,a.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.75 5.25 5.25 18.75M5.25 5.25l13.5 13.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',a.setAttribute("aria-label","Close"),Object.assign(a.style,Xe),a.addEventListener("mouseenter",()=>{a.style.backgroundColor=qe}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor=te}),a.addEventListener("click",()=>this.handleCancel());const u=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=s,this.iframe.setAttribute("allow","web-share; clipboard-write"),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",overflow:"hidden",transition:ee}),u&&(o.appendChild(a),this.closeButton=a),o.appendChild(this.iframe);const m=document.createElement("div");this.footer=m,Object.assign(m.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:`${st}px`,height:`${A}px`,flexShrink:"0",boxSizing:"border-box",padding:"0"});const g=document.createElement("span");g.textContent="Powered by",Object.assign(g.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const d=document.createElement("img");d.alt="Moment",d.src=he,Object.assign(d.style,{display:"block",width:`${ne}px`,height:`${(ne/pe).toFixed(2)}px`}),m.appendChild(g),m.appendChild(d),this.wrapper=r,this.container=o,this.applyFrameLayout();const c=document.createElement("div");this.hairline=c,c.setAttribute("aria-hidden","true"),Object.assign(c.style,{position:"absolute",inset:"0",borderRadius:"inherit",boxShadow:`inset 0 0 0 1px ${nt}`,pointerEvents:"none",zIndex:"2"}),r.appendChild(o),r.appendChild(m),r.appendChild(c),this.overlay.appendChild(r),this.feedback=Le(this.overlay,r),document.body.appendChild(this.overlay),this.revealTimer=setTimeout(()=>this.reveal(),Ke),this.viewportResizeHandler=()=>this.applyFrameLayout(),window.addEventListener("resize",this.viewportResizeHandler);const h=()=>o.querySelectorAll(Ze),l=p=>{if(p.key!=="Tab")return;const y=h(),b=y[0],x=y[y.length-1],T=document.activeElement;p.shiftKey&&(T===b||T===o)?(p.preventDefault(),x.focus()):!p.shiftKey&&T===x&&(p.preventDefault(),b.focus())};o.addEventListener("keydown",l);const f=p=>{const y=document.createElement("span");return y.tabIndex=0,Object.assign(y.style,{position:"fixed",opacity:"0"}),y.addEventListener("focus",()=>{const b=h();b[p==="first"?0:b.length-1].focus()}),y};o.before(f("last")),o.after(f("first"));const C=document.documentElement.clientWidth;this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0;const w=document.documentElement.clientWidth-C;if(w>0){this.previousBodyPaddingRight=document.body.style.paddingRight;const p=Number.parseFloat(getComputedStyle(document.body).paddingRight)||0;document.body.style.paddingRight=`${p+w}px`,this.didManageBodyPadding=!0}this.setupMessageListener(),this.overlay._escHandler=n,this.overlay._focusTrapHandler=l}reveal(){this.revealed||!this.overlay||(this.revealTimer&&clearTimeout(this.revealTimer),this.revealTimer=null,this.revealed=!0,this.overlay.style.visibility="",this.applyFrameLayout(),this.container?.focus())}applyFrameLayout(){if(!this.overlay||!this.wrapper||!this.container||!this.iframe)return;Object.assign(this.wrapper.style,this.currentLayout().wrapper);const e=this.currentLayout();Object.assign(this.overlay.style,e.overlay),Object.assign(this.wrapper.style,e.wrapperMaterial),Object.assign(this.container.style,e.container),Object.assign(this.container.style,e.card),Object.assign(this.iframe.style,e.iframe);const t=this.footer?.style.display!=="none";if(this.footer&&this.revealed&&t!==e.showFooter){const r=this.iframe.offsetHeight;this.iframe.style.transition="none",this.iframe.style.height=`${r+(t?A:-A)}px`,this.iframe.offsetHeight,this.iframe.style.transition=ee}this.footer&&(this.footer.style.display=e.showFooter?"flex":"none"),this.hairline&&(this.hairline.style.display=e.material==="glass"?"none":""),this.wrapper.classList.toggle(R,e.isTray&&this.revealed);const s=Number.parseFloat(this.iframe.style.height),n=this.lastRequestedHeight!==null?ie(this.lastRequestedHeight,e.iframeMaxHeight):Number.isNaN(s)?e.iframeOpeningHeight:Math.min(s,e.iframeMaxHeight);this.iframe.style.height=`${n}px`}currentLayout(){const e=this.wrapper&&Number.parseFloat(getComputedStyle(this.wrapper).paddingBottom)||0;return Qe(window.innerWidth,window.innerHeight,this.cardRadius,this.design,e,this.surface)}buildIframeUrl(e,t){return ke(this.liveBaseUrl,e,void 0,t)}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 s=t;this.emitAnalytics("oauth.start",{provider:s.provider,teamSlug:s.teamSlug}),this.handleOAuthStart(s);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const s=typeof t.height=="number"?t.height:0;if(s>0&&this.iframe){this.lastRequestedHeight=s;const{iframeMaxHeight:n}=this.currentLayout();this.iframe.style.height=`${ie(s,n)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const s=tt(t);s.design&&s.design!==this.design&&(this.design=s.design,this.applyFrameLayout()),s.cardRadius!==void 0&&(this.cardRadius=s.cardRadius,this.applyFrameLayout()),s.hideCloseButton&&this.closeButton&&(document.activeElement===this.closeButton&&this.container?.focus(),this.closeButton.remove()),s.surface!==void 0&&(this.surface=s.surface,this.applyFrameLayout()),s.dismissByEmbed&&(this.dismissByEmbed=!0),s.backByEmbed&&(this.backByEmbed=!0),this.reveal(),this.backByEmbed&&!this.historyToken&&this.pushHistoryLevel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:s}=t;if(Be(s)){const n=Fe(window.open(s,"_blank"));n==="blocked"&&this.emitAnalytics("open.url.blocked",{}),this.sendOpenUrlStatus(n,s)}else this.sendOpenUrlStatus("blocked",typeof s=="string"?s:"");return}if(t.source==="moment-live-embed"&&(t.type==="moment.embed.dismiss.ack"||t.type==="moment.embed.back.ack")){this.clearDismissAckTimer();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.history.push"){this.historyToken&&this.pushHistoryLevel();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.celebrate"){this.feedback?.celebrate();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.toast"){const{text:s,variant:n}=t;typeof s=="string"&&s.trim()!==""&&this.feedback?.toast(s,n);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const s=t;this.handleResult(s)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new _e({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,campaignId:this.activeCampaignId,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)}sendOpenUrlStatus(e,t){const s=this.iframe?.contentWindow;if(!s)return;const n={source:"moment-sdk",type:"moment.embed.open.url.status",status:e,url:t};s.postMessage(n,this.liveOrigin)}handleResult(e){e.result!=="cancelled"&&(e.keepOpen===!0&&e.triggerType!=="schedule"&&(this.closeReported=!0),e.result==="success"||e.result==="partial"?(this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e)):e.result==="error"&&(this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e)),this.opts.onClose?.(e),this.emitAnalytics("embed.close"),Je(e)&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500)))}requestDismiss(e=!1){const t=this.iframe?.contentWindow;if(!(e?this.backByEmbed:this.dismissByEmbed)||this.design!=="v2"||!t){this.handleCancel();return}const s={source:"moment-sdk",type:e?"moment.sdk.back":"moment.sdk.dismiss"};t.postMessage(s,this.liveOrigin),this.dismissAckTimer||(this.dismissAckTimer=setTimeout(()=>this.handleCancel(),Ye))}pushHistoryLevel(){const e=this.historyToken??`${Date.now()}.${Math.random()}`,t=history.state!==null&&typeof history.state=="object"?history.state:{},s=this.historyLevel+1;try{history.pushState({...t,[se]:{token:e,level:s}},""),this.historyToken=e,this.historyLevel=s}catch{}}currentHistoryLevel(){const e=history.state?.[se];return e?.token===this.historyToken&&typeof e.level=="number"?e.level:-1}onPopState=()=>{if(!this.historyToken)return;const e=this.currentHistoryLevel(),t=e<this.historyLevel;this.historyLevel=e,t&&this.requestDismiss(!0)};onBeforeUnload=()=>{this.pageUnloading=!0};clearDismissAckTimer(){this.dismissAckTimer&&clearTimeout(this.dismissAckTimer),this.dismissAckTimer=null}handleCancel(){if(!this.closeReported){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(!0)}cleanup(e=!1){const t=e&&this.design==="v2"&&this.revealed&&!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.revealTimer&&(clearTimeout(this.revealTimer),this.revealTimer=null),this.clearDismissAckTimer(),this.revealed=!1,this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.feedback?.destroy(),this.feedback=null,this.closeReported=!1,window.removeEventListener("popstate",this.onPopState),window.removeEventListener("beforeunload",this.onBeforeUnload);const s=this.historyToken?this.currentHistoryLevel():-1;if(s>=0&&!this.pageUnloading&&history.go(-(s+1)),this.historyToken=null,this.historyLevel=-1,this.pageUnloading=!1,this.design="v1",this.surface=L,this.dismissByEmbed=!1,this.backByEmbed=!1,this.lastRequestedHeight=null,this.footer=null,this.hairline=null,this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:n,_focusTrapHandler:r}=this.overlay;n&&document.removeEventListener("keydown",n);const o=this.overlay.firstElementChild;if(o&&r&&o.removeEventListener("keydown",r),t){const a=this.overlay;a.style.pointerEvents="none",a.style.width=`${document.documentElement.clientWidth}px`,a.classList.add(I);const u=setTimeout(()=>a.remove(),ze);a.addEventListener("animationend",()=>{clearTimeout(u),a.remove()},{once:!0})}else this.overlay.remove();this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.closeButton=null,this.activePayload=null,this.activeCampaignId=void 0,this.cardRadius=k,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.didManageBodyPadding&&(document.body.style.paddingRight=this.previousBodyPaddingRight,this.didManageBodyPadding=!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 re(i){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),i.className&&i.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",i.teamSlug),i.momentSlug&&e.setAttribute("data-moment-slug",i.momentSlug),i.listSlug&&e.setAttribute("data-moment-list-slug",i.listSlug),i.triggerType&&e.setAttribute("data-moment-trigger-type",i.triggerType),i.ids?.length&&e.setAttribute("data-moment-ids",i.ids.join(",")),i.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",i.playlistSlugs.join(",")),i.calendar&&e.setAttribute("data-moment-calendar",i.calendar),i.apiSourceId&&e.setAttribute("data-api-source-id",i.apiSourceId),i.externalEventId&&e.setAttribute("data-external-event-id",i.externalEventId),i.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",i.externalEventIdPrefix),e.textContent=i.label??"Add to Calendar",e}if(typeof window<"u"){const i=window;i.MomentSdk=oe,i.createMomentButton=re}O.MomentSdk=oe,O.createMomentButton=re,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
|
69
|
+
`;function Be(){if(typeof document>"u"||document.getElementById(K))return;const i=document.createElement("style");i.id=K,i.textContent=He,document.head.appendChild(i)}function Fe(i){return typeof i=="string"&&i.startsWith("webcal://")}function Pe(i){return!i||i.closed?"blocked":"opened"}const z=1024,H=600,Ne=400,De=40,V=80,Z=90,Ue=420,$e=520,q=48,X="#0d0d0d",I="#121316",We={backgroundColor:X,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",backdropFilter:"none",webkitBackdropFilter:"none"},Q="inset 0 0.5px 0.75px rgb(255 255 255 / 0.6)",je="inset 0 -0.5px 0.75px rgb(255 255 255 / 0.3)",J=["0 0 0 0.5px #9c9c9c","0 4px 8px 0 #0000001f","0 12px 32px 0 #00000047"],ee={backgroundColor:"rgb(19 19 19 / 0.812)",backdropFilter:"blur(14px)",webkitBackdropFilter:"blur(14px)",boxShadow:[Q,je,...J].join(", ")},Ge={...ee,boxShadow:[Q,...J].join(", ")},x=32,te="height 0.25s cubic-bezier(0.32, 0.72, 0, 1)",Ke=2e3,Ye=500,ze=400,k=12,Ve="2147483647",Ze='button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])',ie="#38393B",qe="#4B4B4E",Xe={position:"absolute",top:"16px",right:"16px",zIndex:"10",width:"40px",height:"40px",padding:"0",border:"none",borderRadius:"50%",backgroundColor:ie,color:"#F5F5F5",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"};function Qe(i,e,t=k,s="v1",n=0,o=I){const r=s==="v2",a=i<z,u={showFooter:!r,material:r?"glass":"solid",wrapperMaterial:r?a?Ge:ee:We,card:{backgroundColor:r?"transparent":o},iframe:r?{background:"transparent",colorScheme:"dark"}:{background:"",colorScheme:""}},g=r?"rgba(0, 0, 0, 0.4)":"rgba(0, 0, 0, 0.5)",d=r?k:t,c=`${d}px ${d}px 0px 0px`;if(a){const l=r?e-q-n:Math.floor(e*Z/100)-x;return{isTray:!0,overlay:{alignItems:"flex-end",padding:"0",backdropFilter:"none",backgroundColor:g},wrapper:{maxWidth:i<H+2*De?"none":`${H}px`,minWidth:"0",borderRadius:c,paddingBottom:"env(safe-area-inset-bottom, 0px)"},container:{maxHeight:r?`calc(100dvh - ${q}px - env(safe-area-inset-bottom, 0px))`:`calc(${Z}dvh - ${x}px)`,borderRadius:c},iframeMaxHeight:l,iframeOpeningHeight:Math.min(Ue,l),...u}}const h=e-V;return{isTray:!1,overlay:{alignItems:"center",padding:"16px",backdropFilter:r?"none":"blur(2px)",backgroundColor:g},wrapper:{maxWidth:`${H}px`,minWidth:`${Ne}px`,borderRadius:`${d}px`,paddingBottom:"0"},container:{maxHeight:`calc(100vh - ${V}px)`,borderRadius:c},iframeMaxHeight:h,iframeOpeningHeight:Math.min($e,h),...u}}function Je(i,e){return{isTray:i<z,overlay:{alignItems:"stretch",padding:"0",backdropFilter:"none",backgroundColor:"transparent"},wrapper:{maxWidth:"none",minWidth:"0",borderRadius:"0px",paddingBottom:"0px"},container:{maxHeight:"none",borderRadius:"0px"},iframeMaxHeight:e,iframeOpeningHeight:e,showFooter:!1,material:"clear",wrapperMaterial:{backgroundColor:"transparent",boxShadow:"none",backdropFilter:"none",webkitBackdropFilter:"none"},card:{backgroundColor:"transparent"},iframe:{background:"transparent",colorScheme:"dark"}}}function se(i,e){return Math.min(i,e)}function et(i){return i.triggerType!=="schedule"&&i.keepOpen!==!0}const tt=32;function it(i){const e={hideCloseButton:i.closeControl==="embed",dismissByEmbed:i.dismiss==="embed",backByEmbed:i.back==="embed"};return typeof i.borderRadius=="number"&&Number.isFinite(i.borderRadius)&&(e.cardRadius=Math.max(0,Math.min(i.borderRadius,tt))),typeof i.surface=="string"&&i.surface!==""&&(e.surface=i.surface),(i.design==="v1"||i.design==="v2")&&(e.design=i.design),e}const st=".moment-sync-trigger",ne="momentSdkSheet",nt=6,re=60,rt="rgba(255, 255, 255, 0.216)",ot="https://live.dev.momentco.ai";class oe{opts;liveBaseUrl;liveOrigin;overlay=null;iframe=null;wrapper=null;container=null;closeButton=null;popupBridge=null;messageHandler=null;boundClickHandlers=new Map;activePayload=null;activeCampaignId;previousFocusedElement=null;previousBodyOverflow="";didManageBodyOverflow=!1;previousBodyPaddingRight="";didManageBodyPadding=!1;closeTimer=null;revealed=!1;revealTimer=null;dismissAckTimer=null;cardRadius=k;design="v1";surface=I;dismissByEmbed=!1;backByEmbed=!1;coverAsked=!1;historyToken=null;historyLevel=-1;pageUnloading=!1;lastRequestedHeight=null;footer=null;hairline=null;viewportResizeHandler=null;feedback=null;closeReported=!1;constructor(e){this.opts={triggerSelector:st,...e},this.liveBaseUrl=ot;try{this.liveOrigin=new URL(this.liveBaseUrl).origin}catch{throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`)}Be(),this.bindTriggers(),this.emitAnalytics("embed.init"),this.opts.autoOpen&&this.autoOpenFromUrl(this.opts.autoOpen.teamSlug)}open(e){this.openWith(e)}close(){this.handleCancel()}rebind(){this.unbindTriggers(),this.bindTriggers()}destroy(){this.cleanup(),this.unbindTriggers()}openWith(e,t){if(this.overlay&&!this.revealed)return;e.externalEventId&&e.externalEventIdPrefix&&console.warn("[MomentSdk] Both externalEventId and externalEventIdPrefix provided; using externalEventId only.");const s=this.scopeOpenPayload(e);this.emitAnalytics("embed.open",{teamSlug:s.teamSlug,triggerType:s.triggerType,...t?{triggerSource:"url"}:{}}),this.createModal(s,t)}autoOpenFromUrl(e){if(!ue())return;const t=me(window.location.href,e);t&&he(document,()=>{this.openWith(t.payload,t),history.replaceState(history.state,"",t.cleanUrl)})}bindTriggers(){document.querySelectorAll(this.opts.triggerSelector).forEach(t=>{const s=o=>{o.preventDefault(),this.handleTriggerClick(t)},n=this.boundClickHandlers.get(t);n&&t.removeEventListener("click",n),t.addEventListener("click",s),this.boundClickHandlers.set(t,s)})}unbindTriggers(){this.boundClickHandlers.forEach((e,t)=>{t.removeEventListener("click",e)}),this.boundClickHandlers.clear()}handleTriggerClick(e){const t=e.getAttribute("data-moment-team-slug")??"",s=e.getAttribute("data-moment-slug")??void 0,n=e.getAttribute("data-moment-list-slug")??void 0,o=e.getAttribute("data-moment-trigger-type");let r="moment";o!=null&&o!==""&&(o==="moment"||o==="list"||o==="team"||o==="brand-playlist"||o==="playlist"||o==="schedule"?r=o:console.warn("[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",o));const a=e.getAttribute("data-moment-ids")??e.getAttribute("data-moment-game-id")??"",m=a?a.split(",").filter(Boolean):[],u=e.getAttribute("data-moment-playlist-slugs")??"",g=u?u.split(",").map(E=>E.trim()).filter(Boolean):[],d=e.getAttribute("data-moment-calendar");let c;d!=null&&d!==""&&(d==="google"||d==="outlook"?c=d:console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:",d));const h=e.getAttribute("data-api-source-id")??void 0,l=e.getAttribute("data-external-event-id")??void 0,f=e.getAttribute("data-external-event-id-prefix")??void 0;if(l&&f&&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 C=r==="team"||r==="brand-playlist"||r==="playlist"||r==="schedule";this.emitAnalytics("embed.trigger.click",{teamSlug:t,triggerType:r,momentIds:C?[]:m}),this.open({teamSlug:t,momentSlug:s,listSlug:n,triggerType:r,ids:m,playlistSlugs:g,calendar:c??void 0,apiSourceId:h,externalEventId:f&&!l?void 0:l,externalEventIdPrefix:l?void 0:f})}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,t){this.cleanup(),this.previousFocusedElement=document.activeElement||null,this.activePayload=e,this.activeCampaignId=t?.campaignId;const s=this.buildIframeUrl(e,t);this.overlay=document.createElement("div"),this.overlay.setAttribute("role","presentation"),Object.assign(this.overlay.style,{position:"fixed",inset:"0",zIndex:Ve,display:"flex",justifyContent:"center",visibility:"hidden"}),this.overlay.addEventListener("click",p=>{p.target===this.overlay&&this.requestDismiss()});const n=p=>{p.key==="Escape"&&this.requestDismiss()};document.addEventListener("keydown",n),window.addEventListener("popstate",this.onPopState),window.addEventListener("beforeunload",this.onBeforeUnload);const o=document.createElement("div");Object.assign(o.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"hidden",backgroundColor:X,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",display:"flex",flexDirection:"column"});const r=document.createElement("div");r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label","Calendar sync modal"),r.tabIndex=-1,Object.assign(r.style,{position:"relative",width:"100%",transition:"border-radius 0.3s ease",overflow:"auto",backgroundColor:I,outline:"none"});const a=document.createElement("button");a.type="button",a.className=Y,a.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.75 5.25 5.25 18.75M5.25 5.25l13.5 13.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>',a.setAttribute("aria-label","Close"),Object.assign(a.style,Xe),a.addEventListener("mouseenter",()=>{a.style.backgroundColor=qe}),a.addEventListener("mouseleave",()=>{a.style.backgroundColor=ie}),a.addEventListener("click",()=>this.handleCancel());const m=e.triggerType!=="schedule";this.iframe=document.createElement("iframe"),this.iframe.src=s,this.iframe.setAttribute("allow","web-share; clipboard-write"),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",overflow:"hidden",transition:te}),m&&(r.appendChild(a),this.closeButton=a),r.appendChild(this.iframe);const u=document.createElement("div");this.footer=u,Object.assign(u.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:`${nt}px`,height:`${x}px`,flexShrink:"0",boxSizing:"border-box",padding:"0"});const g=document.createElement("span");g.textContent="Powered by",Object.assign(g.style,{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:"12px",lineHeight:"16px",color:"#ffffff"});const d=document.createElement("img");d.alt="Moment",d.src=pe,Object.assign(d.style,{display:"block",width:`${re}px`,height:`${(re/fe).toFixed(2)}px`}),u.appendChild(g),u.appendChild(d),this.wrapper=o,this.container=r,this.applyFrameLayout();const c=document.createElement("div");this.hairline=c,c.setAttribute("aria-hidden","true"),Object.assign(c.style,{position:"absolute",inset:"0",borderRadius:"inherit",boxShadow:`inset 0 0 0 1px ${rt}`,pointerEvents:"none",zIndex:"2"}),o.appendChild(r),o.appendChild(u),o.appendChild(c),this.overlay.appendChild(o),this.feedback=ke(this.overlay,o),document.body.appendChild(this.overlay),this.revealTimer=setTimeout(()=>this.reveal(),Ke),this.viewportResizeHandler=()=>this.applyFrameLayout(),window.addEventListener("resize",this.viewportResizeHandler);const h=()=>r.querySelectorAll(Ze),l=p=>{if(p.key!=="Tab")return;const y=h(),b=y[0],A=y[y.length-1],T=document.activeElement;p.shiftKey&&(T===b||T===r)?(p.preventDefault(),A.focus()):!p.shiftKey&&T===A&&(p.preventDefault(),b.focus())};r.addEventListener("keydown",l);const f=p=>{const y=document.createElement("span");return y.tabIndex=0,Object.assign(y.style,{position:"fixed",opacity:"0"}),y.addEventListener("focus",()=>{const b=h();b[p==="first"?0:b.length-1].focus()}),y};r.before(f("last")),r.after(f("first"));const C=document.documentElement.clientWidth;this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.didManageBodyOverflow=!0;const E=document.documentElement.clientWidth-C;if(E>0){this.previousBodyPaddingRight=document.body.style.paddingRight;const p=Number.parseFloat(getComputedStyle(document.body).paddingRight)||0;document.body.style.paddingRight=`${p+E}px`,this.didManageBodyPadding=!0}this.setupMessageListener(),this.overlay._escHandler=n,this.overlay._focusTrapHandler=l}reveal(){this.revealed||!this.overlay||(this.revealTimer&&clearTimeout(this.revealTimer),this.revealTimer=null,this.revealed=!0,this.overlay.style.visibility="",this.applyFrameLayout(),this.container?.focus())}applyFrameLayout(){if(!this.overlay||!this.wrapper||!this.container||!this.iframe)return;Object.assign(this.wrapper.style,this.currentLayout().wrapper);const e=this.currentLayout();Object.assign(this.overlay.style,e.overlay),Object.assign(this.wrapper.style,e.wrapperMaterial),Object.assign(this.container.style,e.container),Object.assign(this.container.style,e.card),Object.assign(this.iframe.style,e.iframe);const t=this.footer?.style.display!=="none";if(this.footer&&this.revealed&&t!==e.showFooter){const o=this.iframe.offsetHeight;this.iframe.style.transition="none",this.iframe.style.height=`${o+(t?x:-x)}px`,this.iframe.offsetHeight,this.iframe.style.transition=te}this.footer&&(this.footer.style.display=e.showFooter?"flex":"none"),this.hairline&&(this.hairline.style.display=e.material==="solid"?"":"none"),this.wrapper.classList.toggle(R,e.isTray&&this.revealed);const s=Number.parseFloat(this.iframe.style.height),n=this.covering()?e.iframeMaxHeight:this.lastRequestedHeight!==null?se(this.lastRequestedHeight,e.iframeMaxHeight):Number.isNaN(s)?e.iframeOpeningHeight:Math.min(s,e.iframeMaxHeight);this.iframe.style.height=`${n}px`}covering(){return this.coverAsked&&this.design==="v2"}currentLayout(){if(this.covering())return Je(window.innerWidth,window.innerHeight);const e=this.wrapper&&Number.parseFloat(getComputedStyle(this.wrapper).paddingBottom)||0;return Qe(window.innerWidth,window.innerHeight,this.cardRadius,this.design,e,this.surface)}buildIframeUrl(e,t){return Me(this.liveBaseUrl,e,void 0,t)}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 s=t;this.emitAnalytics("oauth.start",{provider:s.provider,teamSlug:s.teamSlug}),this.handleOAuthStart(s);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.resize"){const s=typeof t.height=="number"?t.height:0;if(s>0&&this.iframe){if(this.lastRequestedHeight=s,this.covering())return;const{iframeMaxHeight:n}=this.currentLayout();this.iframe.style.height=`${se(s,n)}px`}return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.theme"){const s=it(t);s.design&&s.design!==this.design&&(this.design=s.design,this.applyFrameLayout()),s.cardRadius!==void 0&&(this.cardRadius=s.cardRadius,this.applyFrameLayout()),s.hideCloseButton&&this.closeButton&&(document.activeElement===this.closeButton&&this.container?.focus(),this.closeButton.remove()),s.surface!==void 0&&(this.surface=s.surface,this.applyFrameLayout()),s.dismissByEmbed&&(this.dismissByEmbed=!0),s.backByEmbed&&(this.backByEmbed=!0),this.reveal(),this.backByEmbed&&!this.historyToken&&this.pushHistoryLevel();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.open.url"){const{url:s}=t;if(Fe(s)){const n=Pe(window.open(s,"_blank"));n==="blocked"&&this.emitAnalytics("open.url.blocked",{}),this.sendOpenUrlStatus(n,s)}else this.sendOpenUrlStatus("blocked",typeof s=="string"?s:"");return}if(t.source==="moment-live-embed"&&(t.type==="moment.embed.dismiss.ack"||t.type==="moment.embed.back.ack")){this.clearDismissAckTimer();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.history.push"){this.historyToken&&this.pushHistoryLevel();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.presentation"){const{presentation:s}=t;if(s!=="cover"&&s!=="sheet"||!this.iframe)return;const n=this.covering();if(this.coverAsked=s==="cover",this.covering()===n)return;const o=[this.iframe,this.wrapper,this.container].filter(a=>a!==null),r=o.map(a=>a.style.transition);for(const a of o)a.style.transition="none";this.applyFrameLayout(),this.iframe.offsetHeight,o.forEach((a,m)=>{a.style.transition=r[m]});return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.celebrate"){this.feedback?.celebrate();return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.toast"){const{text:s,variant:n}=t;typeof s=="string"&&s.trim()!==""&&this.feedback?.toast(s,n);return}if(t.source==="moment-live-embed"&&t.type==="moment.embed.result"){const s=t;this.handleResult(s)}}},window.addEventListener("message",this.messageHandler)}handleOAuthStart(e){this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.popupBridge=new Oe({liveBaseUrl:this.liveBaseUrl,liveOrigin:this.liveOrigin,iframeWindow:this.iframe?.contentWindow??null,campaignId:this.activeCampaignId,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)}sendOpenUrlStatus(e,t){const s=this.iframe?.contentWindow;if(!s)return;const n={source:"moment-sdk",type:"moment.embed.open.url.status",status:e,url:t};s.postMessage(n,this.liveOrigin)}handleResult(e){e.result!=="cancelled"&&(e.keepOpen===!0&&e.triggerType!=="schedule"&&(this.closeReported=!0),e.result==="success"||e.result==="partial"?(this.emitAnalytics("subscribe.success",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onSuccess?.(e)):e.result==="error"&&(this.emitAnalytics("subscribe.error",{provider:e.provider,triggerType:e.triggerType,momentIds:e.momentIds}),this.opts.onError?.(e)),this.opts.onClose?.(e),this.emitAnalytics("embed.close"),et(e)&&(this.closeTimer=setTimeout(()=>this.cleanup(),1500)))}requestDismiss(e=!1){const t=this.iframe?.contentWindow;if(!(e?this.backByEmbed:this.dismissByEmbed)||this.design!=="v2"||!t){this.handleCancel();return}const s={source:"moment-sdk",type:e?"moment.sdk.back":"moment.sdk.dismiss"};t.postMessage(s,this.liveOrigin),this.dismissAckTimer||(this.dismissAckTimer=setTimeout(()=>this.handleCancel(),Ye))}pushHistoryLevel(){const e=this.historyToken??`${Date.now()}.${Math.random()}`,t=history.state!==null&&typeof history.state=="object"?history.state:{},s=this.historyLevel+1;try{history.pushState({...t,[ne]:{token:e,level:s}},""),this.historyToken=e,this.historyLevel=s}catch{}}currentHistoryLevel(){const e=history.state?.[ne];return e?.token===this.historyToken&&typeof e.level=="number"?e.level:-1}onPopState=()=>{if(!this.historyToken)return;const e=this.currentHistoryLevel(),t=e<this.historyLevel;this.historyLevel=e,t&&this.requestDismiss(!0)};onBeforeUnload=()=>{this.pageUnloading=!0};clearDismissAckTimer(){this.dismissAckTimer&&clearTimeout(this.dismissAckTimer),this.dismissAckTimer=null}handleCancel(){if(!this.closeReported){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(!0)}cleanup(e=!1){const t=e&&this.design==="v2"&&this.revealed&&!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;this.closeTimer&&(clearTimeout(this.closeTimer),this.closeTimer=null),this.revealTimer&&(clearTimeout(this.revealTimer),this.revealTimer=null),this.clearDismissAckTimer(),this.revealed=!1,this.popupBridge&&(this.popupBridge.cleanup(),this.popupBridge=null),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.feedback?.destroy(),this.feedback=null,this.closeReported=!1,window.removeEventListener("popstate",this.onPopState),window.removeEventListener("beforeunload",this.onBeforeUnload);const s=this.historyToken?this.currentHistoryLevel():-1;if(s>=0&&!this.pageUnloading&&history.go(-(s+1)),this.historyToken=null,this.historyLevel=-1,this.pageUnloading=!1,this.design="v1",this.surface=I,this.dismissByEmbed=!1,this.backByEmbed=!1,this.coverAsked=!1,this.lastRequestedHeight=null,this.footer=null,this.hairline=null,this.viewportResizeHandler&&(window.removeEventListener("resize",this.viewportResizeHandler),this.viewportResizeHandler=null),this.overlay){const{_escHandler:n,_focusTrapHandler:o}=this.overlay;n&&document.removeEventListener("keydown",n);const r=this.overlay.firstElementChild;if(r&&o&&r.removeEventListener("keydown",o),t){const a=this.overlay;a.style.pointerEvents="none",a.style.width=`${document.documentElement.clientWidth}px`,a.classList.add(L);const m=setTimeout(()=>a.remove(),ze);a.addEventListener("animationend",()=>{clearTimeout(m),a.remove()},{once:!0})}else this.overlay.remove();this.overlay=null}this.iframe=null,this.wrapper=null,this.container=null,this.closeButton=null,this.activePayload=null,this.activeCampaignId=void 0,this.cardRadius=k,this.didManageBodyOverflow&&(document.body.style.overflow=this.previousBodyOverflow,this.didManageBodyOverflow=!1),this.didManageBodyPadding&&(document.body.style.paddingRight=this.previousBodyPaddingRight,this.didManageBodyPadding=!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 ae(i){const e=document.createElement("button");return e.type="button",e.classList.add("moment-sync-trigger"),i.className&&i.className.split(" ").forEach(t=>{t&&e.classList.add(t)}),e.setAttribute("data-moment-team-slug",i.teamSlug),i.momentSlug&&e.setAttribute("data-moment-slug",i.momentSlug),i.listSlug&&e.setAttribute("data-moment-list-slug",i.listSlug),i.triggerType&&e.setAttribute("data-moment-trigger-type",i.triggerType),i.ids?.length&&e.setAttribute("data-moment-ids",i.ids.join(",")),i.playlistSlugs?.length&&e.setAttribute("data-moment-playlist-slugs",i.playlistSlugs.join(",")),i.calendar&&e.setAttribute("data-moment-calendar",i.calendar),i.apiSourceId&&e.setAttribute("data-api-source-id",i.apiSourceId),i.externalEventId&&e.setAttribute("data-external-event-id",i.externalEventId),i.externalEventIdPrefix&&e.setAttribute("data-external-event-id-prefix",i.externalEventIdPrefix),e.textContent=i.label??"Add to Calendar",e}if(typeof window<"u"){const i=window;i.MomentSdk=oe,i.createMomentButton=ae}O.MomentSdk=oe,O.createMomentButton=ae,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})})(this.MomentSdk=this.MomentSdk||{});
|
package/dist/moment-sdk.mjs
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
const F = "moment_sync", P = "moment_campaign";
|
|
2
|
-
const
|
|
3
|
-
function
|
|
2
|
+
const he = /^(?:schedule|(moment|list):([a-z0-9-]+)|playlist:([a-z0-9-]+(?:,[a-z0-9-]+)*))$/, pe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
3
|
+
function fe(i, e) {
|
|
4
4
|
if (!e) return null;
|
|
5
5
|
const t = new URL(i), s = t.searchParams.get(F);
|
|
6
6
|
if (s === null || s.length > 200) return null;
|
|
7
|
-
const n =
|
|
7
|
+
const n = he.exec(s);
|
|
8
8
|
if (!n) return null;
|
|
9
|
-
const [,
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
const
|
|
9
|
+
const [, o, r, a] = n;
|
|
10
|
+
let m;
|
|
11
|
+
o === "moment" ? m = { teamSlug: e, triggerType: "moment", momentSlug: r } : o === "list" ? m = { teamSlug: e, triggerType: "list", listSlug: r } : a ? m = { teamSlug: e, triggerType: "playlist", playlistSlugs: a.split(",") } : m = { teamSlug: e, triggerType: "schedule" };
|
|
12
|
+
const u = t.searchParams.get(P);
|
|
13
13
|
return t.search = t.search.slice(1).split("&").filter((g) => {
|
|
14
14
|
const d = g.split("=", 1)[0];
|
|
15
15
|
return d !== F && d !== P;
|
|
16
16
|
}).join("&"), {
|
|
17
|
-
payload:
|
|
18
|
-
...
|
|
17
|
+
payload: m,
|
|
18
|
+
...u && pe.test(u) ? { campaignId: u } : {},
|
|
19
19
|
cleanUrl: t.href
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
let D = !1;
|
|
23
|
-
function
|
|
23
|
+
function ge() {
|
|
24
24
|
return D ? !1 : (D = !0, !0);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Ce(i, e) {
|
|
27
27
|
i.body ? e() : i.addEventListener("DOMContentLoaded", e, { once: !0 });
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const ye = "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", be = 120.52 / 21.28, ve = 4e3, Te = 80, N = ["#f04a34", "#041abe", "#041139", "#1cd4ed", "#b8e070"], we = 260, U = { x: 0.5, y: 0.7 }, xe = [
|
|
30
30
|
{ share: 0.25, spread: 26, velocity: 55, decay: 0.91, scalar: 1 },
|
|
31
31
|
{ share: 0.2, spread: 60, velocity: 45, decay: 0.91, scalar: 1 },
|
|
32
32
|
{ share: 0.35, spread: 100, velocity: 45, decay: 0.91, scalar: 0.8 },
|
|
33
33
|
{ share: 0.1, spread: 120, velocity: 25, decay: 0.92, scalar: 1.2 },
|
|
34
34
|
{ share: 0.1, spread: 120, velocity: 45, decay: 0.91, scalar: 1 }
|
|
35
|
-
],
|
|
36
|
-
success: { fill: "#1c1d22", glyph: "#fafafc", path:
|
|
37
|
-
info: { fill: "#146eaa", glyph: "#ffffff", path:
|
|
38
|
-
warning: { fill: "#aa4e19", glyph: "#ffffff", path:
|
|
39
|
-
error: { fill: "#c62734", glyph: "#ffffff", path:
|
|
40
|
-
},
|
|
35
|
+
], Ee = 3, Ae = 0.2, Se = 200, Le = 1e3 / 60, Ie = 4, ke = 0.75, Me = "M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z", _e = "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z", Oe = "M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z", Re = "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z", $ = {
|
|
36
|
+
success: { fill: "#1c1d22", glyph: "#fafafc", path: Me },
|
|
37
|
+
info: { fill: "#146eaa", glyph: "#ffffff", path: _e },
|
|
38
|
+
warning: { fill: "#aa4e19", glyph: "#ffffff", path: Oe },
|
|
39
|
+
error: { fill: "#c62734", glyph: "#ffffff", path: Re }
|
|
40
|
+
}, He = {
|
|
41
41
|
position: "absolute",
|
|
42
42
|
top: "calc(56px + env(safe-area-inset-top, 0px))",
|
|
43
43
|
left: "0",
|
|
@@ -60,7 +60,7 @@ const Ce = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox
|
|
|
60
60
|
lineHeight: "20px",
|
|
61
61
|
fontWeight: "400",
|
|
62
62
|
overflowWrap: "anywhere"
|
|
63
|
-
},
|
|
63
|
+
}, Be = {
|
|
64
64
|
display: "flex",
|
|
65
65
|
alignItems: "center",
|
|
66
66
|
justifyContent: "center",
|
|
@@ -69,7 +69,7 @@ const Ce = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox
|
|
|
69
69
|
height: "28px",
|
|
70
70
|
margin: "2px",
|
|
71
71
|
borderRadius: "50%"
|
|
72
|
-
},
|
|
72
|
+
}, Fe = {
|
|
73
73
|
position: "absolute",
|
|
74
74
|
width: "1px",
|
|
75
75
|
height: "1px",
|
|
@@ -80,12 +80,12 @@ const Ce = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox
|
|
|
80
80
|
clipPath: "inset(50%)",
|
|
81
81
|
whiteSpace: "nowrap"
|
|
82
82
|
};
|
|
83
|
-
function
|
|
83
|
+
function x(i, e) {
|
|
84
84
|
const t = document.createElement(i);
|
|
85
85
|
return Object.assign(t.style, e), t;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
const t =
|
|
87
|
+
function Pe(i, e) {
|
|
88
|
+
const t = x("div", {
|
|
89
89
|
position: "absolute",
|
|
90
90
|
inset: "0",
|
|
91
91
|
overflow: "hidden",
|
|
@@ -93,12 +93,12 @@ function Fe(i, e) {
|
|
|
93
93
|
zIndex: "1"
|
|
94
94
|
});
|
|
95
95
|
t.setAttribute("aria-hidden", "true"), i.appendChild(t);
|
|
96
|
-
const s =
|
|
96
|
+
const s = x("span", Fe);
|
|
97
97
|
s.setAttribute("role", "status"), (e.querySelector('[role="dialog"]') ?? e).appendChild(s);
|
|
98
|
-
let n = null,
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
},
|
|
98
|
+
let n = null, o = null, r = null, a = null;
|
|
99
|
+
const m = () => {
|
|
100
|
+
o && clearTimeout(o), o = null, a?.(), a = null, n?.remove(), n = null, s.textContent = "";
|
|
101
|
+
}, u = (c) => {
|
|
102
102
|
const h = () => {
|
|
103
103
|
a = null, s.textContent = c;
|
|
104
104
|
};
|
|
@@ -109,10 +109,10 @@ function Fe(i, e) {
|
|
|
109
109
|
const l = setTimeout(h, 0);
|
|
110
110
|
a = () => clearTimeout(l);
|
|
111
111
|
}
|
|
112
|
-
}, g = ({ spread: c, velocity: h, decay: l, scalar: f }, C,
|
|
113
|
-
const y = (4 + Math.random() * 6) * f, b =
|
|
112
|
+
}, g = ({ spread: c, velocity: h, decay: l, scalar: f }, C, w, p) => {
|
|
113
|
+
const y = (4 + Math.random() * 6) * f, b = x("span", {
|
|
114
114
|
position: "absolute",
|
|
115
|
-
left: `${
|
|
115
|
+
left: `${w}px`,
|
|
116
116
|
top: `${p}px`,
|
|
117
117
|
width: `${y}px`,
|
|
118
118
|
height: `${y * (0.5 + Math.random())}px`,
|
|
@@ -120,45 +120,45 @@ function Fe(i, e) {
|
|
|
120
120
|
backgroundColor: C
|
|
121
121
|
});
|
|
122
122
|
b.setAttribute("data-moment-confetti", ""), t.appendChild(b);
|
|
123
|
-
const
|
|
123
|
+
const E = -Math.PI / 2 + (Math.random() - 0.5) * c * Math.PI / 180;
|
|
124
124
|
let T = h * (0.5 + Math.random());
|
|
125
|
-
const oe = (Math.random() * 2 - 1) *
|
|
125
|
+
const oe = (Math.random() * 2 - 1) * Ae, ae = (0.25 + Math.random() * 0.5) * Math.PI, le = Math.random() < 0.5 ? 0.1 : -0.1, de = Math.random() * 10, ce = Math.min(0.11, 0.05 + Math.random() * 0.1), L = [{ tick: 0, x: 0, y: 0 }];
|
|
126
126
|
let [v, O, I] = [0, 0, 0];
|
|
127
127
|
do
|
|
128
|
-
O += Math.cos(
|
|
129
|
-
while (v <
|
|
128
|
+
O += Math.cos(E) * T + oe, I += Math.sin(E) * T + Ee, T *= l, v++, v % Ie === 0 && L.push({ tick: v, x: O, y: I });
|
|
129
|
+
while (v < Se || I < 1);
|
|
130
130
|
L.at(-1).tick !== v && L.push({ tick: v, x: O, y: I }), b.animate(
|
|
131
131
|
L.map((A) => {
|
|
132
|
-
const B = A.tick / v,
|
|
132
|
+
const B = A.tick / v, me = (ae + A.tick * le) * 180 / Math.PI, ue = Math.cos(de + A.tick * ce);
|
|
133
133
|
return {
|
|
134
134
|
offset: B,
|
|
135
|
-
transform: `translate(${A.x.toFixed(1)}px, ${A.y.toFixed(1)}px) rotate(${
|
|
136
|
-
opacity: Math.min(1, (1 - B) / (1 -
|
|
135
|
+
transform: `translate(${A.x.toFixed(1)}px, ${A.y.toFixed(1)}px) rotate(${me.toFixed(0)}deg) scaleY(${ue.toFixed(2)})`,
|
|
136
|
+
opacity: Math.min(1, (1 - B) / (1 - ke))
|
|
137
137
|
};
|
|
138
138
|
}),
|
|
139
|
-
{ duration: v *
|
|
139
|
+
{ duration: v * Le, fill: "both" }
|
|
140
140
|
).onfinish = () => b.remove();
|
|
141
141
|
}, d = () => {
|
|
142
|
-
|
|
142
|
+
r = null;
|
|
143
143
|
const c = window.innerWidth * U.x, h = window.innerHeight * U.y;
|
|
144
144
|
let l = 0;
|
|
145
|
-
for (const f of
|
|
146
|
-
for (let C = Math.floor(
|
|
145
|
+
for (const f of xe)
|
|
146
|
+
for (let C = Math.floor(Te * f.share); C > 0; C--)
|
|
147
147
|
g(f, N[l++ % N.length], c, h);
|
|
148
148
|
};
|
|
149
149
|
return {
|
|
150
150
|
celebrate() {
|
|
151
|
-
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof t.animate != "function" ||
|
|
151
|
+
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || typeof t.animate != "function" || r || (r = setTimeout(d, we));
|
|
152
152
|
},
|
|
153
153
|
toast(c, h = "success") {
|
|
154
|
-
|
|
155
|
-
const l = $[Object.hasOwn($, h) ? h : "success"], f =
|
|
154
|
+
m();
|
|
155
|
+
const l = $[Object.hasOwn($, h) ? h : "success"], f = x("span", { ...Be, backgroundColor: l.fill, color: l.glyph });
|
|
156
156
|
f.innerHTML = `<svg width="16" height="16" viewBox="0 0 256 256" fill="currentColor" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="${l.path}"/></svg>`;
|
|
157
|
-
const C =
|
|
158
|
-
C.textContent = c, n =
|
|
157
|
+
const C = x("span", { minWidth: "0" });
|
|
158
|
+
C.textContent = c, n = x("div", He), n.setAttribute("data-moment-toast", ""), n.appendChild(f), n.appendChild(C), t.appendChild(n), u(c), o = setTimeout(m, ve);
|
|
159
159
|
},
|
|
160
160
|
destroy() {
|
|
161
|
-
|
|
161
|
+
r && clearTimeout(r), r = null, m(), t.remove(), s.remove();
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
}
|
|
@@ -169,16 +169,16 @@ function Q() {
|
|
|
169
169
|
'[MomentSdk] This page has an opaque origin ("null"), so Moment Live cannot message it and calendar sync will not work. Serve the page over http(s), and give a sandboxed iframe allow-same-origin.'
|
|
170
170
|
), e;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function De(i, e, t = Q(), s) {
|
|
173
173
|
if (e.triggerType === "schedule") {
|
|
174
|
-
const
|
|
175
|
-
return
|
|
174
|
+
const o = new URLSearchParams();
|
|
175
|
+
return o.set("teamSlug", e.teamSlug), o.set("returnOrigin", t), o.set("embed", "1"), o.set("sdkVersion", "0.9.0-dev.54"), s && (o.set("entry", "link"), s.campaignId && o.set("campaignId", s.campaignId)), `${i}/en/embed/schedule?${o.toString()}`;
|
|
176
176
|
}
|
|
177
177
|
const n = new URLSearchParams();
|
|
178
|
-
return n.set("teamSlug", e.teamSlug), e.momentSlug && n.set("momentSlug", e.momentSlug), e.listSlug && n.set("listSlug", e.listSlug), n.set("triggerType", e.triggerType), e.ids?.length && n.set("ids", e.ids.join(",")), e.playlistSlugs?.length && n.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && n.set("calendar", e.calendar), e.apiSourceId && n.set("subscriptionId", e.apiSourceId), e.externalEventId && n.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && n.set("externalIdPrefix", e.externalEventIdPrefix), n.set("returnOrigin", t), n.set("embed", "1"), n.set("sdkVersion", "0.9.0-dev.
|
|
178
|
+
return n.set("teamSlug", e.teamSlug), e.momentSlug && n.set("momentSlug", e.momentSlug), e.listSlug && n.set("listSlug", e.listSlug), n.set("triggerType", e.triggerType), e.ids?.length && n.set("ids", e.ids.join(",")), e.playlistSlugs?.length && n.set("playlistSlugs", e.playlistSlugs.join(",")), e.calendar && n.set("calendar", e.calendar), e.apiSourceId && n.set("subscriptionId", e.apiSourceId), e.externalEventId && n.set("externalId", e.externalEventId), e.externalEventIdPrefix && !e.externalEventId && n.set("externalIdPrefix", e.externalEventIdPrefix), n.set("returnOrigin", t), n.set("embed", "1"), n.set("sdkVersion", "0.9.0-dev.54"), s && (n.set("entry", "link"), s.campaignId && n.set("campaignId", s.campaignId)), `${i}/en/embed/sync?${n.toString()}`;
|
|
179
179
|
}
|
|
180
|
-
const W = 500, j = 700,
|
|
181
|
-
class
|
|
180
|
+
const W = 500, j = 700, Ne = 500;
|
|
181
|
+
class Ue {
|
|
182
182
|
popup = null;
|
|
183
183
|
pollTimer = null;
|
|
184
184
|
messageHandler = null;
|
|
@@ -201,10 +201,10 @@ class Ne {
|
|
|
201
201
|
this.sendStatusToIframe("popup-blocked"), this.opts.onPopupBlocked();
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
this.sendStatusToIframe("popup-opened"), this.startPolling(), this.messageHandler = (
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
!
|
|
204
|
+
this.sendStatusToIframe("popup-opened"), this.startPolling(), this.messageHandler = (o) => {
|
|
205
|
+
if (o.origin !== this.opts.liveOrigin || o.source !== this.popup) return;
|
|
206
|
+
const r = o.data;
|
|
207
|
+
!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), e.intent !== "connect" && this.opts.onResult(r), this.cleanup());
|
|
208
208
|
}, window.addEventListener("message", this.messageHandler);
|
|
209
209
|
}
|
|
210
210
|
/**
|
|
@@ -219,13 +219,13 @@ class Ne {
|
|
|
219
219
|
this.popup = null;
|
|
220
220
|
}
|
|
221
221
|
buildPopupUrl(e) {
|
|
222
|
-
const t =
|
|
222
|
+
const t = $e(e, Q());
|
|
223
223
|
return this.opts.campaignId && t.set("campaignId", this.opts.campaignId), `${this.opts.liveBaseUrl}/en/embed/oauth-popup?${t.toString()}`;
|
|
224
224
|
}
|
|
225
225
|
startPolling() {
|
|
226
226
|
this.pollTimer = setInterval(() => {
|
|
227
227
|
(!this.popup || this.popup.closed) && (this.pollTimer && (clearInterval(this.pollTimer), this.pollTimer = null), this.resultReceived || (this.sendStatusToIframe("popup-closed"), this.opts.onPopupClosed()), this.cleanup());
|
|
228
|
-
},
|
|
228
|
+
}, Ne);
|
|
229
229
|
}
|
|
230
230
|
sendStatusToIframe(e) {
|
|
231
231
|
if (!this.opts.iframeWindow) return;
|
|
@@ -237,7 +237,7 @@ class Ne {
|
|
|
237
237
|
this.opts.iframeWindow.postMessage(t, this.opts.liveOrigin);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function $e(i, e) {
|
|
241
241
|
const t = new URLSearchParams({
|
|
242
242
|
provider: i.provider,
|
|
243
243
|
teamSlug: i.teamSlug,
|
|
@@ -251,11 +251,11 @@ function Ue(i, e) {
|
|
|
251
251
|
schedulePlaylistIds: i.schedulePlaylistIds,
|
|
252
252
|
scheduleListIds: i.scheduleListIds
|
|
253
253
|
};
|
|
254
|
-
for (const [n,
|
|
255
|
-
|
|
254
|
+
for (const [n, o] of Object.entries(s))
|
|
255
|
+
o?.length && t.set(n, o.join(","));
|
|
256
256
|
return i.addons?.length && t.set("addons", i.addons.join(",")), i.intent === "connect" && t.set("intent", "connect"), t;
|
|
257
257
|
}
|
|
258
|
-
const G = "moment-sdk-styles", J = "moment-sdk-close", H = "moment-sdk-tray", k = "moment-sdk-closing",
|
|
258
|
+
const G = "moment-sdk-styles", J = "moment-sdk-close", H = "moment-sdk-tray", k = "moment-sdk-closing", We = `
|
|
259
259
|
:where(.moment-sync-trigger) {
|
|
260
260
|
background-color: #1c1917;
|
|
261
261
|
color: #ffffff;
|
|
@@ -324,35 +324,35 @@ const G = "moment-sdk-styles", J = "moment-sdk-close", H = "moment-sdk-tray", k
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
`;
|
|
327
|
-
function
|
|
327
|
+
function je() {
|
|
328
328
|
if (typeof document > "u" || document.getElementById(G)) return;
|
|
329
329
|
const i = document.createElement("style");
|
|
330
|
-
i.id = G, i.textContent =
|
|
330
|
+
i.id = G, i.textContent = We, document.head.appendChild(i);
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function Ge(i) {
|
|
333
333
|
return typeof i == "string" && i.startsWith("webcal://");
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function Ke(i) {
|
|
336
336
|
return !i || i.closed ? "blocked" : "opened";
|
|
337
337
|
}
|
|
338
|
-
const
|
|
339
|
-
backgroundColor:
|
|
338
|
+
const ee = 1024, R = 600, Ye = 400, ze = 40, K = 80, Y = 90, Ve = 420, Ze = 520, z = 48, te = "#0d0d0d", M = "#121316", qe = {
|
|
339
|
+
backgroundColor: te,
|
|
340
340
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
341
341
|
backdropFilter: "none",
|
|
342
342
|
webkitBackdropFilter: "none"
|
|
343
|
-
},
|
|
343
|
+
}, ie = "inset 0 0.5px 0.75px rgb(255 255 255 / 0.6)", Xe = "inset 0 -0.5px 0.75px rgb(255 255 255 / 0.3)", se = [
|
|
344
344
|
"0 0 0 0.5px #9c9c9c",
|
|
345
345
|
"0 4px 8px 0 #0000001f",
|
|
346
346
|
"0 12px 32px 0 #00000047"
|
|
347
|
-
],
|
|
347
|
+
], ne = {
|
|
348
348
|
backgroundColor: "rgb(19 19 19 / 0.812)",
|
|
349
349
|
backdropFilter: "blur(14px)",
|
|
350
350
|
webkitBackdropFilter: "blur(14px)",
|
|
351
|
-
boxShadow: [
|
|
351
|
+
boxShadow: [ie, Xe, ...se].join(", ")
|
|
352
352
|
}, Qe = {
|
|
353
|
-
...
|
|
354
|
-
boxShadow: [
|
|
355
|
-
}, S = 32, V = "height 0.25s cubic-bezier(0.32, 0.72, 0, 1)", Je = 2e3, et = 500, tt = 400, _ = 12, it = "2147483647", st = 'button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])',
|
|
353
|
+
...ne,
|
|
354
|
+
boxShadow: [ie, ...se].join(", ")
|
|
355
|
+
}, S = 32, V = "height 0.25s cubic-bezier(0.32, 0.72, 0, 1)", Je = 2e3, et = 500, tt = 400, _ = 12, it = "2147483647", st = 'button, [href], input, select, textarea, iframe, [tabindex]:not([tabindex="-1"])', re = "#38393B", nt = "#4B4B4E", rt = {
|
|
356
356
|
position: "absolute",
|
|
357
357
|
top: "16px",
|
|
358
358
|
right: "16px",
|
|
@@ -362,23 +362,23 @@ const Ke = 1024, R = 600, Ye = 400, ze = 40, K = 80, Y = 90, Ve = 420, Ze = 520,
|
|
|
362
362
|
padding: "0",
|
|
363
363
|
border: "none",
|
|
364
364
|
borderRadius: "50%",
|
|
365
|
-
backgroundColor:
|
|
365
|
+
backgroundColor: re,
|
|
366
366
|
color: "#F5F5F5",
|
|
367
367
|
cursor: "pointer",
|
|
368
368
|
display: "flex",
|
|
369
369
|
alignItems: "center",
|
|
370
370
|
justifyContent: "center"
|
|
371
371
|
};
|
|
372
|
-
function
|
|
373
|
-
const
|
|
374
|
-
showFooter: !
|
|
375
|
-
material:
|
|
376
|
-
wrapperMaterial:
|
|
377
|
-
card: { backgroundColor:
|
|
378
|
-
iframe:
|
|
379
|
-
}, g =
|
|
372
|
+
function ot(i, e, t = _, s = "v1", n = 0, o = M) {
|
|
373
|
+
const r = s === "v2", a = i < ee, u = {
|
|
374
|
+
showFooter: !r,
|
|
375
|
+
material: r ? "glass" : "solid",
|
|
376
|
+
wrapperMaterial: r ? a ? Qe : ne : qe,
|
|
377
|
+
card: { backgroundColor: r ? "transparent" : o },
|
|
378
|
+
iframe: r ? { background: "transparent", colorScheme: "dark" } : { background: "", colorScheme: "" }
|
|
379
|
+
}, g = r ? "rgba(0, 0, 0, 0.4)" : "rgba(0, 0, 0, 0.5)", d = r ? _ : t, c = `${d}px ${d}px 0px 0px`;
|
|
380
380
|
if (a) {
|
|
381
|
-
const l =
|
|
381
|
+
const l = r ? e - z - n : Math.floor(e * Y / 100) - S;
|
|
382
382
|
return {
|
|
383
383
|
isTray: !0,
|
|
384
384
|
// No blur: iPhone Safari tints its status bar and toolbar from the page, and over a blurred
|
|
@@ -400,12 +400,12 @@ function rt(i, e, t = _, s = "v1", n = 0, r = M) {
|
|
|
400
400
|
container: {
|
|
401
401
|
// ponytail: no vh fallback for browsers without dvh (Safari < 15.4); the iframe cap still
|
|
402
402
|
// holds there.
|
|
403
|
-
maxHeight:
|
|
403
|
+
maxHeight: r ? `calc(100dvh - ${z}px - env(safe-area-inset-bottom, 0px))` : `calc(${Y}dvh - ${S}px)`,
|
|
404
404
|
borderRadius: c
|
|
405
405
|
},
|
|
406
406
|
iframeMaxHeight: l,
|
|
407
407
|
iframeOpeningHeight: Math.min(Ve, l),
|
|
408
|
-
...
|
|
408
|
+
...u
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
411
|
const h = e - K;
|
|
@@ -415,7 +415,7 @@ function rt(i, e, t = _, s = "v1", n = 0, r = M) {
|
|
|
415
415
|
alignItems: "center",
|
|
416
416
|
padding: "16px",
|
|
417
417
|
// Roman (Q1): under v2 the page behind stays sharp; only the dim layer covers it.
|
|
418
|
-
backdropFilter:
|
|
418
|
+
backdropFilter: r ? "none" : "blur(2px)",
|
|
419
419
|
backgroundColor: g
|
|
420
420
|
},
|
|
421
421
|
wrapper: {
|
|
@@ -430,26 +430,52 @@ function rt(i, e, t = _, s = "v1", n = 0, r = M) {
|
|
|
430
430
|
},
|
|
431
431
|
iframeMaxHeight: h,
|
|
432
432
|
iframeOpeningHeight: Math.min(Ze, h),
|
|
433
|
-
...
|
|
433
|
+
...u
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function at(i, e) {
|
|
437
|
+
return {
|
|
438
|
+
// Unchanged, so the tray's slide-up class stays as it is and doesn't replay.
|
|
439
|
+
isTray: i < ee,
|
|
440
|
+
overlay: {
|
|
441
|
+
alignItems: "stretch",
|
|
442
|
+
padding: "0",
|
|
443
|
+
backdropFilter: "none",
|
|
444
|
+
backgroundColor: "transparent"
|
|
445
|
+
},
|
|
446
|
+
wrapper: { maxWidth: "none", minWidth: "0", borderRadius: "0px", paddingBottom: "0px" },
|
|
447
|
+
container: { maxHeight: "none", borderRadius: "0px" },
|
|
448
|
+
iframeMaxHeight: e,
|
|
449
|
+
iframeOpeningHeight: e,
|
|
450
|
+
showFooter: !1,
|
|
451
|
+
material: "clear",
|
|
452
|
+
wrapperMaterial: {
|
|
453
|
+
backgroundColor: "transparent",
|
|
454
|
+
boxShadow: "none",
|
|
455
|
+
backdropFilter: "none",
|
|
456
|
+
webkitBackdropFilter: "none"
|
|
457
|
+
},
|
|
458
|
+
card: { backgroundColor: "transparent" },
|
|
459
|
+
iframe: { background: "transparent", colorScheme: "dark" }
|
|
434
460
|
};
|
|
435
461
|
}
|
|
436
462
|
function Z(i, e) {
|
|
437
463
|
return Math.min(i, e);
|
|
438
464
|
}
|
|
439
|
-
function
|
|
465
|
+
function lt(i) {
|
|
440
466
|
return i.triggerType !== "schedule" && i.keepOpen !== !0;
|
|
441
467
|
}
|
|
442
|
-
const
|
|
443
|
-
function
|
|
468
|
+
const dt = 32;
|
|
469
|
+
function ct(i) {
|
|
444
470
|
const e = {
|
|
445
471
|
hideCloseButton: i.closeControl === "embed",
|
|
446
472
|
dismissByEmbed: i.dismiss === "embed",
|
|
447
473
|
backByEmbed: i.back === "embed"
|
|
448
474
|
};
|
|
449
|
-
return typeof i.borderRadius == "number" && Number.isFinite(i.borderRadius) && (e.cardRadius = Math.max(0, Math.min(i.borderRadius,
|
|
475
|
+
return typeof i.borderRadius == "number" && Number.isFinite(i.borderRadius) && (e.cardRadius = Math.max(0, Math.min(i.borderRadius, dt))), typeof i.surface == "string" && i.surface !== "" && (e.surface = i.surface), (i.design === "v1" || i.design === "v2") && (e.design = i.design), e;
|
|
450
476
|
}
|
|
451
|
-
const
|
|
452
|
-
class
|
|
477
|
+
const mt = ".moment-sync-trigger", q = "momentSdkSheet", ut = 6, X = 60, ht = "rgba(255, 255, 255, 0.216)", pt = "https://live.dev.momentco.ai";
|
|
478
|
+
class ft {
|
|
453
479
|
opts;
|
|
454
480
|
liveBaseUrl;
|
|
455
481
|
liveOrigin;
|
|
@@ -488,6 +514,8 @@ class pt {
|
|
|
488
514
|
dismissByEmbed = !1;
|
|
489
515
|
/** The embed sent `back: 'embed'` this open; it counts only while the frame is v2. */
|
|
490
516
|
backByEmbed = !1;
|
|
517
|
+
/** The embed asked to cover the page (`moment.embed.presentation`); it counts only while v2. */
|
|
518
|
+
coverAsked = !1;
|
|
491
519
|
/** This open's mark on the history entries it holds for the phone's back; null until it holds one. */
|
|
492
520
|
historyToken = null;
|
|
493
521
|
/** The level of the sheet's entry the page is on: 0 is the sheet's own, -1 the page's. */
|
|
@@ -505,15 +533,15 @@ class pt {
|
|
|
505
533
|
closeReported = !1;
|
|
506
534
|
constructor(e) {
|
|
507
535
|
this.opts = {
|
|
508
|
-
triggerSelector:
|
|
536
|
+
triggerSelector: mt,
|
|
509
537
|
...e
|
|
510
|
-
}, this.liveBaseUrl =
|
|
538
|
+
}, this.liveBaseUrl = pt;
|
|
511
539
|
try {
|
|
512
540
|
this.liveOrigin = new URL(this.liveBaseUrl).origin;
|
|
513
541
|
} catch {
|
|
514
542
|
throw new Error(`[MomentSdk] Invalid VITE_LIVE_BASE_URL: "${this.liveBaseUrl}"`);
|
|
515
543
|
}
|
|
516
|
-
|
|
544
|
+
je(), this.bindTriggers(), this.emitAnalytics("embed.init"), this.opts.autoOpen && this.autoOpenFromUrl(this.opts.autoOpen.teamSlug);
|
|
517
545
|
}
|
|
518
546
|
/**
|
|
519
547
|
* Programmatically open the sync modal.
|
|
@@ -558,17 +586,17 @@ class pt {
|
|
|
558
586
|
* params from the address bar so a reload doesn't reopen it.
|
|
559
587
|
*/
|
|
560
588
|
autoOpenFromUrl(e) {
|
|
561
|
-
if (!
|
|
562
|
-
const t =
|
|
563
|
-
t &&
|
|
589
|
+
if (!ge()) return;
|
|
590
|
+
const t = fe(window.location.href, e);
|
|
591
|
+
t && Ce(document, () => {
|
|
564
592
|
this.openWith(t.payload, t), history.replaceState(history.state, "", t.cleanUrl);
|
|
565
593
|
});
|
|
566
594
|
}
|
|
567
595
|
// ── Private: trigger binding ──────────────────────────────────────
|
|
568
596
|
bindTriggers() {
|
|
569
597
|
document.querySelectorAll(this.opts.triggerSelector).forEach((t) => {
|
|
570
|
-
const s = (
|
|
571
|
-
|
|
598
|
+
const s = (o) => {
|
|
599
|
+
o.preventDefault(), this.handleTriggerClick(t);
|
|
572
600
|
}, n = this.boundClickHandlers.get(t);
|
|
573
601
|
n && t.removeEventListener("click", n), t.addEventListener("click", s), this.boundClickHandlers.set(t, s);
|
|
574
602
|
});
|
|
@@ -579,13 +607,13 @@ class pt {
|
|
|
579
607
|
}), this.boundClickHandlers.clear();
|
|
580
608
|
}
|
|
581
609
|
handleTriggerClick(e) {
|
|
582
|
-
const t = e.getAttribute("data-moment-team-slug") ?? "", s = e.getAttribute("data-moment-slug") ?? void 0, n = e.getAttribute("data-moment-list-slug") ?? void 0,
|
|
583
|
-
let
|
|
584
|
-
|
|
610
|
+
const t = e.getAttribute("data-moment-team-slug") ?? "", s = e.getAttribute("data-moment-slug") ?? void 0, n = e.getAttribute("data-moment-list-slug") ?? void 0, o = e.getAttribute("data-moment-trigger-type");
|
|
611
|
+
let r = "moment";
|
|
612
|
+
o != null && o !== "" && (o === "moment" || o === "list" || o === "team" || o === "brand-playlist" || o === "playlist" || o === "schedule" ? r = o : console.warn(
|
|
585
613
|
"[MomentSdk] Invalid data-moment-trigger-type, falling back to 'moment':",
|
|
586
|
-
|
|
614
|
+
o
|
|
587
615
|
));
|
|
588
|
-
const a = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "",
|
|
616
|
+
const a = e.getAttribute("data-moment-ids") ?? e.getAttribute("data-moment-game-id") ?? "", m = a ? a.split(",").filter(Boolean) : [], u = e.getAttribute("data-moment-playlist-slugs") ?? "", g = u ? u.split(",").map((w) => w.trim()).filter(Boolean) : [], d = e.getAttribute("data-moment-calendar");
|
|
589
617
|
let c;
|
|
590
618
|
d != null && d !== "" && (d === "google" || d === "outlook" ? c = d : console.warn("[MomentSdk] Invalid data-moment-calendar, ignoring value:", d));
|
|
591
619
|
const h = e.getAttribute("data-api-source-id") ?? void 0, l = e.getAttribute("data-external-event-id") ?? void 0, f = e.getAttribute("data-external-event-id-prefix") ?? void 0;
|
|
@@ -595,17 +623,17 @@ class pt {
|
|
|
595
623
|
console.warn("[MomentSdk] Missing data-moment-team-slug on trigger element");
|
|
596
624
|
return;
|
|
597
625
|
}
|
|
598
|
-
const C =
|
|
626
|
+
const C = r === "team" || r === "brand-playlist" || r === "playlist" || r === "schedule";
|
|
599
627
|
this.emitAnalytics("embed.trigger.click", {
|
|
600
628
|
teamSlug: t,
|
|
601
|
-
triggerType:
|
|
602
|
-
momentIds: C ? [] :
|
|
629
|
+
triggerType: r,
|
|
630
|
+
momentIds: C ? [] : m
|
|
603
631
|
}), this.open({
|
|
604
632
|
teamSlug: t,
|
|
605
633
|
momentSlug: s,
|
|
606
634
|
listSlug: n,
|
|
607
|
-
triggerType:
|
|
608
|
-
ids:
|
|
635
|
+
triggerType: r,
|
|
636
|
+
ids: m,
|
|
609
637
|
playlistSlugs: g,
|
|
610
638
|
calendar: c ?? void 0,
|
|
611
639
|
apiSourceId: h,
|
|
@@ -650,8 +678,8 @@ class pt {
|
|
|
650
678
|
p.key === "Escape" && this.requestDismiss();
|
|
651
679
|
};
|
|
652
680
|
document.addEventListener("keydown", n), window.addEventListener("popstate", this.onPopState), window.addEventListener("beforeunload", this.onBeforeUnload);
|
|
653
|
-
const
|
|
654
|
-
Object.assign(
|
|
681
|
+
const o = document.createElement("div");
|
|
682
|
+
Object.assign(o.style, {
|
|
655
683
|
position: "relative",
|
|
656
684
|
width: "100%",
|
|
657
685
|
// Ease radius changes so a brand's configured radius (arriving via
|
|
@@ -659,13 +687,13 @@ class pt {
|
|
|
659
687
|
// smoothly instead of snapping.
|
|
660
688
|
transition: "border-radius 0.3s ease",
|
|
661
689
|
overflow: "hidden",
|
|
662
|
-
backgroundColor:
|
|
690
|
+
backgroundColor: te,
|
|
663
691
|
boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
|
|
664
692
|
display: "flex",
|
|
665
693
|
flexDirection: "column"
|
|
666
694
|
});
|
|
667
|
-
const
|
|
668
|
-
|
|
695
|
+
const r = document.createElement("div");
|
|
696
|
+
r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-label", "Calendar sync modal"), r.tabIndex = -1, Object.assign(r.style, {
|
|
669
697
|
position: "relative",
|
|
670
698
|
width: "100%",
|
|
671
699
|
transition: "border-radius 0.3s ease",
|
|
@@ -681,12 +709,12 @@ class pt {
|
|
|
681
709
|
outline: "none"
|
|
682
710
|
});
|
|
683
711
|
const a = document.createElement("button");
|
|
684
|
-
a.type = "button", a.className = J, a.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.75 5.25 5.25 18.75M5.25 5.25l13.5 13.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', a.setAttribute("aria-label", "Close"), Object.assign(a.style,
|
|
712
|
+
a.type = "button", a.className = J, a.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M18.75 5.25 5.25 18.75M5.25 5.25l13.5 13.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', a.setAttribute("aria-label", "Close"), Object.assign(a.style, rt), a.addEventListener("mouseenter", () => {
|
|
685
713
|
a.style.backgroundColor = nt;
|
|
686
714
|
}), a.addEventListener("mouseleave", () => {
|
|
687
|
-
a.style.backgroundColor =
|
|
715
|
+
a.style.backgroundColor = re;
|
|
688
716
|
}), a.addEventListener("click", () => this.handleCancel());
|
|
689
|
-
const
|
|
717
|
+
const m = e.triggerType !== "schedule";
|
|
690
718
|
this.iframe = document.createElement("iframe"), this.iframe.src = s, this.iframe.setAttribute("allow", "web-share; clipboard-write"), this.iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-forms"), this.iframe.setAttribute("scrolling", "no"), Object.assign(this.iframe.style, {
|
|
691
719
|
width: "100%",
|
|
692
720
|
border: "none",
|
|
@@ -696,9 +724,9 @@ class pt {
|
|
|
696
724
|
// guess to the embed's real content height. Eased and a little slower so
|
|
697
725
|
// that reads as the sheet settling rather than a snap.
|
|
698
726
|
transition: V
|
|
699
|
-
}),
|
|
700
|
-
const
|
|
701
|
-
this.footer =
|
|
727
|
+
}), m && (r.appendChild(a), this.closeButton = a), r.appendChild(this.iframe);
|
|
728
|
+
const u = document.createElement("div");
|
|
729
|
+
this.footer = u, Object.assign(u.style, {
|
|
702
730
|
display: "flex",
|
|
703
731
|
alignItems: "center",
|
|
704
732
|
justifyContent: "center",
|
|
@@ -719,28 +747,28 @@ class pt {
|
|
|
719
747
|
color: "#ffffff"
|
|
720
748
|
});
|
|
721
749
|
const d = document.createElement("img");
|
|
722
|
-
d.alt = "Moment", d.src =
|
|
750
|
+
d.alt = "Moment", d.src = ye, Object.assign(d.style, {
|
|
723
751
|
display: "block",
|
|
724
752
|
// Both dimensions are explicit so the tray has no reflow to do, even if
|
|
725
753
|
// the image is ever swapped for one that has to decode.
|
|
726
754
|
width: `${X}px`,
|
|
727
|
-
height: `${(X /
|
|
728
|
-
}),
|
|
755
|
+
height: `${(X / be).toFixed(2)}px`
|
|
756
|
+
}), u.appendChild(g), u.appendChild(d), this.wrapper = o, this.container = r, this.applyFrameLayout();
|
|
729
757
|
const c = document.createElement("div");
|
|
730
758
|
this.hairline = c, c.setAttribute("aria-hidden", "true"), Object.assign(c.style, {
|
|
731
759
|
position: "absolute",
|
|
732
760
|
inset: "0",
|
|
733
761
|
borderRadius: "inherit",
|
|
734
|
-
boxShadow: `inset 0 0 0 1px ${
|
|
762
|
+
boxShadow: `inset 0 0 0 1px ${ht}`,
|
|
735
763
|
pointerEvents: "none",
|
|
736
764
|
zIndex: "2"
|
|
737
|
-
}),
|
|
738
|
-
const h = () =>
|
|
765
|
+
}), o.appendChild(r), o.appendChild(u), o.appendChild(c), this.overlay.appendChild(o), this.feedback = Pe(this.overlay, o), document.body.appendChild(this.overlay), this.revealTimer = setTimeout(() => this.reveal(), Je), this.viewportResizeHandler = () => this.applyFrameLayout(), window.addEventListener("resize", this.viewportResizeHandler);
|
|
766
|
+
const h = () => r.querySelectorAll(st), l = (p) => {
|
|
739
767
|
if (p.key !== "Tab") return;
|
|
740
|
-
const y = h(), b = y[0],
|
|
741
|
-
p.shiftKey && (T === b || T ===
|
|
768
|
+
const y = h(), b = y[0], E = y[y.length - 1], T = document.activeElement;
|
|
769
|
+
p.shiftKey && (T === b || T === r) ? (p.preventDefault(), E.focus()) : !p.shiftKey && T === E && (p.preventDefault(), b.focus());
|
|
742
770
|
};
|
|
743
|
-
|
|
771
|
+
r.addEventListener("keydown", l);
|
|
744
772
|
const f = (p) => {
|
|
745
773
|
const y = document.createElement("span");
|
|
746
774
|
return y.tabIndex = 0, Object.assign(y.style, { position: "fixed", opacity: "0" }), y.addEventListener("focus", () => {
|
|
@@ -748,14 +776,14 @@ class pt {
|
|
|
748
776
|
b[p === "first" ? 0 : b.length - 1].focus();
|
|
749
777
|
}), y;
|
|
750
778
|
};
|
|
751
|
-
|
|
779
|
+
r.before(f("last")), r.after(f("first"));
|
|
752
780
|
const C = document.documentElement.clientWidth;
|
|
753
781
|
this.previousBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this.didManageBodyOverflow = !0;
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
782
|
+
const w = document.documentElement.clientWidth - C;
|
|
783
|
+
if (w > 0) {
|
|
756
784
|
this.previousBodyPaddingRight = document.body.style.paddingRight;
|
|
757
785
|
const p = Number.parseFloat(getComputedStyle(document.body).paddingRight) || 0;
|
|
758
|
-
document.body.style.paddingRight = `${p +
|
|
786
|
+
document.body.style.paddingRight = `${p + w}px`, this.didManageBodyPadding = !0;
|
|
759
787
|
}
|
|
760
788
|
this.setupMessageListener(), this.overlay._escHandler = n, this.overlay._focusTrapHandler = l;
|
|
761
789
|
}
|
|
@@ -774,20 +802,25 @@ class pt {
|
|
|
774
802
|
Object.assign(this.overlay.style, e.overlay), Object.assign(this.wrapper.style, e.wrapperMaterial), Object.assign(this.container.style, e.container), Object.assign(this.container.style, e.card), Object.assign(this.iframe.style, e.iframe);
|
|
775
803
|
const t = this.footer?.style.display !== "none";
|
|
776
804
|
if (this.footer && this.revealed && t !== e.showFooter) {
|
|
777
|
-
const
|
|
778
|
-
this.iframe.style.transition = "none", this.iframe.style.height = `${
|
|
805
|
+
const o = this.iframe.offsetHeight;
|
|
806
|
+
this.iframe.style.transition = "none", this.iframe.style.height = `${o + (t ? S : -S)}px`, this.iframe.offsetHeight, this.iframe.style.transition = V;
|
|
779
807
|
}
|
|
780
|
-
this.footer && (this.footer.style.display = e.showFooter ? "flex" : "none"), this.hairline && (this.hairline.style.display = e.material === "
|
|
781
|
-
const s = Number.parseFloat(this.iframe.style.height), n = this.lastRequestedHeight !== null ? Z(this.lastRequestedHeight, e.iframeMaxHeight) : Number.isNaN(s) ? e.iframeOpeningHeight : Math.min(s, e.iframeMaxHeight);
|
|
808
|
+
this.footer && (this.footer.style.display = e.showFooter ? "flex" : "none"), this.hairline && (this.hairline.style.display = e.material === "solid" ? "" : "none"), this.wrapper.classList.toggle(H, e.isTray && this.revealed);
|
|
809
|
+
const s = Number.parseFloat(this.iframe.style.height), n = this.covering() ? e.iframeMaxHeight : this.lastRequestedHeight !== null ? Z(this.lastRequestedHeight, e.iframeMaxHeight) : Number.isNaN(s) ? e.iframeOpeningHeight : Math.min(s, e.iframeMaxHeight);
|
|
782
810
|
this.iframe.style.height = `${n}px`;
|
|
783
811
|
}
|
|
812
|
+
/** The embed covers the page: it asked to, and the frame is v2. */
|
|
813
|
+
covering() {
|
|
814
|
+
return this.coverAsked && this.design === "v2";
|
|
815
|
+
}
|
|
784
816
|
/**
|
|
785
817
|
* The frame for the current viewport, design, radius and card colour. The bottom inset is the
|
|
786
818
|
* tray's `env(safe-area-inset-bottom)` padding as the browser resolved it, 0 without one.
|
|
787
819
|
*/
|
|
788
820
|
currentLayout() {
|
|
821
|
+
if (this.covering()) return at(window.innerWidth, window.innerHeight);
|
|
789
822
|
const e = this.wrapper && Number.parseFloat(getComputedStyle(this.wrapper).paddingBottom) || 0;
|
|
790
|
-
return
|
|
823
|
+
return ot(
|
|
791
824
|
window.innerWidth,
|
|
792
825
|
window.innerHeight,
|
|
793
826
|
this.cardRadius,
|
|
@@ -797,7 +830,7 @@ class pt {
|
|
|
797
830
|
);
|
|
798
831
|
}
|
|
799
832
|
buildIframeUrl(e, t) {
|
|
800
|
-
return
|
|
833
|
+
return De(this.liveBaseUrl, e, void 0, t);
|
|
801
834
|
}
|
|
802
835
|
// ── Private: message handling ─────────────────────────────────────
|
|
803
836
|
setupMessageListener() {
|
|
@@ -816,21 +849,21 @@ class pt {
|
|
|
816
849
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.resize") {
|
|
817
850
|
const s = typeof t.height == "number" ? t.height : 0;
|
|
818
851
|
if (s > 0 && this.iframe) {
|
|
819
|
-
this.lastRequestedHeight = s;
|
|
852
|
+
if (this.lastRequestedHeight = s, this.covering()) return;
|
|
820
853
|
const { iframeMaxHeight: n } = this.currentLayout();
|
|
821
854
|
this.iframe.style.height = `${Z(s, n)}px`;
|
|
822
855
|
}
|
|
823
856
|
return;
|
|
824
857
|
}
|
|
825
858
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.theme") {
|
|
826
|
-
const s =
|
|
859
|
+
const s = ct(t);
|
|
827
860
|
s.design && s.design !== this.design && (this.design = s.design, this.applyFrameLayout()), s.cardRadius !== void 0 && (this.cardRadius = s.cardRadius, this.applyFrameLayout()), s.hideCloseButton && this.closeButton && (document.activeElement === this.closeButton && this.container?.focus(), this.closeButton.remove()), s.surface !== void 0 && (this.surface = s.surface, this.applyFrameLayout()), s.dismissByEmbed && (this.dismissByEmbed = !0), s.backByEmbed && (this.backByEmbed = !0), this.reveal(), this.backByEmbed && !this.historyToken && this.pushHistoryLevel();
|
|
828
861
|
return;
|
|
829
862
|
}
|
|
830
863
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.open.url") {
|
|
831
864
|
const { url: s } = t;
|
|
832
|
-
if (
|
|
833
|
-
const n =
|
|
865
|
+
if (Ge(s)) {
|
|
866
|
+
const n = Ke(window.open(s, "_blank"));
|
|
834
867
|
n === "blocked" && this.emitAnalytics("open.url.blocked", {}), this.sendOpenUrlStatus(n, s);
|
|
835
868
|
} else
|
|
836
869
|
this.sendOpenUrlStatus("blocked", typeof s == "string" ? s : "");
|
|
@@ -848,6 +881,20 @@ class pt {
|
|
|
848
881
|
this.handleCancel();
|
|
849
882
|
return;
|
|
850
883
|
}
|
|
884
|
+
if (t.source === "moment-live-embed" && t.type === "moment.embed.presentation") {
|
|
885
|
+
const { presentation: s } = t;
|
|
886
|
+
if (s !== "cover" && s !== "sheet" || !this.iframe) return;
|
|
887
|
+
const n = this.covering();
|
|
888
|
+
if (this.coverAsked = s === "cover", this.covering() === n) return;
|
|
889
|
+
const o = [this.iframe, this.wrapper, this.container].filter(
|
|
890
|
+
(a) => a !== null
|
|
891
|
+
), r = o.map((a) => a.style.transition);
|
|
892
|
+
for (const a of o) a.style.transition = "none";
|
|
893
|
+
this.applyFrameLayout(), this.iframe.offsetHeight, o.forEach((a, m) => {
|
|
894
|
+
a.style.transition = r[m];
|
|
895
|
+
});
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
851
898
|
if (t.source === "moment-live-embed" && t.type === "moment.embed.celebrate") {
|
|
852
899
|
this.feedback?.celebrate();
|
|
853
900
|
return;
|
|
@@ -865,7 +912,7 @@ class pt {
|
|
|
865
912
|
}, window.addEventListener("message", this.messageHandler);
|
|
866
913
|
}
|
|
867
914
|
handleOAuthStart(e) {
|
|
868
|
-
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new
|
|
915
|
+
this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.popupBridge = new Ue({
|
|
869
916
|
liveBaseUrl: this.liveBaseUrl,
|
|
870
917
|
liveOrigin: this.liveOrigin,
|
|
871
918
|
iframeWindow: this.iframe?.contentWindow ?? null,
|
|
@@ -909,7 +956,7 @@ class pt {
|
|
|
909
956
|
provider: e.provider,
|
|
910
957
|
triggerType: e.triggerType,
|
|
911
958
|
momentIds: e.momentIds
|
|
912
|
-
}), this.opts.onError?.(e)), this.opts.onClose?.(e), this.emitAnalytics("embed.close"),
|
|
959
|
+
}), this.opts.onError?.(e)), this.opts.onClose?.(e), this.emitAnalytics("embed.close"), lt(e) && (this.closeTimer = setTimeout(() => this.cleanup(), 1500)));
|
|
913
960
|
}
|
|
914
961
|
/**
|
|
915
962
|
* A tap outside the sheet or Escape on the page, or with `back` the phone's back. A v2 sheet that
|
|
@@ -984,18 +1031,18 @@ class pt {
|
|
|
984
1031
|
const t = e && this.design === "v2" && this.revealed && !window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
985
1032
|
this.closeTimer && (clearTimeout(this.closeTimer), this.closeTimer = null), this.revealTimer && (clearTimeout(this.revealTimer), this.revealTimer = null), this.clearDismissAckTimer(), this.revealed = !1, this.popupBridge && (this.popupBridge.cleanup(), this.popupBridge = null), this.messageHandler && (window.removeEventListener("message", this.messageHandler), this.messageHandler = null), this.feedback?.destroy(), this.feedback = null, this.closeReported = !1, window.removeEventListener("popstate", this.onPopState), window.removeEventListener("beforeunload", this.onBeforeUnload);
|
|
986
1033
|
const s = this.historyToken ? this.currentHistoryLevel() : -1;
|
|
987
|
-
if (s >= 0 && !this.pageUnloading && history.go(-(s + 1)), this.historyToken = null, this.historyLevel = -1, this.pageUnloading = !1, this.design = "v1", this.surface = M, this.dismissByEmbed = !1, this.backByEmbed = !1, this.lastRequestedHeight = null, this.footer = null, this.hairline = null, this.viewportResizeHandler && (window.removeEventListener("resize", this.viewportResizeHandler), this.viewportResizeHandler = null), this.overlay) {
|
|
988
|
-
const { _escHandler: n, _focusTrapHandler:
|
|
1034
|
+
if (s >= 0 && !this.pageUnloading && history.go(-(s + 1)), this.historyToken = null, this.historyLevel = -1, this.pageUnloading = !1, this.design = "v1", this.surface = M, this.dismissByEmbed = !1, this.backByEmbed = !1, this.coverAsked = !1, this.lastRequestedHeight = null, this.footer = null, this.hairline = null, this.viewportResizeHandler && (window.removeEventListener("resize", this.viewportResizeHandler), this.viewportResizeHandler = null), this.overlay) {
|
|
1035
|
+
const { _escHandler: n, _focusTrapHandler: o } = this.overlay;
|
|
989
1036
|
n && document.removeEventListener("keydown", n);
|
|
990
|
-
const
|
|
991
|
-
if (
|
|
1037
|
+
const r = this.overlay.firstElementChild;
|
|
1038
|
+
if (r && o && r.removeEventListener("keydown", o), t) {
|
|
992
1039
|
const a = this.overlay;
|
|
993
1040
|
a.style.pointerEvents = "none", a.style.width = `${document.documentElement.clientWidth}px`, a.classList.add(k);
|
|
994
|
-
const
|
|
1041
|
+
const m = setTimeout(() => a.remove(), tt);
|
|
995
1042
|
a.addEventListener(
|
|
996
1043
|
"animationend",
|
|
997
1044
|
() => {
|
|
998
|
-
clearTimeout(
|
|
1045
|
+
clearTimeout(m), a.remove();
|
|
999
1046
|
},
|
|
1000
1047
|
{ once: !0 }
|
|
1001
1048
|
);
|
|
@@ -1014,7 +1061,7 @@ class pt {
|
|
|
1014
1061
|
});
|
|
1015
1062
|
}
|
|
1016
1063
|
}
|
|
1017
|
-
function
|
|
1064
|
+
function gt(i) {
|
|
1018
1065
|
const e = document.createElement("button");
|
|
1019
1066
|
return e.type = "button", e.classList.add("moment-sync-trigger"), i.className && i.className.split(" ").forEach((t) => {
|
|
1020
1067
|
t && e.classList.add(t);
|
|
@@ -1022,9 +1069,9 @@ function ft(i) {
|
|
|
1022
1069
|
}
|
|
1023
1070
|
if (typeof window < "u") {
|
|
1024
1071
|
const i = window;
|
|
1025
|
-
i.MomentSdk =
|
|
1072
|
+
i.MomentSdk = ft, i.createMomentButton = gt;
|
|
1026
1073
|
}
|
|
1027
1074
|
export {
|
|
1028
|
-
|
|
1029
|
-
|
|
1075
|
+
ft as MomentSdk,
|
|
1076
|
+
gt as createMomentButton
|
|
1030
1077
|
};
|
|
@@ -6,11 +6,17 @@ type HeightWrite = {
|
|
|
6
6
|
height: string;
|
|
7
7
|
transition: string | undefined;
|
|
8
8
|
};
|
|
9
|
+
type RadiusWrite = {
|
|
10
|
+
borderRadius: string;
|
|
11
|
+
transition: string | undefined;
|
|
12
|
+
};
|
|
9
13
|
/** The parts of a DOM element the SDK touches, recorded so the tests can read them back. */
|
|
10
14
|
export declare class FakeElement {
|
|
11
15
|
readonly tagName: string;
|
|
12
16
|
/** Every `style.height` write, in order. */
|
|
13
17
|
readonly heightWrites: HeightWrite[];
|
|
18
|
+
/** Every `style.borderRadius` write, in order. */
|
|
19
|
+
readonly radiusWrites: RadiusWrite[];
|
|
14
20
|
readonly style: Record<string, string>;
|
|
15
21
|
/**
|
|
16
22
|
* Where the browser draws the element's height while a height transition is under way. Unset,
|
|
@@ -100,8 +100,11 @@ export interface FrameLayout {
|
|
|
100
100
|
iframeOpeningHeight: number;
|
|
101
101
|
/** Whether the SDK draws its "Powered by" strip. v2 sheets draw their own footer. */
|
|
102
102
|
showFooter: boolean;
|
|
103
|
-
/**
|
|
104
|
-
|
|
103
|
+
/**
|
|
104
|
+
* `glass` for v2: the frame is translucent and blurs the host page. `clear` while the embed
|
|
105
|
+
* covers the page: nothing of the frame is drawn.
|
|
106
|
+
*/
|
|
107
|
+
material: 'solid' | 'glass' | 'clear';
|
|
105
108
|
/** Inline styles for the frame: glass for v2, the solid 0.8.0 frame otherwise. */
|
|
106
109
|
wrapperMaterial: Readonly<Record<string, string>>;
|
|
107
110
|
/** The card's colour: transparent in v2, so the glass shows; the embed's surface otherwise. */
|
|
@@ -124,6 +127,13 @@ export interface FrameLayout {
|
|
|
124
127
|
* embed last sent.
|
|
125
128
|
*/
|
|
126
129
|
export declare function frameLayout(viewportWidth: number, viewportHeight: number, cardRadius?: number, design?: FrameDesign, bottomInset?: number, surface?: string): FrameLayout;
|
|
130
|
+
/**
|
|
131
|
+
* The frame while a v2 embed covers the page (`moment.embed.presentation`): the iframe fills the
|
|
132
|
+
* viewport edge to edge, and no dim, glass, radius, shadow or strip is drawn, so the embed paints
|
|
133
|
+
* the whole screen (Roman's sync progress, Figma 746:30223). `iframeMaxHeight` is the viewport's
|
|
134
|
+
* height, which the iframe takes whatever height the embed last asked for.
|
|
135
|
+
*/
|
|
136
|
+
export declare function coverLayout(viewportWidth: number, viewportHeight: number): FrameLayout;
|
|
127
137
|
/**
|
|
128
138
|
* The iframe's height after the viewport changes: what the embed last asked for, capped to the new
|
|
129
139
|
* frame. Starting from the request (not the current height) lets a full-height sheet grow back
|
|
@@ -39,6 +39,8 @@ export declare class MomentSdk {
|
|
|
39
39
|
private dismissByEmbed;
|
|
40
40
|
/** The embed sent `back: 'embed'` this open; it counts only while the frame is v2. */
|
|
41
41
|
private backByEmbed;
|
|
42
|
+
/** The embed asked to cover the page (`moment.embed.presentation`); it counts only while v2. */
|
|
43
|
+
private coverAsked;
|
|
42
44
|
/** This open's mark on the history entries it holds for the phone's back; null until it holds one. */
|
|
43
45
|
private historyToken;
|
|
44
46
|
/** The level of the sheet's entry the page is on: 0 is the sheet's own, -1 the page's. */
|
|
@@ -91,6 +93,8 @@ export declare class MomentSdk {
|
|
|
91
93
|
* radius.
|
|
92
94
|
*/
|
|
93
95
|
private applyFrameLayout;
|
|
96
|
+
/** The embed covers the page: it asked to, and the frame is v2. */
|
|
97
|
+
private covering;
|
|
94
98
|
/**
|
|
95
99
|
* The frame for the current viewport, design, radius and card colour. The bottom inset is the
|
|
96
100
|
* tray's `env(safe-area-inset-bottom)` padding as the browser resolved it, 0 without one.
|
|
@@ -326,6 +326,18 @@ export interface MomentToastPayload {
|
|
|
326
326
|
variant?: MomentToastVariant;
|
|
327
327
|
text: string;
|
|
328
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Iframe → Parent (0.9.0+): `cover` makes a v2 frame cover the whole page, so the embed paints the
|
|
331
|
+
* screen itself (Roman's sync progress): the iframe fills the viewport with no dim, glass, radius
|
|
332
|
+
* or shadow. `sheet` gives the sheet back, at the height the embed last asked for. Both switch at
|
|
333
|
+
* once, without the height's ease. A cover counts only while the frame is v2, and any other value
|
|
334
|
+
* is ignored. Older SDKs ignore the message, so the embed keeps its screen inside the sheet there.
|
|
335
|
+
*/
|
|
336
|
+
export interface MomentEmbedPresentationPayload {
|
|
337
|
+
source: 'moment-live-embed';
|
|
338
|
+
type: 'moment.embed.presentation';
|
|
339
|
+
presentation: 'cover' | 'sheet';
|
|
340
|
+
}
|
|
329
341
|
export type MomentAnalyticsEventName = 'embed.init' | 'embed.trigger.click' | 'embed.open' | 'oauth.start' | 'oauth.popup.blocked' | 'oauth.popup.closed' | 'open.url.blocked' | 'subscribe.success' | 'subscribe.error' | 'embed.close';
|
|
330
342
|
export interface MomentAnalyticsEvent {
|
|
331
343
|
event: MomentAnalyticsEventName;
|
|
@@ -337,4 +349,4 @@ export interface MomentAnalyticsEvent {
|
|
|
337
349
|
triggerSource?: 'url';
|
|
338
350
|
timestamp: number;
|
|
339
351
|
}
|
|
340
|
-
export type MomentPostMessage = MomentOAuthStartPayload | MomentOAuthStatusPayload | MomentResultPayload | MomentOpenUrlPayload | MomentOpenUrlStatusPayload | MomentClosePayload | MomentThemePayload | MomentSdkDismissPayload | MomentEmbedDismissAckPayload | MomentSdkBackPayload | MomentEmbedBackAckPayload | MomentEmbedHistoryPushPayload | MomentCelebratePayload | MomentToastPayload;
|
|
352
|
+
export type MomentPostMessage = MomentOAuthStartPayload | MomentOAuthStatusPayload | MomentResultPayload | MomentOpenUrlPayload | MomentOpenUrlStatusPayload | MomentClosePayload | MomentThemePayload | MomentSdkDismissPayload | MomentEmbedDismissAckPayload | MomentSdkBackPayload | MomentEmbedBackAckPayload | MomentEmbedHistoryPushPayload | MomentCelebratePayload | MomentToastPayload | MomentEmbedPresentationPayload;
|
package/package.json
CHANGED