@teleporthq/teleport-shared 0.43.67 → 0.43.69

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.
Files changed (107) hide show
  1. package/__tests__/_helpers/embed-runtime-emitter.ts +197 -0
  2. package/__tests__/utils/discount-engine.ts +1548 -0
  3. package/__tests__/utils/product-options.ts +2458 -0
  4. package/__tests__/utils/rich-text-embeds-runtime-module.ts +34 -0
  5. package/__tests__/utils/subscription-access.ts +37 -0
  6. package/dist/cjs/index.d.ts +9 -1
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +17 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  11. package/dist/cjs/utils/cart-currency.d.ts +27 -0
  12. package/dist/cjs/utils/cart-currency.d.ts.map +1 -0
  13. package/dist/cjs/utils/cart-currency.js +31 -0
  14. package/dist/cjs/utils/cart-currency.js.map +1 -0
  15. package/dist/cjs/utils/cart-line-pricing.d.ts +25 -0
  16. package/dist/cjs/utils/cart-line-pricing.d.ts.map +1 -0
  17. package/dist/cjs/utils/cart-line-pricing.js +29 -0
  18. package/dist/cjs/utils/cart-line-pricing.js.map +1 -0
  19. package/dist/cjs/utils/discount-engine.d.ts +74 -0
  20. package/dist/cjs/utils/discount-engine.d.ts.map +1 -0
  21. package/dist/cjs/utils/discount-engine.js +435 -0
  22. package/dist/cjs/utils/discount-engine.js.map +1 -0
  23. package/dist/cjs/utils/product-options.d.ts +25 -0
  24. package/dist/cjs/utils/product-options.d.ts.map +1 -0
  25. package/dist/cjs/utils/product-options.js +1155 -0
  26. package/dist/cjs/utils/product-options.js.map +1 -0
  27. package/dist/cjs/utils/rich-text-embeds-codegen.d.ts +13 -0
  28. package/dist/cjs/utils/rich-text-embeds-codegen.d.ts.map +1 -1
  29. package/dist/cjs/utils/rich-text-embeds-codegen.js +15 -104
  30. package/dist/cjs/utils/rich-text-embeds-codegen.js.map +1 -1
  31. package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts +2 -0
  32. package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
  33. package/dist/cjs/utils/rich-text-embeds-runtime-source.js +409 -0
  34. package/dist/cjs/utils/rich-text-embeds-runtime-source.js.map +1 -0
  35. package/dist/cjs/utils/session-cookie-resolver.d.ts +85 -0
  36. package/dist/cjs/utils/session-cookie-resolver.d.ts.map +1 -0
  37. package/dist/cjs/utils/session-cookie-resolver.js +108 -0
  38. package/dist/cjs/utils/session-cookie-resolver.js.map +1 -0
  39. package/dist/cjs/utils/subscription-access.d.ts +36 -0
  40. package/dist/cjs/utils/subscription-access.d.ts.map +1 -0
  41. package/dist/cjs/utils/subscription-access.js +61 -0
  42. package/dist/cjs/utils/subscription-access.js.map +1 -0
  43. package/dist/cjs/utils/table-access.d.ts +114 -0
  44. package/dist/cjs/utils/table-access.d.ts.map +1 -0
  45. package/dist/cjs/utils/table-access.js +238 -0
  46. package/dist/cjs/utils/table-access.js.map +1 -0
  47. package/dist/cjs/utils/web-push.d.ts +43 -0
  48. package/dist/cjs/utils/web-push.d.ts.map +1 -0
  49. package/dist/cjs/utils/web-push.js +62 -0
  50. package/dist/cjs/utils/web-push.js.map +1 -0
  51. package/dist/esm/index.d.ts +9 -1
  52. package/dist/esm/index.d.ts.map +1 -1
  53. package/dist/esm/index.js +9 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  56. package/dist/esm/utils/cart-currency.d.ts +27 -0
  57. package/dist/esm/utils/cart-currency.d.ts.map +1 -0
  58. package/dist/esm/utils/cart-currency.js +27 -0
  59. package/dist/esm/utils/cart-currency.js.map +1 -0
  60. package/dist/esm/utils/cart-line-pricing.d.ts +25 -0
  61. package/dist/esm/utils/cart-line-pricing.d.ts.map +1 -0
  62. package/dist/esm/utils/cart-line-pricing.js +25 -0
  63. package/dist/esm/utils/cart-line-pricing.js.map +1 -0
  64. package/dist/esm/utils/discount-engine.d.ts +74 -0
  65. package/dist/esm/utils/discount-engine.d.ts.map +1 -0
  66. package/dist/esm/utils/discount-engine.js +431 -0
  67. package/dist/esm/utils/discount-engine.js.map +1 -0
  68. package/dist/esm/utils/product-options.d.ts +25 -0
  69. package/dist/esm/utils/product-options.d.ts.map +1 -0
  70. package/dist/esm/utils/product-options.js +1151 -0
  71. package/dist/esm/utils/product-options.js.map +1 -0
  72. package/dist/esm/utils/rich-text-embeds-codegen.d.ts +13 -0
  73. package/dist/esm/utils/rich-text-embeds-codegen.d.ts.map +1 -1
  74. package/dist/esm/utils/rich-text-embeds-codegen.js +16 -105
  75. package/dist/esm/utils/rich-text-embeds-codegen.js.map +1 -1
  76. package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts +2 -0
  77. package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
  78. package/dist/esm/utils/rich-text-embeds-runtime-source.js +406 -0
  79. package/dist/esm/utils/rich-text-embeds-runtime-source.js.map +1 -0
  80. package/dist/esm/utils/session-cookie-resolver.d.ts +85 -0
  81. package/dist/esm/utils/session-cookie-resolver.d.ts.map +1 -0
  82. package/dist/esm/utils/session-cookie-resolver.js +103 -0
  83. package/dist/esm/utils/session-cookie-resolver.js.map +1 -0
  84. package/dist/esm/utils/subscription-access.d.ts +36 -0
  85. package/dist/esm/utils/subscription-access.d.ts.map +1 -0
  86. package/dist/esm/utils/subscription-access.js +57 -0
  87. package/dist/esm/utils/subscription-access.js.map +1 -0
  88. package/dist/esm/utils/table-access.d.ts +114 -0
  89. package/dist/esm/utils/table-access.d.ts.map +1 -0
  90. package/dist/esm/utils/table-access.js +233 -0
  91. package/dist/esm/utils/table-access.js.map +1 -0
  92. package/dist/esm/utils/web-push.d.ts +43 -0
  93. package/dist/esm/utils/web-push.d.ts.map +1 -0
  94. package/dist/esm/utils/web-push.js +59 -0
  95. package/dist/esm/utils/web-push.js.map +1 -0
  96. package/package.json +3 -3
  97. package/src/index.ts +16 -0
  98. package/src/utils/cart-currency.ts +76 -0
  99. package/src/utils/cart-line-pricing.ts +151 -0
  100. package/src/utils/discount-engine.ts +437 -0
  101. package/src/utils/product-options.ts +1150 -0
  102. package/src/utils/rich-text-embeds-codegen.ts +16 -183
  103. package/src/utils/rich-text-embeds-runtime-source.ts +405 -0
  104. package/src/utils/session-cookie-resolver.ts +305 -0
  105. package/src/utils/subscription-access.ts +59 -0
  106. package/src/utils/table-access.ts +516 -0
  107. package/src/utils/web-push.ts +61 -0
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMBED_RUNTIME_MODULE_SOURCE = void 0;
4
+ // GENERATED from src/utils/rich-text-embeds.ts — do not edit by hand. Regenerate with
5
+ // UPDATE_EMBED_RUNTIME=1 npx jest packages/teleport-shared/__tests__/utils/rich-text-embeds-runtime-module.ts
6
+ // (see generateEmbedRuntimeModuleSource for why this is a string).
7
+ /* tslint:disable:no-invalid-template-strings -- the lines are JavaScript source */
8
+ exports.EMBED_RUNTIME_MODULE_SOURCE = [
9
+ '/**',
10
+ ' * Code embeds inside rich-text content — the shape the editor writes and the',
11
+ ' * page reads back. Generated from @teleporthq/teleport-shared; edit it there.',
12
+ ' *',
13
+ ' * An embed is stored inside the content HTML as a <figure class="tq-embed">.',
14
+ ' * Passive markup (a provider iframe) lives in the figure as real children, so',
15
+ ' * it renders server-side with no JavaScript. Markup that can execute — a',
16
+ ' * <script>, an on* handler, a javascript: URL — is base64-encoded onto the',
17
+ ' * element instead, and mounted at runtime inside a sandboxed iframe so it can',
18
+ ' * never reach this page.',
19
+ ' */',
20
+ '',
21
+ 'export var EMBED_CLASS_NAME = "tq-embed"',
22
+ '',
23
+ 'export var EMBED_FRAME_CLASS_NAME = "tq-embed-frame"',
24
+ '',
25
+ 'export var EMBED_CAPTION_CLASS_NAME = "tq-embed-caption"',
26
+ '',
27
+ 'export var EMBED_BLOT_NAME = "tq-embed"',
28
+ '',
29
+ 'export var EMBED_ATTR = {',
30
+ ' "MARKER": "data-tq-embed",',
31
+ ' "PROVIDER": "data-tq-embed-provider",',
32
+ ' "URL": "data-tq-embed-url",',
33
+ ' "MODE": "data-tq-embed-mode",',
34
+ ' "CODE": "data-tq-embed-code",',
35
+ ' "RATIO": "data-tq-embed-ratio",',
36
+ ' "WIDTH": "data-tq-embed-width",',
37
+ ' "ALIGN": "data-tq-embed-align",',
38
+ ' "CAPTION": "data-tq-embed-caption",',
39
+ ' "SANDBOX": "data-tq-embed-sandbox",',
40
+ ' "ACTIVATED": "data-tq-embed-activated",',
41
+ ' "PREVIEW": "data-tq-embed-preview"',
42
+ '}',
43
+ '',
44
+ 'export var EMBED_ALIGNMENTS = ["center","float-left","float-right"]',
45
+ '',
46
+ 'export var CUSTOM_EMBED_PROVIDER_ID = "custom"',
47
+ '',
48
+ 'export var GENERIC_EMBED_PROVIDER_ID = "iframe-url"',
49
+ '',
50
+ 'export var DEFAULT_EMBED_WIDTH = 100',
51
+ '',
52
+ 'export var DEFAULT_EMBED_ALIGN = "center"',
53
+ '',
54
+ 'export var DEFAULT_EMBED_SANDBOX_LEVEL = "strict"',
55
+ '',
56
+ 'export var WIDESCREEN_EMBED_RATIO = 56.25',
57
+ '',
58
+ 'export var EMBED_CAPTION_STYLE = "margin-top:8px;font-size:0.875em;line-height:1.5;opacity:0.75;text-align:center"',
59
+ '',
60
+ 'export var EMBED_PROVIDERS = [',
61
+ ' { id: "youtube", label: "YouTube", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.|m\\\\.)?youtube\\\\.com\\\\/watch\\\\?(?:[^#]*&)?v=([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/youtu\\\\.be\\\\/([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?youtube\\\\.com\\\\/shorts\\\\/([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?youtube(?:-nocookie)?\\\\.com\\\\/embed\\\\/([A-Za-z0-9_-]{6,})", "i")], template: "<iframe src=\\"https://www.youtube.com/embed/$1\\" title=\\"YouTube video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
62
+ ' { id: "vimeo", label: "Vimeo", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?vimeo\\\\.com\\\\/(\\\\d+)", "i"), new RegExp("^https?:\\\\/\\\\/player\\\\.vimeo\\\\.com\\\\/video\\\\/(\\\\d+)", "i")], template: "<iframe src=\\"https://player.vimeo.com/video/$1\\" title=\\"Vimeo video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
63
+ ' { id: "loom", label: "Loom", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?loom\\\\.com\\\\/(?:share|embed)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://www.loom.com/embed/$1\\" title=\\"Loom video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
64
+ ' { id: "dailymotion", label: "Dailymotion", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?dailymotion\\\\.com\\\\/video\\\\/([A-Za-z0-9]+)", "i"), new RegExp("^https?:\\\\/\\\\/dai\\\\.ly\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://www.dailymotion.com/embed/video/$1\\" title=\\"Dailymotion video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
65
+ ' { id: "spotify", label: "Spotify", patterns: [new RegExp("^https?:\\\\/\\\\/open\\\\.spotify\\\\.com\\\\/(?:embed\\\\/)?(track|album|playlist|episode|show|artist)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://open.spotify.com/embed/$1/$2\\" title=\\"Spotify player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:352px\\"></iframe>", ratio: null },',
66
+ ' { id: "soundcloud", label: "SoundCloud", patterns: [new RegExp("^https?:\\\\/\\\\/soundcloud\\\\.com\\\\/[^?#]+", "i")], template: "<iframe src=\\"https://w.soundcloud.com/player/?url=$E&&color=%23ff5500&auto_play=false&show_teaser=false\\" title=\\"SoundCloud player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:166px\\"></iframe>", ratio: null },',
67
+ ' { id: "apple-podcasts", label: "Apple Podcasts", patterns: [new RegExp("^https?:\\\\/\\\\/podcasts\\\\.apple\\\\.com\\\\/(.+)$", "i")], template: "<iframe src=\\"https://embed.podcasts.apple.com/$1\\" title=\\"Apple Podcasts player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:175px\\"></iframe>", ratio: null },',
68
+ ' { id: "twitter", label: "X (Twitter)", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?(?:twitter|x)\\\\.com\\\\/[^/]+\\\\/status\\\\/(\\\\d+)", "i")], template: "<blockquote class=\\"twitter-tweet\\"><a href=\\"$&\\"></a></blockquote><script async src=\\"https://platform.twitter.com/widgets.js\\" charset=\\"utf-8\\"></script>", ratio: null },',
69
+ ' { id: "instagram", label: "Instagram", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?instagram\\\\.com\\\\/(?:p|reel|tv)\\\\/([A-Za-z0-9_-]+)", "i")], template: "<blockquote class=\\"instagram-media\\" data-instgrm-permalink=\\"https://www.instagram.com/p/$1/\\" data-instgrm-version=\\"14\\"></blockquote><script async src=\\"https://www.instagram.com/embed.js\\"></script>", ratio: null },',
70
+ ' { id: "tiktok", label: "TikTok", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?tiktok\\\\.com\\\\/@[^/]+\\\\/video\\\\/(\\\\d+)", "i")], template: "<blockquote class=\\"tiktok-embed\\" cite=\\"$&\\" data-video-id=\\"$1\\"><section></section></blockquote><script async src=\\"https://www.tiktok.com/embed.js\\"></script>", ratio: null },',
71
+ ' { id: "reddit", label: "Reddit", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?reddit\\\\.com\\\\/r\\\\/[^/]+\\\\/comments\\\\/.+", "i")], template: "<blockquote class=\\"reddit-embed-bq\\"><a href=\\"$&\\"></a></blockquote><script async src=\\"https://embed.reddit.com/widgets.js\\" charset=\\"UTF-8\\"></script>", ratio: null },',
72
+ ' { id: "pinterest", label: "Pinterest", patterns: [new RegExp("^https?:\\\\/\\\\/(?:[a-z]{2}\\\\.)?pinterest\\\\.[a-z.]+\\\\/pin\\\\/[0-9]+", "i")], template: "<a data-pin-do=\\"embedPin\\" href=\\"$&\\"></a><script async defer src=\\"https://assets.pinterest.com/js/pinit.js\\"></script>", ratio: null },',
73
+ ' { id: "facebook", label: "Facebook", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.|web\\\\.)?facebook\\\\.com\\\\/.+\\\\/(?:posts|videos)\\\\/.+", "i")], template: "<iframe src=\\"https://www.facebook.com/plugins/post.php?href=$E&&show_text=true\\" title=\\"Facebook post\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
74
+ ' { id: "github-gist", label: "GitHub Gist", patterns: [new RegExp("^https?:\\\\/\\\\/gist\\\\.github\\\\.com\\\\/([^/]+\\\\/[a-f0-9]+)", "i")], template: "<script src=\\"https://gist.github.com/$1.js\\"></script>", ratio: null },',
75
+ ' { id: "codepen", label: "CodePen", patterns: [new RegExp("^https?:\\\\/\\\\/codepen\\\\.io\\\\/([^/]+)\\\\/(?:pen|embed|details|full)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://codepen.io/$1/embed/$2?default-tab=result\\" title=\\"CodePen\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:400px\\"></iframe>", ratio: null },',
76
+ ' { id: "codesandbox", label: "CodeSandbox", patterns: [new RegExp("^https?:\\\\/\\\\/codesandbox\\\\.io\\\\/(?:s|embed)\\\\/([A-Za-z0-9_-]+)", "i"), new RegExp("^https?:\\\\/\\\\/codesandbox\\\\.io\\\\/p\\\\/(?:sandbox|devbox)\\\\/([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://codesandbox.io/embed/$1\\" title=\\"CodeSandbox\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
77
+ ' { id: "jsfiddle", label: "JSFiddle", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?jsfiddle\\\\.net\\\\/((?:[^/]+\\\\/)?[A-Za-z0-9]+)\\\\/?", "i")], template: "<iframe src=\\"https://jsfiddle.net/$1/embedded/\\" title=\\"JSFiddle\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:400px\\"></iframe>", ratio: null },',
78
+ ' { id: "figma", label: "Figma", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?figma\\\\.com\\\\/(?:file|design|proto|board|slides)\\\\/.+", "i")], template: "<iframe src=\\"https://www.figma.com/embed?embed_host=share&url=$E&\\" title=\\"Figma\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
79
+ ' { id: "canva", label: "Canva", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?canva\\\\.com\\\\/design\\\\/([A-Za-z0-9_-]+)\\\\/([A-Za-z0-9_-]+)\\\\/(?:view|watch)", "i")], template: "<iframe src=\\"https://www.canva.com/design/$1/$2/view?embed\\" title=\\"Canva design\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
80
+ ' { id: "miro", label: "Miro", patterns: [new RegExp("^https?:\\\\/\\\\/miro\\\\.com\\\\/app\\\\/(?:board|live-embed)\\\\/([A-Za-z0-9_=-]+)", "i")], template: "<iframe src=\\"https://miro.com/app/live-embed/$1/\\" title=\\"Miro board\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
81
+ ' { id: "google-maps", label: "Google Maps", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?google\\\\.[a-z.]+\\\\/maps\\\\/embed\\\\?(.+)$", "i")], template: "<iframe src=\\"https://www.google.com/maps/embed?$1\\" title=\\"Google Maps\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
82
+ ' { id: "google-maps-place", label: "Google Maps", patterns: [new RegExp("^https?:\\\\/\\\\/(?:(?:www\\\\.)?google\\\\.[a-z.]+\\\\/maps|maps\\\\.app\\\\.goo\\\\.gl)\\\\/.+", "i")], template: "<iframe src=\\"https://maps.google.com/maps?q=$E&&output=embed\\" title=\\"Google Maps\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
83
+ ' { id: "google-forms", label: "Google Forms", patterns: [new RegExp("^https?:\\\\/\\\\/docs\\\\.google\\\\.com\\\\/forms\\\\/d\\\\/(?:e\\\\/)?([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://docs.google.com/forms/d/e/$1/viewform?embedded=true\\" title=\\"Google Form\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:700px\\"></iframe>", ratio: null },',
84
+ ' { id: "google-docs", label: "Google Docs", patterns: [new RegExp("^https?:\\\\/\\\\/docs\\\\.google\\\\.com\\\\/(document|spreadsheets|presentation)\\\\/d\\\\/([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://docs.google.com/$1/d/$2/preview\\" title=\\"Google Docs\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:600px\\"></iframe>", ratio: null },',
85
+ ' { id: "airtable", label: "Airtable", patterns: [new RegExp("^https?:\\\\/\\\\/airtable\\\\.com\\\\/(?:embed\\\\/)?(app[A-Za-z0-9/?=&_-]+)", "i")], template: "<iframe src=\\"https://airtable.com/embed/$1\\" title=\\"Airtable\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:533px\\"></iframe>", ratio: null },',
86
+ ' { id: "typeform", label: "Typeform", patterns: [new RegExp("^https?:\\\\/\\\\/(?:[A-Za-z0-9-]+\\\\.)?typeform\\\\.com\\\\/to\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://form.typeform.com/to/$1\\" title=\\"Typeform\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
87
+ ' { id: "calendly", label: "Calendly", patterns: [new RegExp("^https?:\\\\/\\\\/calendly\\\\.com\\\\/(.+)$", "i")], template: "<iframe src=\\"https://calendly.com/$1\\" title=\\"Calendly\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:700px\\"></iframe>", ratio: null },',
88
+ ' { id: "iframe-url", label: "Web page", patterns: [new RegExp("^https:\\\\/\\\\/[^\\\\s\\"\'<>]+$", "i")], template: "<iframe src=\\"$&\\" title=\\"Embedded page\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 }',
89
+ ']',
90
+ '',
91
+ 'export var EMBED_SANDBOX_FLAGS_STRICT = "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation"',
92
+ '',
93
+ 'export var EMBED_SANDBOX_FLAGS_TRUSTED = "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation allow-same-origin"',
94
+ '',
95
+ 'export var EMBED_HEIGHT_MESSAGE_TYPE = "tq-embed-height"',
96
+ '',
97
+ 'export var EMBED_TOKEN_PLACEHOLDER = "__TQ_EMBED_TOKEN__"',
98
+ '',
99
+ 'export var EMBED_MIN_HEIGHT = 80',
100
+ '',
101
+ 'export var EMBED_MAX_HEIGHT = 6000',
102
+ '',
103
+ 'export var EMBED_INITIAL_HEIGHT = 320',
104
+ '',
105
+ 'export var EMBED_SANDBOX_DOC_HEAD = "<!doctype html><html><head><meta charset=\\"utf-8\\"><meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1\\"><base target=\\"_blank\\"><style>html,body{margin:0;padding:0;background:transparent}img,iframe,video,blockquote{max-width:100%}</style><script>(function(){var token=\\"__TQ_EMBED_TOKEN__\\";var last=0;function report(){try{var doc=document.documentElement;var body=document.body;var height=Math.max(doc?doc.scrollHeight:0,doc?doc.offsetHeight:0,body?body.scrollHeight:0,body?body.offsetHeight:0);if(!height||height===last){return;}last=height;parent.postMessage({type:\\"tq-embed-height\\",token:token,height:height},\\"*\\");}catch(e){}}function watch(){report();if(typeof ResizeObserver===\\"function\\"&&document.documentElement){new ResizeObserver(report).observe(document.documentElement);}if(typeof MutationObserver===\\"function\\"&&document.body){new MutationObserver(report).observe(document.body,{childList:true,subtree:true,attributes:true});}var delays=[150,400,900,1800,3500];for(var i=0;i<delays.length;i++){setTimeout(report,delays[i]);}}if(document.readyState===\\"loading\\"){document.addEventListener(\\"DOMContentLoaded\\",watch);}else{watch();}window.addEventListener(\\"load\\",report);})();</script></head><body>"',
106
+ '',
107
+ 'export var EMBED_SANDBOX_DOC_TAIL = "</body></html>"',
108
+ '',
109
+ 'export var embedTokenCounter = 0',
110
+ '',
111
+ 'export function isSafeEmbedUrl(url) {',
112
+ " return /^https?:\\/\\/[^\\s\"'<>]+$/i.test((url || '').trim());",
113
+ '}',
114
+ '',
115
+ 'export function resolveEmbedProvider(url) {',
116
+ " const trimmed = (url || '').trim();",
117
+ ' if (!isSafeEmbedUrl(trimmed)) {',
118
+ ' return null;',
119
+ ' }',
120
+ ' for (const provider of EMBED_PROVIDERS) {',
121
+ ' for (const pattern of provider.patterns) {',
122
+ ' const match = trimmed.match(pattern);',
123
+ ' if (match) {',
124
+ ' return { provider, match };',
125
+ ' }',
126
+ ' }',
127
+ ' }',
128
+ ' return null;',
129
+ '}',
130
+ '',
131
+ 'export function applyEmbedTemplate(template, match, url) {',
132
+ ' return template.replace(/\\$(\\$|E?(?:[1-9]|&))/g, (_token, spec) => {',
133
+ ' var _a;',
134
+ " if (spec === '$') {",
135
+ " return '$';",
136
+ ' }',
137
+ " const encoded = spec.charAt(0) === 'E';",
138
+ ' const key = encoded ? spec.slice(1) : spec;',
139
+ " const raw = key === '&' ? url : (_a = match[Number(key)]) !== null && _a !== void 0 ? _a : '';",
140
+ ' return encoded ? encodeURIComponent(raw) : raw;',
141
+ ' });',
142
+ '}',
143
+ '',
144
+ 'export function buildEmbedHtmlFromUrl(url) {',
145
+ ' const resolved = resolveEmbedProvider(url);',
146
+ ' if (!resolved) {',
147
+ ' return null;',
148
+ ' }',
149
+ ' return {',
150
+ ' provider: resolved.provider,',
151
+ ' html: applyEmbedTemplate(resolved.provider.template, resolved.match, url.trim()),',
152
+ ' };',
153
+ '}',
154
+ '',
155
+ 'export function resolveEmbedMode(html) {',
156
+ " const markup = html || '';",
157
+ ' const executes = /<script[\\s/>]/i.test(markup) ||',
158
+ ' /\\son[a-z]+\\s*=/i.test(markup) ||',
159
+ ' /(?:href|src|action|formaction)\\s*=\\s*["\']?\\s*javascript:/i.test(markup);',
160
+ " return executes ? 'sandbox' : 'inline';",
161
+ '}',
162
+ '',
163
+ 'export function clampEmbedWidth(width) {',
164
+ ' if (!isFinite(width)) {',
165
+ ' return DEFAULT_EMBED_WIDTH;',
166
+ ' }',
167
+ ' return Math.max(10, Math.min(100, Math.round(width)));',
168
+ '}',
169
+ '',
170
+ 'export function normalizeEmbedAlign(align) {',
171
+ ' return EMBED_ALIGNMENTS.indexOf(align) !== -1',
172
+ ' ? align',
173
+ ' : DEFAULT_EMBED_ALIGN;',
174
+ '}',
175
+ '',
176
+ 'export function escapeEmbedAttribute(value) {',
177
+ " return String(value !== null && value !== void 0 ? value : '')",
178
+ " .replace(/&/g, '&amp;')",
179
+ " .replace(/\"/g, '&quot;')",
180
+ " .replace(/</g, '&lt;')",
181
+ " .replace(/>/g, '&gt;');",
182
+ '}',
183
+ '',
184
+ 'export function escapeEmbedText(value) {',
185
+ " return String(value !== null && value !== void 0 ? value : '')",
186
+ " .replace(/&/g, '&amp;')",
187
+ " .replace(/</g, '&lt;')",
188
+ " .replace(/>/g, '&gt;');",
189
+ '}',
190
+ '',
191
+ 'export function encodeEmbedCode(code) {',
192
+ ' const binary = encodeURIComponent(code).replace(/%([0-9A-F]{2})/gi, (_m, hex) => String.fromCharCode(parseInt(hex, 16)));',
193
+ " if (typeof btoa === 'function') {",
194
+ ' return btoa(binary);',
195
+ ' }',
196
+ " if (typeof Buffer !== 'undefined') {",
197
+ " return Buffer.from(binary, 'binary').toString('base64');",
198
+ ' }',
199
+ " throw new Error('No base64 encoder available');",
200
+ '}',
201
+ '',
202
+ 'export function decodeEmbedCode(encoded) {',
203
+ ' let binary;',
204
+ " if (typeof atob === 'function') {",
205
+ ' binary = atob(encoded);',
206
+ ' }',
207
+ " else if (typeof Buffer !== 'undefined') {",
208
+ " binary = Buffer.from(encoded, 'base64').toString('binary');",
209
+ ' }',
210
+ ' else {',
211
+ " throw new Error('No base64 decoder available');",
212
+ ' }',
213
+ " let percent = '';",
214
+ ' for (let index = 0; index < binary.length; index += 1) {',
215
+ ' percent += `%${`00${binary.charCodeAt(index).toString(16)}`.slice(-2)}`;',
216
+ ' }',
217
+ ' return decodeURIComponent(percent);',
218
+ '}',
219
+ '',
220
+ 'export function createEmbedValue(params) {',
221
+ ' var _a, _b, _c;',
222
+ " const code = params.code || '';",
223
+ ' return {',
224
+ ' provider: params.provider || CUSTOM_EMBED_PROVIDER_ID,',
225
+ " url: params.url || '',",
226
+ ' code,',
227
+ ' mode: resolveEmbedMode(code),',
228
+ ' ratio: (_a = params.ratio) !== null && _a !== void 0 ? _a : null,',
229
+ ' width: clampEmbedWidth((_b = params.width) !== null && _b !== void 0 ? _b : DEFAULT_EMBED_WIDTH),',
230
+ ' align: normalizeEmbedAlign((_c = params.align) !== null && _c !== void 0 ? _c : DEFAULT_EMBED_ALIGN),',
231
+ " caption: params.caption || '',",
232
+ " sandboxLevel: params.sandboxLevel === 'trusted' ? 'trusted' : DEFAULT_EMBED_SANDBOX_LEVEL,",
233
+ ' };',
234
+ '}',
235
+ '',
236
+ 'export function embedBlockStyle(value) {',
237
+ ' const declarations = [',
238
+ " 'position:relative',",
239
+ ' `width:${clampEmbedWidth(value.width)}%`,',
240
+ " 'max-width:100%',",
241
+ " 'margin:16px 0',",
242
+ ' ];',
243
+ " if (value.align === 'center') {",
244
+ " declarations.push('margin-left:auto', 'margin-right:auto');",
245
+ ' }',
246
+ " else if (value.align === 'float-left') {",
247
+ " declarations.push('float:left', 'margin-right:16px', 'margin-bottom:8px');",
248
+ ' }',
249
+ " else if (value.align === 'float-right') {",
250
+ " declarations.push('float:right', 'margin-left:16px', 'margin-bottom:8px');",
251
+ ' }',
252
+ " return declarations.join(';');",
253
+ '}',
254
+ '',
255
+ 'export function embedFrameStyle(ratio) {',
256
+ ' if (ratio === null || !isFinite(ratio) || ratio <= 0) {',
257
+ " return 'position:relative;width:100%';",
258
+ ' }',
259
+ ' return `position:relative;width:100%;padding-top:${ratio}%`;',
260
+ '}',
261
+ '',
262
+ 'export function buildEmbedElementHtml(value) {',
263
+ ' const attrs = [',
264
+ ' `class="${EMBED_CLASS_NAME}"`,',
265
+ ' `${EMBED_ATTR.MARKER}="1"`,',
266
+ ' `${EMBED_ATTR.PROVIDER}="${escapeEmbedAttribute(value.provider)}"`,',
267
+ ' `${EMBED_ATTR.MODE}="${value.mode}"`,',
268
+ ' `${EMBED_ATTR.WIDTH}="${clampEmbedWidth(value.width)}"`,',
269
+ ' `${EMBED_ATTR.ALIGN}="${value.align}"`,',
270
+ ' `${EMBED_ATTR.SANDBOX}="${value.sandboxLevel}"`,',
271
+ ' ];',
272
+ ' if (value.url) {',
273
+ ' attrs.push(`${EMBED_ATTR.URL}="${escapeEmbedAttribute(value.url)}"`);',
274
+ ' }',
275
+ ' if (value.ratio !== null) {',
276
+ ' attrs.push(`${EMBED_ATTR.RATIO}="${value.ratio}"`);',
277
+ ' }',
278
+ ' if (value.caption) {',
279
+ ' attrs.push(`${EMBED_ATTR.CAPTION}="${escapeEmbedAttribute(value.caption)}"`);',
280
+ ' }',
281
+ " if (value.mode === 'sandbox') {",
282
+ ' attrs.push(`${EMBED_ATTR.CODE}="${escapeEmbedAttribute(encodeEmbedCode(value.code))}"`);',
283
+ ' }',
284
+ ' attrs.push(\'contenteditable="false"\');',
285
+ ' attrs.push(`style="${embedBlockStyle(value)}"`);',
286
+ ' const caption = value.caption',
287
+ ' ? `<figcaption class="${EMBED_CAPTION_CLASS_NAME}" style="${EMBED_CAPTION_STYLE}">${escapeEmbedText(value.caption)}</figcaption>`',
288
+ " : '';",
289
+ " return (`<figure ${attrs.join(' ')}>` +",
290
+ ' `<div class="${EMBED_FRAME_CLASS_NAME}" style="${embedFrameStyle(value.ratio)}">` +',
291
+ ' `${buildEmbedFrameChildren(value)}</div>${caption}</figure>`);',
292
+ '}',
293
+ '',
294
+ 'export function buildEmbedFrameChildren(value) {',
295
+ " if (value.mode === 'inline') {",
296
+ ' return value.code;',
297
+ ' }',
298
+ ' if (!value.url) {',
299
+ " return '';",
300
+ ' }',
301
+ ' return (`<noscript><a href="${escapeEmbedAttribute(value.url)}" rel="noopener noreferrer" ` +',
302
+ ' `target="_blank">${escapeEmbedText(value.url)}</a></noscript>`);',
303
+ '}',
304
+ '',
305
+ 'export function findEmbedFrame(element) {',
306
+ ' return element.querySelector(`.${EMBED_FRAME_CLASS_NAME}`);',
307
+ '}',
308
+ '',
309
+ 'export function readEmbedValueFromElement(element) {',
310
+ " const mode = element.getAttribute(EMBED_ATTR.MODE) === 'sandbox' ? 'sandbox' : 'inline';",
311
+ ' const frame = findEmbedFrame(element);',
312
+ ' const rawRatio = element.getAttribute(EMBED_ATTR.RATIO);',
313
+ ' const parsedRatio = rawRatio === null ? NaN : parseFloat(rawRatio);',
314
+ " let code = '';",
315
+ " if (mode === 'sandbox') {",
316
+ ' code = readEncodedEmbedCode(element);',
317
+ ' }',
318
+ ' else if (frame) {',
319
+ ' code = frame.innerHTML;',
320
+ ' }',
321
+ ' return {',
322
+ ' provider: element.getAttribute(EMBED_ATTR.PROVIDER) || CUSTOM_EMBED_PROVIDER_ID,',
323
+ " url: element.getAttribute(EMBED_ATTR.URL) || '',",
324
+ ' code,',
325
+ ' mode,',
326
+ ' ratio: isFinite(parsedRatio) ? parsedRatio : null,',
327
+ " width: clampEmbedWidth(parseFloat(element.getAttribute(EMBED_ATTR.WIDTH) || '')),",
328
+ " align: normalizeEmbedAlign(element.getAttribute(EMBED_ATTR.ALIGN) || ''),",
329
+ " caption: element.getAttribute(EMBED_ATTR.CAPTION) || '',",
330
+ " sandboxLevel: element.getAttribute(EMBED_ATTR.SANDBOX) === 'trusted'",
331
+ " ? 'trusted'",
332
+ ' : DEFAULT_EMBED_SANDBOX_LEVEL,',
333
+ ' };',
334
+ '}',
335
+ '',
336
+ 'export function readEncodedEmbedCode(element) {',
337
+ ' const encoded = element.getAttribute(EMBED_ATTR.CODE);',
338
+ ' if (!encoded) {',
339
+ " return '';",
340
+ ' }',
341
+ ' try {',
342
+ ' return decodeEmbedCode(encoded);',
343
+ ' }',
344
+ ' catch (_a) {',
345
+ " return '';",
346
+ ' }',
347
+ '}',
348
+ '',
349
+ 'export function normalizeEmbedsForStorage(root) {',
350
+ ' const previews = root.querySelectorAll(`[${EMBED_ATTR.PREVIEW}]`);',
351
+ ' for (let index = previews.length - 1; index >= 0; index -= 1) {',
352
+ ' const preview = previews[index];',
353
+ ' if (preview.parentNode) {',
354
+ ' preview.parentNode.removeChild(preview);',
355
+ ' }',
356
+ ' }',
357
+ ' const blocks = root.querySelectorAll(`[${EMBED_ATTR.MARKER}]`);',
358
+ ' for (let index = 0; index < blocks.length; index += 1) {',
359
+ ' const block = blocks[index];',
360
+ ' block.removeAttribute(EMBED_ATTR.ACTIVATED);',
361
+ ' const frame = findEmbedFrame(block);',
362
+ ' if (!frame) {',
363
+ ' continue;',
364
+ ' }',
365
+ ' const value = readEmbedValueFromElement(block);',
366
+ " if (value.mode !== 'sandbox') {",
367
+ ' continue;',
368
+ ' }',
369
+ ' frame.innerHTML = buildEmbedFrameChildren(value);',
370
+ ' }',
371
+ '}',
372
+ '',
373
+ 'export function resolveEmbedSandboxFlags(level) {',
374
+ " return level === 'trusted' ? EMBED_SANDBOX_FLAGS_TRUSTED : EMBED_SANDBOX_FLAGS_STRICT;",
375
+ '}',
376
+ '',
377
+ 'export function buildEmbedSandboxDocument(code, token) {',
378
+ ' return (EMBED_SANDBOX_DOC_HEAD.replace(EMBED_TOKEN_PLACEHOLDER, token) +',
379
+ " (code || '') +",
380
+ ' EMBED_SANDBOX_DOC_TAIL);',
381
+ '}',
382
+ '',
383
+ 'export function parseEmbedHeightMessage(data) {',
384
+ " if (!data || typeof data !== 'object') {",
385
+ ' return null;',
386
+ ' }',
387
+ ' const message = data;',
388
+ " if (message.type !== EMBED_HEIGHT_MESSAGE_TYPE || typeof message.token !== 'string') {",
389
+ ' return null;',
390
+ ' }',
391
+ ' const height = Number(message.height);',
392
+ ' if (!isFinite(height) || height <= 0) {',
393
+ ' return null;',
394
+ ' }',
395
+ ' return {',
396
+ ' token: message.token,',
397
+ ' height: Math.min(Math.max(Math.round(height), EMBED_MIN_HEIGHT), EMBED_MAX_HEIGHT),',
398
+ ' };',
399
+ '}',
400
+ '',
401
+ 'export function createEmbedToken() {',
402
+ ' embedTokenCounter += 1;',
403
+ ' return `tqe-${Date.now().toString(36)}-${embedTokenCounter.toString(36)}-${Math.random()',
404
+ ' .toString(36)',
405
+ ' .slice(2, 8)}`;',
406
+ '}',
407
+ '',
408
+ ].join('\n');
409
+ //# sourceMappingURL=rich-text-embeds-runtime-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-embeds-runtime-source.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-runtime-source.ts"],"names":[],"mappings":";;;AAAA,sFAAsF;AACtF,8GAA8G;AAC9G,mEAAmE;AACnE,mFAAmF;AACtE,QAAA,2BAA2B,GAAG;IACzC,KAAK;IACL,+EAA+E;IAC/E,gFAAgF;IAChF,IAAI;IACJ,+EAA+E;IAC/E,gFAAgF;IAChF,2EAA2E;IAC3E,6EAA6E;IAC7E,gFAAgF;IAChF,2BAA2B;IAC3B,KAAK;IACL,EAAE;IACF,0CAA0C;IAC1C,EAAE;IACF,sDAAsD;IACtD,EAAE;IACF,0DAA0D;IAC1D,EAAE;IACF,yCAAyC;IACzC,EAAE;IACF,2BAA2B;IAC3B,8BAA8B;IAC9B,yCAAyC;IACzC,+BAA+B;IAC/B,iCAAiC;IACjC,iCAAiC;IACjC,mCAAmC;IACnC,mCAAmC;IACnC,mCAAmC;IACnC,uCAAuC;IACvC,uCAAuC;IACvC,2CAA2C;IAC3C,sCAAsC;IACtC,GAAG;IACH,EAAE;IACF,qEAAqE;IACrE,EAAE;IACF,gDAAgD;IAChD,EAAE;IACF,qDAAqD;IACrD,EAAE;IACF,sCAAsC;IACtC,EAAE;IACF,2CAA2C;IAC3C,EAAE;IACF,mDAAmD;I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 +1,85 @@
1
+ /**
2
+ * Resolving the NextAuth session token in a generated route, WITHOUT asking
3
+ * `process.env.NEXTAUTH_URL` what the session cookie is called.
4
+ *
5
+ * ## ⛔ THE REPORTED DEFECT
6
+ *
7
+ * A published project showed "Failed to load dashboard data. Please refresh."
8
+ * on the home page, "Failed to load meeting data." on the list page and "could
9
+ * not fetch the templates" on a third — for a user who was signed in, on a page
10
+ * whose own `/api/auth/session` returned that user. The failing call was the
11
+ * page-load workflow's server segment, answering **401 `Unauthenticated`** from
12
+ * `guardWorkflowRequest`. Reloading sometimes fixed it; fanning 50 concurrent
13
+ * requests at the same route returned **33 × 401 and 17 × 200**, while 40
14
+ * concurrent `/api/auth/session` calls resolved the user 40/40.
15
+ *
16
+ * ## The mechanism
17
+ *
18
+ * next-auth v4's `getToken()` derives the cookie it reads from an env var:
19
+ *
20
+ * ```js
21
+ * secureCookie = process.env.NEXTAUTH_URL?.startsWith('https://') ?? !!process.env.VERCEL,
22
+ * cookieName = secureCookie ? '__Secure-next-auth.session-token' : 'next-auth.session-token',
23
+ * ```
24
+ *
25
+ * A generated project ships `NEXTAUTH_URL=http://localhost:3000` — the build
26
+ * cannot know the domain it will be published to, so `pages/api/auth/[...nextauth].js`
27
+ * repairs `process.env.NEXTAUTH_URL` **from the incoming request** instead. That
28
+ * repair is process-local: it fixes the value for whichever serverless instance
29
+ * happened to serve an auth request, and for no other. Every other instance
30
+ * still holds `http://localhost:3000`, so `startsWith('https://')` is `false`
31
+ * (NOT `undefined` — the `??` fallback to `!!process.env.VERCEL` never runs),
32
+ * `getToken` looks for `next-auth.session-token`, the browser is holding
33
+ * `__Secure-next-auth.session-token`, nothing is found, and a signed-in user is
34
+ * reported as anonymous.
35
+ *
36
+ * Hence the coin-flip: it depends on whether the instance that served your
37
+ * request had previously served an auth request. Nothing about the session, the
38
+ * secret or the cookie is wrong.
39
+ *
40
+ * The same defect is why the generated middleware carries a `hasSessionCookie`
41
+ * fallback and a round trip to `/api/auth/session`, attributed there to an
42
+ * "Edge runtime quirk" — the Edge process holds that same localhost value.
43
+ *
44
+ * ## The rule
45
+ *
46
+ * ⭐ **A request must be authenticated from the REQUEST, never from an ambient
47
+ * env var that describes the deployment.** So this resolver reads which session
48
+ * cookie the caller actually sent, and tells `getToken` exactly that — falling
49
+ * back to the request's own protocol when the cookie header is unavailable.
50
+ *
51
+ * Emitted as plain ES5 text and inlined into each generated route: a route that
52
+ * carries its own copy cannot be broken by a missing sibling module or an
53
+ * untraced dependency, and every call site gets the identical implementation
54
+ * from this one definition. It lives in teleport-shared because both the
55
+ * workflow routes and the per-table data routes decode the session.
56
+ */
57
+ /** The `__tq`-prefixed globals the emitted snippet declares. */
58
+ export declare const SESSION_TOKEN_RESOLVER_FN = "__tqResolveSessionToken";
59
+ /**
60
+ * ES5 source for the shared session-token resolver, safe to inline into any
61
+ * generated CommonJS route or ESM middleware.
62
+ *
63
+ * Declares:
64
+ * - `__tqCookieNamesPresent(req)` — the set of cookie names on the request,
65
+ * parsed properly (a substring test would see `next-auth.session-token`
66
+ * inside `__Secure-next-auth.session-token` and pick the wrong one).
67
+ * - `__tqRequestIsSecure(req)` — https as the REQUEST reports it.
68
+ * - `__tqSessionTokenCandidates(req)` — `{cookieName, secureCookie}` pairs to try.
69
+ * - `__tqResolveSessionToken(getToken, req, secret)` — the token, or null.
70
+ *
71
+ * `getToken` is passed IN rather than required here, so the same body serves a
72
+ * CommonJS route (lazy `require('next-auth/jwt')`) and the Edge middleware
73
+ * (static `import`). Pure, total, never throws, no env reads.
74
+ */
75
+ export declare const generateSessionTokenResolverCode: () => string;
76
+ /**
77
+ * The resolver plus a lazy `require('next-auth/jwt')`, for a CommonJS route.
78
+ *
79
+ * The require is lazy and guarded because a project generated WITHOUT
80
+ * authentication does not ship `next-auth`; such a project also has no session
81
+ * to read, so resolving to `null` there is the correct answer rather than a
82
+ * module-load crash.
83
+ */
84
+ export declare const generateCommonJsSessionTokenResolverCode: () => string;
85
+ //# sourceMappingURL=session-cookie-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-cookie-resolver.d.ts","sourceRoot":"","sources":["../../../src/utils/session-cookie-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,gEAAgE;AAChE,eAAO,MAAM,yBAAyB,4BAA4B,CAAA;AAiBlE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gCAAgC,QAAO,MAqLnD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wCAAwC,QAAO,MAsB3D,CAAA"}