1import{R as H}from"./index-BqKviU6K.js";const D="https://www.tiktok.com/player/v1",O=/tiktok\.com\/(?:player\/v1\/|share\/video\/|@[^/]+\/video\/)([0-9]+)/,d={INIT:-1,ENDED:0,PLAYING:1,PAUSED:2,BUFFERING:3},x={[d.INIT]:"emptied",[d.PAUSED]:"pause",[d.ENDED]:"ended",[d.PLAYING]:"play",[d.BUFFERING]:"waiting"};function N(o,t={}){const e={src:S(o,t),frameborder:0,width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture"};return t.config&&(e["data-config"]=JSON.stringify(t.config)),` 2 <style> 3 :host { 4 display:inline-block; 5 min-width: 300px; 6 min-height: 150px; 7 position: relative; 8 } 9 iframe { 10 position:absolute; 11 top:0; 12 left:0; 13 width:100%; 14 height:100%; 15 border:0; 16 } 17 </style> 18 <iframe ${$(e)} title="TikTok video"></iframe> 19 `}function S(o,t={}){if(!o.src)return;const e=o.src.match(O),i=e&&e[1],a={controls:o.controls===""?null:0,autoplay:o.autoplay,muted:o.muted,loop:o.loop,rel:0,...t.config};return`${D}/${i}?${W(a)}`}class v extends(globalThis.HTMLElement??class{}){static getTemplateHTML=N;static shadowRootOptions={mode:"open"};static get observedAttributes(){return["src","controls","loop","autoplay","muted"]}loadComplete=new A;#s;#r;#e=!1;#n=0;#a=!0;#l=null;#o=100;#u=0;#i;constructor(){super(),this.#m("config")}async load(){if(this.#s)return;this.shadowRoot||this.attachShadow(v.shadowRootOptions);const t=!this.#r;if(this.#r&&(this.loadComplete=new A),this.#r=!0,await(this.#s=Promise.resolve()),this.#s=null,this.#n=0,this.#e=!1,this.#a=!0,!this.src){this.shadowRoot.innerHTML="",globalThis.removeEventListener("message",this.#c);return}let e=this.shadowRoot.querySelector("iframe");const i=F(this.attributes);t&&e&&(this.#l=JSON.parse(e.getAttribute("data-config")||"{}")),(!e?.src||e.src!==S(i,this))&&(this.shadowRoot.innerHTML=N(i,this),e=this.shadowRoot.querySelector("iframe")),this.#i=e,globalThis.addEventListener("message",this.#c)}async attributeChangedCallback(t,e,i){if(e!==i)switch(t){case"muted":{await this.loadComplete,this.muted=i!=null;break}
19case"autoplay":case"controls":case"loop":case"src":{this.load();return}}}get config(){return this.#l}set config(t){this.#l=t}#c=t=>{var e;if(t.source!==((e=this.#i)==null?void 0:e.contentWindow))return;const i=t.data;if(i?.["x-tiktok-player"])switch(i.type){case"onPlayerReady":this.loadComplete.resolve();break;case"onStateChange":{this.#a=[d.INIT,d.PAUSED,d.ENDED].includes(i.value);const a=x[i.value];a&&this.dispatchEvent(new Event(a));break}case"onCurrentTime":this.#n=i.value.currentTime,this.#u=i.value.duration,this.dispatchEvent(new Event("durationchange")),this.dispatchEvent(new Event("timeupdate"));break;case"onVolumeChange":this.#o=i.value,this.dispatchEvent(new Event("volumechange"));break;case"onMute":this.#e=!!i.value,this.#o=i.value?0:this.#o,this.dispatchEvent(new Event("volumechange"));break;case"onError":this.dispatchEvent(new Event("error"));break;default:console.warn("Unhandled TikTok player message:",i);break}};#t(t,e){var i;if(!((i=this.#i)!=null&&i.contentWindow))return;const a={"x-tiktok-player":!0,type:t,...e!==void 0?{value:e}:{}};this.#i.contentWindow.postMessage(a,"*")}async play(){await this.loadComplete,this.#t("play")}async pause(){await this.loadComplete,this.#t("pause")}async#d(t){await this.loadComplete,this.#t("seekTo",Number(t))}async#h(){await this.loadComplete,this.#t("mute")}async#f(){await this.loadComplete,this.#t("unMute")}get volume(){return this.#o/100}set volume(t){console.warn("Volume control is not supported for TikTok videos.")}get currentTime(){return this.#n}set currentTime(t){this.#d(t)}get muted(){return this.#e}set muted(t){this.#e=t,t?this.#h():this.#f()}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(t){this.toggleAttribute("muted",!!t)}get paused(){return this.#a}get duration(){return this.#u}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t??"")}#m(t){if(Object.prototype.hasOwnProperty.call(this,t)){const e=this[t];delete this[t],this[t]=e}}}class A extends Promise{constructor(t=()=>{}){let e,i;super((a,m)=>{t(a,m),e=a,i=m}),this.resolve=e,this.reject=i}}function F(o){let t={};for(let e of o)t[e.name]=e.value;return t}function U(o){let t={};for(let e in o){let i=o[e];i===!0||i===""?t[e]=1:i===!1?t[e]=0:i!=null&&(t[e]=i)}return t}function W(o){return String(new URLSearchParams(U(o)))}function $(o){let t="";for(const e in o){const i=o[e];i===""?t+=` ${w(e)}`:t+=` ${w(e)}="${w(`${i}`)}"`}return t}function w(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}globalThis.customElements&&!globalThis.customElements.get("tiktok-video")&&globalThis.customElements.define("tiktok-video",v);var j=v,B=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),q={className:"class",htmlFor:"for"};function _(o){return o.toLowerCase()}function P(o){if(typeof o=="boolean")return o?"":void 0;if(typeof o!="function"&&!(typeof o=="object"&&o!==null))return o}function G({react:o,tagName:t,elementClass:e,events:i,displayName:a,defaultProps:m,toAttributeName:C=_,toAttributeValue:I=P}){const b=Number.parseInt(o.version)>=19,E=o.forwardRef((T,f)=>{var k,M;const l=o.useRef(null),g=o.useRef(new Map),y={},L={},u={},p={};for(const[s,r]of Object.entries(T)){if(B.has(s)){u[s]=r;continue}const n=C(q[s]??s);if(e.prototype&&s in e.prototype&&!(s in(((k=globalThis.HTMLElement)==null?void 0:k.prototype)??{}))&&!((M=e.observedAttributes)!=null&&M.some(h=>h===n))){p[s]=r;continue}if(s.startsWith("on")){y[s]=r;continue}const c=I(r);if(n&&c!=null&&(L[n]=String(c),b||(u[n]=c)),n&&b){const h=P(r);c!==h?u[n]=c:u[n]=r}}if(typeof window<"u"){for(const s in y){const r=y[s],n=s.endsWith("Capture"),c=(i?.[s]??s.slice(2).toLowerCase()).slice(0,n?-7:void 0);o.useLayoutEffect(()=>{const h=l?.current;if(!(!h||typeof r!="function"))return h.addEventListener(c,r,n),()=>{h.removeEventListener(c,r,n)}},[l?.current,r])}o.useLayoutEffect(()=>{if(l.current===null)return;const s=new Map;for(const r in p)R(l.current,r,p[r]),g.current.delete(r),s.set(r,p[r]);for(const[r,n]of g.current)R(l.current,r,void 0);g.current=s})}if(typeof window>"u"&&e?.getTemplateHTML&&e?.shadowRootOptions){const{mode:s,delegatesFocus:r}=e.shadowRootOptions,n=o.createElement("template",{shadowrootmode:s,shadowrootdelegatesfocus:r,dangerouslySetInnerHTML:{__html:e.getTemplateHTML(L,T)},key:"ce-la-react-ssr-template-shadow-root"});u.children=[n,u.children]}return o.createElement(t,{...m,...u,ref:o.useCallback(s=>{l.current=s,typeof f=="function"?f(s):f!==null&&(f.current=s)},[f])},u.children)});return E.displayName=a??e.name,E}function R(o,t,e){var i;o[t]=e,e==null&&t in(((i=globalThis.HTMLElement)==null?void 0:i.prototype)??{})&&o.removeAttribute(t)}var J=G({react:H,tagName:"tiktok-video",elementClass:j,toAttributeName(o){return o==="muted"?"":o==="defaultMuted"?"muted":_(o)}});
19export{J as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.