social-embeds 0.5.3 → 0.6.0
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/README.md +68 -0
- package/dist/element.d.ts +32 -0
- package/dist/element.js +1 -0
- package/dist/index.js +827 -524
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -454,6 +454,74 @@ URL shapes, each tested against Facebook's plugins on `www.facebook.com`, `faceb
|
|
|
454
454
|
- Facebook group posts.
|
|
455
455
|
- Fetching embed code from oEmbed endpoints, consent gating and HTML sanitising: these stay with the host.
|
|
456
456
|
|
|
457
|
+
## Without React
|
|
458
|
+
|
|
459
|
+
`social-embeds/element` defines `<social-embed>`, a custom element for plain HTML, CMS templates, Vue, Svelte and Angular. It is one self-contained file with no React in it, about 20 KB gzipped.
|
|
460
|
+
|
|
461
|
+
```html
|
|
462
|
+
<script
|
|
463
|
+
type="module"
|
|
464
|
+
src="https://cdn.jsdelivr.net/npm/social-embeds@0.6.0/dist/element.js"
|
|
465
|
+
integrity="sha384-…"
|
|
466
|
+
crossorigin="anonymous"
|
|
467
|
+
></script>
|
|
468
|
+
|
|
469
|
+
<social-embed url="https://www.youtube.com/watch?v=jNQXAC9IVRw"></social-embed>
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Copy the real `integrity` hash from the file's page on jsDelivr (the package page's "Copy HTML + SRI" button). From npm, import it once: `import 'social-embeds/element'`. Importing defines the tag where `customElements` exists; in Node it does not throw and defines nothing. In a server-rendered app (React or Next.js, Vue or Nuxt, SvelteKit), import it after hydration, in `useEffect` or `onMounted` as the playground's `/element` page does: the upgrade rewrites the element's light DOM, which hydration expects to match the server HTML. The module exports the class as `SocialEmbedElement`.
|
|
473
|
+
|
|
474
|
+
Embed code goes in a `<template>`, which keeps the platform's own `<script>` from running:
|
|
475
|
+
|
|
476
|
+
```html
|
|
477
|
+
<social-embed max-width="540">
|
|
478
|
+
<template>
|
|
479
|
+
<!-- the platform's embed code, exactly as given -->
|
|
480
|
+
</template>
|
|
481
|
+
</social-embed>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
| Attribute / property | Meaning |
|
|
485
|
+
| -------------------------- | ------------------------------------------------------------------------------- |
|
|
486
|
+
| `url` | A post URL. |
|
|
487
|
+
| `width` | A number means pixels; otherwise any CSS length. |
|
|
488
|
+
| `max-width` / `maxWidth` | Pixels: `400` or `400px`. |
|
|
489
|
+
| `height` | Pixels: `400` or `400px`. Reaches only iframe-based platforms, as in React. |
|
|
490
|
+
| `max-height` / `maxHeight` | Pixels: `400` or `400px`. Reaches only iframe-based platforms, as in React. |
|
|
491
|
+
| `eager` | Load at once instead of when near the viewport (the inverse of React's `lazy`). |
|
|
492
|
+
|
|
493
|
+
Each property reflects its attribute, so framework property bindings such as Angular's `[url]` work. `url` and the size properties take a string, and `null` removes the attribute; `eager` takes a boolean.
|
|
494
|
+
|
|
495
|
+
The `html` property takes embed code from script. From a framework, pass embed code this way: a `<template>` the framework renders keeps its children in `childNodes`, not in `content`, where the element reads them. When several inputs are set, `html` wins over the `<template>`, and the `<template>` wins over `url`. Options come only from the embed code, as with `<SocialEmbed>`, and the element renders into the light DOM. The element has no `playerId`, so Dailymotion needs embed code that names a Player ID; a Dailymotion URL alone fires `error`.
|
|
496
|
+
|
|
497
|
+
Child elements other than `<template>` are the placeholder until the embed loads; without any, a neutral skeleton shows. They are read once, when the element first connects; children added later are not a placeholder. If the element connects while the document is still loading, it waits for `DOMContentLoaded` before reading its children.
|
|
498
|
+
|
|
499
|
+
It dispatches `load` (an `Event`) when the platform has rendered, and `error` (an `ErrorEvent`) when it cannot. `error.error` is an `Error` with the same message as React's `onError`. Neither event bubbles, both fire in a microtask, and only while the element is connected.
|
|
500
|
+
|
|
501
|
+
Events dispatch in a microtask after the element connects or changes, so add `load` and `error` listeners before inserting the element, or in the same task. In React, attach them before the element module is imported (as the playground's `/element` page does), or use the React components.
|
|
502
|
+
|
|
503
|
+
```js
|
|
504
|
+
const embed = document.querySelector('social-embed');
|
|
505
|
+
embed.addEventListener('load', () => console.log('rendered'));
|
|
506
|
+
embed.addEventListener('error', (event) => console.warn(event.error.message));
|
|
507
|
+
embed.html = post.embedCode;
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
Platform defaults (maximum width, height, rounded corners, placeholder) are shared with the React components, so the element looks the same.
|
|
511
|
+
|
|
512
|
+
Tell Vue and Angular that `social-embed` is a custom element:
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
// Vue, Vite plugin: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'social-embed' } } })
|
|
516
|
+
// Vue, at runtime:
|
|
517
|
+
app.config.compilerOptions.isCustomElement = (tag) => tag === 'social-embed';
|
|
518
|
+
|
|
519
|
+
// Angular: add CUSTOM_ELEMENTS_SCHEMA to the component's (or module's) schemas
|
|
520
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
521
|
+
|
|
522
|
+
@Component({ schemas: [CUSTOM_ELEMENTS_SCHEMA] /* … */ })
|
|
523
|
+
```
|
|
524
|
+
|
|
457
525
|
## Next.js
|
|
458
526
|
|
|
459
527
|
The `social-embeds` entry starts with `'use client'`, so its components can be rendered straight from a Server Component, with props that can be serialised:
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const Base: {
|
|
2
|
+
new (): HTMLElement;
|
|
3
|
+
prototype: HTMLElement;
|
|
4
|
+
};
|
|
5
|
+
export declare class SocialEmbedElement extends Base {
|
|
6
|
+
#private;
|
|
7
|
+
static observedAttributes: string[];
|
|
8
|
+
constructor();
|
|
9
|
+
get html(): string | null;
|
|
10
|
+
set html(value: string | null);
|
|
11
|
+
get url(): string | null;
|
|
12
|
+
set url(value: string | null);
|
|
13
|
+
get width(): string | null;
|
|
14
|
+
set width(value: string | null);
|
|
15
|
+
get maxWidth(): string | null;
|
|
16
|
+
set maxWidth(value: string | null);
|
|
17
|
+
get height(): string | null;
|
|
18
|
+
set height(value: string | null);
|
|
19
|
+
get maxHeight(): string | null;
|
|
20
|
+
set maxHeight(value: string | null);
|
|
21
|
+
get eager(): boolean;
|
|
22
|
+
set eager(value: boolean | null | undefined);
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(): void;
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'social-embed': SocialEmbedElement;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {};
|
package/dist/element.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`autoplay *; encrypted-media *; fullscreen *; clipboard-write`,t=`allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation`;function n(n){let r=n.url.slice(23),i=r.includes(`/song/`)||r.includes(`?i=`);return{kind:`iframe`,src:`https://embed.music.apple.com${r}`,title:`Apple Music player`,allow:e,sandbox:t,ratio:{width:16,height:9},height:n.size?.height??(i?175:450),maxWidth:660,borderRadius:10}}function r(n){let r=n.url.slice(26);return{kind:`iframe`,src:`https://embed.podcasts.apple.com${r}`,title:`Apple Podcasts player`,allow:e,sandbox:t,ratio:{width:16,height:9},height:n.size?.height??(r.includes(`?i=`)?160:450),maxWidth:640,borderRadius:12}}function i(e,t){return Object.entries(e).filter(([e])=>!t.includes(e.toLowerCase()))}function a(...e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r]of n??[])t.set(e,String(r));let n=[...t].map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`);return n.length>0?`?${n.join(`&`)}`:``}function o(e,t){let n=[];for(let[r,i]of Object.entries(t)){let t=e[r];typeof t==`boolean`?n.push([i,+!!t]):(typeof t==`string`||typeof t==`number`)&&n.push([i,t])}return n}const s={origin:`https://embed.bsky.app`,read(e){let t=e?.height;return typeof t==`number`?t:void 0}};function c(e,t){let n=t.colorMode??e.options.colorMode;return{kind:`iframe`,src:`https://embed.bsky.app/embed/${e.id}${a(typeof n==`string`?[[`colorMode`,n]]:void 0)}`,title:`Bluesky post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:s,startHeight:300,maxWidth:600,fallbackHtml:e.fallbackHtml}}const l=/^x[a-z0-9]{3,12}$/;function u(e,t){let{playerId:n,mute:r,startTime:o,loop:s}=t,{playerId:c,...u}=e.options,d=n??c;if(d===void 0)return{kind:`error`,message:`social-embeds: a Dailymotion embed needs a Player ID: pass playerId to DailymotionEmbed`};if(typeof d!=`string`||!l.test(d))return{kind:`error`,message:`social-embeds: not a Dailymotion Player ID: ${String(d)}`};let f=[];return r!==void 0&&f.push([`mute`,String(r)]),o!==void 0&&f.push([`startTime`,o]),s!==void 0&&f.push([`loop`,String(s)]),{kind:`iframe`,src:`https://geo.dailymotion.com/player/${d}.html${a([[`video`,e.id]],i(u,[`video`,`playlist`]),f)}`,title:`Dailymotion video player`,allow:`autoplay; fullscreen; picture-in-picture; web-share`,ratio:{width:16,height:9},size:e.size}}const d=15e3,f=/* @__PURE__ */ new Map;function p(e){if(typeof document>`u`)return Promise.reject(/* @__PURE__ */ Error(`social-embeds: platform scripts load only in the browser`));let t=f.get(e.key);return t||(t=m(e).catch(t=>{throw f.delete(e.key),t}),f.set(e.key,t)),t}async function m(e){e.isPresent()||await([...document.querySelectorAll(`script[src]`)].some(t=>e.isOwn(t.src))?v(e):g(e)),await e.whenPresent?.()}var h=class extends Error{};async function g(e){let t=e.readyCallback?.();for(let t=1;;t++)try{let n=await _(e);if(t>=3||!e.skipped?.())break;n.remove()}catch(e){if(!(e instanceof h)||t>=3)throw e;await ee(1e3*2**(t-1))}await(t?y(t,`${e.url} did not report ready`):v(e))}async function _(e){let t=e.prepare?.(),n=document.createElement(`script`),r=new Promise((t,r)=>{n.src=e.url,n.async=!0,e.crossOrigin&&(n.crossOrigin=e.crossOrigin),n.addEventListener(`load`,()=>{t()}),n.addEventListener(`error`,()=>{n.remove(),r(new h(`social-embeds: could not load ${e.url}`))}),document.head.appendChild(n)});try{await y(r,`${e.url} did not load`)}finally{t?.()}return n}function v(e){return new Promise((t,n)=>{let r=Date.now()+d,i=()=>{e.isPresent()?t():Date.now()>=r?n(/* @__PURE__ */ Error(`social-embeds: ${e.url} did not initialise`)):setTimeout(i,50)};i()})}function y(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{r(/* @__PURE__ */ Error(`social-embeds: ${t}`))},d);e.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e instanceof Error?e:Error(String(e)))})})}function ee(e){return new Promise(t=>setTimeout(t,e))}const b=()=>window,te=`v26.0`,ne=/^[a-z]{2,3}_[A-Z]{2}$/;function re(e){return()=>{let t=b().instgrm?.Embeds;return t?.registeredEmbedSDKs?.[e]===!0&&typeof t.process==`function`}}const ie={key:`x`,url:`https://platform.twitter.com/widgets.js`,isOwn:e=>/^https?:\/\/platform\.(?:twitter|x)\.com\/widgets\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof b().twttr?.widgets?.load==`function`,whenPresent:()=>new Promise(e=>{let t=b().twttr?.ready;t?t(()=>{e()}):e()})};function ae(){let e=b().FB;return!e||e.__buffer?()=>{}:(e.__buffer=!0,()=>{delete e.__buffer})}function oe(e){let t=re(e);return()=>{let e=b().FB;return!t()&&e!==void 0&&!e.__buffer}}const se={key:`instagram`,url:`https://www.instagram.com/embed.js`,isOwn:e=>/^https?:\/\/www\.instagram\.com\/embed\.js(?:[?#]|$)/.test(e),isPresent:re(`instagram`),prepare:ae,skipped:oe(`instagram`)},ce={key:`threads`,url:`https://www.threads.com/embed.js`,isOwn:e=>/^https?:\/\/www\.threads\.(?:com|net)\/embed\.js(?:[?#]|$)/.test(e),isPresent:re(`threads`),prepare:ae,skipped:oe(`threads`)};function le(e){return{key:`facebook`,url:`https://connect.facebook.net/${e}/sdk.js#xfbml=0&version=${te}`,crossOrigin:`anonymous`,isOwn:e=>/^https?:\/\/connect\.facebook\.net\/[a-z]{2,3}_[A-Z]{2}\/(?:sdk(?:\/debug)?|all)\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof b().FB?.XFBML?.parse==`function`,readyCallback:()=>new Promise(e=>{let t=b().fbAsyncInit;b().fbAsyncInit=()=>{t?.(),e()}})}}const ue={key:`pinterest`,url:`https://assets.pinterest.com/js/pinit_main.js`,isOwn:e=>/^https?:\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js(?:[?#]|$)/.test(e),isPresent:()=>typeof b().PinUtils?.build==`function`};function x(e,{locale:t=`en_US`}={}){switch(e){case`x`:return p(ie);case`instagram`:return p(se);case`threads`:return p(ce);case`pinterest`:return p(ue);case`facebook`:return ne.test(t)?p(le(t)):Promise.reject(/* @__PURE__ */ Error(`social-embeds: invalid Facebook locale "${t}"`))}}const S=()=>window;function C(e,t,n){if(t(e))return n(),()=>{};let r=new MutationObserver(()=>{t(e)&&(r.disconnect(),n())});return r.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`,`style`,`height`]}),()=>{r.disconnect()}}function de(e,t){let n=e.querySelector(`blockquote`);n&&!n.hasAttribute(`class`)&&n.classList.add(t)}function fe(e){return[...e.querySelectorAll(`iframe`)].some(e=>Number.parseFloat(e.style.height)>0)}const pe={load:()=>x(`x`),render(e,t){let n=S().twttr,r=n=>{n.target instanceof Node&&e.contains(n.target)&&t()};n?.events?.bind?.(`rendered`,r);let i=C(e,fe,t);return de(e,`twitter-tweet`),n?.widgets?.load?.(e),()=>{n?.events?.unbind?.(`rendered`,r),i()}}};function me(){let e=S().instgrm?.Embeds?.process;if(!e)throw Error(`social-embeds: instgrm.Embeds.process is missing`);e()}const he={load:()=>x(`instagram`),render(e,t){let n=C(e,e=>e.querySelector(`iframe.instagram-media-rendered`)!==null,t);return de(e,`instagram-media`),me(),n}},ge={load:()=>x(`threads`),render(e,t){let n=C(e,e=>e.querySelector(`iframe`)!==null&&e.querySelector(`blockquote`)===null,t);return de(e,`text-post-media`),me(),n}},_e=/* @__PURE__ */ new Map;function ve(e){let t=_e.get(e);return t||(t={load:()=>x(`facebook`,{locale:e}),render(e,t){let n=S().FB,r=n?.XFBML?.parse;if(!n||!r)throw Error(`social-embeds: FB.XFBML.parse is missing`);let i=()=>{r(e,t)};try{i()}catch(e){if(!(e instanceof Error)||!/init not called/.test(e.message))throw e;n.init?.({xfbml:!1,version:te}),i()}return()=>{}}},_e.set(e,t)),t}const ye={load:()=>x(`pinterest`),render(e,t){let n=S().PinUtils?.build;if(!n)throw Error(`social-embeds: PinUtils.build is missing`);let r=C(e,e=>e.querySelector(`span[data-pin-id]`)!==null,t),i=e.querySelector(`a`);return i&&!i.hasAttribute(`data-pin-do`)&&i.setAttribute(`data-pin-do`,`embedPin`),n(e),r}},be=/* @__PURE__ */ new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]),xe=/* @__PURE__ */ new Map([[`script`,/<\/script\s*>/giu],[`style`,/<\/style\s*>/giu]]),Se=/<([a-zA-Z][a-zA-Z0-9-]*)/y,Ce=/\s+([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/y,we=/\s*(\/?)>/y,w=/<\/([a-zA-Z][a-zA-Z0-9-]*)\s*>/y,Te=/* @__PURE__ */ new Map([[`amp`,`&`],[`lt`,`<`],[`gt`,`>`],[`quot`,`"`],[`apos`,`'`],[`nbsp`,`\xA0`]]);function Ee(e){let t={type:`element`,tag:``,attrs:/* @__PURE__ */ new Map,children:[]},n=[t],r=0;for(;r<e.length;){let i=n[n.length-1]??t,a=e.indexOf(`<`,r),o=a===-1?e.length:a;if(o>r&&i.children.push({type:`text`,raw:e.slice(r,o)}),a===-1)break;if(e.startsWith(`<!--`,a)){let t=e.indexOf(`-->`,a+4);if(t===-1)return null;i.children.push({type:`comment`}),r=t+3;continue}w.lastIndex=a;let s=w.exec(e);if(s){if(i===t||i.tag!==s[1]?.toLowerCase())return null;n.pop(),r=w.lastIndex;continue}let c=De(e,a);if(!c)return null;let{element:l}=c;i.children.push(l),r=c.end;let u=c.selfClosing?void 0:xe.get(l.tag);if(u){u.lastIndex=r;let t=u.exec(e);if(!t)return null;t.index>r&&l.children.push({type:`text`,raw:e.slice(r,t.index)}),r=u.lastIndex}else if(!c.selfClosing&&!be.has(l.tag)){if(n.length>100)return null;n.push(l)}}return n.length===1?t.children:null}function De(e,t){Se.lastIndex=t;let n=Se.exec(e)?.[1];if(n===void 0)return null;let r=/* @__PURE__ */ new Map,i=Se.lastIndex;for(;;){we.lastIndex=i;let t=we.exec(e);if(t)return{element:{type:`element`,tag:n.toLowerCase(),attrs:r,children:[]},selfClosing:t[1]===`/`,end:we.lastIndex};Ce.lastIndex=i;let a=Ce.exec(e);if(!a)return null;let[,o=``,s,c,l]=a,u=o.toLowerCase();r.has(u)||r.set(u,Oe(s??c??l??``)),i=Ce.lastIndex}}function Oe(e){return e.replace(/&(#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z]+);/g,(e,t)=>{if(!t.startsWith(`#`))return Te.get(t)??e;let n=t[1]===`x`||t[1]===`X`,r=Number.parseInt(t.slice(n?2:1),n?16:10);return r>0&&r<=1114111&&(r<55296||r>57343)?String.fromCodePoint(r):e})}function T(e,t){return(e.attrs.get(`class`)??``).split(/\s+/).includes(t)}function E(e){let t=[];for(let n of e)n.type===`element`&&t.push(n,...E(n.children));return t}const ke=/* @__PURE__ */ new Set([`href`,`cite`]),Ae=/^https?:\/\//i;function D(e,t){let n=``;for(let r of e){if(r.type===`text`){n+=r.raw;continue}if(r.type!==`element`)continue;let e=t.get(r.tag);if(e){n+=`<${r.tag}`;for(let t of e){let e=typeof t==`string`?t:t.name,i=r.attrs.get(e);i===void 0||typeof t!=`string`&&!t.value.test(i)||ke.has(e)&&!Ae.test(i)||(n+=` ${e}="${O(i)}"`)}n+=`>`,be.has(r.tag)||(n+=`${D(r.children,t)}</${r.tag}>`)}}return n}function O(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function je(e){let t=``;for(let[n,r]of Object.entries(e))r!==void 0&&(t+=r===!0?` ${n}`:` ${n}="${O(String(r))}"`);return t}function k(e,t){let n={};for(let[r,i]of Object.entries(e)){let e=t[r];e!==void 0&&(n[i]=String(e))}return je(n)}function A(e,t){let n={...e};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}function j(e){return e!==void 0&&e.trim()!==``}const Me={width:`data-width`,showText:`data-show-text`,lazy:`data-lazy`,allowfullscreen:`data-allowfullscreen`,autoplay:`data-autoplay`,showCaptions:`data-show-captions`},Ne={showText:`show_text`,allowfullscreen:`allowfullscreen`,autoplay:`autoplay`,showCaptions:`show_captions`},Pe={post:300,video:200};function Fe(e){let t=Object.entries(e.options).filter(([e])=>e!==`href`);return{kind:`iframe`,src:`https://www.facebook.com/plugins/video.php${a([[`href`,e.url]],t)}`,title:`Facebook video player`,allow:`autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share`,scrolling:`no`,ratio:{width:16,height:9},size:e.size}}function Ie(e,t){if(e.variant===`iframe`)return Fe(e);let n=A(e.options,{showText:t.showText,allowfullscreen:t.allowfullscreen,autoplay:t.autoplay,showCaptions:t.showCaptions}),{size:r}=e;if(e.kind===`video`&&n.showText===!1&&r?.width!==void 0&&r.height!==void 0){let t={};for(let[e,r]of Object.entries(Ne)){let i=n[e];i!==void 0&&(t[r]=i)}return t.width=r.width,t.height=r.height,Fe({...e,options:t})}let i=t.locale??(typeof n.locale==`string`?n.locale:`en_US`),a=`<div class="${e.kind===`video`?`fb-video`:`fb-post`}" data-href="${O(e.url)}"${k(Me,n)}>${e.fallbackHtml??``}</div>`;return{kind:`script`,key:`${i} ${a}`,markup:a,driver:ve(i),minHeight:Pe[e.kind],label:`Facebook`,hasFallback:j(e.fallbackHtml),maxWidth:e.kind===`post`?750:void 0}}function Le(e){return{kind:`iframe`,src:`https://giphy.com/embed/${e.id}`,title:`Giphy GIF`,allow:`fullscreen`,ratio:{width:1,height:1},size:e.size}}function Re(e,t){let n=A(e.options,{captioned:t.captioned}),r=`<blockquote${je({"data-instgrm-permalink":e.url,"data-instgrm-version":n.version,"data-instgrm-captioned":n.captioned===!0||void 0,style:`width:calc(100% - 2px)`})}>${e.fallbackHtml??``}</blockquote>`;return{kind:`script`,key:r,markup:r,driver:he,minHeight:680,label:`Instagram`,hasFallback:j(e.fallbackHtml),maxWidth:540}}const ze=/* @__PURE__ */ new Set([`autoplay`,`muted`]);function Be(e,t){let n=[];return t.autoplay!==void 0&&n.push([`autoplay`,t.autoplay]),t.muted!==void 0&&n.push([`muted`,t.muted]),{kind:`iframe`,src:`https://player.kick.com/${e.id}${a(Object.entries(e.options).filter(([e])=>ze.has(e)),n)}`,title:`Kick player`,allow:`autoplay; fullscreen`,scrolling:`no`,ratio:{width:16,height:9},size:e.size}}function Ve(e,t){let n=new Map(Object.entries(e.options));return t.collapsed===!0&&n.set(`collapsed`,1),t.collapsed===!1&&n.delete(`collapsed`),{kind:`iframe`,src:`https://www.linkedin.com/embed/feed/update/${e.id}${a(n)}`,title:`LinkedIn post`,allow:``,ratio:{width:504,height:670},height:e.size?.height??670,maxWidth:e.size?.width??504}}const He={width:`data-pin-width`,lang:`data-pin-lang`,terse:`data-pin-terse`},Ue={small:236,medium:345,large:600};function We(e,t){let n=A(e.options,{width:t.pinWidth}),r=`<a href="${O(e.url)}"${k(He,n)}></a>`;return{kind:`script`,key:r,markup:r,driver:ye,minHeight:270,label:`Pinterest`,hasFallback:!1,maxWidth:Ue[String(n.width)]??236}}const Ge={theme:`theme`,showMedia:`showmedia`,showTitle:`showtitle`,showUsername:`showusername`,locale:`locale`,depth:`depth`},Ke={origin:`https://embed.reddit.com`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e);return t.type===`resize.embed`&&typeof t.data==`number`?t.data:void 0}};function qe(e,t){let n=[];for(let[e,r]of Object.entries(Ge)){let i=t[e];i!==void 0&&n.push([r,i])}return{kind:`iframe`,src:`https://embed.reddit.com${e.url.slice(22)}${a([[`embed`,!0]],Object.entries(e.options),n)}`,title:`Reddit post`,allow:`clipboard-read; clipboard-write`,sandbox:`allow-scripts allow-same-origin allow-popups`,scrolling:`no`,ratio:{width:1,height:1},messageHeight:Ke,startHeight:e.size?.height??316,maxWidth:640}}function Je(e){let t=e.options.title;return{kind:`iframe`,src:`${e.url}/embed`,title:typeof t==`string`&&t!==``?t:`Snapchat`,allow:`autoplay; camera; microphone; clipboard-write;`,scrolling:`no`,ratio:{width:416,height:692},size:e.size,maxWidth:416}}const Ye={visual:`visual`,color:`color`,autoPlay:`auto_play`,hideRelated:`hide_related`,showComments:`show_comments`,showUser:`show_user`,showReposts:`show_reposts`,showTeaser:`show_teaser`,showArtwork:`show_artwork`};function Xe(e,t){let n=[];for(let[e,r]of Object.entries(Ye)){let i=t[e];i!==void 0&&n.push([r,i])}let r=e.size===void 0;return{kind:`iframe`,src:`https://w.soundcloud.com/player/${a([[`url`,e.url]],r?[[`visual`,!0]]:void 0,i(e.options,[`url`,`secret_token`]),n)}`,title:`SoundCloud player`,allow:`autoplay; encrypted-media`,scrolling:`no`,ratio:{width:16,height:9},height:e.size?.height??400}}const Ze=/* @__PURE__ */ new Set([`track`,`episode`]);function Qe(e,t){let n=new URL(e.url).pathname.split(`/`)[1]??``,r=e.kind===`video`,i=a(Object.entries(e.options),t.theme===void 0?void 0:[[`theme`,t.theme]]);return{kind:`iframe`,src:`https://open.spotify.com/embed/${n}/${e.id}${r?`/video`:``}${i}`,title:`Spotify Embed`,allow:`autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture`,ratio:{width:16,height:9},size:r?e.size:void 0,borderRadius:12,height:r?void 0:e.size?.height??(Ze.has(n)?152:352)}}const $e=[[`comment`,`comment`],[`userpic`,`userpic`],[`mode`,`mode`],[`single`,`single`],[`color`,`color`],[`dark`,`dark`],[`darkColor`,`dark_color`]];function et(e,t){return typeof t==`boolean`?e===`userpic`?String(t):e===`single`?t?1:void 0:+!!t:typeof t==`string`||typeof t==`number`?t:void 0}const tt={origin:`https://t.me`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e);return t.event===`resize`&&typeof t.height==`number`?t.height:void 0}};function nt(e,t){let{userpic:n,color:r,dark:i,darkColor:o}=t,s={...e.options,...n===void 0?{}:{userpic:n},...r===void 0?{}:{color:r},...i===void 0?{}:{dark:i},...o===void 0?{}:{darkColor:o}},c=[[`embed`,1]];for(let[e,t]of $e){let n=et(t,s[e]);n!==void 0&&c.push([t,n])}return{kind:`iframe`,src:`${e.url}${a(c)}`,title:`Telegram post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:tt,startHeight:300,maxWidth:500}}function rt(e,t){let n=A(e.options,{theme:t.theme}),r=`<blockquote${je({"data-text-post-permalink":e.url,"data-text-post-version":n.version??0,id:`ig-tp-${e.id}`,"data-theme":n.theme})}>${e.fallbackHtml??``}</blockquote>`;return{kind:`script`,key:r,markup:r,driver:ge,minHeight:240,label:`Threads`,hasFallback:j(e.fallbackHtml),maxWidth:658}}const it={controls:`controls`,progressBar:`progress_bar`,playButton:`play_button`,volumeControl:`volume_control`,fullscreenButton:`fullscreen_button`,timestamp:`timestamp`,loop:`loop`,autoplay:`autoplay`,musicInfo:`music_info`,description:`description`,rel:`rel`,nativeContextMenu:`native_context_menu`,closedCaption:`closed_caption`,forceMuted:`force_muted`};function at(e,t){let n=o(t,it);return{kind:`iframe`,src:`https://www.tiktok.com/player/v1/${e.id}${a(Object.entries(e.options),n)}`,title:`TikTok video player`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share`,ratio:{width:9,height:16},size:e.size,maxWidth:325}}const ot={origin:`https://embed.tumblr.com`,read(e){if(typeof e!=`string`)return;let t=JSON.parse(e),[n]=Array.isArray(t.args)?t.args:[];return t.method===`tumblr-post:sizeChange`&&typeof n==`number`?n:void 0}};function st(e){return{kind:`iframe`,src:`https://embed.tumblr.com/embed/post/${e.url.slice(23).split(`/`)[0]??``}/${e.id}/v2`,title:`Tumblr post`,allow:``,scrolling:`no`,ratio:{width:1,height:1},messageHeight:ot,startHeight:400,maxWidth:540}}const ct=[`channel`,`video`,`collection`,`clip`,`parent`];function lt(e,t){let{hostname:n,pathname:r}=new URL(e);if(n===`clips.twitch.tv`)return[`https://clips.twitch.tv/embed`,[`clip`,t]];let i=r.split(`/`)[1];return[`https://player.twitch.tv/`,i===`videos`?[`video`,`v${t}`]:i===`collections`?[`collection`,t]:[`channel`,t]]}function ut(e,t){let{autoplay:n,muted:r,time:o}=t,s=[];n!==void 0&&s.push([`autoplay`,String(n)]),r!==void 0&&s.push([`muted`,String(r)]),o!==void 0&&s.push([`time`,o]);let[c,l]=lt(e.url,e.id);return{kind:`iframe`,src:`${c}${a([l],i(e.options,ct),s)}`,title:`Twitch player`,allow:``,ratio:{width:16,height:9},size:e.size,hostParam:`parent`}}const dt={autopause:`autopause`,autoplay:`autoplay`,background:`background`,byline:`byline`,color:`color`,controls:`controls`,dnt:`dnt`,keyboard:`keyboard`,loop:`loop`,muted:`muted`,pip:`pip`,playsinline:`playsinline`,portrait:`portrait`,quality:`quality`,speed:`speed`,title:`title`,transparent:`transparent`};function ft(e,t){let{t:n,...r}=t,{t:s,...c}=e.options,l=new URL(e.url).pathname.split(`/`)[2],u=o(r,dt),d=n??s;return{kind:`iframe`,src:`https://player.vimeo.com/video/${e.id}${a(l?[[`h`,l]]:void 0,i(c,[`h`]),u)}${d===void 0?``:`#t=${encodeURIComponent(String(d))}`}`,title:`Vimeo video player`,allow:`autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share`,referrerPolicy:`strict-origin-when-cross-origin`,ratio:{width:16,height:9},size:e.size}}const pt={theme:`data-theme`,conversation:`data-conversation`,cards:`data-cards`,align:`data-align`,lang:`data-lang`,dnt:`data-dnt`,width:`data-width`};function mt(e,t){let n=A(e.options,{...t}),r=e.fallbackHtml??`<a href="${O(e.url)}"></a>`,i=`<blockquote${k(pt,n)}>${r}</blockquote>`;return{kind:`script`,key:i,markup:i,driver:pe,minHeight:250,label:`X`,hasFallback:j(e.fallbackHtml),maxWidth:550}}const ht={autoplay:`autoplay`,ccLangPref:`cc_lang_pref`,ccLoadPolicy:`cc_load_policy`,color:`color`,controls:`controls`,disablekb:`disablekb`,enablejsapi:`enablejsapi`,end:`end`,fs:`fs`,hl:`hl`,ivLoadPolicy:`iv_load_policy`,list:`list`,listType:`listType`,loop:`loop`,origin:`origin`,playlist:`playlist`,playsinline:`playsinline`,rel:`rel`,start:`start`,widgetReferrer:`widget_referrer`};function gt(e,t){let{nocookie:n,...r}=t,{nocookie:i,...s}=e.options,c=n??i===!0?`https://www.youtube-nocookie.com`:`https://www.youtube.com`,l=o(r,ht);return{kind:`iframe`,src:`${c}/embed/${e.id}${a(Object.entries(s),l)}`,title:`YouTube video player`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,referrerPolicy:`strict-origin-when-cross-origin`,ratio:e.url.includes(`/shorts/`)?{width:9,height:16}:{width:16,height:9},size:e.size}}function _t(e){switch(e.platform){case`x`:return mt(e,{});case`instagram`:return Re(e,{});case`threads`:return rt(e,{});case`facebook`:return Ie(e,{});case`tiktok`:return at(e,{});case`youtube`:return gt(e,{});case`telegram`:return nt(e,{});case`snapchat`:return Je(e);case`linkedin`:return Ve(e,{});case`reddit`:return qe(e,{});case`pinterest`:return We(e,{});case`spotify`:return Qe(e,{});case`vimeo`:return ft(e,{});case`twitch`:return ut(e,{});case`dailymotion`:return u(e,{});case`bluesky`:return c(e,{});case`soundcloud`:return Xe(e,{});case`applemusic`:return n(e);case`applepodcasts`:return r(e);case`tumblr`:return st(e);case`kick`:return Be(e,{});case`giphy`:return Le(e);default:return e.platform}}const vt=/^(?:https?:)?\/\/([^/?#\s@]+)((?:\/[^?#\s]*)?)(?:\?([^#\s]*))?(?:#(\S*))?$/i;function M(e){let t=vt.exec(e.trim());if(!t)return null;let[,n=``,r=``,i=``,a]=t,o=/* @__PURE__ */ new Map;for(let e of i.split(`&`)){if(e===``)continue;let t=e.indexOf(`=`),n=yt(t===-1?e:e.slice(0,t)),r=yt(t===-1?``:e.slice(t+1));if(n===null||r===null)return null;o.has(n)||o.set(n,r)}return{host:n.toLowerCase(),path:r,query:o,...a?{fragment:a}:{}}}function yt(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return null}}function N(e){return e===`true`?!0:e===`false`?!1:/^(?:0|[1-9]\d{0,14})$/.test(e)?Number(e):e}function P(e){return e!==void 0&&/^[1-9]\d{0,5}$/.test(e)?Number(e):void 0}function F(e,t,n){let r={};for(let[i,a]of t){let t=e.attrs.get(i);t!==void 0&&!(a in r)&&(r[a]=n(t))}return r}function I(e){let t=P(e.attrs.get(`width`)),n=P(e.attrs.get(`height`));if(t!==void 0||n!==void 0)return{...t===void 0?{}:{width:t},...n===void 0?{}:{height:n}}}function L(e,t){return t?{...e,size:t}:e}function bt(e,t){if(e.tag!==`div`||e.attrs.size!==1)return null;let[,n]=t.exec(e.attrs.get(`style`)??``)??[];if(n===void 0)return null;let r;for(let t of e.children)if(!(t.type===`text`&&/^\s*$/.test(t.raw))){if(t.type!==`element`||t.tag!==`iframe`||r)return null;r=t}let i=Math.round(Number(n)*100);if(!r||!(i>0&&i<=1e5))return null;let a=xt(1e4,i);return{iframe:r,size:{width:1e4/a,height:i/a}}}function xt(e,t){return t===0?e:xt(t,e%t)}const St=/^\/([a-z]{2})\/(album|song|playlist)\/(?:[^/]{1,200}\/)?(\d{1,15}|pl\.[A-Za-z0-9-]{1,64})\/?$/,Ct=/^\d{1,15}$/;function wt(e,t){if(e?.host!==t)return null;let[,n,r,i]=St.exec(e.path)??[];if(n===void 0||r===void 0||i===void 0||(r===`playlist`?!i.startsWith(`pl.`):!Ct.test(i)))return null;let a=r===`album`?e.query.get(`i`):void 0;return a!==void 0&&!Ct.test(a)?null:{kind:`post`,url:`https://music.apple.com/${n}/${r}/${i}${a?`?i=${a}`:``}`,id:a??i,variant:`iframe`}}const Tt={platform:`applemusic`,parse(e){if(e.tag!==`iframe`)return null;let t=wt(M(e.attrs.get(`src`)??``),`embed.music.apple.com`);if(!t)return null;let{height:n}=I(e)??{};return L({platform:`applemusic`,...t,options:{}},n===void 0?void 0:{height:n})},isOwnScript:()=>!1,match(e){let t=wt(e,`music.apple.com`);return t&&{platform:`applemusic`,...t,options:{}}}},Et=/^\/([a-z]{2})\/podcast\/(?:[^/]{1,200}\/)?(?:id)?(\d{1,15})\/?$/,Dt=/^\d{1,15}$/;function Ot(e,t){if(e?.host!==t)return null;let[,n,r]=Et.exec(e.path)??[];if(n===void 0||r===void 0)return null;let i=e.query.get(`i`);return i!==void 0&&!Dt.test(i)?null:{platform:`applepodcasts`,kind:`post`,url:`https://podcasts.apple.com/${n}/podcast/id${r}${i?`?i=${i}`:``}`,id:i??r,variant:`iframe`}}const kt={platform:`applepodcasts`,parse(e){if(e.tag!==`iframe`)return null;let t=Ot(M(e.attrs.get(`src`)??``),`embed.podcasts.apple.com`);return t&&L({...t,options:{}},I(e))},isOwnScript:()=>!1,match(e){let t=Ot(e,`podcasts.apple.com`);return t&&{...t,options:{}}}},At=`(did:(?:plc:[a-z2-7]{24}|web:[a-z0-9.-]{1,253}))`,jt=`((?!\\.{1,2}(?:/|$))[A-Za-z0-9._~:-]{1,512})`,Mt=/* @__PURE__ */ new Set([`bsky.app`,`www.bsky.app`]),Nt=RegExp(`^/profile/${At}/post/${jt}/?$`),Pt=RegExp(`^at://${At}/app\\.bsky\\.feed\\.post/${jt}$`),Ft=/^[a-z2-7]{20,100}$/,It=/* @__PURE__ */ new Set([`light`,`dark`,`system`]),Lt=/^(?:https?:)?\/\/embed\.bsky\.app\/static\/embed\.js$/,Rt=/* @__PURE__ */ new Map([[`p`,[`lang`]],[`a`,[`href`]],[`br`,[]]]);function zt(e,t){return{platform:`bluesky`,kind:`post`,url:`https://bsky.app/profile/${e}/post/${t}`,id:`${e}/app.bsky.feed.post/${t}`,variant:`iframe`}}function Bt(e){if(!e||!Mt.has(e.host))return null;let[,t,n]=Nt.exec(e.path)??[];return t===void 0||n===void 0?null:zt(t,n)}const Vt={platform:`bluesky`,fallback:Rt,parse(e){if(e.tag!==`blockquote`||!T(e,`bluesky-embed`))return null;let[,t,n]=Pt.exec(e.attrs.get(`data-bluesky-uri`)??``)??[];if(t===void 0||n===void 0)return null;let r=zt(t,n);if(E(e.children).reverse().map(e=>e.tag===`a`?Bt(M(e.attrs.get(`href`)??``)):null).find(e=>e!==null)?.id!==r.id)return null;let i={},a=e.attrs.get(`data-bluesky-cid`);a!==void 0&&Ft.test(a)&&(i.cid=a);let o=e.attrs.get(`data-bluesky-embed-color-mode`);return o!==void 0&&It.has(o)&&(i.colorMode=o),{...r,options:i,fallbackHtml:D(e.children,Rt)}},isOwnScript:e=>Lt.test(e),match(e){let t=Bt(e);return t&&{...t,options:{}}}},Ht=/^x[a-z0-9]{4,12}$/,Ut=/^x[a-z0-9]{3,12}$/,Wt=/^position:\s*relative;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*height:\s*0;\s*overflow:\s*hidden;?$/,Gt=/* @__PURE__ */ new Set([`dailymotion.com`,`www.dailymotion.com`]);function R(e,t){return{platform:`dailymotion`,kind:`video`,url:`https://www.dailymotion.com/video/${e}`,id:e,variant:`iframe`,options:t}}function Kt(e){if(e.host!==`geo.dailymotion.com`||e.query.has(`playlist`))return null;let t=/^\/player(?:\/([a-z0-9]+))?\.html$/.exec(e.path);if(!t)return null;let[,n]=t,r=e.query.get(`video`)??``;if(!Ht.test(r)||n!==void 0&&!Ut.test(n))return null;let i=Object.fromEntries([...e.query].filter(([e])=>e!==`video`).map(([e,t])=>[e,N(t)]));return n!==void 0&&(i.playerId=n),R(r,i)}function qt(e){if(e.host===`dai.ly`){let t=e.path.replace(/^\/|\/$/g,``);return Ht.test(t)?R(t,{}):null}if(!Gt.has(e.host))return null;let[,t]=/^(?:\/embed)?\/video\/([a-z0-9]+)\/?$/.exec(e.path)??[];return t!==void 0&&Ht.test(t)?R(t,{}):null}const Jt={platform:`dailymotion`,parse(e){let t=bt(e,Wt),n=t?.iframe??e;if(n.tag!==`iframe`)return null;let r=M(n.attrs.get(`src`)??``);if(!r)return null;let i=Kt(r)??qt(r);return i&&L(i,t?.size??I(n))},isOwnScript:()=>!1,match(e){return Kt(e)??qt(e)}},Yt=/* @__PURE__ */ new Set([`facebook.com`,`www.facebook.com`,`m.facebook.com`]),Xt=/* @__PURE__ */ new Set([`facebook.com`,`www.facebook.com`]),z=`https://www.facebook.com`,B=`[A-Za-z0-9.\\-]{1,80}`,Zt=`(?:\\d{1,25}|pfbid[A-Za-z0-9]{10,120})`,Qt=RegExp(`^/(${B})/posts/(${Zt})/?$`),$t=RegExp(`^/(${B})/photos/([A-Za-z0-9.]{1,40})/(\\d{1,25})/?$`),en=RegExp(`^/(${B})/videos/(?:[^/]{1,200}/)?(\\d{1,25})/?$`),tn=/^\/reel\/(\d{1,25})\/?$/,nn=/* @__PURE__ */ new Set([`/permalink.php`,`/story.php`]),rn=/* @__PURE__ */ new Set([`/photo.php`,`/photo/`,`/photo`]),an=RegExp(`^${Zt}$`),V=/^\d{1,25}$/,on=/^(?:https?:)?\/\/connect\.facebook\.net\/([a-z]{2,3}_[A-Z]{2})\/sdk\.js(?:[?#].*)?$/,sn=[[`data-width`,`width`],[`data-show-text`,`showText`],[`data-lazy`,`lazy`],[`data-allowfullscreen`,`allowfullscreen`],[`data-autoplay`,`autoplay`],[`data-show-captions`,`showCaptions`]],cn=[[`show_text`,`showText`],[`allowfullscreen`,`allowfullscreen`],[`autoplay`,`autoplay`],[`show_captions`,`showCaptions`]],ln={name:`class`,value:/^fb-xfbml-parse-ignore$/},un=/* @__PURE__ */ new Map([[`div`,[ln]],[`blockquote`,[`cite`,ln]],[`a`,[`href`]],[`p`,[]]]);function H(e){if(!e||!Yt.has(e.host))return null;let{path:t,query:n}=e,[,r,i]=Qt.exec(t)??[];if(r!==void 0&&i!==void 0)return{kind:`post`,id:i,url:`${z}/${r}/posts/${i}`};if(nn.has(t)){let e=n.get(`story_fbid`);if(e===void 0||!an.test(e))return null;let r=n.get(`id`),i=r!==void 0&&V.test(r)?`&id=${r}`:``;return{kind:`post`,id:e,url:`${z}${t}?story_fbid=${e}${i}`}}if(rn.has(t)){let e=n.get(`fbid`);return e===void 0||!V.test(e)?null:{kind:`post`,id:e,url:`${z}${t}?fbid=${e}`}}let[,a,o,s]=$t.exec(t)??[];if(a!==void 0&&o!==void 0&&s!==void 0)return{kind:`post`,id:s,url:`${z}/${a}/photos/${o}/${s}/`};let[,c,l]=en.exec(t)??[];if(c!==void 0&&l!==void 0)return{kind:`video`,id:l,url:`${z}/${c}/videos/${l}/`};if(t===`/watch`||t===`/watch/`||t===`/video.php`){let e=n.get(`v`);return e===void 0||!V.test(e)?null:{kind:`video`,id:e,url:`${z}${t===`/video.php`?t:`/watch/`}?v=${e}`}}let[,u]=tn.exec(t)??[];return u===void 0?null:{kind:`video`,id:u,url:`${z}/reel/${u}`}}function U(e,t,n,r){return{platform:`facebook`,kind:t,url:e.url,id:e.id,variant:n,options:r}}const dn={platform:`facebook`,fallback:un,parse(e){if(e.tag===`div`){let t=T(e,`fb-post`)?`post`:T(e,`fb-video`)?`video`:null,n=H(M(e.attrs.get(`data-href`)??``));return!t||!n?null:{...U(n,t,`sdk`,F(e,sn,N)),fallbackHtml:D(e.children,un)}}if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(!t||!Xt.has(t.host))return null;let n=H(M(t.query.get(`href`)??``));if(!n)return null;if(t.path===`/plugins/post.php`){let e={},r=t.query.get(`show_text`),i=t.query.get(`width`);return r!==void 0&&(e.showText=N(r)),i!==void 0&&(e.width=N(i)),U(n,`post`,`sdk`,e)}if(t.path===`/plugins/video.php`){let r=N(t.query.get(`show_text`)??``);if(r===!0||r===1){let e={};for(let[n,r]of cn){let i=t.query.get(n);i!==void 0&&(e[r]=N(i))}let r=P(t.query.get(`width`)),i=P(t.query.get(`height`));return L(U(n,`video`,`sdk`,{...e,showText:!0}),r===void 0||i===void 0?void 0:{width:r,height:i})}return L(U(n,`video`,`iframe`,Object.fromEntries([...t.query].filter(([e])=>e!==`href`).map(([e,t])=>[e,N(t)]))),I(e))}return null},isOwnScript:e=>on.test(e),scriptOptions(e){let[,t]=on.exec(e)??[];return t===void 0?{}:{locale:t}},allowsFbRoot:!0,match(e){let t=H(e);return t&&U(t,t.kind,`sdk`,{})}},W=`([A-Za-z0-9]{6,40})`,G=/* @__PURE__ */ new Set([`giphy.com`,`www.giphy.com`]),fn=RegExp(`^/gifs/(?:[A-Za-z0-9-]{0,200}-)?${W}/?$`),pn=RegExp(`^/embed/${W}/?$`),mn=/^media\d?\.giphy\.com$/,hn=RegExp(`^/media/${W}/giphy\\.(?:gif|webp|mp4)$`),gn=/^width:\s*100%;\s*height:\s*0;\s*padding-bottom:\s*(\d{1,3}(?:\.\d{1,4})?)%;\s*position:\s*relative;?$/;function _n(e){return{platform:`giphy`,kind:`video`,url:`https://giphy.com/gifs/${e}`,id:e,variant:`iframe`}}function vn(e){if(e){if(G.has(e.host))return(fn.exec(e.path)??pn.exec(e.path))?.[1];if(mn.test(e.host))return hn.exec(e.path)?.[1]}}function yn(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(!t||!G.has(t.host))return null;let[,n]=pn.exec(t.path)??[];return n===void 0?null:_n(n)}function bn(e,t){if(e.tag!==`p`||e.attrs.size!==0)return!1;let[n,...r]=e.children;if(r.length>0||n?.type!==`element`||n.tag!==`a`||n.attrs.size!==1)return!1;let i=M(n.attrs.get(`href`)??``);if(!i||!G.has(i.host)||fn.exec(i.path)?.[1]!==t.id)return!1;let[a,...o]=n.children;return o.length===0&&a?.type===`text`&&a.raw.trim()===`via GIPHY`}const xn={platform:`giphy`,parse(e){let t=bt(e,gn),n=t?.iframe??e,r=yn(n);return r?L({...r,options:{}},t?.size??I(n)):null},isOwnScript:()=>!1,isOwnExtra:bn,match(e){let t=vn(e);return t===void 0?null:{..._n(t),options:{}}}},Sn=/* @__PURE__ */ new Set([`instagram.com`,`www.instagram.com`]),Cn=/^\/(?:([A-Za-z0-9._]{1,30})\/)?(p|reel|reels|tv)\/([A-Za-z0-9_-]{1,64})\/?$/,wn=/* @__PURE__ */ new Set([`p`,`reel`,`reels`,`tv`]),Tn=/* @__PURE__ */ new Set([`p`,`reel`]),En=/^(?:https?:)?\/\/www\.instagram\.com\/embed\.js$/,Dn=/* @__PURE__ */ new Map([[`div`,[]],[`a`,[`href`]],[`p`,[]]]);function K(e){if(!e||!Sn.has(e.host))return null;let[,t,n,r]=Cn.exec(e.path)??[];return n===void 0||r===void 0||t!==void 0&&(wn.has(t)||!Tn.has(n))?null:{platform:`instagram`,kind:`post`,url:`https://www.instagram.com/${n===`reels`?`reel`:n}/${r}/`,id:r,variant:`sdk`}}const On={platform:`instagram`,fallback:Dn,parse(e){if(e.tag!==`blockquote`||!T(e,`instagram-media`))return null;let t=e.attrs.get(`data-instgrm-permalink`),n=t===void 0?E(e.children).reverse().map(e=>e.tag===`a`?K(M(e.attrs.get(`href`)??``)):null).find(e=>e!==null):K(M(t));if(!n)return null;let r={};e.attrs.has(`data-instgrm-captioned`)&&(r.captioned=!0);let i=e.attrs.get(`data-instgrm-version`);return i!==void 0&&(r.version=N(i)),{...n,options:r,fallbackHtml:D(e.children,Dn)}},isOwnScript:e=>En.test(e),match(e){let t=K(e);return t&&{...t,options:{}}}},kn=/* @__PURE__ */ new Set([`kick.com`,`www.kick.com`]),An=/^\/([A-Za-z0-9_-]{1,32})\/?$/,jn=/* @__PURE__ */ new Set([`browse`,`categories`,`category`,`clips`,`video`,`videos`,`following`,`search`,`settings`,`dashboard`,`subscriptions`,`privacy-policy`,`terms-of-service`,`community-guidelines`,`help`]),Mn=/* @__PURE__ */ new Set([`autoplay`,`muted`]);function Nn(e,t){if(!e||!t.has(e.host))return null;let[,n]=An.exec(e.path)??[];if(n===void 0||jn.has(n.toLowerCase()))return null;let r=n.toLowerCase();return{platform:`kick`,kind:`video`,url:`https://kick.com/${r}`,id:r,variant:`iframe`}}const Pn=/* @__PURE__ */ new Set([`player.kick.com`]),Fn={platform:`kick`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``),n=Nn(t,Pn);if(!n||!t)return null;let r=Object.fromEntries([...t.query].filter(([e])=>Mn.has(e)).map(([e,t])=>[e,N(t)]));return L({...n,options:r},I(e))},isOwnScript:()=>!1,match(e){let t=Nn(e,kn)??Nn(e,Pn);return t&&{...t,options:{}}}},In=/^(?:www\.|[a-z]{2}\.)?linkedin\.com$/,Ln=`(activity|share|ugcPost):(\\d{19})`,Rn=RegExp(`^(?:/embed)?/feed/update/urn:li:${Ln}/?$`),zn=/* @__PURE__ */ RegExp(`^/posts/[^/]{1,300}-(activity|share|ugcPost)-(\\d{19})-[A-Za-z0-9_-]{1,8}/?$`),Bn=RegExp(`^/embed/feed/update/urn:li:${Ln}$`);function Vn(e,t,n={}){let r=`urn:li:${e}:${t}`;return{platform:`linkedin`,kind:`post`,url:`https://www.linkedin.com/feed/update/${r}/`,id:r,variant:`iframe`,options:n}}const Hn=e=>e.replace(/%3A/gi,`:`),Un={platform:`linkedin`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(t?.host!==`www.linkedin.com`)return null;let[,n,r]=Bn.exec(t.path)??[];return n===void 0||r===void 0?null:L(Vn(n,r,Object.fromEntries([...t.query].map(([e,t])=>[e,N(t)]))),I(e))},isOwnScript:()=>!1,match(e){if(!In.test(e.host))return null;let t=Hn(e.path),[,n,r]=Rn.exec(t)??zn.exec(t)??[];return n===void 0||r===void 0?null:Vn(n,r)}},Wn=/^(?:(?:www|[a-z]{2})\.)?pinterest\.(?:[a-z]{2,3}|co\.[a-z]{2}|com\.[a-z]{2})$/,Gn=/^\/pin\/(?:[A-Za-z0-9-]{0,200}--)?(\d{1,25})\/?$/,Kn=/^\d{1,25}$/,qn=/^(?:https?:)?\/\/assets\.pinterest\.com\/js\/pinit(?:_main)?\.js$/,Jn=[[`data-pin-width`,`width`],[`data-pin-lang`,`lang`],[`data-pin-terse`,`terse`]];function Yn(e){return{platform:`pinterest`,kind:`post`,url:`https://www.pinterest.com/pin/${e}/`,id:e,variant:`sdk`}}function Xn(e){if(!e||!Wn.test(e.host))return null;let[,t]=Gn.exec(e.path)??[];return t===void 0?null:Yn(t)}const Zn={platform:`pinterest`,parse(e){if(e.tag===`a`){if(e.attrs.get(`data-pin-do`)!==`embedPin`||e.children.some(e=>e.type===`element`))return null;let t=Xn(M(e.attrs.get(`href`)??``));return t&&{...t,options:F(e,Jn,N)}}if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(t?.host!==`assets.pinterest.com`||t.path!==`/ext/embed.html`)return null;let n=t.query.get(`id`);return n!==void 0&&Kn.test(n)?{...Yn(n),options:{}}:null},isOwnScript:e=>qn.test(e),match(e){let t=Xn(e);return t&&{...t,options:{}}}},Qn=/* @__PURE__ */ new Set([`reddit.com`,`www.reddit.com`,`old.reddit.com`,`new.reddit.com`]),$n=/^\/r\/([A-Za-z0-9_]{2,21})\/comments\/([a-z0-9]{1,12})(?:\/([^/]{1,300}))?(?:\/([a-z0-9]{1,16}))?\/?$/,er=/^(?:https?:)?\/\/embed\.reddit\.com\/widgets\.js$/,tr=[`depth`,`style`,`theme`,`showmedia`,`showtitle`,`showedits`,`created`,`locale`,`showusername`,`snippet`].map(e=>[`data-embed-${e}`,e]);function nr(e){if(!e||!Qn.has(e.host))return null;let[,t,n,r,i]=$n.exec(e.path)??[];if(t===void 0||n===void 0)return null;let a={platform:`reddit`,kind:`post`,variant:`iframe`},o=`https://www.reddit.com/r/${t}/comments/${n}/`;return i===void 0?{...a,url:o,id:n}:r===void 0?null:{...a,url:`${o}comment/${i}/`,id:i}}const rr={platform:`reddit`,parse(e){if(e.tag!==`blockquote`||!T(e,`reddit-embed-bq`))return null;let t=E(e.children).map(e=>e.tag===`a`?nr(M(e.attrs.get(`href`)??``)):null).find(e=>e!==null);if(!t)return null;let n=P(e.attrs.get(`data-embed-height`));return L({...t,options:F(e,tr,N)},n===void 0?void 0:{height:n})},isOwnScript:e=>er.test(e),match(e){let t=nr(e);return t&&{...t,options:{}}}},ir=/* @__PURE__ */ new Set([`snapchat.com`,`www.snapchat.com`]),ar=`([A-Za-z][A-Za-z0-9._-]{1,29})`,or=RegExp(`^(?:/@${ar})?/spotlight/([A-Za-z0-9_-]{20,120})$`),sr=RegExp(`^/(?:@|add/)${ar}$`),cr=/^\/lens\/([0-9a-f]{32}|\d{1,20})$/,lr=RegExp(`^/@${ar}/highlight/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`),ur=/^(?:https?:)?\/\/www\.snapchat\.com\/embed\.js$/;function dr(e){if(!e||!ir.has(e.host))return null;let t=e.path.replace(/\/$/,``),n={platform:`snapchat`,variant:`iframe`},[,r,i]=or.exec(t)??[];if(i!==void 0){let e=r===void 0?``:`/@${r}`;return{...n,kind:`video`,url:`https://www.snapchat.com${e}/spotlight/${i}`,id:i}}let[,a]=sr.exec(t)??[];if(a!==void 0)return{...n,kind:`post`,url:`https://www.snapchat.com/@${a}`,id:a};let[,o]=cr.exec(t)??[];if(o!==void 0)return{...n,kind:`post`,url:`https://www.snapchat.com/lens/${o}`,id:o};let[,s,c]=lr.exec(t)??[];return s!==void 0&&c!==void 0?{...n,kind:`post`,url:`https://www.snapchat.com/@${s}/highlight/${c}`,id:c}:null}const fr={platform:`snapchat`,parse(e){if(e.tag!==`blockquote`||!T(e,`snapchat-embed`))return null;let t=M(e.attrs.get(`data-snapchat-embed-url`)??``);if(!t?.path.endsWith(`/embed`))return null;let n=dr({...t,path:t.path.slice(0,-6)});if(!n||!E(e.children).filter(e=>e.tag===`a`).every(e=>{let t=dr(M(e.attrs.get(`href`)??``));return t?.kind===n.kind&&t.id===n.id}))return null;let r=e.attrs.get(`data-snapchat-embed-title`),i=P(e.attrs.get(`data-snapchat-embed-width`)),a=P(e.attrs.get(`data-snapchat-embed-height`));return L({...n,options:r===void 0?{}:{title:r}},i===void 0||a===void 0?void 0:{width:i,height:a})},isOwnScript:e=>ur.test(e),match(e){let t=dr(e);return t&&{...t,options:{}}}},pr=/* @__PURE__ */ new Set([`soundcloud.com`,`www.soundcloud.com`,`m.soundcloud.com`]),mr=/^\/(tracks|playlists|users)\/(?:soundcloud%3A(?:tracks|playlists|users)%3A)?(\d{1,15})\/?$/i,hr=`[a-z0-9_-]{1,64}`,gr=`s-[A-Za-z0-9]{1,32}`,_r=RegExp(`^/(${hr})(?:/(sets/${hr}|${hr})(?:/(${gr}))?)?/?$`,`i`),vr=/* @__PURE__ */ new Set([`discover`,`search`,`stream`,`feed`,`you`,`upload`,`charts`,`pages`,`settings`,`messages`,`notifications`,`people`,`stations`,`library`,`terms-of-use`,`signin`]),yr=/* @__PURE__ */ new Set([`likes`,`tracks`,`sets`,`albums`,`reposts`,`popular-tracks`,`followers`,`following`,`comments`,`spotlight`,`toptracks`]),br=RegExp(`^${gr}$`);function xr(e,t){return{platform:`soundcloud`,kind:`post`,url:e,id:t,variant:`iframe`}}function Sr(e){if(e?.host!==`api.soundcloud.com`)return null;let[,t,n]=mr.exec(e.path)??[];if(t===void 0||n===void 0)return null;let r=e.query.get(`secret_token`);if(r!==void 0&&!br.test(r))return null;let i=r===void 0?``:`?secret_token=${r}`;return xr(`https://api.soundcloud.com/${t.toLowerCase()}/${n}${i}`,n)}function Cr(e){if(!pr.has(e.host))return null;let[,t,n,r]=_r.exec(e.path)??[];if(t===void 0||vr.has(t.toLowerCase())||n!==void 0&&yr.has(n.toLowerCase()))return null;let i=[t,n,r].filter(Boolean).join(`/`);return xr(`https://soundcloud.com/${i}`,i)}const wr=/* @__PURE__ */ new Set([`href`,`title`,`target`,`style`]);function Tr(e){if(e?.type!==`element`||e.tag!==`a`||[...e.attrs.keys()].some(e=>!wr.has(e)))return!1;let[t,...n]=e.children;return n.length===0&&t?.type===`text`&&pr.has(M(e.attrs.get(`href`)??``)?.host??``)}function Er(e){if(e.tag!==`div`||e.attrs.size!==1||!e.attrs.has(`style`))return!1;let[t,n,r,...i]=e.children;return i.length===0&&Tr(t)&&n?.type===`text`&&/^\s*·\s*$/.test(n.raw)&&Tr(r)}const Dr={platform:`soundcloud`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(t?.host!==`w.soundcloud.com`||!/^\/player\/?$/.test(t.path))return null;let n=Sr(M(t.query.get(`url`)??``));if(!n)return null;let r=t.query.get(`secret_token`);if(r!==void 0){if(!br.test(r))return null;n.url.includes(`?`)||(n={...n,url:`${n.url}?secret_token=${r}`})}let i=Object.fromEntries([...t.query].filter(([e])=>e!==`url`&&e!==`secret_token`).map(([e,t])=>[e,N(t)])),{height:a}=I(e)??{};return L({...n,options:i},a===void 0?void 0:{height:a})},isOwnScript:()=>!1,isOwnExtra:Er,match(e){let t=Sr(e)??Cr(e);return t&&{...t,options:{}}}},Or=/* @__PURE__ */ RegExp(`^(?:/intl-[a-z]{2}(?:-[A-Za-z]{2})?)?(?:/embed)?/(track|album|playlist|artist|episode|show|audiobook|chapter)/([A-Za-z0-9]{22})(/video)?/?$`),kr=/* @__PURE__ */ new Set([`utm_source`,`si`]);function Ar(e){if(e?.host!==`open.spotify.com`)return null;let[,t,n,r]=Or.exec(e.path)??[];return t===void 0||n===void 0?null:{platform:`spotify`,kind:r?`video`:`post`,url:`https://open.spotify.com/${t}/${n}`,id:n,variant:`iframe`,query:e.query}}function jr(e){return Object.fromEntries([...e].filter(([e])=>!kr.has(e)).map(([e,t])=>[e,N(t)]))}const Mr={platform:`spotify`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(!t?.path.startsWith(`/embed/`))return null;let n=Ar(t);if(!n)return null;let{query:r,...i}=n;return L({...i,options:jr(r)},I(e))},isOwnScript:()=>!1,match(e){let t=Ar(e);return t&&{platform:t.platform,kind:`post`,url:t.url,id:t.id,variant:t.variant,options:{}}}},Nr=/* @__PURE__ */ new Set([`t.me`,`telegram.me`,`www.telegram.me`]),Pr=`[A-Za-z][A-Za-z0-9_]{2,31}`,Fr=RegExp(`^(${Pr})/(\\d{1,10})$`),Ir=RegExp(`^/(?:s/)?(${Pr})/(\\d{1,10})/?$`),Lr=/^(?:https?:)?\/\/telegram\.org\/js\/telegram-widget\.js(?:\?\d{1,3})?$/,Rr=[`data-telegram-login`,`data-telegram-discussion`,`data-telegram-share-url`],zr=[[`data-width`,`width`],[`data-comment`,`comment`],[`data-userpic`,`userpic`],[`data-mode`,`mode`],[`data-color`,`color`],[`data-dark`,`dark`],[`data-dark-color`,`darkColor`]];function Br(e,t,n){return{platform:`telegram`,kind:`post`,url:`https://t.me/${e}/${t}`,id:`${e}/${t}`,variant:`iframe`,options:n}}const Vr={platform:`telegram`,parse:()=>null,parseScript(e){if(!Lr.test(e.attrs.get(`src`)??``)||Rr.some(t=>e.attrs.has(t)))return null;let[,t,n]=Fr.exec(e.attrs.get(`data-telegram-post`)??``)??[];if(t===void 0||n===void 0)return null;let r=F(e,zr,N);return e.attrs.has(`data-single`)&&(r.single=!0),Br(t,n,r)},isOwnScript:e=>Lr.test(e),match(e){if(!Nr.has(e.host))return null;let[,t,n]=Ir.exec(e.path)??[];if(t===void 0||n===void 0)return null;let r={};e.query.has(`single`)&&(r.single=!0);let i=e.query.get(`comment`);return i!==void 0&&/^\d{1,10}$/.test(i)&&(r.comment=Number(i)),Br(t,n,r)}},Hr=/* @__PURE__ */ new Set([`threads.com`,`www.threads.com`,`threads.net`,`www.threads.net`]),Ur=/^\/(?:@[A-Za-z0-9._]{1,30}\/post|t)\/([A-Za-z0-9_-]{1,64})\/?$/,Wr=/^(?:https?:)?\/\/www\.threads\.(?:com|net)\/embed\.js$/,Gr=[[`data-theme`,`theme`],[`data-text-post-version`,`version`]],Kr=/* @__PURE__ */ new Map([[`a`,[`href`]],[`div`,[]]]);function qr(e){if(!e||!Hr.has(e.host))return null;let[,t]=Ur.exec(e.path)??[];return t===void 0?null:{platform:`threads`,kind:`post`,url:`https://www.threads.com/t/${t}`,id:t,variant:`sdk`}}const Jr={platform:`threads`,fallback:Kr,parse(e){if(e.tag!==`blockquote`||!T(e,`text-post-media`))return null;let t=qr(M(e.attrs.get(`data-text-post-permalink`)??``));if(!t)return null;let n=e.attrs.get(`id`);return n!==void 0&&n!==`ig-tp-${t.id}`?null:{...t,options:F(e,Gr,N),fallbackHtml:D(e.children,Kr)}},isOwnScript:e=>Wr.test(e),match(e){let t=qr(e);return t&&{...t,options:{}}}},Yr=/* @__PURE__ */ new Set([`tiktok.com`,`www.tiktok.com`]),Xr=/^\/@([A-Za-z0-9._]{0,64})\/video\/(\d{1,25})\/?$/,Zr=/^\/player\/v1\/(\d{1,25})\/?$/,Qr=/^\d{1,25}$/,$r=/^(?:https?:)?\/\/www\.tiktok\.com\/embed\.js$/;function ei(e,t=``,n={}){return{platform:`tiktok`,kind:`video`,url:`https://www.tiktok.com/@${t}/video/${e}`,id:e,variant:`iframe`,options:n}}const ti={platform:`tiktok`,parse(e){if(e.tag===`blockquote`&&T(e,`tiktok-embed`)){let t=M(e.attrs.get(`cite`)??``),[,n,r]=t&&Yr.has(t.host)?Xr.exec(t.path)??[]:[],i=e.attrs.get(`data-video-id`);if(i!==void 0&&!Qr.test(i)||i!==void 0&&r!==void 0&&i!==r)return null;let a=i??r;return a===void 0?null:ei(a,n)}if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(!t||!Yr.has(t.host))return null;let[,n]=Zr.exec(t.path)??[];return n===void 0?null:L(ei(n,``,Object.fromEntries([...t.query].map(([e,t])=>[e,N(t)]))),I(e))},isOwnScript:e=>$r.test(e),match(e){if(!Yr.has(e.host))return null;let[,t,n]=Xr.exec(e.path)??[];return t===void 0||n===void 0?null:ei(n,t)}},ni=`([a-z0-9-]{1,32})`,ri=`(\\d{1,20})`,ii=/* @__PURE__ */ new Set([`www.tumblr.com`,`tumblr.com`]),ai=RegExp(`^/${ni}/${ri}(?:/[^/]{1,200})?/?$`),oi=RegExp(`^${ni}\\.tumblr\\.com$`),si=RegExp(`^/post/${ri}(?:/[^/]{1,200})?/?$`),ci=RegExp(`^/embed/post/(?:t:[A-Za-z0-9_-]{1,64}|${ni})/${ri}/v2$`),li=/* @__PURE__ */ new Set([`dashboard`,`explore`,`tagged`,`search`,`settings`,`blog`,`www`,`assets`,`embed`,`api`,`help`]),ui=/^(?:https?:)?\/\/assets\.tumblr\.com\/post\.js(?:\?[^#]*)?$/;function di(e){if(!e)return null;let t,n;return ii.has(e.host)?[,t,n]=ai.exec(e.path)??[]:([,t]=oi.exec(e.host)??[],[,n]=si.exec(e.path)??[]),t===void 0||n===void 0||li.has(t)?null:{platform:`tumblr`,kind:`post`,url:`https://www.tumblr.com/${t}/${n}`,id:n,variant:`iframe`}}const fi={platform:`tumblr`,parse(e){if(e.tag!==`div`||!T(e,`tumblr-post`))return null;let t=M(e.attrs.get(`data-href`)??``);if(t?.host!==`embed.tumblr.com`)return null;let[,n,r]=ci.exec(t.path)??[];if(r===void 0)return null;let[i,...a]=e.children.filter(e=>e.type!==`text`||e.raw.trim()!==``);if(a.length>0||i?.type!==`element`||i.tag!==`a`)return null;let o=di(M(i.attrs.get(`href`)??``));return o?.id!==r||n!==void 0&&o.url!==`https://www.tumblr.com/${n}/${r}`?null:{...o,options:{}}},isOwnScript:e=>ui.test(e),match(e){let t=di(e);return t&&{...t,options:{}}}},pi=/* @__PURE__ */ new Set([`twitch.tv`,`www.twitch.tv`,`m.twitch.tv`]),mi=/^[A-Za-z0-9_]{3,25}$/,hi=/^v?(\d{1,12})$/,gi=/^[A-Za-z0-9_-]{6,30}$/,_i=/^[A-Za-z0-9_-]{6,100}$/,vi=/^(?:\d+h)?(?:\d+m)?(?:\d+s)?$/,yi=/* @__PURE__ */ new Set([`directory`,`videos`,`collections`,`settings`,`subscriptions`,`inventory`,`wallet`,`drops`,`search`,`downloads`,`jobs`,`turbo`,`p`,`login`,`signup`]),bi=[`autoplay`,`muted`,`time`];function q(e,t){return{platform:`twitch`,kind:`video`,url:e,id:t,variant:`iframe`}}const xi=e=>q(`https://www.twitch.tv/${e.toLowerCase()}`,e.toLowerCase()),Si=e=>q(`https://www.twitch.tv/videos/${e}`,e),Ci=e=>q(`https://www.twitch.tv/collections/${e}`,e),wi=e=>q(`https://clips.twitch.tv/${e}`,e);function Ti(e){let t={};for(let n of bi){let r=e.get(n);r!==void 0&&(t[n]=N(r))}return t}function Ei(e){let t=e.query.get(`channel`);if(t!==void 0)return mi.test(t)?xi(t):null;let[,n]=hi.exec(e.query.get(`video`)??``)??[];if(n!==void 0)return Si(n);let r=e.query.get(`collection`);return r!==void 0&&gi.test(r)?Ci(r):null}function Di(e){if(e.host===`clips.twitch.tv`){let t=e.path.replace(/^\/|\/$/g,``);return _i.test(t)?{found:wi(t),options:{}}:null}if(!pi.has(e.host))return null;let t=e.path.replace(/^\/|\/$/g,``).split(`/`),[n=``,r,i]=t;if(t.length===2&&n===`videos`){let[,t]=hi.exec(r??``)??[];if(t===void 0)return null;let n=e.query.get(`t`);return{found:Si(t),options:n!==void 0&&vi.test(n)&&n?{time:n}:{}}}return t.length===2&&n===`collections`?gi.test(r??``)?{found:Ci(r??``),options:{}}:null:t.length===3&&r===`clip`?mi.test(n)&&_i.test(i??``)?{found:wi(i??``),options:{}}:null:t.length===1&&mi.test(n)&&!yi.has(n.toLowerCase())?{found:xi(n),options:{}}:null}const Oi={platform:`twitch`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``);if(!t)return null;let n=null;if(t.host===`player.twitch.tv`&&/^\/?$/.test(t.path)&&(n=Ei(t)),t.host===`clips.twitch.tv`&&t.path===`/embed`){let e=t.query.get(`clip`)??``;n=_i.test(e)?wi(e):null}return n&&L({...n,options:Ti(t.query)},I(e))},isOwnScript:()=>!1,match(e){let t=Di(e);return t&&{...t.found,options:t.options}}},ki=/* @__PURE__ */ new Set([`vimeo.com`,`www.vimeo.com`]),J=`(\\d{1,12})`,Ai=`([0-9a-f]{6,20})`,ji=[RegExp(`^/${J}(?:/${Ai})?/?$`),RegExp(`^/channels/[A-Za-z0-9_-]{1,64}/${J}/?$`),RegExp(`^/groups/[A-Za-z0-9_-]{1,64}/videos/${J}/?$`),RegExp(`^/showcase/\\d{1,12}/video/${J}/?$`)],Mi=RegExp(`^/video/${J}/?$`),Ni=/^padding:\s*(\d{1,3}(?:\.\d{1,4})?)% 0 0 0;\s*position:\s*relative;?$/,Pi=/^(?:https?:)?\/\/player\.vimeo\.com\/api\/player\.js$/,Fi=/* @__PURE__ */ new Set([`h`,`app_id`,`player_id`]),Ii=/^t=(\d+(?:\.\d+)?|(?:\d+h)?(?:\d+m)?(?:\d+s)?)$/;function Li(e,t){return{platform:`vimeo`,kind:`video`,url:`https://vimeo.com/${e}${t?`/${t}`:``}`,id:e,variant:`iframe`}}function Ri(e){let[,t]=Ii.exec(e.fragment??``)??[];return t?{t}:{}}function zi(e){if(e?.host!==`player.vimeo.com`)return null;let[,t]=Mi.exec(e.path)??[];if(t===void 0)return null;let n=e.query.get(`h`);if(n!==void 0&&!RegExp(`^${Ai}$`).test(n))return null;let r=Object.fromEntries([...e.query].filter(([e])=>!Fi.has(e)).map(([e,t])=>[e,N(t)]));return{...Li(t,n),options:{...r,...Ri(e)}}}const Bi={platform:`vimeo`,parse(e){let t=bt(e,Ni),n=t?.iframe??e;if(n.tag!==`iframe`)return null;let r=zi(M(n.attrs.get(`src`)??``));return r&&L(r,t?.size??I(n))},isOwnScript:e=>Pi.test(e),match(e){let t=zi(e);if(t)return t;if(!ki.has(e.host))return null;for(let t of ji){let[,n,r]=t.exec(e.path)??[];if(n!==void 0)return{...Li(n,r),options:Ri(e)}}return null}},Vi=/* @__PURE__ */ new Set([`x.com`,`www.x.com`,`mobile.x.com`,`twitter.com`,`www.twitter.com`,`mobile.twitter.com`]),Hi=/^\/([A-Za-z0-9_]{1,15})\/status\/(\d{1,20})\/?$/,Ui=/^(?:https?:)?\/\/platform\.(?:x|twitter)\.com\/widgets\.js$/,Wi=[[`data-theme`,`theme`],[`data-conversation`,`conversation`],[`data-cards`,`cards`],[`data-align`,`align`],[`align`,`align`],[`data-lang`,`lang`],[`data-dnt`,`dnt`],[`data-width`,`width`]],Gi=/* @__PURE__ */ new Map([[`p`,[`lang`,`dir`]],[`a`,[`href`]],[`br`,[]]]);function Ki(e){if(!e||!Vi.has(e.host))return null;let[,t,n]=Hi.exec(e.path)??[];return t===void 0||n===void 0?null:{platform:`x`,kind:`post`,url:`https://x.com/${t}/status/${n}`,id:n,variant:`sdk`}}const qi={platform:`x`,fallback:Gi,parse(e){if(e.tag!==`blockquote`||!T(e,`twitter-tweet`))return null;let t=E(e.children).reverse().map(e=>e.tag===`a`?Ki(M(e.attrs.get(`href`)??``)):null).find(e=>e!==null);return t?{...t,options:F(e,Wi,N),fallbackHtml:D(e.children,Gi)}:null},isOwnScript:e=>Ui.test(e),match(e){let t=Ki(e);return t&&{...t,options:{}}}},Ji=/* @__PURE__ */ new Set([`youtube.com`,`www.youtube.com`,`m.youtube.com`]),Yi=/* @__PURE__ */ new Set([`youtube-nocookie.com`,`www.youtube-nocookie.com`]),Xi=/^(?!videoseries)[A-Za-z0-9_-]{11}$/,Zi=/^\/embed\/((?!videoseries)[A-Za-z0-9_-]{11})\/?$/,Qi=/^\/(shorts|embed|live)\/((?!videoseries)[A-Za-z0-9_-]{11})\/?$/,$i=/^\/([A-Za-z0-9_-]{11})\/?$/,ea=/^(?:(\d{1,5})h)?(?:(\d{1,6})m)?(?:(\d{1,7})s?)?$/;function ta(e){if(e===void 0||e===``)return;let t=ea.exec(e);if(!t)return;let[,n=`0`,r=`0`,i=`0`]=t;return Number(n)*3600+Number(r)*60+Number(i)}function na(e){return ta(e.get(`start`))??ta(e.get(`t`))}function Y(e,t=!1){return{platform:`youtube`,kind:`video`,url:t?`https://www.youtube.com/shorts/${e}`:`https://www.youtube.com/watch?v=${e}`,id:e,variant:`iframe`}}function ra(e,t){let n=na(e.query);return{...n===void 0?{}:{start:n},...t?{nocookie:!0}:{}}}const X=[qi,On,dn,Jr,ti,{platform:`youtube`,parse(e){if(e.tag!==`iframe`)return null;let t=M(e.attrs.get(`src`)??``),n=t!==null&&Yi.has(t.host);if(!t||!(n||Ji.has(t.host)))return null;let[,r]=Zi.exec(t.path)??[];if(r===void 0)return null;let i=[...t.query].filter(([e])=>e!==`t`).map(([e,t])=>[e,N(t)]),a=Object.fromEntries(i),o=na(t.query);return o!==void 0&&(a.start=o),n&&(a.nocookie=!0),L({...Y(r),options:a},I(e))},isOwnScript:()=>!1,match(e){if(e.host===`youtu.be`){let[,t]=$i.exec(e.path)??[];return t===void 0?null:{...Y(t),options:ra(e,!1)}}let t=Yi.has(e.host);if(!t&&!Ji.has(e.host))return null;if(!t&&/^\/watch\/?$/.test(e.path)){let t=e.query.get(`v`);return t!==void 0&&Xi.test(t)?{...Y(t),options:ra(e,!1)}:null}let[,n,r]=Qi.exec(e.path)??[];return n===void 0||r===void 0||t&&n!==`embed`?null:{...Y(r,n===`shorts`),options:ra(e,t)}}},Vr,fr,Un,rr,Zn,Mr,Bi,Oi,Jt,Dr,Tt,kt,Fn,xn,Vt,fi];function Z(e){if(typeof e!=`string`)return null;let t=M(e);if(!t)return null;for(let e of X){let n=e.match(t);if(n)return n}return null}function ia(e){if(typeof e!=`string`)return null;let t=Ee(e);if(!t)return null;let n,r,i=[],a=!1;for(let e of t)if(e.type!==`comment`){if(e.type===`text`){if(/^\s*$/.test(e.raw))continue;return null}if(e.tag===`script`)i.push(e);else if(aa(e))a=!0;else if(n){if(r)return null;r=e}else n=e}if(!n){let[e]=i;if(a||i.length!==1||!e||e.children.length!==0)return null;for(let t of X){let n=t.parseScript?.(e);if(n)return n}return null}for(let e of X){let t=e.parse(n);if(!t)continue;if(a&&!e.allowsFbRoot||r&&!e.isOwnExtra?.(r,t))return null;let o=i.map(e=>e.children.length===0?e.attrs.get(`src`):void 0);if(!o.every(t=>t!==void 0&&e.isOwnScript(t)))return null;let s=o.map(t=>t===void 0?{}:e.scriptOptions?.(t)??{});return{...t,options:Object.assign({},...s,t.options)}}return null}function aa(e){return e.tag===`div`&&e.attrs.get(`id`)===`fb-root`&&e.attrs.size===1&&e.children.length===0}const oa=/* @__PURE__ */ new Set([`bsky.app`,`www.bsky.app`]),sa=/^\/profile\/([^/]{1,253})\/post\/[A-Za-z0-9._~:-]{1,512}\/?$/,ca=/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;function la(e){let t=typeof e==`string`?M(e):null;if(!t||!oa.has(t.host))return null;let[,n]=sa.exec(t.path)??[];return n!==void 0&&ca.test(n)?`bluesky`:null}const ua={x:[`post sdk`],instagram:[`post sdk`],threads:[`post sdk`],facebook:[`post sdk`,`video sdk`,`video iframe`],tiktok:[`video iframe`],youtube:[`video iframe`],telegram:[`post iframe`],snapchat:[`post iframe`,`video iframe`],linkedin:[`post iframe`],reddit:[`post iframe`],pinterest:[`post sdk`],spotify:[`post iframe`,`video iframe`],vimeo:[`video iframe`],twitch:[`video iframe`],dailymotion:[`video iframe`],bluesky:[`post iframe`],soundcloud:[`post iframe`],applemusic:[`post iframe`],applepodcasts:[`post iframe`],tumblr:[`post iframe`],kick:[`video iframe`],giphy:[`video iframe`]};function da(e){let t=Z(e.url);if(t?.platform!==e.platform||t.id!==e.id||t.url!==e.url||!ua[e.platform].includes(`${e.kind} ${e.variant}`))return null;if(e.fallbackHtml===void 0||fa(e,e.fallbackHtml))return e;let n={...e};return delete n.fallbackHtml,n}function fa(e,t){let n=X.find(t=>t.platform===e.platform)?.fallback,r=Ee(t);if(!n||!r||D(r,n)!==t)return!1;if(e.platform!==`x`)return!0;let[i]=Ee(`<blockquote class="twitter-tweet">${t}</blockquote>`)??[];return i?.type===`element`&&qi.parse(i)?.id===e.id}const Q={x:`X`,instagram:`Instagram`,facebook:`Facebook`,threads:`Threads`,tiktok:`TikTok`,youtube:`YouTube`,telegram:`Telegram`,snapchat:`Snapchat`,linkedin:`LinkedIn`,reddit:`Reddit`,pinterest:`Pinterest`,spotify:`Spotify`,vimeo:`Vimeo`,twitch:`Twitch`,dailymotion:`Dailymotion`,bluesky:`Bluesky`,soundcloud:`SoundCloud`,applemusic:`Apple Music`,applepodcasts:`Apple Podcasts`,tumblr:`Tumblr`,kick:`Kick`,giphy:`Giphy`};function pa(e){return`social-embeds: a ${Q[e]} URL needs a lookup: use the embed code`}function ma(e,t,n){let r=t??(e===void 0?null:Z(e));if(!r&&e!==void 0&&la(e)===n)return{error:pa(n)};if(!r)return{error:`social-embeds: not a ${Q[n]} post URL: ${String(e)}`};if(r.platform!==n)return{error:`social-embeds: expected a ${Q[n]} embed, got ${Q[r.platform]}`};let i=da(r);return i?{embed:i}:{error:`social-embeds: the ${Q[n]} embed's url and id do not match`}}function ha(e){if(`html`in e)return`social-embeds: unrecognised embed code`;let t=la(e.url);return t?pa(t):`social-embeds: not a supported post URL: ${e.url}`}function ga(e){if(e===null||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)&&t>=0?t:void 0}function _a(e){return e===null?void 0:ga(e.trim().replace(/px$/i,``))}function va(e){for(let t of e.children)if(t instanceof HTMLTemplateElement)return t}function ya(e,t){let n=t??va(e)?.innerHTML,r=e.getAttribute(`url`),i=e.getAttribute(`width`);return{source:n===void 0?r===null?null:{url:r}:{html:n},layout:{width:ga(i)??(i?.trim()?i:void 0),maxWidth:_a(e.getAttribute(`max-width`)),height:_a(e.getAttribute(`height`)),maxHeight:_a(e.getAttribute(`max-height`))},eager:e.hasAttribute(`eager`)}}function ba(e,t,n){let{width:r=`100%`,maxHeight:i}=t,a=t.height??e.height,o=t.maxWidth??e.maxWidth,s=e.size?.width??e.ratio.width,c=e.size?.height??e.ratio.height,l=i===void 0||a!==void 0?void 0:Math.floor(i*s/c);return{position:`relative`,width:r,maxWidth:l===void 0||o!==void 0&&o<l?o:l,...e.messageHeight?{height:n??e.startHeight}:a===void 0?{aspectRatio:`${String(s)} / ${String(c)}`}:{height:a,maxHeight:i},...e.borderRadius===void 0?{}:{borderRadius:e.borderRadius,overflow:`hidden`}}}const xa=/* @__PURE__ */ new Set([`width`,`maxWidth`,`height`,`maxHeight`,`minHeight`,`borderRadius`]);function $(e,t){for(let[n,r]of Object.entries(t)){if(r===void 0)continue;let t=typeof r==`number`&&xa.has(n)?`${String(r)}px`:String(r);e.style.setProperty(n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),t)}}function Sa(e){let t=document.createElement(`div`);return t.setAttribute(`aria-hidden`,`true`),$(t,{width:`100%`,height:`100%`,minHeight:e,background:`rgba(128, 128, 128, 0.12)`}),t}function Ca(e,t,n){if(t||typeof IntersectionObserver>`u`)return n(),()=>{};let r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(r.disconnect(),n())},{rootMargin:`200px 0px`});return r.observe(e),()=>{r.disconnect()}}function wa(e,t){return`${e}${e.includes(`?`)?`&`:`?`}${encodeURIComponent(t)}=${encodeURIComponent(window.location.hostname)}`}function Ta(e){return e.style.position=`absolute`,e.style.setProperty(`inset`,`0`),e}function Ea(e,t,n){let{eager:r,placeholder:i,onLoad:a,onError:o,...s}=n,{messageHeight:c}=t,l=document.createElement(`div`);$(l,ba(t,s));let u=Ta(document.createElement(`div`)),d=Ta(document.createElement(`div`)),f=i.length>0?i:[t.fallbackHtml===void 0?Sa():Da(t.fallbackHtml)];d.append(...f),u.append(d),l.append(u),e.append(l);let p,m=!1,h=!1,g,_=[],v=()=>{d.remove(),h||(h=!0,a())},y=e=>{if(!c||e.origin!==c.origin||!p||e.source!==p.contentWindow)return;let t;try{t=c.read(e.data)}catch{return}typeof t==`number`&&t>0&&t<=5e4&&(m=!0,$(l,{height:Math.ceil(t)}),v())},ee=()=>{g=setTimeout(()=>{m||(d.remove(),o(/* @__PURE__ */ Error(`social-embeds: ${t.title} did not report its height`)))},15e3)},b=()=>{let e=document.createElement(`iframe`);e.src=t.hostParam?wa(t.src,t.hostParam):t.src,e.title=t.title,e.setAttribute(`allow`,t.allow),e.setAttribute(`allowfullscreen`,``),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),t.scrolling&&e.setAttribute(`scrolling`,t.scrolling),t.sandbox!==void 0&&e.setAttribute(`sandbox`,t.sandbox),$(e,{display:`block`,width:`100%`,height:`100%`,border:0}),e.addEventListener(`load`,()=>{c||v()}),p=e,u.insertBefore(e,d),c&&window.addEventListener(`message`,y)};return r?(b(),c&&_.push(Ca(u,!1,ee))):_.push(Ca(u,!1,()=>{b(),c&&ee()})),()=>{for(let e of _)e();clearTimeout(g),window.removeEventListener(`message`,y),l.remove()}}function Da(e){let t=document.createElement(`blockquote`);return t.innerHTML=e,t}function Oa(e){return e instanceof Error?e:Error(String(e))}function ka(e,t,n){let{driver:r,label:i}=t,{eager:a,placeholder:o,onLoad:s,onError:c}=n,l=document.createElement(`div`);$(l,{width:n.width??`100%`,maxWidth:n.maxWidth??t.maxWidth});let u=document.createElement(`div`);u.innerHTML=t.markup,l.append(u);let d=o.length>0?o:[Sa(t.minHeight)];t.hasFallback||l.append(...d),e.append(l);let f=!1,p=!1,m,h=()=>{},g=()=>{if(!(f||p)){p=!0,clearTimeout(m),h();for(let e of d)e.parentNode?.removeChild(e);s()}},_=(e,t)=>{f||p||(h(),h=()=>{},e>=3?c(t):m=setTimeout(()=>{v(e+1)},1e3*2**(e-1)))},v=e=>{if(!(f||p)){try{h=r.render(u,g)}catch(t){_(e,Oa(t));return}m=setTimeout(()=>{_(e,/* @__PURE__ */ Error(`social-embeds: the ${i} embed did not render`))},15e3)}},y=Ca(u,a,()=>{r.load().then(()=>{v(1)},e=>{f||c(Oa(e))})});return()=>{f=!0,y(),clearTimeout(m),h(),l.remove()}}const Aa=typeof HTMLElement>`u`?class{}:HTMLElement;function ja(e){let t=[];for(let n of[...e.childNodes])n instanceof HTMLTemplateElement||(e.removeChild(n),(n.nodeType===Node.ELEMENT_NODE||n.nodeType===Node.TEXT_NODE&&n.textContent?.trim())&&t.push(n));return t}const Ma=[`html`,`url`,`width`,`maxWidth`,`height`,`maxHeight`,`eager`];var Na=class extends Aa{static observedAttributes=[`url`,`width`,`max-width`,`height`,`max-height`,`eager`];#e=null;#t;#n;#r;#i=()=>{};#a=0;#o=!1;constructor(){super();for(let e of Ma){if(!Object.hasOwn(this,e))continue;let t=this[e];Reflect.deleteProperty(this,e),Reflect.set(this,e,t)}}get html(){return this.#e}set html(e){this.#e=typeof e==`string`?e:null,this.#l()}get url(){return this.getAttribute(`url`)}set url(e){this.#c(`url`,e)}get width(){return this.getAttribute(`width`)}set width(e){this.#c(`width`,e)}get maxWidth(){return this.getAttribute(`max-width`)}set maxWidth(e){this.#c(`max-width`,e)}get height(){return this.getAttribute(`height`)}set height(e){this.#c(`height`,e)}get maxHeight(){return this.getAttribute(`max-height`)}set maxHeight(e){this.#c(`max-height`,e)}get eager(){return this.hasAttribute(`eager`)}set eager(e){this.toggleAttribute(`eager`,!!e)}connectedCallback(){this.#t===void 0&&document.readyState===`loading`?this.#o||(this.#o=!0,document.addEventListener(`DOMContentLoaded`,()=>{this.#o=!1,this.isConnected&&this.connectedCallback()},{once:!0})):(this.#t??=ja(this),this.#n??=new MutationObserver(()=>{this.#s(),this.#l()}),this.#s(),this.#l())}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||(this.#n?.disconnect(),this.#u(),this.#r=void 0)})}attributeChangedCallback(){this.#l()}#s(){let e=this.#n;if(e){e.disconnect(),e.observe(this,{childList:!0});for(let t of this.children)t instanceof HTMLTemplateElement&&e.observe(t.content,{childList:!0,subtree:!0,characterData:!0})}}#c(e,t){t==null?this.removeAttribute(e):this.setAttribute(e,t)}#l(){if(!this.isConnected||this.#t===void 0)return;let e=ya(this,this.#e),t=JSON.stringify(e);t!==this.#r&&(this.#u(),this.#r=t,this.#d(e,this.#t))}#u(){this.#a+=1;let e=this.#i;this.#i=()=>{},e()}#d(e,t){let{source:n,layout:r,eager:i}=e;if(!n)return;let a=this.#a,o=e=>{queueMicrotask(()=>{a===this.#a&&this.isConnected&&this.dispatchEvent(e)})},s=e=>{o(new ErrorEvent(`error`,{error:e,message:e.message}))},c=`html`in n?ia(n.html):Z(n.url);if(!c){s(Error(ha(n)));return}let l=ma(void 0,c,c.platform);if(l.error!==void 0){s(Error(l.error));return}let u=_t(l.embed);if(u.kind===`error`){s(Error(u.message));return}let d={...r,eager:i,placeholder:t.map(e=>e.cloneNode(!0)),onLoad:()=>{o(new Event(`load`))},onError:s};this.#i=u.kind===`iframe`?Ea(this,u,d):ka(this,u,d)}};typeof customElements<`u`&&!customElements.get(`social-embed`)&&customElements.define(`social-embed`,Na);export{Na as SocialEmbedElement};
|