"use strict";var U=Object.defineProperty;var w=(r,t,e)=>t in r?U(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>w(r,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index-BQRd8ZzE.cjs"),T=b.Quill.import("blots/block/embed"),y=b.Quill.import("formats/link"),f=["height","width"],E=new Set(f),c=new Map,a=new Map,h=[/(?:youtube\.com\/watch\?(?:.*&)?v=|youtu\.be\/)([a-z0-9_-]+)/i,/youtube\.com\/embed\/([a-z0-9_-]+)/i,/youtube\.com\/shorts\/([a-z0-9_-]+)/i],A=/vimeo\.com\/(?:video\/)?(\d+)/i;function m(r){if(a.has(r))return a.get(r)??null;const t=y.sanitize(r),e=!t||t==="about:blank"?null:t;return a.set(r,e),e}function N(r){const t=r.trim();return t?h.some(e=>e.test(t))?!0:A.test(t):!1}const g=r=>{const t=r.trim(),e=c.get(t);if(e)return e;for(const s of h){const i=s.exec(t);if(i!=null&&i[1]){const u=`https://www.youtube.com/embed/${i[1]}`;return c.set(t,u),u}}const o=A.exec(t);if(o!=null&&o[1]){const s=`https://player.vimeo.com/video/${o[1]}`;return c.set(t,s),s}return c.set(t,t),t},n=class n extends T{static create(t){const e=g(t),o=m(e)??m(t)??"about:blank",s=super.create(o);return s.setAttribute("frameborder","0"),s.setAttribute("allowfullscreen","true"),s.setAttribute("loading","lazy"),s.setAttribute("src",o),s}static formats(t){return f.reduce((e,o)=>(t.hasAttribute(o)&&(e[o]=t.getAttribute(o)),e),{})}static value(t){return t.getAttribute("src")??""}format(t,e){if(E.has(t)){e?this.domNode.setAttribute(t,e):this.domNode.removeAttribute(t);return}super.format(t,e)}html(){const t=n.value(this.domNode),e=this.domNode.getAttribute("width"),o=this.domNode.getAttribute("height"),s=this.domNode.getAttribute("style"),i=this.domNode.getAttribute("loading");return`<iframe ${['class="ql-video"','frameborder="0"','allowfullscreen="true"',`src="${t}"`,e?`width="${e}"`:"",o?`height="${o}"`:"",s?`style="${s}"`:"",i?`loading="${i}"`:""].filter(Boolean).join(" ")}></iframe>`}};l(n,"blotName","video"),l(n,"className","ql-video"),l(n,"tagName","IFRAME");let d=n;exports.default=d;exports.isVideoUrl=N;exports.normalizeVideoUrl=g;
