@innovastudio/contentbuilder-interactive-runtime 1.0.5 → 1.0.7

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.
@@ -1,4 +1,4 @@
1
- var ContentBuilderRuntime=(function(){"use strict";const Rt=Date.now();function fe(){let c={},e=!0,t=0,i=arguments.length;Object.prototype.toString.call(arguments[0])==="[object Boolean]"&&(e=arguments[0],t++);let n=s=>{for(let r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e&&Object.prototype.toString.call(s[r])==="[object Object]"?c[r]=fe(!0,c[r],s[r]):c[r]=s[r])};for(;t<i;t++){let s=arguments[t];n(s)}return c}function V(c,e){if((ge(c)||c===window||c===document)&&(c=[c]),!Ot(c)&&!Ce(c)&&(c=[c]),$t(c)!=0){if(Ot(c)&&!Ce(c)){let t=c.length,i=0;for(;i<t&&e.call(c[i],c[i],i,c)!==!1;i++);}else if(Ce(c)){for(let t in c)if(Z(c,t)&&e.call(c[t],c[t],t,c)===!1)break}}}function Mt(c,e=null,t=null){const i=c[Rt]=c[Rt]||[],n={all:i,evt:null,found:null};return e&&t&&$t(i)>0&&V(i,(s,r)=>{if(s.eventName==e&&s.fn.toString()==t.toString())return n.found=!0,n.evt=r,!1}),n}function oe(c,{onElement:e,withCallback:t,avoidDuplicate:i=!0,once:n=!1,useCapture:s=!1}={},r){let o=e||[];Ae(o)&&(o=document.querySelectorAll(o));function a(d){F(t)&&t.call(r,d,this),n&&a.destroy()}return a.destroy=function(){V(o,d=>{const u=Mt(d,c,a);u.found&&u.all.splice(u.evt,1),d.removeEventListener&&d.removeEventListener(c,a,s)})},V(o,d=>{const u=Mt(d,c,a);(d.addEventListener&&i&&!u.found||!i)&&(d.addEventListener(c,a,s),u.all.push({eventName:c,fn:a}))}),a}function H(c,e){V(e.split(" "),t=>c.classList.add(t))}function J(c,e){V(e.split(" "),t=>c.classList.remove(t))}function ee(c,e){return c.classList.contains(e)}function ce(c,e){for(;c!==document.body;){if(c=c.parentElement,!c)return!1;if(typeof c.matches=="function"?c.matches(e):c.msMatchesSelector(e))return c}}function Ee(c,e="",t=!1){if(!c||e==="")return!1;if(e==="none")return F(t)&&t(),!1;const i=yi(),n=e.split(" ");V(n,s=>{H(c,"g"+s)}),oe(i,{onElement:c,avoidDuplicate:!1,once:!0,withCallback:(s,r)=>{V(n,o=>{J(r,"g"+o)}),F(t)&&t()}})}function ze(c,e=""){if(e==="")return c.style.webkitTransform="",c.style.MozTransform="",c.style.msTransform="",c.style.OTransform="",c.style.transform="",!1;c.style.webkitTransform=e,c.style.MozTransform=e,c.style.msTransform=e,c.style.OTransform=e,c.style.transform=e}function At(c){c.style.display="block"}function rt(c){c.style.display="none"}function xe(c){let e=document.createDocumentFragment(),t=document.createElement("div");for(t.innerHTML=c;t.firstChild;)e.appendChild(t.firstChild);return e}function qt(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function yi(){let c,e=document.createElement("fakeelement"),t={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(c in t)if(e.style[c]!==void 0)return t[c]}function vi(){let c,e=document.createElement("fakeelement");const t={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(c in t)if(e.style[c]!==void 0)return t[c]}function wi(c){let{url:e,allow:t,callback:i,appendTo:n}=c,s=document.createElement("iframe");return s.className="vimeo-video gvideo",s.src=e,s.style.width="100%",s.style.height="100%",t&&s.setAttribute("allow",t),s.onload=function(){s.onload=null,H(s,"node-ready"),F(i)&&i()},n&&n.appendChild(s),s}function ot(c,e,t,i){if(c()){e();return}t||(t=100);let n=setInterval(()=>{c()&&(clearInterval(n),e())},t)}function Pt(c,e,t){if(ne(c)){console.error("Inject assets error");return}if(F(e)&&(t=e,e=!1),Ae(e)&&e in window){F(t)&&t();return}let i;if(c.indexOf(".css")!==-1){if(i=document.querySelectorAll('link[href="'+c+'"]'),i&&i.length>0){F(t)&&t();return}const s=document.getElementsByTagName("head")[0],r=s.querySelectorAll('link[rel="stylesheet"]'),o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=c,o.media="all",r?s.insertBefore(o,r[0]):s.appendChild(o),F(t)&&t();return}if(i=document.querySelectorAll('script[src="'+c+'"]'),i&&i.length>0){if(F(t)){if(Ae(e))return ot(()=>typeof window[e]<"u",()=>{t()}),!1;t()}return}let n=document.createElement("script");n.type="text/javascript",n.src=c,n.onload=()=>{if(F(t)){if(Ae(e))return ot(()=>typeof window[e]<"u",()=>{t()}),!1;t()}},document.body.appendChild(n)}function lt(){return typeof window>"u"?!1:"navigator"in window&&window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i)}function xi(){return typeof document>"u"?!1:lt()!==null||document.createTouch!==void 0||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints}function F(c){return typeof c=="function"}function Ae(c){return typeof c=="string"}function ge(c){return!!(c&&c.nodeType&&c.nodeType==1)}function It(c){return Array.isArray(c)}function Ot(c){return c&&c.length&&isFinite(c.length)}function Ce(c){return typeof c==="object"&&c!=null&&!F(c)&&!It(c)}function ne(c){return c==null}function Z(c,e){return c!==null&&hasOwnProperty.call(c,e)}function $t(c){if(Ce(c)){if(c.keys)return c.keys().length;let e=0;for(let t in c)Z(c,t)&&e++;return e}else return c.length}function Ue(c){return!isNaN(parseFloat(c))&&isFinite(c)}function Nt(c=-1){const e=document.querySelectorAll(".gbtn[data-taborder]:not(.disabled)");if(!e.length)return!1;if(e.length==1)return e[0];typeof c=="string"&&(c=parseInt(c));const t=[];V(e,o=>{t.push(o.getAttribute("data-taborder"))});const i=Math.max.apply(Math,t.map(o=>parseInt(o)));let n=c<0?1:c+1;n>i&&(n="1");const r=t.filter(o=>o>=parseInt(n)).sort()[0];return document.querySelector(`.gbtn[data-taborder="${r}"]`)}function ki(c){if(c.events.hasOwnProperty("keyboard"))return!1;c.events.keyboard=oe("keydown",{onElement:window,withCallback:(e,t)=>{e=e||window.event;const i=e.keyCode;if(i==9){const n=document.querySelector(".gbtn.focused");if(!n){const a=document.activeElement&&document.activeElement.nodeName?document.activeElement.nodeName.toLocaleLowerCase():!1;if(a=="input"||a=="textarea"||a=="button")return}e.preventDefault();const s=document.querySelectorAll(".gbtn[data-taborder]");if(!s||s.length<=0)return;if(!n){const a=Nt();a&&(a.focus(),H(a,"focused"));return}let r=n.getAttribute("data-taborder"),o=Nt(r);J(n,"focused"),o&&(o.focus(),H(o,"focused"))}i==39&&c.nextSlide(),i==37&&c.prevSlide(),i==27&&c.close()}})}function je(c){return Math.sqrt(c.x*c.x+c.y*c.y)}function _i(c,e){return c.x*e.x+c.y*e.y}function Si(c,e){var t=je(c)*je(e);if(t===0)return 0;var i=_i(c,e)/t;return i>1&&(i=1),Math.acos(i)}function Ti(c,e){return c.x*e.y-e.x*c.y}function Ei(c,e){var t=Si(c,e);return Ti(c,e)>0&&(t*=-1),t*180/Math.PI}class Ci{constructor(e){this.handlers=[],this.el=e}add(e){this.handlers.push(e)}del(e){e||(this.handlers=[]);for(var t=this.handlers.length;t>=0;t--)this.handlers[t]===e&&this.handlers.splice(t,1)}dispatch(){for(var e=0,t=this.handlers.length;e<t;e++){var i=this.handlers[e];typeof i=="function"&&i.apply(this.el,arguments)}}}function te(c,e){var t=new Ci(c);return t.add(e),t}class Li{constructor(e,t){this.element=typeof e=="string"?document.querySelector(e):e,this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1;var i=function(){};this.rotate=te(this.element,t.rotate||i),this.touchStart=te(this.element,t.touchStart||i),this.multipointStart=te(this.element,t.multipointStart||i),this.multipointEnd=te(this.element,t.multipointEnd||i),this.pinch=te(this.element,t.pinch||i),this.swipe=te(this.element,t.swipe||i),this.tap=te(this.element,t.tap||i),this.doubleTap=te(this.element,t.doubleTap||i),this.longTap=te(this.element,t.longTap||i),this.singleTap=te(this.element,t.singleTap||i),this.pressMove=te(this.element,t.pressMove||i),this.twoFingerPressMove=te(this.element,t.twoFingerPressMove||i),this.touchMove=te(this.element,t.touchMove||i),this.touchEnd=te(this.element,t.touchEnd||i),this.touchCancel=te(this.element,t.touchCancel||i),this.translateContainer=this.element,this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null}}start(e){if(!e.touches)return;const t=["a","button","input"];if(e.target&&e.target.nodeName&&t.indexOf(e.target.nodeName.toLowerCase())>=0){console.log("ignore drag for this touched element",e.target.nodeName.toLowerCase());return}this.now=Date.now(),this.x1=e.touches[0].pageX,this.y1=e.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(e,this.element),this.preTapPosition.x!==null&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var i=this.preV,n=e.touches.length;if(n>1){this._cancelLongTap(),this._cancelSingleTap();var s={x:e.touches[1].pageX-this.x1,y:e.touches[1].pageY-this.y1};i.x=s.x,i.y=s.y,this.pinchStartLen=je(i),this.multipointStart.dispatch(e,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout((function(){this.longTap.dispatch(e,this.element),this._preventTap=!0}).bind(this),750)}move(e){if(e.touches){var t=this.preV,i=e.touches.length,n=e.touches[0].pageX,s=e.touches[0].pageY;if(this.isDoubleTap=!1,i>1){var r=e.touches[1].pageX,o=e.touches[1].pageY,a={x:e.touches[1].pageX-n,y:e.touches[1].pageY-s};t.x!==null&&(this.pinchStartLen>0&&(e.zoom=je(a)/this.pinchStartLen,this.pinch.dispatch(e,this.element)),e.angle=Ei(a,t),this.rotate.dispatch(e,this.element)),t.x=a.x,t.y=a.y,this.x2!==null&&this.sx2!==null?(e.deltaX=(n-this.x2+r-this.sx2)/2,e.deltaY=(s-this.y2+o-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.twoFingerPressMove.dispatch(e,this.element),this.sx2=r,this.sy2=o}else{if(this.x2!==null){e.deltaX=n-this.x2,e.deltaY=s-this.y2;var d=Math.abs(this.x1-this.x2),u=Math.abs(this.y1-this.y2);(d>10||u>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.pressMove.dispatch(e,this.element)}this.touchMove.dispatch(e,this.element),this._cancelLongTap(),this.x2=n,this.y2=s,i>1&&e.preventDefault()}}end(e){if(e.changedTouches){this._cancelLongTap();var t=this;e.touches.length<2&&(this.multipointEnd.dispatch(e,this.element),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout(function(){t.swipe.dispatch(e,t.element)},0)):(this.tapTimeout=setTimeout(function(){t._preventTap||t.tap.dispatch(e,t.element),t.isDoubleTap&&(t.doubleTap.dispatch(e,t.element),t.isDoubleTap=!1)},0),t.isDoubleTap||(t.singleTapTimeout=setTimeout(function(){t.singleTap.dispatch(e,t.element)},250))),this.touchEnd.dispatch(e,this.element),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}}cancelAll(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}cancel(e){this.cancelAll(),this.touchCancel.dispatch(e,this.element)}_cancelLongTap(){clearTimeout(this.longTapTimeout)}_cancelSingleTap(){clearTimeout(this.singleTapTimeout)}_swipeDirection(e,t,i,n){return Math.abs(e-t)>=Math.abs(i-n)?e-t>0?"Left":"Right":i-n>0?"Up":"Down"}on(e,t){this[e]&&this[e].add(t)}off(e,t){this[e]&&this[e].del(t)}destroy(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel),this.rotate.del(),this.touchStart.del(),this.multipointStart.del(),this.multipointEnd.del(),this.pinch.del(),this.swipe.del(),this.tap.del(),this.doubleTap.del(),this.longTap.del(),this.singleTap.del(),this.pressMove.del(),this.twoFingerPressMove.del(),this.touchMove.del(),this.touchEnd.del(),this.touchCancel.del(),this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=this.rotate=this.touchStart=this.multipointStart=this.multipointEnd=this.pinch=this.swipe=this.tap=this.doubleTap=this.longTap=this.singleTap=this.pressMove=this.touchMove=this.touchEnd=this.touchCancel=this.twoFingerPressMove=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}function at(c){const e=vi(),t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;let i=ee(c,"gslide-media")?c:c.querySelector(".gslide-media"),n=ce(i,".ginner-container"),s=c.querySelector(".gslide-description");t>769&&(i=n),H(i,"greset"),ze(i,"translate3d(0, 0, 0)"),oe(e,{onElement:i,once:!0,withCallback:(r,o)=>{J(i,"greset")}}),i.style.opacity="",s&&(s.style.opacity="")}function Ri(c){if(c.events.hasOwnProperty("touch"))return!1;let e=qt(),t=e.width,i=e.height,n=!1,s=null,r=null,o=null,a=!1,d=1,u=4.5,l=1,h=!1,p=!1,b=null,w=null,_=null,g=null,v,f,m=0,y=0,k=!1,x=!1,S={},E={},C=0,A=0,L;const D=document.getElementById("glightbox-slider"),I=document.querySelector(".goverlay"),O=new Li(D,{touchStart:R=>{if(n=!0,(ee(R.targetTouches[0].target,"ginner-container")||ce(R.targetTouches[0].target,".gslide-desc")||R.targetTouches[0].target.nodeName.toLowerCase()=="a")&&(n=!1),ce(R.targetTouches[0].target,".gslide-inline")&&!ee(R.targetTouches[0].target.parentNode,"gslide-inline")&&(n=!1),n){if(E=R.targetTouches[0],S.pageX=R.targetTouches[0].pageX,S.pageY=R.targetTouches[0].pageY,C=R.targetTouches[0].clientX,A=R.targetTouches[0].clientY,s=c.activeSlide,r=s.querySelector(".gslide-media"),L=s.querySelector(".gslide-inline"),o=null,ee(r,"gslide-image")&&(o=r.querySelector("img")),(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)>769&&(r=s.querySelector(".ginner-container")),J(I,"greset"),R.pageX>20&&R.pageX<window.innerWidth-20)return;R.preventDefault()}},touchMove:R=>{if(!n||(E=R.targetTouches[0],h||p))return;if(L&&L.offsetHeight>i){const U=S.pageX-E.pageX;if(Math.abs(U)<=13)return!1}a=!0;let q=R.targetTouches[0].clientX,M=R.targetTouches[0].clientY,T=C-q,$=A-M;Math.abs(T)>Math.abs($)?(k=!1,x=!0):(x=!1,k=!0),v=E.pageX-S.pageX,m=v*100/t,f=E.pageY-S.pageY,y=f*100/i;let N;if(k&&o&&(N=1-Math.abs(f)/i,I.style.opacity=N,c.settings.touchFollowAxis&&(m=0)),x&&(N=1-Math.abs(v)/t,r.style.opacity=N,c.settings.touchFollowAxis&&(y=0)),!o)return ze(r,`translate3d(${m}%, 0, 0)`);ze(r,`translate3d(${m}%, ${y}%, 0)`)},touchEnd:()=>{if(!n)return;if(a=!1,p||h){_=b,g=w;return}const R=Math.abs(parseInt(y)),q=Math.abs(parseInt(m));if(R>29&&o){c.close();return}if(R<29&&q<25)return H(I,"greset"),I.style.opacity=1,at(r)},multipointEnd:()=>{setTimeout(()=>{h=!1},50)},multipointStart:()=>{h=!0,d=l||1},pinch:R=>{if(!o||a)return!1;h=!0,o.scaleX=o.scaleY=d*R.zoom;let q=d*R.zoom;if(p=!0,q<=1){p=!1,q=1,g=null,_=null,b=null,w=null,o.setAttribute("style","");return}q>u&&(q=u),o.style.transform=`scale3d(${q}, ${q}, 1)`,l=q},pressMove:R=>{if(p&&!h){var q=E.pageX-S.pageX,M=E.pageY-S.pageY;_&&(q=q+_),g&&(M=M+g),b=q,w=M;let T=`translate3d(${q}px, ${M}px, 0)`;l&&(T+=` scale3d(${l}, ${l}, 1)`),ze(o,T)}},swipe:R=>{if(!p){if(h){h=!1;return}if(R.direction=="Left"){if(c.index==c.elements.length-1)return at(r);c.nextSlide()}if(R.direction=="Right"){if(c.index==0)return at(r);c.prevSlide()}}}});c.events.touch=O}class Mi{constructor(e,t,i=null){if(this.img=e,this.slide=t,this.onclose=i,this.img.setZoomEvents)return!1;this.active=!1,this.zoomedIn=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.img.addEventListener("mousedown",n=>this.dragStart(n),!1),this.img.addEventListener("mouseup",n=>this.dragEnd(n),!1),this.img.addEventListener("mousemove",n=>this.drag(n),!1),this.img.addEventListener("click",n=>{if(this.slide.classList.contains("dragging-nav"))return this.zoomOut(),!1;if(!this.zoomedIn)return this.zoomIn();this.zoomedIn&&!this.dragging&&this.zoomOut()},!1),this.img.setZoomEvents=!0}zoomIn(){let e=this.widowWidth();if(this.zoomedIn||e<=768)return;const t=this.img;if(t.setAttribute("data-style",t.getAttribute("style")),t.style.maxWidth=t.naturalWidth+"px",t.style.maxHeight=t.naturalHeight+"px",t.naturalWidth>e){let i=e/2-t.naturalWidth/2;this.setTranslate(this.img.parentNode,i,0)}this.slide.classList.add("zoomed"),this.zoomedIn=!0}zoomOut(){this.img.parentNode.setAttribute("style",""),this.img.setAttribute("style",this.img.getAttribute("data-style")),this.slide.classList.remove("zoomed"),this.zoomedIn=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.onclose&&typeof this.onclose=="function"&&this.onclose()}dragStart(e){if(e.preventDefault(),!this.zoomedIn){this.active=!1;return}e.type==="touchstart"?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset),e.target===this.img&&(this.active=!0,this.img.classList.add("dragging"))}dragEnd(e){e.preventDefault(),this.initialX=this.currentX,this.initialY=this.currentY,this.active=!1,setTimeout(()=>{this.dragging=!1,this.img.isDragging=!1,this.img.classList.remove("dragging")},100)}drag(e){this.active&&(e.preventDefault(),e.type==="touchmove"?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.img.isDragging=!0,this.dragging=!0,this.setTranslate(this.img,this.currentX,this.currentY))}onMove(e){if(!this.zoomedIn)return;let t=e.clientX-this.img.naturalWidth/2,i=e.clientY-this.img.naturalHeight/2;this.setTranslate(this.img,t,i)}setTranslate(e,t,i){e.style.transform="translate3d("+t+"px, "+i+"px, 0)"}widowWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}class Dt{constructor(e={}){let{dragEl:t,toleranceX:i=40,toleranceY:n=65,slide:s=null,instance:r=null}=e;this.el=t,this.active=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.direction=null,this.lastDirection=null,this.toleranceX=i,this.toleranceY=n,this.toleranceReached=!1,this.dragContainer=this.el,this.slide=s,this.instance=r,this.el.addEventListener("mousedown",o=>this.dragStart(o),!1),this.el.addEventListener("mouseup",o=>this.dragEnd(o),!1),this.el.addEventListener("mousemove",o=>this.drag(o),!1)}dragStart(e){if(this.slide.classList.contains("zoomed")){this.active=!1;return}e.type==="touchstart"?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset);let t=e.target.nodeName.toLowerCase(),i=["input","select","textarea","button","a"];if(e.target.classList.contains("nodrag")||ce(e.target,".nodrag")||i.indexOf(t)!==-1){this.active=!1;return}e.preventDefault(),(e.target===this.el||t!=="img"&&ce(e.target,".gslide-inline"))&&(this.active=!0,this.el.classList.add("dragging"),this.dragContainer=ce(e.target,".ginner-container"))}dragEnd(e){e&&e.preventDefault(),this.initialX=0,this.initialY=0,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.active=!1,this.doSlideChange&&(this.instance.preventOutsideClick=!0,this.doSlideChange=="right"&&this.instance.prevSlide(),this.doSlideChange=="left"&&this.instance.nextSlide()),this.doSlideClose&&this.instance.close(),this.toleranceReached||this.setTranslate(this.dragContainer,0,0,!0),setTimeout(()=>{this.instance.preventOutsideClick=!1,this.toleranceReached=!1,this.lastDirection=null,this.dragging=!1,this.el.isDragging=!1,this.el.classList.remove("dragging"),this.slide.classList.remove("dragging-nav"),this.dragContainer.style.transform="",this.dragContainer.style.transition=""},100)}drag(e){if(this.active){e.preventDefault(),this.slide.classList.add("dragging-nav"),e.type==="touchmove"?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.el.isDragging=!0,this.dragging=!0,this.doSlideChange=!1,this.doSlideClose=!1;let t=Math.abs(this.currentX),i=Math.abs(this.currentY);if(t>0&&t>=Math.abs(this.currentY)&&(!this.lastDirection||this.lastDirection=="x")){this.yOffset=0,this.lastDirection="x",this.setTranslate(this.dragContainer,this.currentX,0);let n=this.shouldChange();if(!this.instance.settings.dragAutoSnap&&n&&(this.doSlideChange=n),this.instance.settings.dragAutoSnap&&n){this.instance.preventOutsideClick=!0,this.toleranceReached=!0,this.active=!1,this.instance.preventOutsideClick=!0,this.dragEnd(null),n=="right"&&this.instance.prevSlide(),n=="left"&&this.instance.nextSlide();return}}if(this.toleranceY>0&&i>0&&i>=t&&(!this.lastDirection||this.lastDirection=="y")){this.xOffset=0,this.lastDirection="y",this.setTranslate(this.dragContainer,0,this.currentY);let n=this.shouldClose();!this.instance.settings.dragAutoSnap&&n&&(this.doSlideClose=!0),this.instance.settings.dragAutoSnap&&n&&this.instance.close();return}}}shouldChange(){let e=!1;if(Math.abs(this.currentX)>=this.toleranceX){let i=this.currentX>0?"right":"left";(i=="left"&&this.slide!==this.slide.parentNode.lastChild||i=="right"&&this.slide!==this.slide.parentNode.firstChild)&&(e=i)}return e}shouldClose(){let e=!1;return Math.abs(this.currentY)>=this.toleranceY&&(e=!0),e}setTranslate(e,t,i,n=!1){n?e.style.transition="all .2s ease":e.style.transition="",e.style.transform=`translate3d(${t}px, ${i}px, 0)`}}function Ai(c,e,t,i){const n=c.querySelector(".gslide-media");let s=new Image,r="gSlideTitle_"+t,o="gSlideDesc_"+t;s.addEventListener("load",()=>{F(i)&&i()},!1),s.src=e.href,e.sizes!=""&&e.srcset!=""&&(s.sizes=e.sizes,s.srcset=e.srcset),s.alt="",!ne(e.alt)&&e.alt!==""&&(s.alt=e.alt),e.title!==""&&s.setAttribute("aria-labelledby",r),e.description!==""&&s.setAttribute("aria-describedby",o),e.hasOwnProperty("_hasCustomWidth")&&e._hasCustomWidth&&(s.style.width=e.width),e.hasOwnProperty("_hasCustomHeight")&&e._hasCustomHeight&&(s.style.height=e.height),n.insertBefore(s,n.firstChild)}function qi(c,e,t,i){const n=c.querySelector(".ginner-container"),s="gvideo"+t,r=c.querySelector(".gslide-media"),o=this.getAllPlayers();H(n,"gvideo-container"),r.insertBefore(xe('<div class="gvideo-wrapper"></div>'),r.firstChild);const a=c.querySelector(".gvideo-wrapper");Pt(this.settings.plyr.css,"Plyr");let d=e.href,u=e?.videoProvider,l=!1;r.style.maxWidth=e.width,Pt(this.settings.plyr.js,"Plyr",()=>{if(!u&&d.match(/vimeo\.com\/([0-9]*)/)&&(u="vimeo"),!u&&(d.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||d.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||d.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/))&&(u="youtube"),u==="local"||!u){u="local";let w='<video id="'+s+'" ';w+=`style="background:#000; max-width: ${e.width};" `,w+='preload="metadata" ',w+='x-webkit-airplay="allow" ',w+="playsinline ",w+="controls ",w+='class="gvideo-local">',w+=`<source src="${d}">`,w+="</video>",l=xe(w)}const h=l||xe(`<div id="${s}" data-plyr-provider="${u}" data-plyr-embed-id="${d}"></div>`);H(a,`${u}-video gvideo`),a.appendChild(h),a.setAttribute("data-id",s),a.setAttribute("data-index",t);const p=Z(this.settings.plyr,"config")?this.settings.plyr.config:{},b=new Plyr("#"+s,p);b.on("ready",w=>{o[s]=w.detail.plyr,F(i)&&i()}),ot(()=>c.querySelector("iframe")&&c.querySelector("iframe").dataset.ready=="true",()=>{this.resize(c)}),b.on("enterfullscreen",Ht),b.on("exitfullscreen",Ht)})}function Ht(c){const e=ce(c.target,".gslide-media");c.type==="enterfullscreen"&&H(e,"fullscreen"),c.type==="exitfullscreen"&&J(e,"fullscreen")}function Pi(c,e,t,i){const n=c.querySelector(".gslide-media"),s=Z(e,"href")&&e.href?e.href.split("#").pop().trim():!1,r=Z(e,"content")&&e.content?e.content:!1;let o;if(r&&(Ae(r)&&(o=xe(`<div class="ginlined-content">${r}</div>`)),ge(r))){r.style.display=="none"&&(r.style.display="block");const a=document.createElement("div");a.className="ginlined-content",a.appendChild(r),o=a}if(s){let a=document.getElementById(s);if(!a)return!1;const d=a.cloneNode(!0);d.style.height=e.height,d.style.maxWidth=e.width,H(d,"ginlined-content"),o=d}if(!o)return console.error("Unable to append inline slide content",e),!1;n.style.height=e.height,n.style.width=e.width,n.appendChild(o),this.events["inlineclose"+s]=oe("click",{onElement:n.querySelectorAll(".gtrigger-close"),withCallback:a=>{a.preventDefault(),this.close()}}),F(i)&&i()}function Ii(c,e,t,i){const n=c.querySelector(".gslide-media"),s=wi({url:e.href,callback:i});n.parentNode.style.maxWidth=e.width,n.parentNode.style.height=e.height,n.appendChild(s)}class Oi{constructor(e={}){this.defaults={href:"",sizes:"",srcset:"",title:"",type:"",videoProvider:"",description:"",alt:"",descPosition:"bottom",effect:"",width:"",height:"",content:!1,zoomable:!0,draggable:!0},Ce(e)&&(this.defaults=fe(this.defaults,e))}sourceType(e){let t=e;return e=e.toLowerCase(),e.match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/)!==null?"image":e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/vimeo\.com\/([0-9]*)/)||e.match(/\.(mp4|ogg|webm|mov)/)!==null?"video":e.match(/\.(mp3|wav|wma|aac|ogg)/)!==null?"audio":e.indexOf("#")>-1&&t.split("#").pop().trim()!==""?"inline":e.indexOf("goajax=true")>-1?"ajax":"external"}parseConfig(e,t){let i=fe({descPosition:t.descPosition},this.defaults);if(Ce(e)&&!ge(e)){Z(e,"type")||(Z(e,"content")&&e.content?e.type="inline":Z(e,"href")&&(e.type=this.sourceType(e.href)));let o=fe(i,e);return this.setSize(o,t),o}let n="",s=e.getAttribute("data-glightbox"),r=e.nodeName.toLowerCase();if(r==="a"&&(n=e.href),r==="img"&&(n=e.src,i.alt=e.alt),i.href=n,V(i,(o,a)=>{Z(t,a)&&a!=="width"&&(i[a]=t[a]);const d=e.dataset[a];ne(d)||(i[a]=this.sanitizeValue(d))}),i.content&&(i.type="inline"),!i.type&&n&&(i.type=this.sourceType(n)),ne(s)){if(!i.title&&r=="a"){let o=e.title;!ne(o)&&o!==""&&(i.title=o)}if(!i.title&&r=="img"){let o=e.alt;!ne(o)&&o!==""&&(i.title=o)}}else{let o=[];V(i,(a,d)=>{o.push(";\\s?"+d)}),o=o.join("\\s?:|"),s.trim()!==""&&V(i,(a,d)=>{const u=s,l="s?"+d+"s?:s?(.*?)("+o+"s?:|$)",h=new RegExp(l),p=u.match(h);if(p&&p.length&&p[1]){const b=p[1].trim().replace(/;\s*$/,"");i[d]=this.sanitizeValue(b)}})}if(i.description&&i.description.substring(0,1)==="."){let o;try{o=document.querySelector(i.description).innerHTML}catch(a){if(!(a instanceof DOMException))throw a}o&&(i.description=o)}if(!i.description){let o=e.querySelector(".glightbox-desc");o&&(i.description=o.innerHTML)}return this.setSize(i,t,e),this.slideConfig=i,i}setSize(e,t,i=null){const n=e.type=="video"?this.checkSize(t.videosWidth):this.checkSize(t.width),s=this.checkSize(t.height);return e.width=Z(e,"width")&&e.width!==""?this.checkSize(e.width):n,e.height=Z(e,"height")&&e.height!==""?this.checkSize(e.height):s,i&&e.type=="image"&&(e._hasCustomWidth=!!i.dataset.width,e._hasCustomHeight=!!i.dataset.height),e}checkSize(e){return Ue(e)?`${e}px`:e}sanitizeValue(e){return e!=="true"&&e!=="false"?e:e==="true"}}class Be{constructor(e,t,i){this.element=e,this.instance=t,this.index=i}setContent(e=null,t=!1){if(ee(e,"loaded"))return!1;const i=this.instance.settings,n=this.slideConfig,s=lt();F(i.beforeSlideLoad)&&i.beforeSlideLoad({index:this.index,slide:e,player:!1});let r=n.type,o=n.descPosition,a=e.querySelector(".gslide-media"),d=e.querySelector(".gslide-title"),u=e.querySelector(".gslide-desc"),l=e.querySelector(".gdesc-inner"),h=t,p="gSlideTitle_"+this.index,b="gSlideDesc_"+this.index;if(F(i.afterSlideLoad)&&(h=()=>{F(t)&&t(),i.afterSlideLoad({index:this.index,slide:e,player:this.instance.getSlidePlayerInstance(this.index)})}),n.title==""&&n.description==""?l&&l.parentNode.parentNode.removeChild(l.parentNode):(d&&n.title!==""?(d.id=p,d.innerHTML=n.title):d.parentNode.removeChild(d),u&&n.description!==""?(u.id=b,s&&i.moreLength>0?(n.smallDescription=this.slideShortDesc(n.description,i.moreLength,i.moreText),u.innerHTML=n.smallDescription,this.descriptionEvents(u,n)):u.innerHTML=n.description):u.parentNode.removeChild(u),H(a.parentNode,`desc-${o}`),H(l.parentNode,`description-${o}`)),H(a,`gslide-${r}`),H(e,"loaded"),r==="video"){qi.apply(this.instance,[e,n,this.index,h]);return}if(r==="external"){Ii.apply(this,[e,n,this.index,h]);return}if(r==="inline"){Pi.apply(this.instance,[e,n,this.index,h]),n.draggable&&new Dt({dragEl:e.querySelector(".gslide-inline"),toleranceX:i.dragToleranceX,toleranceY:i.dragToleranceY,slide:e,instance:this.instance});return}if(r==="image"){Ai(e,n,this.index,()=>{const w=e.querySelector("img");n.draggable&&new Dt({dragEl:w,toleranceX:i.dragToleranceX,toleranceY:i.dragToleranceY,slide:e,instance:this.instance}),n.zoomable&&w.naturalWidth>w.offsetWidth&&(H(w,"zoomable"),new Mi(w,e,()=>{this.instance.resize()})),F(h)&&h()});return}F(h)&&h()}slideShortDesc(e,t=50,i=!1){let n=document.createElement("div");n.innerHTML=e;let s=n.innerText,r=i;if(e=s.trim(),e.length<=t)return e;let o=e.substr(0,t-1);return r?(n=null,o+'... <a href="#" class="desc-more">'+i+"</a>"):o}descriptionEvents(e,t){let i=e.querySelector(".desc-more");if(!i)return!1;oe("click",{onElement:i,withCallback:(n,s)=>{n.preventDefault();const r=document.body;let o=ce(s,".gslide-desc");if(!o)return!1;o.innerHTML=t.description,H(r,"gdesc-open");let a=oe("click",{onElement:[r,ce(o,".gslide-description")],withCallback:(d,u)=>{d.target.nodeName.toLowerCase()!=="a"&&(J(r,"gdesc-open"),H(r,"gdesc-closed"),o.innerHTML=t.smallDescription,this.descriptionEvents(o,t),setTimeout(()=>{J(r,"gdesc-closed")},400),a.destroy())}})}})}create(){return xe(this.instance.settings.slideHTML)}getConfig(){!ge(this.element)&&!this.element.hasOwnProperty("draggable")&&(this.element.draggable=this.instance.settings.draggable);const e=new Oi(this.instance.settings.slideExtraAttributes);return this.slideConfig=e.parseConfig(this.element,this.instance.settings),this.slideConfig}}const $i="3.2.0",zt=lt(),Ut=xi();let ct;typeof document>"u"||(ct=document.getElementsByTagName("html")[0]);const ut={selector:".glightbox",elements:null,skin:"clean",theme:"clean",closeButton:!0,startAt:null,autoplayVideos:!0,autofocusVideos:!0,descPosition:"bottom",width:"900px",height:"506px",videosWidth:"960px",beforeSlideChange:null,afterSlideChange:null,beforeSlideLoad:null,afterSlideLoad:null,slideInserted:null,slideRemoved:null,slideExtraAttributes:null,onOpen:null,onClose:null,loop:!1,zoomable:!0,draggable:!0,dragAutoSnap:!1,dragToleranceX:40,dragToleranceY:65,preload:!0,oneSlidePerOpen:!1,touchNavigation:!0,touchFollowAxis:!0,keyboardNavigation:!0,closeOnOutsideClick:!0,plugins:!1,plyr:{css:"https://cdn.plyr.io/3.6.12/plyr.css",js:"https://cdn.plyr.io/3.6.12/plyr.js",config:{ratio:"16:9",fullscreen:{enabled:!0,iosNative:!0},youtube:{noCookie:!0,rel:0,showinfo:0,iv_load_policy:3},vimeo:{byline:!1,portrait:!1,title:!1,transparent:!1}}},openEffect:"zoom",closeEffect:"zoom",slideEffect:"slide",moreText:"See more",moreLength:60,cssEfects:{fade:{in:"fadeIn",out:"fadeOut"},zoom:{in:"zoomIn",out:"zoomOut"},slide:{in:"slideInRight",out:"slideOutLeft"},slideBack:{in:"slideInLeft",out:"slideOutRight"},none:{in:"none",out:"none"}},svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>'}};ut.slideHTML=`<div class="gslide">
1
+ var ContentBuilderRuntime=(function(){"use strict";const Rt=Date.now();function fe(){let c={},e=!0,t=0,i=arguments.length;Object.prototype.toString.call(arguments[0])==="[object Boolean]"&&(e=arguments[0],t++);let n=s=>{for(let r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e&&Object.prototype.toString.call(s[r])==="[object Object]"?c[r]=fe(!0,c[r],s[r]):c[r]=s[r])};for(;t<i;t++){let s=arguments[t];n(s)}return c}function V(c,e){if((ge(c)||c===window||c===document)&&(c=[c]),!Ot(c)&&!Ce(c)&&(c=[c]),$t(c)!=0){if(Ot(c)&&!Ce(c)){let t=c.length,i=0;for(;i<t&&e.call(c[i],c[i],i,c)!==!1;i++);}else if(Ce(c)){for(let t in c)if(Z(c,t)&&e.call(c[t],c[t],t,c)===!1)break}}}function Mt(c,e=null,t=null){const i=c[Rt]=c[Rt]||[],n={all:i,evt:null,found:null};return e&&t&&$t(i)>0&&V(i,(s,r)=>{if(s.eventName==e&&s.fn.toString()==t.toString())return n.found=!0,n.evt=r,!1}),n}function oe(c,{onElement:e,withCallback:t,avoidDuplicate:i=!0,once:n=!1,useCapture:s=!1}={},r){let o=e||[];Ae(o)&&(o=document.querySelectorAll(o));function a(u){F(t)&&t.call(r,u,this),n&&a.destroy()}return a.destroy=function(){V(o,u=>{const d=Mt(u,c,a);d.found&&d.all.splice(d.evt,1),u.removeEventListener&&u.removeEventListener(c,a,s)})},V(o,u=>{const d=Mt(u,c,a);(u.addEventListener&&i&&!d.found||!i)&&(u.addEventListener(c,a,s),d.all.push({eventName:c,fn:a}))}),a}function H(c,e){V(e.split(" "),t=>c.classList.add(t))}function J(c,e){V(e.split(" "),t=>c.classList.remove(t))}function ee(c,e){return c.classList.contains(e)}function ce(c,e){for(;c!==document.body;){if(c=c.parentElement,!c)return!1;if(typeof c.matches=="function"?c.matches(e):c.msMatchesSelector(e))return c}}function Ee(c,e="",t=!1){if(!c||e==="")return!1;if(e==="none")return F(t)&&t(),!1;const i=yi(),n=e.split(" ");V(n,s=>{H(c,"g"+s)}),oe(i,{onElement:c,avoidDuplicate:!1,once:!0,withCallback:(s,r)=>{V(n,o=>{J(r,"g"+o)}),F(t)&&t()}})}function ze(c,e=""){if(e==="")return c.style.webkitTransform="",c.style.MozTransform="",c.style.msTransform="",c.style.OTransform="",c.style.transform="",!1;c.style.webkitTransform=e,c.style.MozTransform=e,c.style.msTransform=e,c.style.OTransform=e,c.style.transform=e}function At(c){c.style.display="block"}function rt(c){c.style.display="none"}function xe(c){let e=document.createDocumentFragment(),t=document.createElement("div");for(t.innerHTML=c;t.firstChild;)e.appendChild(t.firstChild);return e}function qt(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function yi(){let c,e=document.createElement("fakeelement"),t={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(c in t)if(e.style[c]!==void 0)return t[c]}function vi(){let c,e=document.createElement("fakeelement");const t={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(c in t)if(e.style[c]!==void 0)return t[c]}function wi(c){let{url:e,allow:t,callback:i,appendTo:n}=c,s=document.createElement("iframe");return s.className="vimeo-video gvideo",s.src=e,s.style.width="100%",s.style.height="100%",t&&s.setAttribute("allow",t),s.onload=function(){s.onload=null,H(s,"node-ready"),F(i)&&i()},n&&n.appendChild(s),s}function ot(c,e,t,i){if(c()){e();return}t||(t=100);let n=setInterval(()=>{c()&&(clearInterval(n),e())},t)}function Pt(c,e,t){if(ne(c)){console.error("Inject assets error");return}if(F(e)&&(t=e,e=!1),Ae(e)&&e in window){F(t)&&t();return}let i;if(c.indexOf(".css")!==-1){if(i=document.querySelectorAll('link[href="'+c+'"]'),i&&i.length>0){F(t)&&t();return}const s=document.getElementsByTagName("head")[0],r=s.querySelectorAll('link[rel="stylesheet"]'),o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.href=c,o.media="all",r?s.insertBefore(o,r[0]):s.appendChild(o),F(t)&&t();return}if(i=document.querySelectorAll('script[src="'+c+'"]'),i&&i.length>0){if(F(t)){if(Ae(e))return ot(()=>typeof window[e]<"u",()=>{t()}),!1;t()}return}let n=document.createElement("script");n.type="text/javascript",n.src=c,n.onload=()=>{if(F(t)){if(Ae(e))return ot(()=>typeof window[e]<"u",()=>{t()}),!1;t()}},document.body.appendChild(n)}function lt(){return typeof window>"u"?!1:"navigator"in window&&window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i)}function xi(){return typeof document>"u"?!1:lt()!==null||document.createTouch!==void 0||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints}function F(c){return typeof c=="function"}function Ae(c){return typeof c=="string"}function ge(c){return!!(c&&c.nodeType&&c.nodeType==1)}function It(c){return Array.isArray(c)}function Ot(c){return c&&c.length&&isFinite(c.length)}function Ce(c){return typeof c==="object"&&c!=null&&!F(c)&&!It(c)}function ne(c){return c==null}function Z(c,e){return c!==null&&hasOwnProperty.call(c,e)}function $t(c){if(Ce(c)){if(c.keys)return c.keys().length;let e=0;for(let t in c)Z(c,t)&&e++;return e}else return c.length}function Ue(c){return!isNaN(parseFloat(c))&&isFinite(c)}function Nt(c=-1){const e=document.querySelectorAll(".gbtn[data-taborder]:not(.disabled)");if(!e.length)return!1;if(e.length==1)return e[0];typeof c=="string"&&(c=parseInt(c));const t=[];V(e,o=>{t.push(o.getAttribute("data-taborder"))});const i=Math.max.apply(Math,t.map(o=>parseInt(o)));let n=c<0?1:c+1;n>i&&(n="1");const r=t.filter(o=>o>=parseInt(n)).sort()[0];return document.querySelector(`.gbtn[data-taborder="${r}"]`)}function ki(c){if(c.events.hasOwnProperty("keyboard"))return!1;c.events.keyboard=oe("keydown",{onElement:window,withCallback:(e,t)=>{e=e||window.event;const i=e.keyCode;if(i==9){const n=document.querySelector(".gbtn.focused");if(!n){const a=document.activeElement&&document.activeElement.nodeName?document.activeElement.nodeName.toLocaleLowerCase():!1;if(a=="input"||a=="textarea"||a=="button")return}e.preventDefault();const s=document.querySelectorAll(".gbtn[data-taborder]");if(!s||s.length<=0)return;if(!n){const a=Nt();a&&(a.focus(),H(a,"focused"));return}let r=n.getAttribute("data-taborder"),o=Nt(r);J(n,"focused"),o&&(o.focus(),H(o,"focused"))}i==39&&c.nextSlide(),i==37&&c.prevSlide(),i==27&&c.close()}})}function je(c){return Math.sqrt(c.x*c.x+c.y*c.y)}function _i(c,e){return c.x*e.x+c.y*e.y}function Si(c,e){var t=je(c)*je(e);if(t===0)return 0;var i=_i(c,e)/t;return i>1&&(i=1),Math.acos(i)}function Ti(c,e){return c.x*e.y-e.x*c.y}function Ei(c,e){var t=Si(c,e);return Ti(c,e)>0&&(t*=-1),t*180/Math.PI}class Ci{constructor(e){this.handlers=[],this.el=e}add(e){this.handlers.push(e)}del(e){e||(this.handlers=[]);for(var t=this.handlers.length;t>=0;t--)this.handlers[t]===e&&this.handlers.splice(t,1)}dispatch(){for(var e=0,t=this.handlers.length;e<t;e++){var i=this.handlers[e];typeof i=="function"&&i.apply(this.el,arguments)}}}function te(c,e){var t=new Ci(c);return t.add(e),t}class Li{constructor(e,t){this.element=typeof e=="string"?document.querySelector(e):e,this.start=this.start.bind(this),this.move=this.move.bind(this),this.end=this.end.bind(this),this.cancel=this.cancel.bind(this),this.element.addEventListener("touchstart",this.start,!1),this.element.addEventListener("touchmove",this.move,!1),this.element.addEventListener("touchend",this.end,!1),this.element.addEventListener("touchcancel",this.cancel,!1),this.preV={x:null,y:null},this.pinchStartLen=null,this.zoom=1,this.isDoubleTap=!1;var i=function(){};this.rotate=te(this.element,t.rotate||i),this.touchStart=te(this.element,t.touchStart||i),this.multipointStart=te(this.element,t.multipointStart||i),this.multipointEnd=te(this.element,t.multipointEnd||i),this.pinch=te(this.element,t.pinch||i),this.swipe=te(this.element,t.swipe||i),this.tap=te(this.element,t.tap||i),this.doubleTap=te(this.element,t.doubleTap||i),this.longTap=te(this.element,t.longTap||i),this.singleTap=te(this.element,t.singleTap||i),this.pressMove=te(this.element,t.pressMove||i),this.twoFingerPressMove=te(this.element,t.twoFingerPressMove||i),this.touchMove=te(this.element,t.touchMove||i),this.touchEnd=te(this.element,t.touchEnd||i),this.touchCancel=te(this.element,t.touchCancel||i),this.translateContainer=this.element,this._cancelAllHandler=this.cancelAll.bind(this),window.addEventListener("scroll",this._cancelAllHandler),this.delta=null,this.last=null,this.now=null,this.tapTimeout=null,this.singleTapTimeout=null,this.longTapTimeout=null,this.swipeTimeout=null,this.x1=this.x2=this.y1=this.y2=null,this.preTapPosition={x:null,y:null}}start(e){if(!e.touches)return;const t=["a","button","input"];if(e.target&&e.target.nodeName&&t.indexOf(e.target.nodeName.toLowerCase())>=0){console.log("ignore drag for this touched element",e.target.nodeName.toLowerCase());return}this.now=Date.now(),this.x1=e.touches[0].pageX,this.y1=e.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(e,this.element),this.preTapPosition.x!==null&&(this.isDoubleTap=this.delta>0&&this.delta<=250&&Math.abs(this.preTapPosition.x-this.x1)<30&&Math.abs(this.preTapPosition.y-this.y1)<30,this.isDoubleTap&&clearTimeout(this.singleTapTimeout)),this.preTapPosition.x=this.x1,this.preTapPosition.y=this.y1,this.last=this.now;var i=this.preV,n=e.touches.length;if(n>1){this._cancelLongTap(),this._cancelSingleTap();var s={x:e.touches[1].pageX-this.x1,y:e.touches[1].pageY-this.y1};i.x=s.x,i.y=s.y,this.pinchStartLen=je(i),this.multipointStart.dispatch(e,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout((function(){this.longTap.dispatch(e,this.element),this._preventTap=!0}).bind(this),750)}move(e){if(e.touches){var t=this.preV,i=e.touches.length,n=e.touches[0].pageX,s=e.touches[0].pageY;if(this.isDoubleTap=!1,i>1){var r=e.touches[1].pageX,o=e.touches[1].pageY,a={x:e.touches[1].pageX-n,y:e.touches[1].pageY-s};t.x!==null&&(this.pinchStartLen>0&&(e.zoom=je(a)/this.pinchStartLen,this.pinch.dispatch(e,this.element)),e.angle=Ei(a,t),this.rotate.dispatch(e,this.element)),t.x=a.x,t.y=a.y,this.x2!==null&&this.sx2!==null?(e.deltaX=(n-this.x2+r-this.sx2)/2,e.deltaY=(s-this.y2+o-this.sy2)/2):(e.deltaX=0,e.deltaY=0),this.twoFingerPressMove.dispatch(e,this.element),this.sx2=r,this.sy2=o}else{if(this.x2!==null){e.deltaX=n-this.x2,e.deltaY=s-this.y2;var u=Math.abs(this.x1-this.x2),d=Math.abs(this.y1-this.y2);(u>10||d>10)&&(this._preventTap=!0)}else e.deltaX=0,e.deltaY=0;this.pressMove.dispatch(e,this.element)}this.touchMove.dispatch(e,this.element),this._cancelLongTap(),this.x2=n,this.y2=s,i>1&&e.preventDefault()}}end(e){if(e.changedTouches){this._cancelLongTap();var t=this;e.touches.length<2&&(this.multipointEnd.dispatch(e,this.element),this.sx2=this.sy2=null),this.x2&&Math.abs(this.x1-this.x2)>30||this.y2&&Math.abs(this.y1-this.y2)>30?(e.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout(function(){t.swipe.dispatch(e,t.element)},0)):(this.tapTimeout=setTimeout(function(){t._preventTap||t.tap.dispatch(e,t.element),t.isDoubleTap&&(t.doubleTap.dispatch(e,t.element),t.isDoubleTap=!1)},0),t.isDoubleTap||(t.singleTapTimeout=setTimeout(function(){t.singleTap.dispatch(e,t.element)},250))),this.touchEnd.dispatch(e,this.element),this.preV.x=0,this.preV.y=0,this.zoom=1,this.pinchStartLen=null,this.x1=this.x2=this.y1=this.y2=null}}cancelAll(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}cancel(e){this.cancelAll(),this.touchCancel.dispatch(e,this.element)}_cancelLongTap(){clearTimeout(this.longTapTimeout)}_cancelSingleTap(){clearTimeout(this.singleTapTimeout)}_swipeDirection(e,t,i,n){return Math.abs(e-t)>=Math.abs(i-n)?e-t>0?"Left":"Right":i-n>0?"Up":"Down"}on(e,t){this[e]&&this[e].add(t)}off(e,t){this[e]&&this[e].del(t)}destroy(){return this.singleTapTimeout&&clearTimeout(this.singleTapTimeout),this.tapTimeout&&clearTimeout(this.tapTimeout),this.longTapTimeout&&clearTimeout(this.longTapTimeout),this.swipeTimeout&&clearTimeout(this.swipeTimeout),this.element.removeEventListener("touchstart",this.start),this.element.removeEventListener("touchmove",this.move),this.element.removeEventListener("touchend",this.end),this.element.removeEventListener("touchcancel",this.cancel),this.rotate.del(),this.touchStart.del(),this.multipointStart.del(),this.multipointEnd.del(),this.pinch.del(),this.swipe.del(),this.tap.del(),this.doubleTap.del(),this.longTap.del(),this.singleTap.del(),this.pressMove.del(),this.twoFingerPressMove.del(),this.touchMove.del(),this.touchEnd.del(),this.touchCancel.del(),this.preV=this.pinchStartLen=this.zoom=this.isDoubleTap=this.delta=this.last=this.now=this.tapTimeout=this.singleTapTimeout=this.longTapTimeout=this.swipeTimeout=this.x1=this.x2=this.y1=this.y2=this.preTapPosition=this.rotate=this.touchStart=this.multipointStart=this.multipointEnd=this.pinch=this.swipe=this.tap=this.doubleTap=this.longTap=this.singleTap=this.pressMove=this.touchMove=this.touchEnd=this.touchCancel=this.twoFingerPressMove=null,window.removeEventListener("scroll",this._cancelAllHandler),null}}function at(c){const e=vi(),t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;let i=ee(c,"gslide-media")?c:c.querySelector(".gslide-media"),n=ce(i,".ginner-container"),s=c.querySelector(".gslide-description");t>769&&(i=n),H(i,"greset"),ze(i,"translate3d(0, 0, 0)"),oe(e,{onElement:i,once:!0,withCallback:(r,o)=>{J(i,"greset")}}),i.style.opacity="",s&&(s.style.opacity="")}function Ri(c){if(c.events.hasOwnProperty("touch"))return!1;let e=qt(),t=e.width,i=e.height,n=!1,s=null,r=null,o=null,a=!1,u=1,d=4.5,l=1,h=!1,p=!1,b=null,w=null,_=null,g=null,v,f,m=0,y=0,k=!1,x=!1,S={},E={},C=0,A=0,L;const D=document.getElementById("glightbox-slider"),I=document.querySelector(".goverlay"),O=new Li(D,{touchStart:R=>{if(n=!0,(ee(R.targetTouches[0].target,"ginner-container")||ce(R.targetTouches[0].target,".gslide-desc")||R.targetTouches[0].target.nodeName.toLowerCase()=="a")&&(n=!1),ce(R.targetTouches[0].target,".gslide-inline")&&!ee(R.targetTouches[0].target.parentNode,"gslide-inline")&&(n=!1),n){if(E=R.targetTouches[0],S.pageX=R.targetTouches[0].pageX,S.pageY=R.targetTouches[0].pageY,C=R.targetTouches[0].clientX,A=R.targetTouches[0].clientY,s=c.activeSlide,r=s.querySelector(".gslide-media"),L=s.querySelector(".gslide-inline"),o=null,ee(r,"gslide-image")&&(o=r.querySelector("img")),(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)>769&&(r=s.querySelector(".ginner-container")),J(I,"greset"),R.pageX>20&&R.pageX<window.innerWidth-20)return;R.preventDefault()}},touchMove:R=>{if(!n||(E=R.targetTouches[0],h||p))return;if(L&&L.offsetHeight>i){const U=S.pageX-E.pageX;if(Math.abs(U)<=13)return!1}a=!0;let q=R.targetTouches[0].clientX,M=R.targetTouches[0].clientY,T=C-q,$=A-M;Math.abs(T)>Math.abs($)?(k=!1,x=!0):(x=!1,k=!0),v=E.pageX-S.pageX,m=v*100/t,f=E.pageY-S.pageY,y=f*100/i;let N;if(k&&o&&(N=1-Math.abs(f)/i,I.style.opacity=N,c.settings.touchFollowAxis&&(m=0)),x&&(N=1-Math.abs(v)/t,r.style.opacity=N,c.settings.touchFollowAxis&&(y=0)),!o)return ze(r,`translate3d(${m}%, 0, 0)`);ze(r,`translate3d(${m}%, ${y}%, 0)`)},touchEnd:()=>{if(!n)return;if(a=!1,p||h){_=b,g=w;return}const R=Math.abs(parseInt(y)),q=Math.abs(parseInt(m));if(R>29&&o){c.close();return}if(R<29&&q<25)return H(I,"greset"),I.style.opacity=1,at(r)},multipointEnd:()=>{setTimeout(()=>{h=!1},50)},multipointStart:()=>{h=!0,u=l||1},pinch:R=>{if(!o||a)return!1;h=!0,o.scaleX=o.scaleY=u*R.zoom;let q=u*R.zoom;if(p=!0,q<=1){p=!1,q=1,g=null,_=null,b=null,w=null,o.setAttribute("style","");return}q>d&&(q=d),o.style.transform=`scale3d(${q}, ${q}, 1)`,l=q},pressMove:R=>{if(p&&!h){var q=E.pageX-S.pageX,M=E.pageY-S.pageY;_&&(q=q+_),g&&(M=M+g),b=q,w=M;let T=`translate3d(${q}px, ${M}px, 0)`;l&&(T+=` scale3d(${l}, ${l}, 1)`),ze(o,T)}},swipe:R=>{if(!p){if(h){h=!1;return}if(R.direction=="Left"){if(c.index==c.elements.length-1)return at(r);c.nextSlide()}if(R.direction=="Right"){if(c.index==0)return at(r);c.prevSlide()}}}});c.events.touch=O}class Mi{constructor(e,t,i=null){if(this.img=e,this.slide=t,this.onclose=i,this.img.setZoomEvents)return!1;this.active=!1,this.zoomedIn=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.img.addEventListener("mousedown",n=>this.dragStart(n),!1),this.img.addEventListener("mouseup",n=>this.dragEnd(n),!1),this.img.addEventListener("mousemove",n=>this.drag(n),!1),this.img.addEventListener("click",n=>{if(this.slide.classList.contains("dragging-nav"))return this.zoomOut(),!1;if(!this.zoomedIn)return this.zoomIn();this.zoomedIn&&!this.dragging&&this.zoomOut()},!1),this.img.setZoomEvents=!0}zoomIn(){let e=this.widowWidth();if(this.zoomedIn||e<=768)return;const t=this.img;if(t.setAttribute("data-style",t.getAttribute("style")),t.style.maxWidth=t.naturalWidth+"px",t.style.maxHeight=t.naturalHeight+"px",t.naturalWidth>e){let i=e/2-t.naturalWidth/2;this.setTranslate(this.img.parentNode,i,0)}this.slide.classList.add("zoomed"),this.zoomedIn=!0}zoomOut(){this.img.parentNode.setAttribute("style",""),this.img.setAttribute("style",this.img.getAttribute("data-style")),this.slide.classList.remove("zoomed"),this.zoomedIn=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.onclose&&typeof this.onclose=="function"&&this.onclose()}dragStart(e){if(e.preventDefault(),!this.zoomedIn){this.active=!1;return}e.type==="touchstart"?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset),e.target===this.img&&(this.active=!0,this.img.classList.add("dragging"))}dragEnd(e){e.preventDefault(),this.initialX=this.currentX,this.initialY=this.currentY,this.active=!1,setTimeout(()=>{this.dragging=!1,this.img.isDragging=!1,this.img.classList.remove("dragging")},100)}drag(e){this.active&&(e.preventDefault(),e.type==="touchmove"?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.img.isDragging=!0,this.dragging=!0,this.setTranslate(this.img,this.currentX,this.currentY))}onMove(e){if(!this.zoomedIn)return;let t=e.clientX-this.img.naturalWidth/2,i=e.clientY-this.img.naturalHeight/2;this.setTranslate(this.img,t,i)}setTranslate(e,t,i){e.style.transform="translate3d("+t+"px, "+i+"px, 0)"}widowWidth(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}class Dt{constructor(e={}){let{dragEl:t,toleranceX:i=40,toleranceY:n=65,slide:s=null,instance:r=null}=e;this.el=t,this.active=!1,this.dragging=!1,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.direction=null,this.lastDirection=null,this.toleranceX=i,this.toleranceY=n,this.toleranceReached=!1,this.dragContainer=this.el,this.slide=s,this.instance=r,this.el.addEventListener("mousedown",o=>this.dragStart(o),!1),this.el.addEventListener("mouseup",o=>this.dragEnd(o),!1),this.el.addEventListener("mousemove",o=>this.drag(o),!1)}dragStart(e){if(this.slide.classList.contains("zoomed")){this.active=!1;return}e.type==="touchstart"?(this.initialX=e.touches[0].clientX-this.xOffset,this.initialY=e.touches[0].clientY-this.yOffset):(this.initialX=e.clientX-this.xOffset,this.initialY=e.clientY-this.yOffset);let t=e.target.nodeName.toLowerCase(),i=["input","select","textarea","button","a"];if(e.target.classList.contains("nodrag")||ce(e.target,".nodrag")||i.indexOf(t)!==-1){this.active=!1;return}e.preventDefault(),(e.target===this.el||t!=="img"&&ce(e.target,".gslide-inline"))&&(this.active=!0,this.el.classList.add("dragging"),this.dragContainer=ce(e.target,".ginner-container"))}dragEnd(e){e&&e.preventDefault(),this.initialX=0,this.initialY=0,this.currentX=null,this.currentY=null,this.initialX=null,this.initialY=null,this.xOffset=0,this.yOffset=0,this.active=!1,this.doSlideChange&&(this.instance.preventOutsideClick=!0,this.doSlideChange=="right"&&this.instance.prevSlide(),this.doSlideChange=="left"&&this.instance.nextSlide()),this.doSlideClose&&this.instance.close(),this.toleranceReached||this.setTranslate(this.dragContainer,0,0,!0),setTimeout(()=>{this.instance.preventOutsideClick=!1,this.toleranceReached=!1,this.lastDirection=null,this.dragging=!1,this.el.isDragging=!1,this.el.classList.remove("dragging"),this.slide.classList.remove("dragging-nav"),this.dragContainer.style.transform="",this.dragContainer.style.transition=""},100)}drag(e){if(this.active){e.preventDefault(),this.slide.classList.add("dragging-nav"),e.type==="touchmove"?(this.currentX=e.touches[0].clientX-this.initialX,this.currentY=e.touches[0].clientY-this.initialY):(this.currentX=e.clientX-this.initialX,this.currentY=e.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.el.isDragging=!0,this.dragging=!0,this.doSlideChange=!1,this.doSlideClose=!1;let t=Math.abs(this.currentX),i=Math.abs(this.currentY);if(t>0&&t>=Math.abs(this.currentY)&&(!this.lastDirection||this.lastDirection=="x")){this.yOffset=0,this.lastDirection="x",this.setTranslate(this.dragContainer,this.currentX,0);let n=this.shouldChange();if(!this.instance.settings.dragAutoSnap&&n&&(this.doSlideChange=n),this.instance.settings.dragAutoSnap&&n){this.instance.preventOutsideClick=!0,this.toleranceReached=!0,this.active=!1,this.instance.preventOutsideClick=!0,this.dragEnd(null),n=="right"&&this.instance.prevSlide(),n=="left"&&this.instance.nextSlide();return}}if(this.toleranceY>0&&i>0&&i>=t&&(!this.lastDirection||this.lastDirection=="y")){this.xOffset=0,this.lastDirection="y",this.setTranslate(this.dragContainer,0,this.currentY);let n=this.shouldClose();!this.instance.settings.dragAutoSnap&&n&&(this.doSlideClose=!0),this.instance.settings.dragAutoSnap&&n&&this.instance.close();return}}}shouldChange(){let e=!1;if(Math.abs(this.currentX)>=this.toleranceX){let i=this.currentX>0?"right":"left";(i=="left"&&this.slide!==this.slide.parentNode.lastChild||i=="right"&&this.slide!==this.slide.parentNode.firstChild)&&(e=i)}return e}shouldClose(){let e=!1;return Math.abs(this.currentY)>=this.toleranceY&&(e=!0),e}setTranslate(e,t,i,n=!1){n?e.style.transition="all .2s ease":e.style.transition="",e.style.transform=`translate3d(${t}px, ${i}px, 0)`}}function Ai(c,e,t,i){const n=c.querySelector(".gslide-media");let s=new Image,r="gSlideTitle_"+t,o="gSlideDesc_"+t;s.addEventListener("load",()=>{F(i)&&i()},!1),s.src=e.href,e.sizes!=""&&e.srcset!=""&&(s.sizes=e.sizes,s.srcset=e.srcset),s.alt="",!ne(e.alt)&&e.alt!==""&&(s.alt=e.alt),e.title!==""&&s.setAttribute("aria-labelledby",r),e.description!==""&&s.setAttribute("aria-describedby",o),e.hasOwnProperty("_hasCustomWidth")&&e._hasCustomWidth&&(s.style.width=e.width),e.hasOwnProperty("_hasCustomHeight")&&e._hasCustomHeight&&(s.style.height=e.height),n.insertBefore(s,n.firstChild)}function qi(c,e,t,i){const n=c.querySelector(".ginner-container"),s="gvideo"+t,r=c.querySelector(".gslide-media"),o=this.getAllPlayers();H(n,"gvideo-container"),r.insertBefore(xe('<div class="gvideo-wrapper"></div>'),r.firstChild);const a=c.querySelector(".gvideo-wrapper");Pt(this.settings.plyr.css,"Plyr");let u=e.href,d=e?.videoProvider,l=!1;r.style.maxWidth=e.width,Pt(this.settings.plyr.js,"Plyr",()=>{if(!d&&u.match(/vimeo\.com\/([0-9]*)/)&&(d="vimeo"),!d&&(u.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||u.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||u.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/))&&(d="youtube"),d==="local"||!d){d="local";let w='<video id="'+s+'" ';w+=`style="background:#000; max-width: ${e.width};" `,w+='preload="metadata" ',w+='x-webkit-airplay="allow" ',w+="playsinline ",w+="controls ",w+='class="gvideo-local">',w+=`<source src="${u}">`,w+="</video>",l=xe(w)}const h=l||xe(`<div id="${s}" data-plyr-provider="${d}" data-plyr-embed-id="${u}"></div>`);H(a,`${d}-video gvideo`),a.appendChild(h),a.setAttribute("data-id",s),a.setAttribute("data-index",t);const p=Z(this.settings.plyr,"config")?this.settings.plyr.config:{},b=new Plyr("#"+s,p);b.on("ready",w=>{o[s]=w.detail.plyr,F(i)&&i()}),ot(()=>c.querySelector("iframe")&&c.querySelector("iframe").dataset.ready=="true",()=>{this.resize(c)}),b.on("enterfullscreen",Ht),b.on("exitfullscreen",Ht)})}function Ht(c){const e=ce(c.target,".gslide-media");c.type==="enterfullscreen"&&H(e,"fullscreen"),c.type==="exitfullscreen"&&J(e,"fullscreen")}function Pi(c,e,t,i){const n=c.querySelector(".gslide-media"),s=Z(e,"href")&&e.href?e.href.split("#").pop().trim():!1,r=Z(e,"content")&&e.content?e.content:!1;let o;if(r&&(Ae(r)&&(o=xe(`<div class="ginlined-content">${r}</div>`)),ge(r))){r.style.display=="none"&&(r.style.display="block");const a=document.createElement("div");a.className="ginlined-content",a.appendChild(r),o=a}if(s){let a=document.getElementById(s);if(!a)return!1;const u=a.cloneNode(!0);u.style.height=e.height,u.style.maxWidth=e.width,H(u,"ginlined-content"),o=u}if(!o)return console.error("Unable to append inline slide content",e),!1;n.style.height=e.height,n.style.width=e.width,n.appendChild(o),this.events["inlineclose"+s]=oe("click",{onElement:n.querySelectorAll(".gtrigger-close"),withCallback:a=>{a.preventDefault(),this.close()}}),F(i)&&i()}function Ii(c,e,t,i){const n=c.querySelector(".gslide-media"),s=wi({url:e.href,callback:i});n.parentNode.style.maxWidth=e.width,n.parentNode.style.height=e.height,n.appendChild(s)}class Oi{constructor(e={}){this.defaults={href:"",sizes:"",srcset:"",title:"",type:"",videoProvider:"",description:"",alt:"",descPosition:"bottom",effect:"",width:"",height:"",content:!1,zoomable:!0,draggable:!0},Ce(e)&&(this.defaults=fe(this.defaults,e))}sourceType(e){let t=e;return e=e.toLowerCase(),e.match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/)!==null?"image":e.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||e.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||e.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||e.match(/vimeo\.com\/([0-9]*)/)||e.match(/\.(mp4|ogg|webm|mov)/)!==null?"video":e.match(/\.(mp3|wav|wma|aac|ogg)/)!==null?"audio":e.indexOf("#")>-1&&t.split("#").pop().trim()!==""?"inline":e.indexOf("goajax=true")>-1?"ajax":"external"}parseConfig(e,t){let i=fe({descPosition:t.descPosition},this.defaults);if(Ce(e)&&!ge(e)){Z(e,"type")||(Z(e,"content")&&e.content?e.type="inline":Z(e,"href")&&(e.type=this.sourceType(e.href)));let o=fe(i,e);return this.setSize(o,t),o}let n="",s=e.getAttribute("data-glightbox"),r=e.nodeName.toLowerCase();if(r==="a"&&(n=e.href),r==="img"&&(n=e.src,i.alt=e.alt),i.href=n,V(i,(o,a)=>{Z(t,a)&&a!=="width"&&(i[a]=t[a]);const u=e.dataset[a];ne(u)||(i[a]=this.sanitizeValue(u))}),i.content&&(i.type="inline"),!i.type&&n&&(i.type=this.sourceType(n)),ne(s)){if(!i.title&&r=="a"){let o=e.title;!ne(o)&&o!==""&&(i.title=o)}if(!i.title&&r=="img"){let o=e.alt;!ne(o)&&o!==""&&(i.title=o)}}else{let o=[];V(i,(a,u)=>{o.push(";\\s?"+u)}),o=o.join("\\s?:|"),s.trim()!==""&&V(i,(a,u)=>{const d=s,l="s?"+u+"s?:s?(.*?)("+o+"s?:|$)",h=new RegExp(l),p=d.match(h);if(p&&p.length&&p[1]){const b=p[1].trim().replace(/;\s*$/,"");i[u]=this.sanitizeValue(b)}})}if(i.description&&i.description.substring(0,1)==="."){let o;try{o=document.querySelector(i.description).innerHTML}catch(a){if(!(a instanceof DOMException))throw a}o&&(i.description=o)}if(!i.description){let o=e.querySelector(".glightbox-desc");o&&(i.description=o.innerHTML)}return this.setSize(i,t,e),this.slideConfig=i,i}setSize(e,t,i=null){const n=e.type=="video"?this.checkSize(t.videosWidth):this.checkSize(t.width),s=this.checkSize(t.height);return e.width=Z(e,"width")&&e.width!==""?this.checkSize(e.width):n,e.height=Z(e,"height")&&e.height!==""?this.checkSize(e.height):s,i&&e.type=="image"&&(e._hasCustomWidth=!!i.dataset.width,e._hasCustomHeight=!!i.dataset.height),e}checkSize(e){return Ue(e)?`${e}px`:e}sanitizeValue(e){return e!=="true"&&e!=="false"?e:e==="true"}}class Be{constructor(e,t,i){this.element=e,this.instance=t,this.index=i}setContent(e=null,t=!1){if(ee(e,"loaded"))return!1;const i=this.instance.settings,n=this.slideConfig,s=lt();F(i.beforeSlideLoad)&&i.beforeSlideLoad({index:this.index,slide:e,player:!1});let r=n.type,o=n.descPosition,a=e.querySelector(".gslide-media"),u=e.querySelector(".gslide-title"),d=e.querySelector(".gslide-desc"),l=e.querySelector(".gdesc-inner"),h=t,p="gSlideTitle_"+this.index,b="gSlideDesc_"+this.index;if(F(i.afterSlideLoad)&&(h=()=>{F(t)&&t(),i.afterSlideLoad({index:this.index,slide:e,player:this.instance.getSlidePlayerInstance(this.index)})}),n.title==""&&n.description==""?l&&l.parentNode.parentNode.removeChild(l.parentNode):(u&&n.title!==""?(u.id=p,u.innerHTML=n.title):u.parentNode.removeChild(u),d&&n.description!==""?(d.id=b,s&&i.moreLength>0?(n.smallDescription=this.slideShortDesc(n.description,i.moreLength,i.moreText),d.innerHTML=n.smallDescription,this.descriptionEvents(d,n)):d.innerHTML=n.description):d.parentNode.removeChild(d),H(a.parentNode,`desc-${o}`),H(l.parentNode,`description-${o}`)),H(a,`gslide-${r}`),H(e,"loaded"),r==="video"){qi.apply(this.instance,[e,n,this.index,h]);return}if(r==="external"){Ii.apply(this,[e,n,this.index,h]);return}if(r==="inline"){Pi.apply(this.instance,[e,n,this.index,h]),n.draggable&&new Dt({dragEl:e.querySelector(".gslide-inline"),toleranceX:i.dragToleranceX,toleranceY:i.dragToleranceY,slide:e,instance:this.instance});return}if(r==="image"){Ai(e,n,this.index,()=>{const w=e.querySelector("img");n.draggable&&new Dt({dragEl:w,toleranceX:i.dragToleranceX,toleranceY:i.dragToleranceY,slide:e,instance:this.instance}),n.zoomable&&w.naturalWidth>w.offsetWidth&&(H(w,"zoomable"),new Mi(w,e,()=>{this.instance.resize()})),F(h)&&h()});return}F(h)&&h()}slideShortDesc(e,t=50,i=!1){let n=document.createElement("div");n.innerHTML=e;let s=n.innerText,r=i;if(e=s.trim(),e.length<=t)return e;let o=e.substr(0,t-1);return r?(n=null,o+'... <a href="#" class="desc-more">'+i+"</a>"):o}descriptionEvents(e,t){let i=e.querySelector(".desc-more");if(!i)return!1;oe("click",{onElement:i,withCallback:(n,s)=>{n.preventDefault();const r=document.body;let o=ce(s,".gslide-desc");if(!o)return!1;o.innerHTML=t.description,H(r,"gdesc-open");let a=oe("click",{onElement:[r,ce(o,".gslide-description")],withCallback:(u,d)=>{u.target.nodeName.toLowerCase()!=="a"&&(J(r,"gdesc-open"),H(r,"gdesc-closed"),o.innerHTML=t.smallDescription,this.descriptionEvents(o,t),setTimeout(()=>{J(r,"gdesc-closed")},400),a.destroy())}})}})}create(){return xe(this.instance.settings.slideHTML)}getConfig(){!ge(this.element)&&!this.element.hasOwnProperty("draggable")&&(this.element.draggable=this.instance.settings.draggable);const e=new Oi(this.instance.settings.slideExtraAttributes);return this.slideConfig=e.parseConfig(this.element,this.instance.settings),this.slideConfig}}const $i="3.2.0",zt=lt(),Ut=xi();let ct;typeof document>"u"||(ct=document.getElementsByTagName("html")[0]);const ut={selector:".glightbox",elements:null,skin:"clean",theme:"clean",closeButton:!0,startAt:null,autoplayVideos:!0,autofocusVideos:!0,descPosition:"bottom",width:"900px",height:"506px",videosWidth:"960px",beforeSlideChange:null,afterSlideChange:null,beforeSlideLoad:null,afterSlideLoad:null,slideInserted:null,slideRemoved:null,slideExtraAttributes:null,onOpen:null,onClose:null,loop:!1,zoomable:!0,draggable:!0,dragAutoSnap:!1,dragToleranceX:40,dragToleranceY:65,preload:!0,oneSlidePerOpen:!1,touchNavigation:!0,touchFollowAxis:!0,keyboardNavigation:!0,closeOnOutsideClick:!0,plugins:!1,plyr:{css:"https://cdn.plyr.io/3.6.12/plyr.css",js:"https://cdn.plyr.io/3.6.12/plyr.js",config:{ratio:"16:9",fullscreen:{enabled:!0,iosNative:!0},youtube:{noCookie:!0,rel:0,showinfo:0,iv_load_policy:3},vimeo:{byline:!1,portrait:!1,title:!1,transparent:!1}}},openEffect:"zoom",closeEffect:"zoom",slideEffect:"slide",moreText:"See more",moreLength:60,cssEfects:{fade:{in:"fadeIn",out:"fadeOut"},zoom:{in:"zoomIn",out:"zoomOut"},slide:{in:"slideInRight",out:"slideOutLeft"},slideBack:{in:"slideInLeft",out:"slideOutRight"},none:{in:"none",out:"none"}},svg:{close:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" xml:space="preserve"><g><g><path d="M505.943,6.058c-8.077-8.077-21.172-8.077-29.249,0L6.058,476.693c-8.077,8.077-8.077,21.172,0,29.249C10.096,509.982,15.39,512,20.683,512c5.293,0,10.586-2.019,14.625-6.059L505.943,35.306C514.019,27.23,514.019,14.135,505.943,6.058z"/></g></g><g><g><path d="M505.942,476.694L35.306,6.059c-8.076-8.077-21.172-8.077-29.248,0c-8.077,8.076-8.077,21.171,0,29.248l470.636,470.636c4.038,4.039,9.332,6.058,14.625,6.058c5.293,0,10.587-2.019,14.624-6.057C514.018,497.866,514.018,484.771,505.942,476.694z"/></g></g></svg>',next:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"> <g><path d="M360.731,229.075l-225.1-225.1c-5.3-5.3-13.8-5.3-19.1,0s-5.3,13.8,0,19.1l215.5,215.5l-215.5,215.5c-5.3,5.3-5.3,13.8,0,19.1c2.6,2.6,6.1,4,9.5,4c3.4,0,6.9-1.3,9.5-4l225.1-225.1C365.931,242.875,365.931,234.275,360.731,229.075z"/></g></svg>',prev:'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 477.175 477.175" xml:space="preserve"><g><path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/></g></svg>'}};ut.slideHTML=`<div class="gslide">
2
2
  <div class="gslide-inner-content">
3
3
  <div class="ginner-container">
4
4
  <div class="gslide-media">
@@ -20,46 +20,46 @@ var ContentBuilderRuntime=(function(){"use strict";const Rt=Date.now();function
20
20
  <button class="gprev gbtn" aria-label="Previous" data-taborder="2">{prevSVG}</button>
21
21
  <button class="gnext gbtn" aria-label="Next" data-taborder="1">{nextSVG}</button>
22
22
  </div>
23
- </div>`;class jt{constructor(e={}){this.customOptions=e,this.settings=fe(ut,e),this.effectsClasses=this.getAnimationClasses(),this.videoPlayers={},this.apiEvents=[],this.fullElementsList=!1}init(){const e=this.getSelector();e&&(this.baseEvents=oe("click",{onElement:e,withCallback:(t,i)=>{t.preventDefault(),this.open(i)}})),this.elements=this.getElements()}open(e=null,t=null){if(this.elements.length===0)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;let i=Ue(t)?t:this.settings.startAt;if(ge(e)){const o=e.getAttribute("data-gallery");o&&(this.fullElementsList=this.elements,this.elements=this.getGalleryElements(this.elements,o)),ne(i)&&(i=this.getElementIndex(e),i<0&&(i=0))}Ue(i)||(i=0),this.build(),Ee(this.overlay,this.settings.openEffect==="none"?"none":this.settings.cssEfects.fade.in);const n=document.body,s=window.innerWidth-document.documentElement.clientWidth;if(s>0){var r=document.createElement("style");r.type="text/css",r.className="gcss-styles",r.innerText=`.gscrollbar-fixer {margin-right: ${s}px}`,document.head.appendChild(r),H(n,"gscrollbar-fixer")}H(n,"glightbox-open"),H(ct,"glightbox-open"),zt&&(H(document.body,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(i,!0),this.elements.length===1?(H(this.prevButton,"glightbox-button-hidden"),H(this.nextButton,"glightbox-button-hidden")):(J(this.prevButton,"glightbox-button-hidden"),J(this.nextButton,"glightbox-button-hidden")),this.lightboxOpen=!0,this.trigger("open"),F(this.settings.onOpen)&&this.settings.onOpen(),Ut&&this.settings.touchNavigation&&Ri(this),this.settings.keyboardNavigation&&ki(this)}openAt(e=0){this.open(null,e)}showSlide(e=0,t=!1){At(this.loader),this.index=parseInt(e);let i=this.slidesContainer.querySelector(".current");i&&J(i,"current"),this.slideAnimateOut();let n=this.slidesContainer.querySelectorAll(".gslide")[e];if(ee(n,"loaded"))this.slideAnimateIn(n,t),rt(this.loader);else{At(this.loader);const s=this.elements[e],r={index:this.index,slide:n,slideNode:n,slideConfig:s.slideConfig,slideIndex:this.index,trigger:s.node,player:null};this.trigger("slide_before_load",r),s.instance.setContent(n,()=>{rt(this.loader),this.resize(),this.slideAnimateIn(n,t),this.trigger("slide_after_load",r)})}this.slideDescription=n.querySelector(".gslide-description"),this.slideDescriptionContained=this.slideDescription&&ee(this.slideDescription.parentNode,"gslide-media"),this.settings.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1)),this.updateNavigationClasses(),this.activeSlide=n}preloadSlide(e){if(e<0||e>this.elements.length-1||ne(this.elements[e]))return!1;let t=this.slidesContainer.querySelectorAll(".gslide")[e];if(ee(t,"loaded"))return!1;const i=this.elements[e],n=i.type,s={index:e,slide:t,slideNode:t,slideConfig:i.slideConfig,slideIndex:e,trigger:i.node,player:null};this.trigger("slide_before_load",s),n==="video"||n==="external"?setTimeout(()=>{i.instance.setContent(t,()=>{this.trigger("slide_after_load",s)})},200):i.instance.setContent(t,()=>{this.trigger("slide_after_load",s)})}prevSlide(){this.goToSlide(this.index-1)}nextSlide(){this.goToSlide(this.index+1)}goToSlide(e=!1){if(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,!this.loop()&&(e<0||e>this.elements.length-1))return!1;e<0?e=this.elements.length-1:e>=this.elements.length&&(e=0),this.showSlide(e)}insertSlide(e={},t=-1){t<0&&(t=this.elements.length);const i=new Be(e,this,t),n=i.getConfig(),s=fe({},n),r=i.create(),o=this.elements.length-1;s.index=t,s.node=!1,s.instance=i,s.slideConfig=n,this.elements.splice(t,0,s);let a=null,d=null;if(this.slidesContainer){if(t>o)this.slidesContainer.appendChild(r);else{let u=this.slidesContainer.querySelectorAll(".gslide")[t];this.slidesContainer.insertBefore(r,u)}(this.settings.preload&&this.index==0&&t==0||this.index-1==t||this.index+1==t)&&this.preloadSlide(t),this.index===0&&t===0&&(this.index=1),this.updateNavigationClasses(),a=this.slidesContainer.querySelectorAll(".gslide")[t],d=this.getSlidePlayerInstance(t),s.slideNode=a}this.trigger("slide_inserted",{index:t,slide:a,slideNode:a,slideConfig:n,slideIndex:t,trigger:null,player:d}),F(this.settings.slideInserted)&&this.settings.slideInserted({index:t,slide:a,player:d})}removeSlide(e=-1){if(e<0||e>this.elements.length-1)return!1;const t=this.slidesContainer&&this.slidesContainer.querySelectorAll(".gslide")[e];t&&(this.getActiveSlideIndex()==e&&(e==this.elements.length-1?this.prevSlide():this.nextSlide()),t.parentNode.removeChild(t)),this.elements.splice(e,1),this.trigger("slide_removed",e),F(this.settings.slideRemoved)&&this.settings.slideRemoved(e)}slideAnimateIn(e,t){let i=e.querySelector(".gslide-media"),n=e.querySelector(".gslide-description"),s={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlide,slideConfig:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},r={index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideConfig:this.elements[this.index].slideConfig,slideIndex:this.index,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)};if(i.offsetWidth>0&&n&&(rt(n),n.style.display=""),J(e,this.effectsClasses),t)Ee(e,this.settings.cssEfects[this.settings.openEffect].in,()=>{this.settings.autoplayVideos&&this.slidePlayerPlay(e),this.trigger("slide_changed",{prev:s,current:r}),F(this.settings.afterSlideChange)&&this.settings.afterSlideChange.apply(this,[s,r])});else{let o=this.settings.slideEffect,a=o!=="none"?this.settings.cssEfects[o].in:o;this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(a=this.settings.cssEfects.slideBack.in),Ee(e,a,()=>{this.settings.autoplayVideos&&this.slidePlayerPlay(e),this.trigger("slide_changed",{prev:s,current:r}),F(this.settings.afterSlideChange)&&this.settings.afterSlideChange.apply(this,[s,r])})}setTimeout(()=>{this.resize(e)},100),H(e,"current")}slideAnimateOut(){if(!this.prevActiveSlide)return!1;let e=this.prevActiveSlide;J(e,this.effectsClasses),H(e,"prev");let t=this.settings.slideEffect,i=t!=="none"?this.settings.cssEfects[t].out:t;this.slidePlayerPause(e),this.trigger("slide_before_change",{prev:{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlideIndex,slideConfig:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},current:{index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideIndex:this.index,slideConfig:this.elements[this.index].slideConfig,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)}}),F(this.settings.beforeSlideChange)&&this.settings.beforeSlideChange.apply(this,[{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},{index:this.index,slide:this.activeSlide,player:this.getSlidePlayerInstance(this.index)}]),this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(i=this.settings.cssEfects.slideBack.out),Ee(e,i,()=>{let n=e.querySelector(".ginner-container"),s=e.querySelector(".gslide-media"),r=e.querySelector(".gslide-description");n.style.transform="",s.style.transform="",J(s,"greset"),s.style.opacity="",r&&(r.style.opacity=""),J(e,"prev")})}getAllPlayers(){return this.videoPlayers}getSlidePlayerInstance(e){const t="gvideo"+e,i=this.getAllPlayers();return Z(i,t)&&i[t]?i[t]:!1}stopSlideVideo(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}console.log("stopSlideVideo is deprecated, use slidePlayerPause");const t=this.getSlidePlayerInstance(e);t&&t.playing&&t.pause()}slidePlayerPause(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}const t=this.getSlidePlayerInstance(e);t&&t.playing&&t.pause()}playSlideVideo(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}console.log("playSlideVideo is deprecated, use slidePlayerPlay");const t=this.getSlidePlayerInstance(e);t&&!t.playing&&t.play()}slidePlayerPlay(e){if(zt&&!this.settings.plyr.config?.muted)return;if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}const t=this.getSlidePlayerInstance(e);t&&!t.playing&&(t.play(),this.settings.autofocusVideos&&t.elements.container.focus())}setElements(e){this.settings.elements=!1;const t=[];e&&e.length&&V(e,(i,n)=>{const s=new Be(i,this,n),r=s.getConfig(),o=fe({},r);o.slideConfig=r,o.instance=s,o.index=n,t.push(o)}),this.elements=t,this.lightboxOpen&&(this.slidesContainer.innerHTML="",this.elements.length&&(V(this.elements,()=>{let i=xe(this.settings.slideHTML);this.slidesContainer.appendChild(i)}),this.showSlide(0,!0)))}getElementIndex(e){let t=!1;return V(this.elements,(i,n)=>{if(Z(i,"node")&&i.node==e)return t=n,!0}),t}getElements(){let e=[];this.elements=this.elements?this.elements:[],!ne(this.settings.elements)&&It(this.settings.elements)&&this.settings.elements.length&&V(this.settings.elements,(n,s)=>{const r=new Be(n,this,s),o=r.getConfig(),a=fe({},o);a.node=!1,a.index=s,a.instance=r,a.slideConfig=o,e.push(a)});let t=!1;return this.getSelector()&&(t=document.querySelectorAll(this.getSelector())),t&&V(t,(n,s)=>{const r=new Be(n,this,s),o=r.getConfig(),a=fe({},o);a.node=n,a.index=s,a.instance=r,a.slideConfig=o,a.gallery=n.getAttribute("data-gallery"),e.push(a)}),e}getGalleryElements(e,t){return e.filter(i=>i.gallery==t)}getSelector(){return this.settings.elements?!1:this.settings.selector&&this.settings.selector.substring(0,5)=="data-"?`*[${this.settings.selector}]`:this.settings.selector}getActiveSlide(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}getActiveSlideIndex(){return this.index}getAnimationClasses(){let e=[];for(let t in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(t)){let i=this.settings.cssEfects[t];e.push(`g${i.in}`),e.push(`g${i.out}`)}return e.join(" ")}build(){if(this.built)return!1;const e=document.body.childNodes,t=[];V(e,d=>{d.parentNode==document.body&&d.nodeName.charAt(0)!=="#"&&d.hasAttribute&&!d.hasAttribute("aria-hidden")&&(t.push(d),d.setAttribute("aria-hidden","true"))});const i=Z(this.settings.svg,"next")?this.settings.svg.next:"",n=Z(this.settings.svg,"prev")?this.settings.svg.prev:"",s=Z(this.settings.svg,"close")?this.settings.svg.close:"";let r=this.settings.lightboxHTML;r=r.replace(/{nextSVG}/g,i),r=r.replace(/{prevSVG}/g,n),r=r.replace(/{closeSVG}/g,s),r=xe(r),document.body.appendChild(r);const o=document.getElementById("glightbox-body");this.modal=o;let a=o.querySelector(".gclose");this.prevButton=o.querySelector(".gprev"),this.nextButton=o.querySelector(".gnext"),this.overlay=o.querySelector(".goverlay"),this.loader=o.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.bodyHiddenChildElms=t,this.events={},H(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&a&&(this.events.close=oe("click",{onElement:a,withCallback:(d,u)=>{d.preventDefault(),this.close()}})),a&&!this.settings.closeButton&&a.parentNode.removeChild(a),this.nextButton&&(this.events.next=oe("click",{onElement:this.nextButton,withCallback:(d,u)=>{d.preventDefault(),this.nextSlide()}})),this.prevButton&&(this.events.prev=oe("click",{onElement:this.prevButton,withCallback:(d,u)=>{d.preventDefault(),this.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=oe("click",{onElement:o,withCallback:(d,u)=>{!this.preventOutsideClick&&!ee(document.body,"glightbox-mobile")&&!ce(d.target,".ginner-container")&&!ce(d.target,".gbtn")&&!ee(d.target,"gnext")&&!ee(d.target,"gprev")&&this.close()}})),V(this.elements,(d,u)=>{this.slidesContainer.appendChild(d.instance.create()),d.slideNode=this.slidesContainer.querySelectorAll(".gslide")[u]}),Ut&&H(document.body,"glightbox-touch"),this.events.resize=oe("resize",{onElement:window,withCallback:()=>{this.resize()}}),this.built=!0}resize(e=null){if(e=e||this.activeSlide,!e||ee(e,"zoomed"))return;const t=qt(),i=e.querySelector(".gvideo-wrapper"),n=e.querySelector(".gslide-image"),s=this.slideDescription;let r=t.width,o=t.height;if(r<=768?H(document.body,"glightbox-mobile"):J(document.body,"glightbox-mobile"),!i&&!n)return;let a=!1;if(s&&(ee(s,"description-bottom")||ee(s,"description-top"))&&!ee(s,"gabsolute")&&(a=!0),n){if(r<=768)n.querySelector("img");else if(a){let d=s.offsetHeight,u=n.querySelector("img");const h=this.elements[this.index].node.getAttribute("data-height")??"100vh";u.setAttribute("style",`max-height: calc(${h} - ${d}px)`),s.setAttribute("style",`max-width: ${u.offsetWidth}px;`)}}if(i){let d=Z(this.settings.plyr.config,"ratio")?this.settings.plyr.config.ratio:"";if(!d){const b=i.clientWidth,w=i.clientHeight,_=b/w;d=`${b/_}:${w/_}`}let u=d.split(":"),l=this.settings.videosWidth,h=this.settings.videosWidth;Ue(l)||l.indexOf("px")!==-1?h=parseInt(l):l.indexOf("vw")!==-1?h=r*parseInt(l)/100:l.indexOf("vh")!==-1?h=o*parseInt(l)/100:l.indexOf("%")!==-1?h=r*parseInt(l)/100:h=parseInt(i.clientWidth);let p=h/(parseInt(u[0])/parseInt(u[1]));if(p=Math.floor(p),a&&(o=o-s.offsetHeight),h>r||p>o||o<p&&r>h){let b=i.offsetWidth,w=i.offsetHeight,_=o/w,g={width:b*_};i.parentNode.setAttribute("style",`max-width: ${g.width}px`),a&&s.setAttribute("style",`max-width: ${g.width}px;`)}else i.parentNode.style.maxWidth=`${l}`,a&&s.setAttribute("style",`max-width: ${l};`)}}reload(){this.init()}updateNavigationClasses(){const e=this.loop();J(this.nextButton,"disabled"),J(this.prevButton,"disabled"),this.index==0&&this.elements.length-1==0?(H(this.prevButton,"disabled"),H(this.nextButton,"disabled")):this.index===0&&!e?H(this.prevButton,"disabled"):this.index===this.elements.length-1&&!e&&H(this.nextButton,"disabled")}loop(){let e=Z(this.settings,"loopAtEnd")?this.settings.loopAtEnd:null;return e=Z(this.settings,"loop")?this.settings.loop:e,e}close(){if(!this.lightboxOpen){if(this.events){for(let e in this.events)this.events.hasOwnProperty(e)&&this.events[e].destroy();this.events=null}return!1}if(this.closing)return!1;this.closing=!0,this.slidePlayerPause(this.activeSlide),this.fullElementsList&&(this.elements=this.fullElementsList),this.bodyHiddenChildElms.length&&V(this.bodyHiddenChildElms,e=>{e.removeAttribute("aria-hidden")}),H(this.modal,"glightbox-closing"),Ee(this.overlay,this.settings.openEffect=="none"?"none":this.settings.cssEfects.fade.out),Ee(this.activeSlide,this.settings.cssEfects[this.settings.closeEffect].out,()=>{if(this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null,this.built=!1,this.events){for(let i in this.events)this.events.hasOwnProperty(i)&&this.events[i].destroy();this.events=null}const e=document.body;J(ct,"glightbox-open"),J(e,"glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer"),this.modal.parentNode.removeChild(this.modal),this.trigger("close"),F(this.settings.onClose)&&this.settings.onClose();const t=document.querySelector(".gcss-styles");t&&t.parentNode.removeChild(t),this.lightboxOpen=!1,this.closing=null})}destroy(){this.close(),this.clearAllEvents(),this.baseEvents&&this.baseEvents.destroy()}on(e,t,i=!1){if(!e||!F(t))throw new TypeError("Event name and callback must be defined");this.apiEvents.push({evt:e,once:i,callback:t})}once(e,t){this.on(e,t,!0)}trigger(e,t=null){const i=[];V(this.apiEvents,(n,s)=>{const{evt:r,once:o,callback:a}=n;r==e&&(a(t),o&&i.push(s))}),i.length&&V(i,n=>this.apiEvents.splice(n,1))}clearAllEvents(){this.apiEvents.splice(0,this.apiEvents.length)}version(){return $i}}/*!
23
+ </div>`;class jt{constructor(e={}){this.customOptions=e,this.settings=fe(ut,e),this.effectsClasses=this.getAnimationClasses(),this.videoPlayers={},this.apiEvents=[],this.fullElementsList=!1}init(){const e=this.getSelector();e&&(this.baseEvents=oe("click",{onElement:e,withCallback:(t,i)=>{t.preventDefault(),this.open(i)}})),this.elements=this.getElements()}open(e=null,t=null){if(this.elements.length===0)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;let i=Ue(t)?t:this.settings.startAt;if(ge(e)){const o=e.getAttribute("data-gallery");o&&(this.fullElementsList=this.elements,this.elements=this.getGalleryElements(this.elements,o)),ne(i)&&(i=this.getElementIndex(e),i<0&&(i=0))}Ue(i)||(i=0),this.build(),Ee(this.overlay,this.settings.openEffect==="none"?"none":this.settings.cssEfects.fade.in);const n=document.body,s=window.innerWidth-document.documentElement.clientWidth;if(s>0){var r=document.createElement("style");r.type="text/css",r.className="gcss-styles",r.innerText=`.gscrollbar-fixer {margin-right: ${s}px}`,document.head.appendChild(r),H(n,"gscrollbar-fixer")}H(n,"glightbox-open"),H(ct,"glightbox-open"),zt&&(H(document.body,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(i,!0),this.elements.length===1?(H(this.prevButton,"glightbox-button-hidden"),H(this.nextButton,"glightbox-button-hidden")):(J(this.prevButton,"glightbox-button-hidden"),J(this.nextButton,"glightbox-button-hidden")),this.lightboxOpen=!0,this.trigger("open"),F(this.settings.onOpen)&&this.settings.onOpen(),Ut&&this.settings.touchNavigation&&Ri(this),this.settings.keyboardNavigation&&ki(this)}openAt(e=0){this.open(null,e)}showSlide(e=0,t=!1){At(this.loader),this.index=parseInt(e);let i=this.slidesContainer.querySelector(".current");i&&J(i,"current"),this.slideAnimateOut();let n=this.slidesContainer.querySelectorAll(".gslide")[e];if(ee(n,"loaded"))this.slideAnimateIn(n,t),rt(this.loader);else{At(this.loader);const s=this.elements[e],r={index:this.index,slide:n,slideNode:n,slideConfig:s.slideConfig,slideIndex:this.index,trigger:s.node,player:null};this.trigger("slide_before_load",r),s.instance.setContent(n,()=>{rt(this.loader),this.resize(),this.slideAnimateIn(n,t),this.trigger("slide_after_load",r)})}this.slideDescription=n.querySelector(".gslide-description"),this.slideDescriptionContained=this.slideDescription&&ee(this.slideDescription.parentNode,"gslide-media"),this.settings.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1)),this.updateNavigationClasses(),this.activeSlide=n}preloadSlide(e){if(e<0||e>this.elements.length-1||ne(this.elements[e]))return!1;let t=this.slidesContainer.querySelectorAll(".gslide")[e];if(ee(t,"loaded"))return!1;const i=this.elements[e],n=i.type,s={index:e,slide:t,slideNode:t,slideConfig:i.slideConfig,slideIndex:e,trigger:i.node,player:null};this.trigger("slide_before_load",s),n==="video"||n==="external"?setTimeout(()=>{i.instance.setContent(t,()=>{this.trigger("slide_after_load",s)})},200):i.instance.setContent(t,()=>{this.trigger("slide_after_load",s)})}prevSlide(){this.goToSlide(this.index-1)}nextSlide(){this.goToSlide(this.index+1)}goToSlide(e=!1){if(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,!this.loop()&&(e<0||e>this.elements.length-1))return!1;e<0?e=this.elements.length-1:e>=this.elements.length&&(e=0),this.showSlide(e)}insertSlide(e={},t=-1){t<0&&(t=this.elements.length);const i=new Be(e,this,t),n=i.getConfig(),s=fe({},n),r=i.create(),o=this.elements.length-1;s.index=t,s.node=!1,s.instance=i,s.slideConfig=n,this.elements.splice(t,0,s);let a=null,u=null;if(this.slidesContainer){if(t>o)this.slidesContainer.appendChild(r);else{let d=this.slidesContainer.querySelectorAll(".gslide")[t];this.slidesContainer.insertBefore(r,d)}(this.settings.preload&&this.index==0&&t==0||this.index-1==t||this.index+1==t)&&this.preloadSlide(t),this.index===0&&t===0&&(this.index=1),this.updateNavigationClasses(),a=this.slidesContainer.querySelectorAll(".gslide")[t],u=this.getSlidePlayerInstance(t),s.slideNode=a}this.trigger("slide_inserted",{index:t,slide:a,slideNode:a,slideConfig:n,slideIndex:t,trigger:null,player:u}),F(this.settings.slideInserted)&&this.settings.slideInserted({index:t,slide:a,player:u})}removeSlide(e=-1){if(e<0||e>this.elements.length-1)return!1;const t=this.slidesContainer&&this.slidesContainer.querySelectorAll(".gslide")[e];t&&(this.getActiveSlideIndex()==e&&(e==this.elements.length-1?this.prevSlide():this.nextSlide()),t.parentNode.removeChild(t)),this.elements.splice(e,1),this.trigger("slide_removed",e),F(this.settings.slideRemoved)&&this.settings.slideRemoved(e)}slideAnimateIn(e,t){let i=e.querySelector(".gslide-media"),n=e.querySelector(".gslide-description"),s={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlide,slideConfig:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},r={index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideConfig:this.elements[this.index].slideConfig,slideIndex:this.index,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)};if(i.offsetWidth>0&&n&&(rt(n),n.style.display=""),J(e,this.effectsClasses),t)Ee(e,this.settings.cssEfects[this.settings.openEffect].in,()=>{this.settings.autoplayVideos&&this.slidePlayerPlay(e),this.trigger("slide_changed",{prev:s,current:r}),F(this.settings.afterSlideChange)&&this.settings.afterSlideChange.apply(this,[s,r])});else{let o=this.settings.slideEffect,a=o!=="none"?this.settings.cssEfects[o].in:o;this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(a=this.settings.cssEfects.slideBack.in),Ee(e,a,()=>{this.settings.autoplayVideos&&this.slidePlayerPlay(e),this.trigger("slide_changed",{prev:s,current:r}),F(this.settings.afterSlideChange)&&this.settings.afterSlideChange.apply(this,[s,r])})}setTimeout(()=>{this.resize(e)},100),H(e,"current")}slideAnimateOut(){if(!this.prevActiveSlide)return!1;let e=this.prevActiveSlide;J(e,this.effectsClasses),H(e,"prev");let t=this.settings.slideEffect,i=t!=="none"?this.settings.cssEfects[t].out:t;this.slidePlayerPause(e),this.trigger("slide_before_change",{prev:{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlideIndex,slideConfig:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:ne(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},current:{index:this.index,slide:this.activeSlide,slideNode:this.activeSlide,slideIndex:this.index,slideConfig:this.elements[this.index].slideConfig,trigger:this.elements[this.index].node,player:this.getSlidePlayerInstance(this.index)}}),F(this.settings.beforeSlideChange)&&this.settings.beforeSlideChange.apply(this,[{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},{index:this.index,slide:this.activeSlide,player:this.getSlidePlayerInstance(this.index)}]),this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(i=this.settings.cssEfects.slideBack.out),Ee(e,i,()=>{let n=e.querySelector(".ginner-container"),s=e.querySelector(".gslide-media"),r=e.querySelector(".gslide-description");n.style.transform="",s.style.transform="",J(s,"greset"),s.style.opacity="",r&&(r.style.opacity=""),J(e,"prev")})}getAllPlayers(){return this.videoPlayers}getSlidePlayerInstance(e){const t="gvideo"+e,i=this.getAllPlayers();return Z(i,t)&&i[t]?i[t]:!1}stopSlideVideo(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}console.log("stopSlideVideo is deprecated, use slidePlayerPause");const t=this.getSlidePlayerInstance(e);t&&t.playing&&t.pause()}slidePlayerPause(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}const t=this.getSlidePlayerInstance(e);t&&t.playing&&t.pause()}playSlideVideo(e){if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}console.log("playSlideVideo is deprecated, use slidePlayerPlay");const t=this.getSlidePlayerInstance(e);t&&!t.playing&&t.play()}slidePlayerPlay(e){if(zt&&!this.settings.plyr.config?.muted)return;if(ge(e)){let i=e.querySelector(".gvideo-wrapper");i&&(e=i.getAttribute("data-index"))}const t=this.getSlidePlayerInstance(e);t&&!t.playing&&(t.play(),this.settings.autofocusVideos&&t.elements.container.focus())}setElements(e){this.settings.elements=!1;const t=[];e&&e.length&&V(e,(i,n)=>{const s=new Be(i,this,n),r=s.getConfig(),o=fe({},r);o.slideConfig=r,o.instance=s,o.index=n,t.push(o)}),this.elements=t,this.lightboxOpen&&(this.slidesContainer.innerHTML="",this.elements.length&&(V(this.elements,()=>{let i=xe(this.settings.slideHTML);this.slidesContainer.appendChild(i)}),this.showSlide(0,!0)))}getElementIndex(e){let t=!1;return V(this.elements,(i,n)=>{if(Z(i,"node")&&i.node==e)return t=n,!0}),t}getElements(){let e=[];this.elements=this.elements?this.elements:[],!ne(this.settings.elements)&&It(this.settings.elements)&&this.settings.elements.length&&V(this.settings.elements,(n,s)=>{const r=new Be(n,this,s),o=r.getConfig(),a=fe({},o);a.node=!1,a.index=s,a.instance=r,a.slideConfig=o,e.push(a)});let t=!1;return this.getSelector()&&(t=document.querySelectorAll(this.getSelector())),t&&V(t,(n,s)=>{const r=new Be(n,this,s),o=r.getConfig(),a=fe({},o);a.node=n,a.index=s,a.instance=r,a.slideConfig=o,a.gallery=n.getAttribute("data-gallery"),e.push(a)}),e}getGalleryElements(e,t){return e.filter(i=>i.gallery==t)}getSelector(){return this.settings.elements?!1:this.settings.selector&&this.settings.selector.substring(0,5)=="data-"?`*[${this.settings.selector}]`:this.settings.selector}getActiveSlide(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}getActiveSlideIndex(){return this.index}getAnimationClasses(){let e=[];for(let t in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(t)){let i=this.settings.cssEfects[t];e.push(`g${i.in}`),e.push(`g${i.out}`)}return e.join(" ")}build(){if(this.built)return!1;const e=document.body.childNodes,t=[];V(e,u=>{u.parentNode==document.body&&u.nodeName.charAt(0)!=="#"&&u.hasAttribute&&!u.hasAttribute("aria-hidden")&&(t.push(u),u.setAttribute("aria-hidden","true"))});const i=Z(this.settings.svg,"next")?this.settings.svg.next:"",n=Z(this.settings.svg,"prev")?this.settings.svg.prev:"",s=Z(this.settings.svg,"close")?this.settings.svg.close:"";let r=this.settings.lightboxHTML;r=r.replace(/{nextSVG}/g,i),r=r.replace(/{prevSVG}/g,n),r=r.replace(/{closeSVG}/g,s),r=xe(r),document.body.appendChild(r);const o=document.getElementById("glightbox-body");this.modal=o;let a=o.querySelector(".gclose");this.prevButton=o.querySelector(".gprev"),this.nextButton=o.querySelector(".gnext"),this.overlay=o.querySelector(".goverlay"),this.loader=o.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.bodyHiddenChildElms=t,this.events={},H(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&a&&(this.events.close=oe("click",{onElement:a,withCallback:(u,d)=>{u.preventDefault(),this.close()}})),a&&!this.settings.closeButton&&a.parentNode.removeChild(a),this.nextButton&&(this.events.next=oe("click",{onElement:this.nextButton,withCallback:(u,d)=>{u.preventDefault(),this.nextSlide()}})),this.prevButton&&(this.events.prev=oe("click",{onElement:this.prevButton,withCallback:(u,d)=>{u.preventDefault(),this.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=oe("click",{onElement:o,withCallback:(u,d)=>{!this.preventOutsideClick&&!ee(document.body,"glightbox-mobile")&&!ce(u.target,".ginner-container")&&!ce(u.target,".gbtn")&&!ee(u.target,"gnext")&&!ee(u.target,"gprev")&&this.close()}})),V(this.elements,(u,d)=>{this.slidesContainer.appendChild(u.instance.create()),u.slideNode=this.slidesContainer.querySelectorAll(".gslide")[d]}),Ut&&H(document.body,"glightbox-touch"),this.events.resize=oe("resize",{onElement:window,withCallback:()=>{this.resize()}}),this.built=!0}resize(e=null){if(e=e||this.activeSlide,!e||ee(e,"zoomed"))return;const t=qt(),i=e.querySelector(".gvideo-wrapper"),n=e.querySelector(".gslide-image"),s=this.slideDescription;let r=t.width,o=t.height;if(r<=768?H(document.body,"glightbox-mobile"):J(document.body,"glightbox-mobile"),!i&&!n)return;let a=!1;if(s&&(ee(s,"description-bottom")||ee(s,"description-top"))&&!ee(s,"gabsolute")&&(a=!0),n){if(r<=768)n.querySelector("img");else if(a){let u=s.offsetHeight,d=n.querySelector("img");const h=this.elements[this.index].node.getAttribute("data-height")??"100vh";d.setAttribute("style",`max-height: calc(${h} - ${u}px)`),s.setAttribute("style",`max-width: ${d.offsetWidth}px;`)}}if(i){let u=Z(this.settings.plyr.config,"ratio")?this.settings.plyr.config.ratio:"";if(!u){const b=i.clientWidth,w=i.clientHeight,_=b/w;u=`${b/_}:${w/_}`}let d=u.split(":"),l=this.settings.videosWidth,h=this.settings.videosWidth;Ue(l)||l.indexOf("px")!==-1?h=parseInt(l):l.indexOf("vw")!==-1?h=r*parseInt(l)/100:l.indexOf("vh")!==-1?h=o*parseInt(l)/100:l.indexOf("%")!==-1?h=r*parseInt(l)/100:h=parseInt(i.clientWidth);let p=h/(parseInt(d[0])/parseInt(d[1]));if(p=Math.floor(p),a&&(o=o-s.offsetHeight),h>r||p>o||o<p&&r>h){let b=i.offsetWidth,w=i.offsetHeight,_=o/w,g={width:b*_};i.parentNode.setAttribute("style",`max-width: ${g.width}px`),a&&s.setAttribute("style",`max-width: ${g.width}px;`)}else i.parentNode.style.maxWidth=`${l}`,a&&s.setAttribute("style",`max-width: ${l};`)}}reload(){this.init()}updateNavigationClasses(){const e=this.loop();J(this.nextButton,"disabled"),J(this.prevButton,"disabled"),this.index==0&&this.elements.length-1==0?(H(this.prevButton,"disabled"),H(this.nextButton,"disabled")):this.index===0&&!e?H(this.prevButton,"disabled"):this.index===this.elements.length-1&&!e&&H(this.nextButton,"disabled")}loop(){let e=Z(this.settings,"loopAtEnd")?this.settings.loopAtEnd:null;return e=Z(this.settings,"loop")?this.settings.loop:e,e}close(){if(!this.lightboxOpen){if(this.events){for(let e in this.events)this.events.hasOwnProperty(e)&&this.events[e].destroy();this.events=null}return!1}if(this.closing)return!1;this.closing=!0,this.slidePlayerPause(this.activeSlide),this.fullElementsList&&(this.elements=this.fullElementsList),this.bodyHiddenChildElms.length&&V(this.bodyHiddenChildElms,e=>{e.removeAttribute("aria-hidden")}),H(this.modal,"glightbox-closing"),Ee(this.overlay,this.settings.openEffect=="none"?"none":this.settings.cssEfects.fade.out),Ee(this.activeSlide,this.settings.cssEfects[this.settings.closeEffect].out,()=>{if(this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null,this.built=!1,this.events){for(let i in this.events)this.events.hasOwnProperty(i)&&this.events[i].destroy();this.events=null}const e=document.body;J(ct,"glightbox-open"),J(e,"glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer"),this.modal.parentNode.removeChild(this.modal),this.trigger("close"),F(this.settings.onClose)&&this.settings.onClose();const t=document.querySelector(".gcss-styles");t&&t.parentNode.removeChild(t),this.lightboxOpen=!1,this.closing=null})}destroy(){this.close(),this.clearAllEvents(),this.baseEvents&&this.baseEvents.destroy()}on(e,t,i=!1){if(!e||!F(t))throw new TypeError("Event name and callback must be defined");this.apiEvents.push({evt:e,once:i,callback:t})}once(e,t){this.on(e,t,!0)}trigger(e,t=null){const i=[];V(this.apiEvents,(n,s)=>{const{evt:r,once:o,callback:a}=n;r==e&&(a(t),o&&i.push(s))}),i.length&&V(i,n=>this.apiEvents.splice(n,1))}clearAllEvents(){this.apiEvents.splice(0,this.apiEvents.length)}version(){return $i}}/*!
24
24
  * Glide.js v3.7.1
25
25
  * (c) 2013-2024 Jędrzej Chałubek (https://github.com/jedrzejchalubek/)
26
26
  * Released under the MIT License.
27
- */function Bt(c,e){var t=Object.keys(c);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(c);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(c,n).enumerable})),t.push.apply(t,i)}return t}function Ft(c){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bt(Object(t),!0).forEach(function(i){Di(c,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(t)):Bt(Object(t)).forEach(function(i){Object.defineProperty(c,i,Object.getOwnPropertyDescriptor(t,i))})}return c}function Fe(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fe=function(e){return typeof e}:Fe=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(c)}function Ge(c,e){if(!(c instanceof e))throw new TypeError("Cannot call a class as a function")}function Ni(c,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(c,i.key,i)}}function We(c,e,t){return e&&Ni(c.prototype,e),c}function Di(c,e,t){return e in c?Object.defineProperty(c,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):c[e]=t,c}function Hi(c,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(e&&e.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),e&&dt(c,e)}function Le(c){return Le=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Le(c)}function dt(c,e){return dt=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},dt(c,e)}function zi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ui(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ji(c,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ui(c)}function Bi(c){var e=zi();return function(){var i=Le(c),n;if(e){var s=Le(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return ji(this,n)}}function Fi(c,e){for(;!Object.prototype.hasOwnProperty.call(c,e)&&(c=Le(c),c!==null););return c}function Ve(){return typeof Reflect<"u"&&Reflect.get?Ve=Reflect.get:Ve=function(e,t,i){var n=Fi(e,t);if(n){var s=Object.getOwnPropertyDescriptor(n,t);return s.get?s.get.call(arguments.length<3?e:i):s.value}},Ve.apply(this,arguments)}var Gi={type:"slider",startAt:0,perView:1,focusAt:0,gap:10,autoplay:!1,hoverpause:!0,keyboard:!0,bound:!1,swipeThreshold:80,dragThreshold:120,perSwipe:"",touchRatio:.5,touchAngle:45,animationDuration:400,rewind:!0,rewindDuration:800,animationTimingFunc:"cubic-bezier(.165, .840, .440, 1)",waitForTransition:!0,throttle:10,direction:"ltr",peek:0,cloningRatio:1,breakpoints:{},classes:{swipeable:"glide--swipeable",dragging:"glide--dragging",direction:{ltr:"glide--ltr",rtl:"glide--rtl"},type:{slider:"glide--slider",carousel:"glide--carousel"},slide:{clone:"glide__slide--clone",active:"glide__slide--active"},arrow:{disabled:"glide__arrow--disabled"},nav:{active:"glide__bullet--active"}}};function me(c){console.error("[Glide warn]: ".concat(c))}function Q(c){return parseInt(c)}function Wi(c){return parseFloat(c)}function ht(c){return typeof c=="string"}function Re(c){var e=Fe(c);return e==="function"||e==="object"&&!!c}function Ye(c){return typeof c=="function"}function Gt(c){return typeof c>"u"}function pt(c){return c.constructor===Array}function Vi(c,e,t){var i={};for(var n in e)Ye(e[n])?i[n]=e[n](c,i,t):me("Extension must be a function");for(var s in i)Ye(i[s].mount)&&i[s].mount();return i}function W(c,e,t){Object.defineProperty(c,e,t)}function Yi(c){return Object.keys(c).sort().reduce(function(e,t){return e[t]=c[t],e[t],e},{})}function ft(c,e){var t=Object.assign({},c,e);if(e.hasOwnProperty("classes")){t.classes=Object.assign({},c.classes,e.classes);var i=["direction","type","slide","arrow","nav"];i.forEach(function(n){e.classes.hasOwnProperty(n)&&(t.classes[n]=Ft(Ft({},c.classes[n]),e.classes[n]))})}return e.hasOwnProperty("breakpoints")&&(t.breakpoints=Object.assign({},c.breakpoints,e.breakpoints)),t}var Xi=(function(){function c(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ge(this,c),this.events=e,this.hop=e.hasOwnProperty}return We(c,[{key:"on",value:function(t,i){if(pt(t)){for(var n=0;n<t.length;n++)this.on(t[n],i);return}this.hop.call(this.events,t)||(this.events[t]=[]);var s=this.events[t].push(i)-1;return{remove:function(){delete this.events[t][s]}}}},{key:"emit",value:function(t,i){if(pt(t)){for(var n=0;n<t.length;n++)this.emit(t[n],i);return}this.hop.call(this.events,t)&&this.events[t].forEach(function(s){s(i||{})})}}]),c})(),Ji=(function(){function c(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ge(this,c),this._c={},this._t=[],this._e=new Xi,this.disabled=!1,this.selector=e,this.settings=ft(Gi,t),this.index=this.settings.startAt}return We(c,[{key:"mount",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this._e.emit("mount.before"),Re(t)?this._c=Vi(this,t,this._e):me("You need to provide a object on `mount()`"),this._e.emit("mount.after"),this}},{key:"mutate",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return pt(t)?this._t=t:me("You need to provide a array on `mutate()`"),this}},{key:"update",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.settings=ft(this.settings,t),t.hasOwnProperty("startAt")&&(this.index=t.startAt),this._e.emit("update"),this}},{key:"go",value:function(t){return this._c.Run.make(t),this}},{key:"move",value:function(t){return this._c.Transition.disable(),this._c.Move.make(t),this}},{key:"destroy",value:function(){return this._e.emit("destroy"),this}},{key:"play",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return t&&(this.settings.autoplay=t),this._e.emit("play"),this}},{key:"pause",value:function(){return this._e.emit("pause"),this}},{key:"disable",value:function(){return this.disabled=!0,this}},{key:"enable",value:function(){return this.disabled=!1,this}},{key:"on",value:function(t,i){return this._e.on(t,i),this}},{key:"isType",value:function(t){return this.settings.type===t}},{key:"settings",get:function(){return this._o},set:function(t){Re(t)?this._o=t:me("Options must be an `object` instance.")}},{key:"index",get:function(){return this._i},set:function(t){this._i=Q(t)}},{key:"type",get:function(){return this.settings.type}},{key:"disabled",get:function(){return this._d},set:function(t){this._d=!!t}}]),c})();function Zi(c,e,t){var i={mount:function(){this._o=!1},make:function(d){var u=this;c.disabled||(!c.settings.waitForTransition||c.disable(),this.move=d,t.emit("run.before",this.move),this.calculate(),t.emit("run",this.move),e.Transition.after(function(){u.isStart()&&t.emit("run.start",u.move),u.isEnd()&&t.emit("run.end",u.move),u.isOffset()&&(u._o=!1,t.emit("run.offset",u.move)),t.emit("run.after",u.move),c.enable()}))},calculate:function(){var d=this.move,u=this.length,l=d.steps,h=d.direction,p=1;if(h==="="){if(c.settings.bound&&Q(l)>u){c.index=u;return}c.index=l;return}if(h===">"&&l===">"){c.index=u;return}if(h==="<"&&l==="<"){c.index=0;return}if(h==="|"&&(p=c.settings.perView||1),h===">"||h==="|"&&l===">"){var b=n(p);b>u&&(this._o=!0),c.index=s(b,p);return}if(h==="<"||h==="|"&&l==="<"){var w=r(p);w<0&&(this._o=!0),c.index=o(w,p);return}me("Invalid direction pattern [".concat(h).concat(l,"] has been used"))},isStart:function(){return c.index<=0},isEnd:function(){return c.index>=this.length},isOffset:function(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return d?this._o?d==="|>"?this.move.direction==="|"&&this.move.steps===">":d==="|<"?this.move.direction==="|"&&this.move.steps==="<":this.move.direction===d:!1:this._o},isBound:function(){return c.isType("slider")&&c.settings.focusAt!=="center"&&c.settings.bound}};function n(a){var d=c.index;return c.isType("carousel")?d+a:d+(a-d%a)}function s(a,d){var u=i.length;return a<=u?a:c.isType("carousel")?a-(u+1):c.settings.rewind?i.isBound()&&!i.isEnd()?u:0:i.isBound()?u:Math.floor(u/d)*d}function r(a){var d=c.index;if(c.isType("carousel"))return d-a;var u=Math.ceil(d/a);return(u-1)*a}function o(a,d){var u=i.length;return a>=0?a:c.isType("carousel")?a+(u+1):c.settings.rewind?i.isBound()&&i.isStart()?u:Math.floor(u/d)*d:0}return W(i,"move",{get:function(){return this._m},set:function(d){var u=d.substr(1);this._m={direction:d.substr(0,1),steps:u?Q(u)?Q(u):u:0}}}),W(i,"length",{get:function(){var d=c.settings,u=e.Html.slides.length;return this.isBound()?u-1-(Q(d.perView)-1)+Q(d.focusAt):u-1}}),W(i,"offset",{get:function(){return this._o}}),i}function Wt(){return new Date().getTime()}function Xe(c,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,n,s,r,o=0,a=function(){o=t.leading===!1?0:Wt(),i=null,r=c.apply(n,s),i||(n=s=null)},d=function(){var l=Wt();!o&&t.leading===!1&&(o=l);var h=e-(l-o);return n=this,s=arguments,h<=0||h>e?(i&&(clearTimeout(i),i=null),o=l,r=c.apply(n,s),i||(n=s=null)):!i&&t.trailing!==!1&&(i=setTimeout(a,h)),r};return d.cancel=function(){clearTimeout(i),o=0,i=n=s=null},d}var Je={ltr:["marginLeft","marginRight"],rtl:["marginRight","marginLeft"]};function Qi(c,e,t){var i={apply:function(s){for(var r=0,o=s.length;r<o;r++){var a=s[r].style,d=e.Direction.value;r!==0?a[Je[d][0]]="".concat(this.value/2,"px"):a[Je[d][0]]="",r!==s.length-1?a[Je[d][1]]="".concat(this.value/2,"px"):a[Je[d][1]]=""}},remove:function(s){for(var r=0,o=s.length;r<o;r++){var a=s[r].style;a.marginLeft="",a.marginRight=""}}};return W(i,"value",{get:function(){return Q(c.settings.gap)}}),W(i,"grow",{get:function(){return i.value*e.Sizes.length}}),W(i,"reductor",{get:function(){var s=c.settings.perView;return i.value*(s-1)/s}}),t.on(["build.after","update"],Xe(function(){i.apply(e.Html.wrapper.children)},30)),t.on("destroy",function(){i.remove(e.Html.wrapper.children)}),i}function Vt(c){if(c&&c.parentNode){for(var e=c.parentNode.firstChild,t=[];e;e=e.nextSibling)e.nodeType===1&&e!==c&&t.push(e);return t}return[]}function gt(c){return Array.prototype.slice.call(c)}var Ki='[data-glide-el="track"]';function es(c,e,t){var i={mount:function(){this.root=c.selector,this.track=this.root.querySelector(Ki),this.collectSlides()},collectSlides:function(){this.slides=gt(this.wrapper.children).filter(function(s){return!s.classList.contains(c.settings.classes.slide.clone)})}};return W(i,"root",{get:function(){return i._r},set:function(s){ht(s)&&(s=document.querySelector(s)),s!==null?i._r=s:me("Root element must be a existing Html node")}}),W(i,"track",{get:function(){return i._t},set:function(s){i._t=s}}),W(i,"wrapper",{get:function(){return i.track.children[0]}}),t.on("update",function(){i.collectSlides()}),i}function ts(c,e,t){var i={mount:function(){this.value=c.settings.peek}};return W(i,"value",{get:function(){return i._v},set:function(s){Re(s)?(s.before=Q(s.before),s.after=Q(s.after)):s=Q(s),i._v=s}}),W(i,"reductor",{get:function(){var s=i.value,r=c.settings.perView;return Re(s)?s.before/r+s.after/r:s*2/r}}),t.on(["resize","update"],function(){i.mount()}),i}function is(c,e,t){var i={mount:function(){this._o=0},make:function(){var s=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.offset=r,t.emit("move",{movement:this.value}),e.Transition.after(function(){t.emit("move.after",{movement:s.value})})}};return W(i,"offset",{get:function(){return i._o},set:function(s){i._o=Gt(s)?0:Q(s)}}),W(i,"translate",{get:function(){return e.Sizes.slideWidth*c.index}}),W(i,"value",{get:function(){var s=this.offset,r=this.translate;return e.Direction.is("rtl")?r+s:r-s}}),t.on(["build.before","run"],function(){i.make()}),i}function ss(c,e,t){var i={setupSlides:function(){for(var s="".concat(this.slideWidth,"px"),r=e.Html.slides,o=0;o<r.length;o++)r[o].style.width=s},setupWrapper:function(){e.Html.wrapper.style.width="".concat(this.wrapperSize,"px")},remove:function(){for(var s=e.Html.slides,r=0;r<s.length;r++)s[r].style.width="";e.Html.wrapper.style.width=""}};return W(i,"length",{get:function(){return e.Html.slides.length}}),W(i,"width",{get:function(){return e.Html.track.offsetWidth}}),W(i,"wrapperSize",{get:function(){return i.slideWidth*i.length+e.Gaps.grow+e.Clones.grow}}),W(i,"slideWidth",{get:function(){return i.width/c.settings.perView-e.Peek.reductor-e.Gaps.reductor}}),t.on(["build.before","resize","update"],function(){i.setupSlides(),i.setupWrapper()}),t.on("destroy",function(){i.remove()}),i}function ns(c,e,t){var i={mount:function(){t.emit("build.before"),this.typeClass(),this.activeClass(),t.emit("build.after")},typeClass:function(){e.Html.root.classList.add(c.settings.classes.type[c.settings.type])},activeClass:function(){var s=c.settings.classes,r=e.Html.slides[c.index];r&&(r.classList.add(s.slide.active),Vt(r).forEach(function(o){o.classList.remove(s.slide.active)}))},removeClasses:function(){var s=c.settings.classes,r=s.type,o=s.slide;e.Html.root.classList.remove(r[c.settings.type]),e.Html.slides.forEach(function(a){a.classList.remove(o.active)})}};return t.on(["destroy","update"],function(){i.removeClasses()}),t.on(["resize","update"],function(){i.mount()}),t.on("move.after",function(){i.activeClass()}),i}function rs(c,e,t){var i={mount:function(){this.items=[],c.isType("carousel")&&(this.items=this.collect())},collect:function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=e.Html.slides,o=c.settings,a=o.perView,d=o.classes,u=o.cloningRatio;if(r.length>0)for(var l=+!!c.settings.peek,h=a+l+Math.round(a/2),p=r.slice(0,h).reverse(),b=r.slice(h*-1),w=0;w<Math.max(u,Math.floor(a/r.length));w++){for(var _=0;_<p.length;_++){var g=p[_].cloneNode(!0);g.classList.add(d.slide.clone),s.push(g)}for(var v=0;v<b.length;v++){var f=b[v].cloneNode(!0);f.classList.add(d.slide.clone),s.unshift(f)}}return s},append:function(){for(var s=this.items,r=e.Html,o=r.wrapper,a=r.slides,d=Math.floor(s.length/2),u=s.slice(0,d).reverse(),l=s.slice(d*-1).reverse(),h="".concat(e.Sizes.slideWidth,"px"),p=0;p<l.length;p++)o.appendChild(l[p]);for(var b=0;b<u.length;b++)o.insertBefore(u[b],a[0]);for(var w=0;w<s.length;w++)s[w].style.width=h},remove:function(){for(var s=this.items,r=0;r<s.length;r++)e.Html.wrapper.removeChild(s[r])}};return W(i,"grow",{get:function(){return(e.Sizes.slideWidth+e.Gaps.value)*i.items.length}}),t.on("update",function(){i.remove(),i.mount(),i.append()}),t.on("build.before",function(){c.isType("carousel")&&i.append()}),t.on("destroy",function(){i.remove()}),i}var be=(function(){function c(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ge(this,c),this.listeners=e}return We(c,[{key:"on",value:function(t,i,n){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;ht(t)&&(t=[t]);for(var r=0;r<t.length;r++)this.listeners[t[r]]=n,i.addEventListener(t[r],this.listeners[t[r]],s)}},{key:"off",value:function(t,i){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;ht(t)&&(t=[t]);for(var s=0;s<t.length;s++)i.removeEventListener(t[s],this.listeners[t[s]],n)}},{key:"destroy",value:function(){delete this.listeners}}]),c})();function os(c,e,t){var i=new be,n={mount:function(){this.bind()},bind:function(){i.on("resize",window,Xe(function(){t.emit("resize")},c.settings.throttle))},unbind:function(){i.off("resize",window)}};return t.on("destroy",function(){n.unbind(),i.destroy()}),n}var ls=["ltr","rtl"],as={">":"<","<":">","=":"="};function cs(c,e,t){var i={mount:function(){this.value=c.settings.direction},resolve:function(s){var r=s.slice(0,1);return this.is("rtl")?s.split(r).join(as[r]):s},is:function(s){return this.value===s},addClass:function(){e.Html.root.classList.add(c.settings.classes.direction[this.value])},removeClass:function(){e.Html.root.classList.remove(c.settings.classes.direction[this.value])}};return W(i,"value",{get:function(){return i._v},set:function(s){ls.indexOf(s)>-1?i._v=s:me("Direction value must be `ltr` or `rtl`")}}),t.on(["destroy","update"],function(){i.removeClass()}),t.on("update",function(){i.mount()}),t.on(["build.before","update"],function(){i.addClass()}),i}function us(c,e){return{modify:function(i){return e.Direction.is("rtl")?-i:i}}}function ds(c,e){return{modify:function(i){var n=Math.floor(i/e.Sizes.slideWidth);return i+e.Gaps.value*n}}}function hs(c,e){return{modify:function(i){return i+e.Clones.grow/2}}}function ps(c,e){return{modify:function(i){if(c.settings.focusAt>=0){var n=e.Peek.value;return Re(n)?i-n.before:i-n}return i}}}function fs(c,e){return{modify:function(i){var n=e.Gaps.value,s=e.Sizes.width,r=c.settings.focusAt,o=e.Sizes.slideWidth;return r==="center"?i-(s/2-o/2):i-o*r-n*r}}}function gs(c,e,t){var i=[ds,hs,ps,fs].concat(c._t,[us]);return{mutate:function(s){for(var r=0;r<i.length;r++){var o=i[r];Ye(o)&&Ye(o().modify)?s=o(c,e,t).modify(s):me("Transformer should be a function that returns an object with `modify()` method")}return s}}}function ms(c,e,t){var i={set:function(s){var r=gs(c,e).mutate(s),o="translate3d(".concat(-1*r,"px, 0px, 0px)");e.Html.wrapper.style.mozTransform=o,e.Html.wrapper.style.webkitTransform=o,e.Html.wrapper.style.transform=o},remove:function(){e.Html.wrapper.style.transform=""},getStartIndex:function(){var s=e.Sizes.length,r=c.index,o=c.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s+(r-o):(r+o)%s},getTravelDistance:function(){var s=e.Sizes.slideWidth*c.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s*-1:s}};return t.on("move",function(n){if(!c.isType("carousel")||!e.Run.isOffset())return i.set(n.movement);e.Transition.after(function(){t.emit("translate.jump"),i.set(e.Sizes.slideWidth*c.index)});var s=e.Sizes.slideWidth*e.Translate.getStartIndex();return i.set(s-e.Translate.getTravelDistance())}),t.on("destroy",function(){i.remove()}),i}function bs(c,e,t){var i=!1,n={compose:function(r){var o=c.settings;return i?"".concat(r," 0ms ").concat(o.animationTimingFunc):"".concat(r," ").concat(this.duration,"ms ").concat(o.animationTimingFunc)},set:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";e.Html.wrapper.style.transition=this.compose(r)},remove:function(){e.Html.wrapper.style.transition=""},after:function(r){setTimeout(function(){r()},this.duration)},enable:function(){i=!1,this.set()},disable:function(){i=!0,this.set()}};return W(n,"duration",{get:function(){var r=c.settings;return c.isType("slider")&&e.Run.offset?r.rewindDuration:r.animationDuration}}),t.on("move",function(){n.set()}),t.on(["build.before","resize","translate.jump"],function(){n.disable()}),t.on("run",function(){n.enable()}),t.on("destroy",function(){n.remove()}),n}var Yt=!1;try{var Xt=Object.defineProperty({},"passive",{get:function(){Yt=!0}});window.addEventListener("testPassive",null,Xt),window.removeEventListener("testPassive",null,Xt)}catch{}var mt=Yt,Ze=["touchstart","mousedown"],Jt=["touchmove","mousemove"],Zt=["touchend","touchcancel","mouseup","mouseleave"],Qt=["mousedown","mousemove","mouseup","mouseleave"];function ys(c,e,t){var i=new be,n=0,s=0,r=0,o=!1,a=mt?{passive:!0}:!1,d={mount:function(){this.bindSwipeStart()},start:function(l){if(!o&&!c.disabled){this.disable();var h=this.touches(l);n=null,s=Q(h.pageX),r=Q(h.pageY),this.bindSwipeMove(),this.bindSwipeEnd(),t.emit("swipe.start")}},move:function(l){if(!c.disabled){var h=c.settings,p=h.touchAngle,b=h.touchRatio,w=h.classes,_=this.touches(l),g=Q(_.pageX)-s,v=Q(_.pageY)-r,f=Math.abs(g<<2),m=Math.abs(v<<2),y=Math.sqrt(f+m),k=Math.sqrt(m);if(n=Math.asin(k/y),n*180/Math.PI<p)l.stopPropagation(),e.Move.make(g*Wi(b)),e.Html.root.classList.add(w.dragging),t.emit("swipe.move");else return!1}},end:function(l){if(!c.disabled){var h=c.settings,p=h.perSwipe,b=h.touchAngle,w=h.classes,_=this.touches(l),g=this.threshold(l),v=_.pageX-s,f=n*180/Math.PI;this.enable(),v>g&&f<b?e.Run.make(e.Direction.resolve("".concat(p,"<"))):v<-g&&f<b?e.Run.make(e.Direction.resolve("".concat(p,">"))):e.Move.make(),e.Html.root.classList.remove(w.dragging),this.unbindSwipeMove(),this.unbindSwipeEnd(),t.emit("swipe.end")}},bindSwipeStart:function(){var l=this,h=c.settings,p=h.swipeThreshold,b=h.dragThreshold;p&&i.on(Ze[0],e.Html.wrapper,function(w){l.start(w)},a),b&&i.on(Ze[1],e.Html.wrapper,function(w){l.start(w)},a)},unbindSwipeStart:function(){i.off(Ze[0],e.Html.wrapper,a),i.off(Ze[1],e.Html.wrapper,a)},bindSwipeMove:function(){var l=this;i.on(Jt,e.Html.wrapper,Xe(function(h){l.move(h)},c.settings.throttle),a)},unbindSwipeMove:function(){i.off(Jt,e.Html.wrapper,a)},bindSwipeEnd:function(){var l=this;i.on(Zt,e.Html.wrapper,function(h){l.end(h)})},unbindSwipeEnd:function(){i.off(Zt,e.Html.wrapper)},touches:function(l){return Qt.indexOf(l.type)>-1?l:l.touches[0]||l.changedTouches[0]},threshold:function(l){var h=c.settings;return Qt.indexOf(l.type)>-1?h.dragThreshold:h.swipeThreshold},enable:function(){return o=!1,e.Transition.enable(),this},disable:function(){return o=!0,e.Transition.disable(),this}};return t.on("build.after",function(){e.Html.root.classList.add(c.settings.classes.swipeable)}),t.on("destroy",function(){d.unbindSwipeStart(),d.unbindSwipeMove(),d.unbindSwipeEnd(),i.destroy()}),d}function vs(c,e,t){var i=new be,n={mount:function(){this.bind()},bind:function(){i.on("dragstart",e.Html.wrapper,this.dragstart)},unbind:function(){i.off("dragstart",e.Html.wrapper)},dragstart:function(r){r.preventDefault()}};return t.on("destroy",function(){n.unbind(),i.destroy()}),n}function ws(c,e,t){var i=new be,n=!1,s=!1,r={mount:function(){this._a=e.Html.wrapper.querySelectorAll("a"),this.bind()},bind:function(){i.on("click",e.Html.wrapper,this.click)},unbind:function(){i.off("click",e.Html.wrapper)},click:function(a){s&&(a.stopPropagation(),a.preventDefault())},detach:function(){if(s=!0,!n){for(var a=0;a<this.items.length;a++)this.items[a].draggable=!1;n=!0}return this},attach:function(){if(s=!1,n){for(var a=0;a<this.items.length;a++)this.items[a].draggable=!0;n=!1}return this}};return W(r,"items",{get:function(){return r._a}}),t.on("swipe.move",function(){r.detach()}),t.on("swipe.end",function(){e.Transition.after(function(){r.attach()})}),t.on("destroy",function(){r.attach(),r.unbind(),i.destroy()}),r}var xs='[data-glide-el="controls[nav]"]',bt='[data-glide-el^="controls"]',ks="".concat(bt,' [data-glide-dir*="<"]'),_s="".concat(bt,' [data-glide-dir*=">"]');function Ss(c,e,t){var i=new be,n=mt?{passive:!0}:!1,s={mount:function(){this._n=e.Html.root.querySelectorAll(xs),this._c=e.Html.root.querySelectorAll(bt),this._arrowControls={previous:e.Html.root.querySelectorAll(ks),next:e.Html.root.querySelectorAll(_s)},this.addBindings()},setActive:function(){for(var o=0;o<this._n.length;o++)this.addClass(this._n[o].children)},removeActive:function(){for(var o=0;o<this._n.length;o++)this.removeClass(this._n[o].children)},addClass:function(o){var a=c.settings,d=o[c.index];d&&(d.classList.add(a.classes.nav.active),Vt(d).forEach(function(u){u.classList.remove(a.classes.nav.active)}))},removeClass:function(o){var a=o[c.index];a?.classList.remove(c.settings.classes.nav.active)},setArrowState:function(){if(!c.settings.rewind){var o=s._arrowControls.next,a=s._arrowControls.previous;this.resetArrowState(o,a),c.index===0&&this.disableArrow(a),c.index===e.Run.length&&this.disableArrow(o)}},resetArrowState:function(){for(var o=c.settings,a=arguments.length,d=new Array(a),u=0;u<a;u++)d[u]=arguments[u];d.forEach(function(l){gt(l).forEach(function(h){h.classList.remove(o.classes.arrow.disabled)})})},disableArrow:function(){for(var o=c.settings,a=arguments.length,d=new Array(a),u=0;u<a;u++)d[u]=arguments[u];d.forEach(function(l){gt(l).forEach(function(h){h.classList.add(o.classes.arrow.disabled)})})},addBindings:function(){for(var o=0;o<this._c.length;o++)this.bind(this._c[o].children)},removeBindings:function(){for(var o=0;o<this._c.length;o++)this.unbind(this._c[o].children)},bind:function(o){for(var a=0;a<o.length;a++)i.on("click",o[a],this.click),i.on("touchstart",o[a],this.click,n)},unbind:function(o){for(var a=0;a<o.length;a++)i.off(["click","touchstart"],o[a])},click:function(o){!mt&&o.type==="touchstart"&&o.preventDefault();var a=o.currentTarget.getAttribute("data-glide-dir");e.Run.make(e.Direction.resolve(a))}};return W(s,"items",{get:function(){return s._c}}),t.on(["mount.after","move.after"],function(){s.setActive()}),t.on(["mount.after","run"],function(){s.setArrowState()}),t.on("destroy",function(){s.removeBindings(),s.removeActive(),i.destroy()}),s}function Ts(c,e,t){var i=new be,n={mount:function(){c.settings.keyboard&&this.bind()},bind:function(){i.on("keyup",document,this.press)},unbind:function(){i.off("keyup",document)},press:function(r){var o=c.settings.perSwipe,a={ArrowRight:">",ArrowLeft:"<"};["ArrowRight","ArrowLeft"].includes(r.code)&&e.Run.make(e.Direction.resolve("".concat(o).concat(a[r.code])))}};return t.on(["destroy","update"],function(){n.unbind()}),t.on("update",function(){n.mount()}),t.on("destroy",function(){i.destroy()}),n}function Es(c,e,t){var i=new be,n={mount:function(){this.enable(),this.start(),c.settings.hoverpause&&this.bind()},enable:function(){this._e=!0},disable:function(){this._e=!1},start:function(){var r=this;this._e&&(this.enable(),c.settings.autoplay&&Gt(this._i)&&(this._i=setInterval(function(){r.stop(),e.Run.make(">"),r.start(),t.emit("autoplay")},this.time)))},stop:function(){this._i=clearInterval(this._i)},bind:function(){var r=this;i.on("mouseover",e.Html.root,function(){r._e&&r.stop()}),i.on("mouseout",e.Html.root,function(){r._e&&r.start()})},unbind:function(){i.off(["mouseover","mouseout"],e.Html.root)}};return W(n,"time",{get:function(){var r=e.Html.slides[c.index].getAttribute("data-glide-autoplay");return Q(r||c.settings.autoplay)}}),t.on(["destroy","update"],function(){n.unbind()}),t.on(["run.before","swipe.start","update"],function(){n.stop()}),t.on(["pause","destroy"],function(){n.disable(),n.stop()}),t.on(["run.after","swipe.end"],function(){n.start()}),t.on(["play"],function(){n.enable(),n.start()}),t.on("update",function(){n.mount()}),t.on("destroy",function(){i.destroy()}),n}function Kt(c){return Re(c)?Yi(c):(me("Breakpoints option must be an object"),{})}function Cs(c,e,t){var i=new be,n=c.settings,s=Kt(n.breakpoints),r=Object.assign({},n),o={match:function(d){if(typeof window.matchMedia<"u"){for(var u in d)if(d.hasOwnProperty(u)&&window.matchMedia("(max-width: ".concat(u,"px)")).matches)return d[u]}return r}};return Object.assign(n,o.match(s)),i.on("resize",window,Xe(function(){c.settings=ft(n,o.match(s))},c.settings.throttle)),t.on("update",function(){s=Kt(s),r=Object.assign({},n)}),t.on("destroy",function(){i.off("resize",window)}),o}var Ls={Html:es,Translate:ms,Transition:bs,Direction:cs,Peek:ts,Sizes:ss,Gaps:Qi,Move:is,Clones:rs,Resize:os,Build:ns,Run:Zi,Swipe:ys,Images:vs,Anchors:ws,Controls:Ss,Keyboard:Ts,Autoplay:Es,Breakpoints:Cs},Rs=(function(c){Hi(t,c);var e=Bi(t);function t(){return Ge(this,t),e.apply(this,arguments)}return We(t,[{key:"mount",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Ve(Le(t.prototype),"mount",this).call(this,Object.assign({},Ls,n))}}]),t})(Ji);function yt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ke=yt();function ei(c){ke=c}const qe={exec:()=>null};function B(c,e=""){let t=typeof c=="string"?c:c.source;const i={replace:(n,s)=>{let r=typeof s=="string"?s:s.source;return r=r.replace(ie.caret,"$1"),t=t.replace(n,r),i},getRegex:()=>new RegExp(t,e)};return i}const ie={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:c=>new RegExp(`^( {0,3}${c})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}#`),htmlBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}<(?:[a-z].*>|!--)`,"i")},Ms=/^(?:[ \t]*(?:\n|$))+/,As=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ps=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vt=/(?:[*+-]|\d{1,9}[.)])/,ti=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ii=B(ti).replace(/bull/g,vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Is=B(ti).replace(/bull/g,vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),wt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Os=/^[^\n]+/,xt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,$s=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ns=B(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vt).getRegex(),Qe="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",kt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ds=B("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",kt).replace("tag",Qe).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),si=B(wt).replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex(),_t={blockquote:B(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",si).getRegex(),code:As,def:$s,fences:qs,heading:Ps,hr:Pe,html:Ds,lheading:ii,list:Ns,newline:Ms,paragraph:si,table:qe,text:Os},ni=B("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex(),Hs={..._t,lheading:Is,table:ni,paragraph:B(wt).replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ni).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex()},zs={..._t,html:B(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:qe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(wt).replace("hr",Pe).replace("heading",` *#{1,6} *[^
28
- ]`).replace("lheading",ii).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Us=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,js=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ri=/^( {2,}|\\)\n(?!\s*$)/,Bs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ke=/[\p{P}\p{S}]/u,St=/[\s\p{P}\p{S}]/u,oi=/[^\s\p{P}\p{S}]/u,Fs=B(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,St).getRegex(),li=/(?!~)[\p{P}\p{S}]/u,Gs=/(?!~)[\s\p{P}\p{S}]/u,Ws=/(?:[^\s\p{P}\p{S}]|~)/u,Vs=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ai=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ys=B(ai,"u").replace(/punct/g,Ke).getRegex(),Xs=B(ai,"u").replace(/punct/g,li).getRegex(),ci="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Js=B(ci,"gu").replace(/notPunctSpace/g,oi).replace(/punctSpace/g,St).replace(/punct/g,Ke).getRegex(),Zs=B(ci,"gu").replace(/notPunctSpace/g,Ws).replace(/punctSpace/g,Gs).replace(/punct/g,li).getRegex(),Qs=B("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,oi).replace(/punctSpace/g,St).replace(/punct/g,Ke).getRegex(),Ks=B(/\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),en=B(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),tn=B(kt).replace("(?:-->|$)","-->").getRegex(),sn=B("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",tn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),et=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,nn=B(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ui=B(/^!?\[(label)\]\[(ref)\]/).replace("label",et).replace("ref",xt).getRegex(),di=B(/^!?\[(ref)\](?:\[\])?/).replace("ref",xt).getRegex(),rn=B("reflink|nolink(?!\\()","g").replace("reflink",ui).replace("nolink",di).getRegex(),Tt={_backpedal:qe,anyPunctuation:Ks,autolink:en,blockSkip:Vs,br:ri,code:js,del:qe,emStrongLDelim:Ys,emStrongRDelimAst:Js,emStrongRDelimUnd:Qs,escape:Us,link:nn,nolink:di,punctuation:Fs,reflink:ui,reflinkSearch:rn,tag:sn,text:Bs,url:qe},on={...Tt,link:B(/^!?\[(label)\]\((.*?)\)/).replace("label",et).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",et).getRegex()},Et={...Tt,emStrongRDelimAst:Zs,emStrongLDelim:Xs,url:B(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},ln={...Et,br:B(ri).replace("{2,}","*").getRegex(),text:B(Et.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tt={normal:_t,gfm:Hs,pedantic:zs},Ie={normal:Tt,gfm:Et,breaks:ln,pedantic:on},an={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hi=c=>an[c];function de(c,e){if(e){if(ie.escapeTest.test(c))return c.replace(ie.escapeReplace,hi)}else if(ie.escapeTestNoEncode.test(c))return c.replace(ie.escapeReplaceNoEncode,hi);return c}function pi(c){try{c=encodeURI(c).replace(ie.percentDecode,"%")}catch{return null}return c}function fi(c,e){const t=c.replace(ie.findPipe,(s,r,o)=>{let a=!1,d=r;for(;--d>=0&&o[d]==="\\";)a=!a;return a?"|":" |"}),i=t.split(ie.splitPipe);let n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(ie.slashPipe,"|");return i}function Oe(c,e,t){const i=c.length;if(i===0)return"";let n=0;for(;n<i&&c.charAt(i-n-1)===e;)n++;return c.slice(0,i-n)}function cn(c,e){if(c.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<c.length;i++)if(c[i]==="\\")i++;else if(c[i]===e[0])t++;else if(c[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function gi(c,e,t,i,n){const s=e.href,r=e.title||null,o=c[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;const a={type:c[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,a}function un(c,e,t){const i=c.match(t.other.indentCodeCompensation);if(i===null)return e;const n=i[1];return e.split(`
27
+ */function Bt(c,e){var t=Object.keys(c);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(c);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(c,n).enumerable})),t.push.apply(t,i)}return t}function Ft(c){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bt(Object(t),!0).forEach(function(i){Di(c,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(t)):Bt(Object(t)).forEach(function(i){Object.defineProperty(c,i,Object.getOwnPropertyDescriptor(t,i))})}return c}function Fe(c){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fe=function(e){return typeof e}:Fe=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Fe(c)}function Ge(c,e){if(!(c instanceof e))throw new TypeError("Cannot call a class as a function")}function Ni(c,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(c,i.key,i)}}function We(c,e,t){return e&&Ni(c.prototype,e),c}function Di(c,e,t){return e in c?Object.defineProperty(c,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):c[e]=t,c}function Hi(c,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");c.prototype=Object.create(e&&e.prototype,{constructor:{value:c,writable:!0,configurable:!0}}),e&&dt(c,e)}function Le(c){return Le=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Le(c)}function dt(c,e){return dt=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},dt(c,e)}function zi(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ui(c){if(c===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return c}function ji(c,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ui(c)}function Bi(c){var e=zi();return function(){var i=Le(c),n;if(e){var s=Le(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return ji(this,n)}}function Fi(c,e){for(;!Object.prototype.hasOwnProperty.call(c,e)&&(c=Le(c),c!==null););return c}function Ve(){return typeof Reflect<"u"&&Reflect.get?Ve=Reflect.get:Ve=function(e,t,i){var n=Fi(e,t);if(n){var s=Object.getOwnPropertyDescriptor(n,t);return s.get?s.get.call(arguments.length<3?e:i):s.value}},Ve.apply(this,arguments)}var Gi={type:"slider",startAt:0,perView:1,focusAt:0,gap:10,autoplay:!1,hoverpause:!0,keyboard:!0,bound:!1,swipeThreshold:80,dragThreshold:120,perSwipe:"",touchRatio:.5,touchAngle:45,animationDuration:400,rewind:!0,rewindDuration:800,animationTimingFunc:"cubic-bezier(.165, .840, .440, 1)",waitForTransition:!0,throttle:10,direction:"ltr",peek:0,cloningRatio:1,breakpoints:{},classes:{swipeable:"glide--swipeable",dragging:"glide--dragging",direction:{ltr:"glide--ltr",rtl:"glide--rtl"},type:{slider:"glide--slider",carousel:"glide--carousel"},slide:{clone:"glide__slide--clone",active:"glide__slide--active"},arrow:{disabled:"glide__arrow--disabled"},nav:{active:"glide__bullet--active"}}};function me(c){console.error("[Glide warn]: ".concat(c))}function Q(c){return parseInt(c)}function Wi(c){return parseFloat(c)}function ht(c){return typeof c=="string"}function Re(c){var e=Fe(c);return e==="function"||e==="object"&&!!c}function Ye(c){return typeof c=="function"}function Gt(c){return typeof c>"u"}function pt(c){return c.constructor===Array}function Vi(c,e,t){var i={};for(var n in e)Ye(e[n])?i[n]=e[n](c,i,t):me("Extension must be a function");for(var s in i)Ye(i[s].mount)&&i[s].mount();return i}function W(c,e,t){Object.defineProperty(c,e,t)}function Yi(c){return Object.keys(c).sort().reduce(function(e,t){return e[t]=c[t],e[t],e},{})}function ft(c,e){var t=Object.assign({},c,e);if(e.hasOwnProperty("classes")){t.classes=Object.assign({},c.classes,e.classes);var i=["direction","type","slide","arrow","nav"];i.forEach(function(n){e.classes.hasOwnProperty(n)&&(t.classes[n]=Ft(Ft({},c.classes[n]),e.classes[n]))})}return e.hasOwnProperty("breakpoints")&&(t.breakpoints=Object.assign({},c.breakpoints,e.breakpoints)),t}var Xi=(function(){function c(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ge(this,c),this.events=e,this.hop=e.hasOwnProperty}return We(c,[{key:"on",value:function(t,i){if(pt(t)){for(var n=0;n<t.length;n++)this.on(t[n],i);return}this.hop.call(this.events,t)||(this.events[t]=[]);var s=this.events[t].push(i)-1;return{remove:function(){delete this.events[t][s]}}}},{key:"emit",value:function(t,i){if(pt(t)){for(var n=0;n<t.length;n++)this.emit(t[n],i);return}this.hop.call(this.events,t)&&this.events[t].forEach(function(s){s(i||{})})}}]),c})(),Ji=(function(){function c(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Ge(this,c),this._c={},this._t=[],this._e=new Xi,this.disabled=!1,this.selector=e,this.settings=ft(Gi,t),this.index=this.settings.startAt}return We(c,[{key:"mount",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this._e.emit("mount.before"),Re(t)?this._c=Vi(this,t,this._e):me("You need to provide a object on `mount()`"),this._e.emit("mount.after"),this}},{key:"mutate",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return pt(t)?this._t=t:me("You need to provide a array on `mutate()`"),this}},{key:"update",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.settings=ft(this.settings,t),t.hasOwnProperty("startAt")&&(this.index=t.startAt),this._e.emit("update"),this}},{key:"go",value:function(t){return this._c.Run.make(t),this}},{key:"move",value:function(t){return this._c.Transition.disable(),this._c.Move.make(t),this}},{key:"destroy",value:function(){return this._e.emit("destroy"),this}},{key:"play",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return t&&(this.settings.autoplay=t),this._e.emit("play"),this}},{key:"pause",value:function(){return this._e.emit("pause"),this}},{key:"disable",value:function(){return this.disabled=!0,this}},{key:"enable",value:function(){return this.disabled=!1,this}},{key:"on",value:function(t,i){return this._e.on(t,i),this}},{key:"isType",value:function(t){return this.settings.type===t}},{key:"settings",get:function(){return this._o},set:function(t){Re(t)?this._o=t:me("Options must be an `object` instance.")}},{key:"index",get:function(){return this._i},set:function(t){this._i=Q(t)}},{key:"type",get:function(){return this.settings.type}},{key:"disabled",get:function(){return this._d},set:function(t){this._d=!!t}}]),c})();function Zi(c,e,t){var i={mount:function(){this._o=!1},make:function(u){var d=this;c.disabled||(!c.settings.waitForTransition||c.disable(),this.move=u,t.emit("run.before",this.move),this.calculate(),t.emit("run",this.move),e.Transition.after(function(){d.isStart()&&t.emit("run.start",d.move),d.isEnd()&&t.emit("run.end",d.move),d.isOffset()&&(d._o=!1,t.emit("run.offset",d.move)),t.emit("run.after",d.move),c.enable()}))},calculate:function(){var u=this.move,d=this.length,l=u.steps,h=u.direction,p=1;if(h==="="){if(c.settings.bound&&Q(l)>d){c.index=d;return}c.index=l;return}if(h===">"&&l===">"){c.index=d;return}if(h==="<"&&l==="<"){c.index=0;return}if(h==="|"&&(p=c.settings.perView||1),h===">"||h==="|"&&l===">"){var b=n(p);b>d&&(this._o=!0),c.index=s(b,p);return}if(h==="<"||h==="|"&&l==="<"){var w=r(p);w<0&&(this._o=!0),c.index=o(w,p);return}me("Invalid direction pattern [".concat(h).concat(l,"] has been used"))},isStart:function(){return c.index<=0},isEnd:function(){return c.index>=this.length},isOffset:function(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return u?this._o?u==="|>"?this.move.direction==="|"&&this.move.steps===">":u==="|<"?this.move.direction==="|"&&this.move.steps==="<":this.move.direction===u:!1:this._o},isBound:function(){return c.isType("slider")&&c.settings.focusAt!=="center"&&c.settings.bound}};function n(a){var u=c.index;return c.isType("carousel")?u+a:u+(a-u%a)}function s(a,u){var d=i.length;return a<=d?a:c.isType("carousel")?a-(d+1):c.settings.rewind?i.isBound()&&!i.isEnd()?d:0:i.isBound()?d:Math.floor(d/u)*u}function r(a){var u=c.index;if(c.isType("carousel"))return u-a;var d=Math.ceil(u/a);return(d-1)*a}function o(a,u){var d=i.length;return a>=0?a:c.isType("carousel")?a+(d+1):c.settings.rewind?i.isBound()&&i.isStart()?d:Math.floor(d/u)*u:0}return W(i,"move",{get:function(){return this._m},set:function(u){var d=u.substr(1);this._m={direction:u.substr(0,1),steps:d?Q(d)?Q(d):d:0}}}),W(i,"length",{get:function(){var u=c.settings,d=e.Html.slides.length;return this.isBound()?d-1-(Q(u.perView)-1)+Q(u.focusAt):d-1}}),W(i,"offset",{get:function(){return this._o}}),i}function Wt(){return new Date().getTime()}function Xe(c,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,n,s,r,o=0,a=function(){o=t.leading===!1?0:Wt(),i=null,r=c.apply(n,s),i||(n=s=null)},u=function(){var l=Wt();!o&&t.leading===!1&&(o=l);var h=e-(l-o);return n=this,s=arguments,h<=0||h>e?(i&&(clearTimeout(i),i=null),o=l,r=c.apply(n,s),i||(n=s=null)):!i&&t.trailing!==!1&&(i=setTimeout(a,h)),r};return u.cancel=function(){clearTimeout(i),o=0,i=n=s=null},u}var Je={ltr:["marginLeft","marginRight"],rtl:["marginRight","marginLeft"]};function Qi(c,e,t){var i={apply:function(s){for(var r=0,o=s.length;r<o;r++){var a=s[r].style,u=e.Direction.value;r!==0?a[Je[u][0]]="".concat(this.value/2,"px"):a[Je[u][0]]="",r!==s.length-1?a[Je[u][1]]="".concat(this.value/2,"px"):a[Je[u][1]]=""}},remove:function(s){for(var r=0,o=s.length;r<o;r++){var a=s[r].style;a.marginLeft="",a.marginRight=""}}};return W(i,"value",{get:function(){return Q(c.settings.gap)}}),W(i,"grow",{get:function(){return i.value*e.Sizes.length}}),W(i,"reductor",{get:function(){var s=c.settings.perView;return i.value*(s-1)/s}}),t.on(["build.after","update"],Xe(function(){i.apply(e.Html.wrapper.children)},30)),t.on("destroy",function(){i.remove(e.Html.wrapper.children)}),i}function Vt(c){if(c&&c.parentNode){for(var e=c.parentNode.firstChild,t=[];e;e=e.nextSibling)e.nodeType===1&&e!==c&&t.push(e);return t}return[]}function gt(c){return Array.prototype.slice.call(c)}var Ki='[data-glide-el="track"]';function es(c,e,t){var i={mount:function(){this.root=c.selector,this.track=this.root.querySelector(Ki),this.collectSlides()},collectSlides:function(){this.slides=gt(this.wrapper.children).filter(function(s){return!s.classList.contains(c.settings.classes.slide.clone)})}};return W(i,"root",{get:function(){return i._r},set:function(s){ht(s)&&(s=document.querySelector(s)),s!==null?i._r=s:me("Root element must be a existing Html node")}}),W(i,"track",{get:function(){return i._t},set:function(s){i._t=s}}),W(i,"wrapper",{get:function(){return i.track.children[0]}}),t.on("update",function(){i.collectSlides()}),i}function ts(c,e,t){var i={mount:function(){this.value=c.settings.peek}};return W(i,"value",{get:function(){return i._v},set:function(s){Re(s)?(s.before=Q(s.before),s.after=Q(s.after)):s=Q(s),i._v=s}}),W(i,"reductor",{get:function(){var s=i.value,r=c.settings.perView;return Re(s)?s.before/r+s.after/r:s*2/r}}),t.on(["resize","update"],function(){i.mount()}),i}function is(c,e,t){var i={mount:function(){this._o=0},make:function(){var s=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.offset=r,t.emit("move",{movement:this.value}),e.Transition.after(function(){t.emit("move.after",{movement:s.value})})}};return W(i,"offset",{get:function(){return i._o},set:function(s){i._o=Gt(s)?0:Q(s)}}),W(i,"translate",{get:function(){return e.Sizes.slideWidth*c.index}}),W(i,"value",{get:function(){var s=this.offset,r=this.translate;return e.Direction.is("rtl")?r+s:r-s}}),t.on(["build.before","run"],function(){i.make()}),i}function ss(c,e,t){var i={setupSlides:function(){for(var s="".concat(this.slideWidth,"px"),r=e.Html.slides,o=0;o<r.length;o++)r[o].style.width=s},setupWrapper:function(){e.Html.wrapper.style.width="".concat(this.wrapperSize,"px")},remove:function(){for(var s=e.Html.slides,r=0;r<s.length;r++)s[r].style.width="";e.Html.wrapper.style.width=""}};return W(i,"length",{get:function(){return e.Html.slides.length}}),W(i,"width",{get:function(){return e.Html.track.offsetWidth}}),W(i,"wrapperSize",{get:function(){return i.slideWidth*i.length+e.Gaps.grow+e.Clones.grow}}),W(i,"slideWidth",{get:function(){return i.width/c.settings.perView-e.Peek.reductor-e.Gaps.reductor}}),t.on(["build.before","resize","update"],function(){i.setupSlides(),i.setupWrapper()}),t.on("destroy",function(){i.remove()}),i}function ns(c,e,t){var i={mount:function(){t.emit("build.before"),this.typeClass(),this.activeClass(),t.emit("build.after")},typeClass:function(){e.Html.root.classList.add(c.settings.classes.type[c.settings.type])},activeClass:function(){var s=c.settings.classes,r=e.Html.slides[c.index];r&&(r.classList.add(s.slide.active),Vt(r).forEach(function(o){o.classList.remove(s.slide.active)}))},removeClasses:function(){var s=c.settings.classes,r=s.type,o=s.slide;e.Html.root.classList.remove(r[c.settings.type]),e.Html.slides.forEach(function(a){a.classList.remove(o.active)})}};return t.on(["destroy","update"],function(){i.removeClasses()}),t.on(["resize","update"],function(){i.mount()}),t.on("move.after",function(){i.activeClass()}),i}function rs(c,e,t){var i={mount:function(){this.items=[],c.isType("carousel")&&(this.items=this.collect())},collect:function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=e.Html.slides,o=c.settings,a=o.perView,u=o.classes,d=o.cloningRatio;if(r.length>0)for(var l=+!!c.settings.peek,h=a+l+Math.round(a/2),p=r.slice(0,h).reverse(),b=r.slice(h*-1),w=0;w<Math.max(d,Math.floor(a/r.length));w++){for(var _=0;_<p.length;_++){var g=p[_].cloneNode(!0);g.classList.add(u.slide.clone),s.push(g)}for(var v=0;v<b.length;v++){var f=b[v].cloneNode(!0);f.classList.add(u.slide.clone),s.unshift(f)}}return s},append:function(){for(var s=this.items,r=e.Html,o=r.wrapper,a=r.slides,u=Math.floor(s.length/2),d=s.slice(0,u).reverse(),l=s.slice(u*-1).reverse(),h="".concat(e.Sizes.slideWidth,"px"),p=0;p<l.length;p++)o.appendChild(l[p]);for(var b=0;b<d.length;b++)o.insertBefore(d[b],a[0]);for(var w=0;w<s.length;w++)s[w].style.width=h},remove:function(){for(var s=this.items,r=0;r<s.length;r++)e.Html.wrapper.removeChild(s[r])}};return W(i,"grow",{get:function(){return(e.Sizes.slideWidth+e.Gaps.value)*i.items.length}}),t.on("update",function(){i.remove(),i.mount(),i.append()}),t.on("build.before",function(){c.isType("carousel")&&i.append()}),t.on("destroy",function(){i.remove()}),i}var be=(function(){function c(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ge(this,c),this.listeners=e}return We(c,[{key:"on",value:function(t,i,n){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;ht(t)&&(t=[t]);for(var r=0;r<t.length;r++)this.listeners[t[r]]=n,i.addEventListener(t[r],this.listeners[t[r]],s)}},{key:"off",value:function(t,i){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;ht(t)&&(t=[t]);for(var s=0;s<t.length;s++)i.removeEventListener(t[s],this.listeners[t[s]],n)}},{key:"destroy",value:function(){delete this.listeners}}]),c})();function os(c,e,t){var i=new be,n={mount:function(){this.bind()},bind:function(){i.on("resize",window,Xe(function(){t.emit("resize")},c.settings.throttle))},unbind:function(){i.off("resize",window)}};return t.on("destroy",function(){n.unbind(),i.destroy()}),n}var ls=["ltr","rtl"],as={">":"<","<":">","=":"="};function cs(c,e,t){var i={mount:function(){this.value=c.settings.direction},resolve:function(s){var r=s.slice(0,1);return this.is("rtl")?s.split(r).join(as[r]):s},is:function(s){return this.value===s},addClass:function(){e.Html.root.classList.add(c.settings.classes.direction[this.value])},removeClass:function(){e.Html.root.classList.remove(c.settings.classes.direction[this.value])}};return W(i,"value",{get:function(){return i._v},set:function(s){ls.indexOf(s)>-1?i._v=s:me("Direction value must be `ltr` or `rtl`")}}),t.on(["destroy","update"],function(){i.removeClass()}),t.on("update",function(){i.mount()}),t.on(["build.before","update"],function(){i.addClass()}),i}function us(c,e){return{modify:function(i){return e.Direction.is("rtl")?-i:i}}}function ds(c,e){return{modify:function(i){var n=Math.floor(i/e.Sizes.slideWidth);return i+e.Gaps.value*n}}}function hs(c,e){return{modify:function(i){return i+e.Clones.grow/2}}}function ps(c,e){return{modify:function(i){if(c.settings.focusAt>=0){var n=e.Peek.value;return Re(n)?i-n.before:i-n}return i}}}function fs(c,e){return{modify:function(i){var n=e.Gaps.value,s=e.Sizes.width,r=c.settings.focusAt,o=e.Sizes.slideWidth;return r==="center"?i-(s/2-o/2):i-o*r-n*r}}}function gs(c,e,t){var i=[ds,hs,ps,fs].concat(c._t,[us]);return{mutate:function(s){for(var r=0;r<i.length;r++){var o=i[r];Ye(o)&&Ye(o().modify)?s=o(c,e,t).modify(s):me("Transformer should be a function that returns an object with `modify()` method")}return s}}}function ms(c,e,t){var i={set:function(s){var r=gs(c,e).mutate(s),o="translate3d(".concat(-1*r,"px, 0px, 0px)");e.Html.wrapper.style.mozTransform=o,e.Html.wrapper.style.webkitTransform=o,e.Html.wrapper.style.transform=o},remove:function(){e.Html.wrapper.style.transform=""},getStartIndex:function(){var s=e.Sizes.length,r=c.index,o=c.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s+(r-o):(r+o)%s},getTravelDistance:function(){var s=e.Sizes.slideWidth*c.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s*-1:s}};return t.on("move",function(n){if(!c.isType("carousel")||!e.Run.isOffset())return i.set(n.movement);e.Transition.after(function(){t.emit("translate.jump"),i.set(e.Sizes.slideWidth*c.index)});var s=e.Sizes.slideWidth*e.Translate.getStartIndex();return i.set(s-e.Translate.getTravelDistance())}),t.on("destroy",function(){i.remove()}),i}function bs(c,e,t){var i=!1,n={compose:function(r){var o=c.settings;return i?"".concat(r," 0ms ").concat(o.animationTimingFunc):"".concat(r," ").concat(this.duration,"ms ").concat(o.animationTimingFunc)},set:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";e.Html.wrapper.style.transition=this.compose(r)},remove:function(){e.Html.wrapper.style.transition=""},after:function(r){setTimeout(function(){r()},this.duration)},enable:function(){i=!1,this.set()},disable:function(){i=!0,this.set()}};return W(n,"duration",{get:function(){var r=c.settings;return c.isType("slider")&&e.Run.offset?r.rewindDuration:r.animationDuration}}),t.on("move",function(){n.set()}),t.on(["build.before","resize","translate.jump"],function(){n.disable()}),t.on("run",function(){n.enable()}),t.on("destroy",function(){n.remove()}),n}var Yt=!1;try{var Xt=Object.defineProperty({},"passive",{get:function(){Yt=!0}});window.addEventListener("testPassive",null,Xt),window.removeEventListener("testPassive",null,Xt)}catch{}var mt=Yt,Ze=["touchstart","mousedown"],Jt=["touchmove","mousemove"],Zt=["touchend","touchcancel","mouseup","mouseleave"],Qt=["mousedown","mousemove","mouseup","mouseleave"];function ys(c,e,t){var i=new be,n=0,s=0,r=0,o=!1,a=mt?{passive:!0}:!1,u={mount:function(){this.bindSwipeStart()},start:function(l){if(!o&&!c.disabled){this.disable();var h=this.touches(l);n=null,s=Q(h.pageX),r=Q(h.pageY),this.bindSwipeMove(),this.bindSwipeEnd(),t.emit("swipe.start")}},move:function(l){if(!c.disabled){var h=c.settings,p=h.touchAngle,b=h.touchRatio,w=h.classes,_=this.touches(l),g=Q(_.pageX)-s,v=Q(_.pageY)-r,f=Math.abs(g<<2),m=Math.abs(v<<2),y=Math.sqrt(f+m),k=Math.sqrt(m);if(n=Math.asin(k/y),n*180/Math.PI<p)l.stopPropagation(),e.Move.make(g*Wi(b)),e.Html.root.classList.add(w.dragging),t.emit("swipe.move");else return!1}},end:function(l){if(!c.disabled){var h=c.settings,p=h.perSwipe,b=h.touchAngle,w=h.classes,_=this.touches(l),g=this.threshold(l),v=_.pageX-s,f=n*180/Math.PI;this.enable(),v>g&&f<b?e.Run.make(e.Direction.resolve("".concat(p,"<"))):v<-g&&f<b?e.Run.make(e.Direction.resolve("".concat(p,">"))):e.Move.make(),e.Html.root.classList.remove(w.dragging),this.unbindSwipeMove(),this.unbindSwipeEnd(),t.emit("swipe.end")}},bindSwipeStart:function(){var l=this,h=c.settings,p=h.swipeThreshold,b=h.dragThreshold;p&&i.on(Ze[0],e.Html.wrapper,function(w){l.start(w)},a),b&&i.on(Ze[1],e.Html.wrapper,function(w){l.start(w)},a)},unbindSwipeStart:function(){i.off(Ze[0],e.Html.wrapper,a),i.off(Ze[1],e.Html.wrapper,a)},bindSwipeMove:function(){var l=this;i.on(Jt,e.Html.wrapper,Xe(function(h){l.move(h)},c.settings.throttle),a)},unbindSwipeMove:function(){i.off(Jt,e.Html.wrapper,a)},bindSwipeEnd:function(){var l=this;i.on(Zt,e.Html.wrapper,function(h){l.end(h)})},unbindSwipeEnd:function(){i.off(Zt,e.Html.wrapper)},touches:function(l){return Qt.indexOf(l.type)>-1?l:l.touches[0]||l.changedTouches[0]},threshold:function(l){var h=c.settings;return Qt.indexOf(l.type)>-1?h.dragThreshold:h.swipeThreshold},enable:function(){return o=!1,e.Transition.enable(),this},disable:function(){return o=!0,e.Transition.disable(),this}};return t.on("build.after",function(){e.Html.root.classList.add(c.settings.classes.swipeable)}),t.on("destroy",function(){u.unbindSwipeStart(),u.unbindSwipeMove(),u.unbindSwipeEnd(),i.destroy()}),u}function vs(c,e,t){var i=new be,n={mount:function(){this.bind()},bind:function(){i.on("dragstart",e.Html.wrapper,this.dragstart)},unbind:function(){i.off("dragstart",e.Html.wrapper)},dragstart:function(r){r.preventDefault()}};return t.on("destroy",function(){n.unbind(),i.destroy()}),n}function ws(c,e,t){var i=new be,n=!1,s=!1,r={mount:function(){this._a=e.Html.wrapper.querySelectorAll("a"),this.bind()},bind:function(){i.on("click",e.Html.wrapper,this.click)},unbind:function(){i.off("click",e.Html.wrapper)},click:function(a){s&&(a.stopPropagation(),a.preventDefault())},detach:function(){if(s=!0,!n){for(var a=0;a<this.items.length;a++)this.items[a].draggable=!1;n=!0}return this},attach:function(){if(s=!1,n){for(var a=0;a<this.items.length;a++)this.items[a].draggable=!0;n=!1}return this}};return W(r,"items",{get:function(){return r._a}}),t.on("swipe.move",function(){r.detach()}),t.on("swipe.end",function(){e.Transition.after(function(){r.attach()})}),t.on("destroy",function(){r.attach(),r.unbind(),i.destroy()}),r}var xs='[data-glide-el="controls[nav]"]',bt='[data-glide-el^="controls"]',ks="".concat(bt,' [data-glide-dir*="<"]'),_s="".concat(bt,' [data-glide-dir*=">"]');function Ss(c,e,t){var i=new be,n=mt?{passive:!0}:!1,s={mount:function(){this._n=e.Html.root.querySelectorAll(xs),this._c=e.Html.root.querySelectorAll(bt),this._arrowControls={previous:e.Html.root.querySelectorAll(ks),next:e.Html.root.querySelectorAll(_s)},this.addBindings()},setActive:function(){for(var o=0;o<this._n.length;o++)this.addClass(this._n[o].children)},removeActive:function(){for(var o=0;o<this._n.length;o++)this.removeClass(this._n[o].children)},addClass:function(o){var a=c.settings,u=o[c.index];u&&(u.classList.add(a.classes.nav.active),Vt(u).forEach(function(d){d.classList.remove(a.classes.nav.active)}))},removeClass:function(o){var a=o[c.index];a?.classList.remove(c.settings.classes.nav.active)},setArrowState:function(){if(!c.settings.rewind){var o=s._arrowControls.next,a=s._arrowControls.previous;this.resetArrowState(o,a),c.index===0&&this.disableArrow(a),c.index===e.Run.length&&this.disableArrow(o)}},resetArrowState:function(){for(var o=c.settings,a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];u.forEach(function(l){gt(l).forEach(function(h){h.classList.remove(o.classes.arrow.disabled)})})},disableArrow:function(){for(var o=c.settings,a=arguments.length,u=new Array(a),d=0;d<a;d++)u[d]=arguments[d];u.forEach(function(l){gt(l).forEach(function(h){h.classList.add(o.classes.arrow.disabled)})})},addBindings:function(){for(var o=0;o<this._c.length;o++)this.bind(this._c[o].children)},removeBindings:function(){for(var o=0;o<this._c.length;o++)this.unbind(this._c[o].children)},bind:function(o){for(var a=0;a<o.length;a++)i.on("click",o[a],this.click),i.on("touchstart",o[a],this.click,n)},unbind:function(o){for(var a=0;a<o.length;a++)i.off(["click","touchstart"],o[a])},click:function(o){!mt&&o.type==="touchstart"&&o.preventDefault();var a=o.currentTarget.getAttribute("data-glide-dir");e.Run.make(e.Direction.resolve(a))}};return W(s,"items",{get:function(){return s._c}}),t.on(["mount.after","move.after"],function(){s.setActive()}),t.on(["mount.after","run"],function(){s.setArrowState()}),t.on("destroy",function(){s.removeBindings(),s.removeActive(),i.destroy()}),s}function Ts(c,e,t){var i=new be,n={mount:function(){c.settings.keyboard&&this.bind()},bind:function(){i.on("keyup",document,this.press)},unbind:function(){i.off("keyup",document)},press:function(r){var o=c.settings.perSwipe,a={ArrowRight:">",ArrowLeft:"<"};["ArrowRight","ArrowLeft"].includes(r.code)&&e.Run.make(e.Direction.resolve("".concat(o).concat(a[r.code])))}};return t.on(["destroy","update"],function(){n.unbind()}),t.on("update",function(){n.mount()}),t.on("destroy",function(){i.destroy()}),n}function Es(c,e,t){var i=new be,n={mount:function(){this.enable(),this.start(),c.settings.hoverpause&&this.bind()},enable:function(){this._e=!0},disable:function(){this._e=!1},start:function(){var r=this;this._e&&(this.enable(),c.settings.autoplay&&Gt(this._i)&&(this._i=setInterval(function(){r.stop(),e.Run.make(">"),r.start(),t.emit("autoplay")},this.time)))},stop:function(){this._i=clearInterval(this._i)},bind:function(){var r=this;i.on("mouseover",e.Html.root,function(){r._e&&r.stop()}),i.on("mouseout",e.Html.root,function(){r._e&&r.start()})},unbind:function(){i.off(["mouseover","mouseout"],e.Html.root)}};return W(n,"time",{get:function(){var r=e.Html.slides[c.index].getAttribute("data-glide-autoplay");return Q(r||c.settings.autoplay)}}),t.on(["destroy","update"],function(){n.unbind()}),t.on(["run.before","swipe.start","update"],function(){n.stop()}),t.on(["pause","destroy"],function(){n.disable(),n.stop()}),t.on(["run.after","swipe.end"],function(){n.start()}),t.on(["play"],function(){n.enable(),n.start()}),t.on("update",function(){n.mount()}),t.on("destroy",function(){i.destroy()}),n}function Kt(c){return Re(c)?Yi(c):(me("Breakpoints option must be an object"),{})}function Cs(c,e,t){var i=new be,n=c.settings,s=Kt(n.breakpoints),r=Object.assign({},n),o={match:function(u){if(typeof window.matchMedia<"u"){for(var d in u)if(u.hasOwnProperty(d)&&window.matchMedia("(max-width: ".concat(d,"px)")).matches)return u[d]}return r}};return Object.assign(n,o.match(s)),i.on("resize",window,Xe(function(){c.settings=ft(n,o.match(s))},c.settings.throttle)),t.on("update",function(){s=Kt(s),r=Object.assign({},n)}),t.on("destroy",function(){i.off("resize",window)}),o}var Ls={Html:es,Translate:ms,Transition:bs,Direction:cs,Peek:ts,Sizes:ss,Gaps:Qi,Move:is,Clones:rs,Resize:os,Build:ns,Run:Zi,Swipe:ys,Images:vs,Anchors:ws,Controls:Ss,Keyboard:Ts,Autoplay:Es,Breakpoints:Cs},Rs=(function(c){Hi(t,c);var e=Bi(t);function t(){return Ge(this,t),e.apply(this,arguments)}return We(t,[{key:"mount",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Ve(Le(t.prototype),"mount",this).call(this,Object.assign({},Ls,n))}}]),t})(Ji);function yt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ke=yt();function ei(c){ke=c}const qe={exec:()=>null};function B(c,e=""){let t=typeof c=="string"?c:c.source;const i={replace:(n,s)=>{let r=typeof s=="string"?s:s.source;return r=r.replace(ie.caret,"$1"),t=t.replace(n,r),i},getRegex:()=>new RegExp(t,e)};return i}const ie={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:c=>new RegExp(`^( {0,3}${c})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}#`),htmlBeginRegex:c=>new RegExp(`^ {0,${Math.min(3,c-1)}}<(?:[a-z].*>|!--)`,"i")},Ms=/^(?:[ \t]*(?:\n|$))+/,As=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,qs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Pe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ps=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vt=/(?:[*+-]|\d{1,9}[.)])/,ti=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ii=B(ti).replace(/bull/g,vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Is=B(ti).replace(/bull/g,vt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),wt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Os=/^[^\n]+/,xt=/(?!\s*\])(?:\\.|[^\[\]\\])+/,$s=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",xt).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ns=B(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vt).getRegex(),Qe="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",kt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ds=B("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",kt).replace("tag",Qe).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),si=B(wt).replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex(),_t={blockquote:B(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",si).getRegex(),code:As,def:$s,fences:qs,heading:Ps,hr:Pe,html:Ds,lheading:ii,list:Ns,newline:Ms,paragraph:si,table:qe,text:Os},ni=B("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex(),Hs={..._t,lheading:Is,table:ni,paragraph:B(wt).replace("hr",Pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ni).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Qe).getRegex()},zs={..._t,html:B(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",kt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:qe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(wt).replace("hr",Pe).replace("heading",` *#{1,6} *[^
28
+ ]`).replace("lheading",ii).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Us=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,js=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ri=/^( {2,}|\\)\n(?!\s*$)/,Bs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ke=/[\p{P}\p{S}]/u,St=/[\s\p{P}\p{S}]/u,oi=/[^\s\p{P}\p{S}]/u,Fs=B(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,St).getRegex(),li=/(?!~)[\p{P}\p{S}]/u,Gs=/(?!~)[\s\p{P}\p{S}]/u,Ws=/(?:[^\s\p{P}\p{S}]|~)/u,Vs=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ai=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ys=B(ai,"u").replace(/punct/g,Ke).getRegex(),Xs=B(ai,"u").replace(/punct/g,li).getRegex(),ci="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Js=B(ci,"gu").replace(/notPunctSpace/g,oi).replace(/punctSpace/g,St).replace(/punct/g,Ke).getRegex(),Zs=B(ci,"gu").replace(/notPunctSpace/g,Ws).replace(/punctSpace/g,Gs).replace(/punct/g,li).getRegex(),Qs=B("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,oi).replace(/punctSpace/g,St).replace(/punct/g,Ke).getRegex(),Ks=B(/\\(punct)/,"gu").replace(/punct/g,Ke).getRegex(),en=B(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),tn=B(kt).replace("(?:-->|$)","-->").getRegex(),sn=B("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",tn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),et=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,nn=B(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",et).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ui=B(/^!?\[(label)\]\[(ref)\]/).replace("label",et).replace("ref",xt).getRegex(),di=B(/^!?\[(ref)\](?:\[\])?/).replace("ref",xt).getRegex(),rn=B("reflink|nolink(?!\\()","g").replace("reflink",ui).replace("nolink",di).getRegex(),Tt={_backpedal:qe,anyPunctuation:Ks,autolink:en,blockSkip:Vs,br:ri,code:js,del:qe,emStrongLDelim:Ys,emStrongRDelimAst:Js,emStrongRDelimUnd:Qs,escape:Us,link:nn,nolink:di,punctuation:Fs,reflink:ui,reflinkSearch:rn,tag:sn,text:Bs,url:qe},on={...Tt,link:B(/^!?\[(label)\]\((.*?)\)/).replace("label",et).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",et).getRegex()},Et={...Tt,emStrongRDelimAst:Zs,emStrongLDelim:Xs,url:B(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},ln={...Et,br:B(ri).replace("{2,}","*").getRegex(),text:B(Et.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tt={normal:_t,gfm:Hs,pedantic:zs},Ie={normal:Tt,gfm:Et,breaks:ln,pedantic:on},an={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},hi=c=>an[c];function de(c,e){if(e){if(ie.escapeTest.test(c))return c.replace(ie.escapeReplace,hi)}else if(ie.escapeTestNoEncode.test(c))return c.replace(ie.escapeReplaceNoEncode,hi);return c}function pi(c){try{c=encodeURI(c).replace(ie.percentDecode,"%")}catch{return null}return c}function fi(c,e){const t=c.replace(ie.findPipe,(s,r,o)=>{let a=!1,u=r;for(;--u>=0&&o[u]==="\\";)a=!a;return a?"|":" |"}),i=t.split(ie.splitPipe);let n=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),e)if(i.length>e)i.splice(e);else for(;i.length<e;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(ie.slashPipe,"|");return i}function Oe(c,e,t){const i=c.length;if(i===0)return"";let n=0;for(;n<i&&c.charAt(i-n-1)===e;)n++;return c.slice(0,i-n)}function cn(c,e){if(c.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<c.length;i++)if(c[i]==="\\")i++;else if(c[i]===e[0])t++;else if(c[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function gi(c,e,t,i,n){const s=e.href,r=e.title||null,o=c[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;const a={type:c[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,a}function un(c,e,t){const i=c.match(t.other.indentCodeCompensation);if(i===null)return e;const n=i[1];return e.split(`
29
29
  `).map(s=>{const r=s.match(t.other.beginningSpace);if(r===null)return s;const[o]=r;return o.length>=n.length?s.slice(n.length):s}).join(`
30
30
  `)}class it{options;rules;lexer;constructor(e){this.options=e||ke}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const i=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?i:Oe(i,`
31
31
  `)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const i=t[0],n=un(i,t[3]||"",this.rules);return{type:"code",raw:i,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let i=t[2].trim();if(this.rules.other.endingHash.test(i)){const n=Oe(i,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(i=n.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Oe(t[0],`
32
32
  `)}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let i=Oe(t[0],`
33
33
  `).split(`
34
- `),n="",s="";const r=[];for(;i.length>0;){let o=!1;const a=[];let d;for(d=0;d<i.length;d++)if(this.rules.other.blockquoteStart.test(i[d]))a.push(i[d]),o=!0;else if(!o)a.push(i[d]);else break;i=i.slice(d);const u=a.join(`
35
- `),l=u.replace(this.rules.other.blockquoteSetextReplace,`
34
+ `),n="",s="";const r=[];for(;i.length>0;){let o=!1;const a=[];let u;for(u=0;u<i.length;u++)if(this.rules.other.blockquoteStart.test(i[u]))a.push(i[u]),o=!0;else if(!o)a.push(i[u]);else break;i=i.slice(u);const d=a.join(`
35
+ `),l=d.replace(this.rules.other.blockquoteSetextReplace,`
36
36
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
37
- ${u}`:u,s=s?`${s}
37
+ ${d}`:d,s=s?`${s}
38
38
  ${l}`:l;const h=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,r,!0),this.lexer.state.top=h,i.length===0)break;const p=r.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){const b=p,w=b.raw+`
39
39
  `+i.join(`
40
40
  `),_=this.blockquote(w);r[r.length-1]=_,n=n.substring(0,n.length-b.raw.length)+_.raw,s=s.substring(0,s.length-b.text.length)+_.text;break}else if(p?.type==="list"){const b=p,w=b.raw+`
41
41
  `+i.join(`
42
42
  `),_=this.list(w);r[r.length-1]=_,n=n.substring(0,n.length-p.raw.length)+_.raw,s=s.substring(0,s.length-b.raw.length)+_.raw,i=w.substring(r.at(-1).raw.length).split(`
43
- `);continue}}return{type:"blockquote",raw:n,tokens:r,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const n=i.length>1,s={type:"list",raw:"",ordered:n,start:n?+i.slice(0,-1):"",loose:!1,items:[]};i=n?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=n?i:"[*+-]");const r=this.rules.other.listItemRegex(i);let o=!1;for(;e;){let d=!1,u="",l="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let h=t[2].split(`
43
+ `);continue}}return{type:"blockquote",raw:n,tokens:r,text:s}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i=t[1].trim();const n=i.length>1,s={type:"list",raw:"",ordered:n,start:n?+i.slice(0,-1):"",loose:!1,items:[]};i=n?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=n?i:"[*+-]");const r=this.rules.other.listItemRegex(i);let o=!1;for(;e;){let u=!1,d="",l="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let h=t[2].split(`
44
44
  `,1)[0].replace(this.rules.other.listReplaceTabs,v=>" ".repeat(3*v.length)),p=e.split(`
45
- `,1)[0],b=!h.trim(),w=0;if(this.options.pedantic?(w=2,l=h.trimStart()):b?w=t[1].length+1:(w=t[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,l=h.slice(w),w+=t[1].length),b&&this.rules.other.blankLine.test(p)&&(u+=p+`
46
- `,e=e.substring(p.length+1),d=!0),!d){const v=this.rules.other.nextBulletRegex(w),f=this.rules.other.hrRegex(w),m=this.rules.other.fencesBeginRegex(w),y=this.rules.other.headingBeginRegex(w),k=this.rules.other.htmlBeginRegex(w);for(;e;){const x=e.split(`
45
+ `,1)[0],b=!h.trim(),w=0;if(this.options.pedantic?(w=2,l=h.trimStart()):b?w=t[1].length+1:(w=t[2].search(this.rules.other.nonSpaceChar),w=w>4?1:w,l=h.slice(w),w+=t[1].length),b&&this.rules.other.blankLine.test(p)&&(d+=p+`
46
+ `,e=e.substring(p.length+1),u=!0),!u){const v=this.rules.other.nextBulletRegex(w),f=this.rules.other.hrRegex(w),m=this.rules.other.fencesBeginRegex(w),y=this.rules.other.headingBeginRegex(w),k=this.rules.other.htmlBeginRegex(w);for(;e;){const x=e.split(`
47
47
  `,1)[0];let S;if(p=x,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),S=p):S=p.replace(this.rules.other.tabCharGlobal," "),m.test(p)||y.test(p)||k.test(p)||v.test(p)||f.test(p))break;if(S.search(this.rules.other.nonSpaceChar)>=w||!p.trim())l+=`
48
48
  `+S.slice(w);else{if(b||h.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||m.test(h)||y.test(h)||f.test(h))break;l+=`
49
- `+p}!b&&!p.trim()&&(b=!0),u+=x+`
50
- `,e=e.substring(x.length+1),h=S.slice(w)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(o=!0));let _=null,g;this.options.gfm&&(_=this.rules.other.listIsTask.exec(l),_&&(g=_[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:u,task:!!_,checked:g,loose:!1,text:l,tokens:[]}),s.raw+=u}const a=s.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let d=0;d<s.items.length;d++)if(this.lexer.state.top=!1,s.items[d].tokens=this.lexer.blockTokens(s.items[d].text,[]),!s.loose){const u=s.items[d].tokens.filter(h=>h.type==="space"),l=u.length>0&&u.some(h=>this.rules.other.anyLine.test(h.raw));s.loose=l}if(s.loose)for(let d=0;d<s.items.length;d++)s.items[d].loose=!0;return s}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const i=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:i,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;const i=fi(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
51
- `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===n.length){for(const o of n)this.rules.other.tableAlignRight.test(o)?r.align.push("right"):this.rules.other.tableAlignCenter.test(o)?r.align.push("center"):this.rules.other.tableAlignLeft.test(o)?r.align.push("left"):r.align.push(null);for(let o=0;o<i.length;o++)r.header.push({text:i[o],tokens:this.lexer.inline(i[o]),header:!0,align:r.align[o]});for(const o of s)r.rows.push(fi(o,r.header.length).map((a,d)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[d]})));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const i=t[1].charAt(t[1].length-1)===`
52
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:i,tokens:this.lexer.inline(i)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const i=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;const r=Oe(i.slice(0,-1),"\\");if((i.length-r.length)%2===0)return}else{const r=cn(t[2],"()");if(r===-2)return;if(r>-1){const a=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const r=this.rules.other.pedanticHrefTitle.exec(n);r&&(n=r[1],s=r[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?n=n.slice(1):n=n.slice(1,-1)),gi(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){const n=(i[2]||i[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[n.toLowerCase()];if(!s){const r=i[0].charAt(0);return{type:"text",raw:r,text:r}}return gi(i,s,i[0],this.lexer,this.rules)}}emStrong(e,t,i=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!n||n[3]&&i.match(this.rules.other.unicodeAlphaNumeric))return;if(!(n[1]||n[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const r=[...n[0]].length-1;let o,a,d=r,u=0;const l=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);(n=l.exec(t))!=null;){if(o=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!o)continue;if(a=[...o].length,n[3]||n[4]){d+=a;continue}else if((n[5]||n[6])&&r%3&&!((r+a)%3)){u+=a;continue}if(d-=a,d>0)continue;a=Math.min(a,a+d+u);const h=[...n[0]][0].length,p=e.slice(0,r+n.index+h+a);if(Math.min(r,a)%2){const w=p.slice(1,-1);return{type:"em",raw:p,text:w,tokens:this.lexer.inlineTokens(w)}}const b=p.slice(2,-2);return{type:"strong",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(this.rules.other.newLineCharGlobal," ");const n=this.rules.other.nonSpaceChar.test(i),s=this.rules.other.startingSpaceChar.test(i)&&this.rules.other.endingSpaceChar.test(i);return n&&s&&(i=i.substring(1,i.length-1)),{type:"codespan",raw:t[0],text:i}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let i,n;return t[2]==="@"?(i=t[1],n="mailto:"+i):(i=t[1],n=i),{type:"link",raw:t[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let i,n;if(t[2]==="@")i=t[0],n="mailto:"+i;else{let s;do s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(s!==t[0]);i=t[0],t[1]==="www."?n="http://"+t[0]:n=t[0]}return{type:"link",raw:t[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const i=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:i}}}}class le{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ke,this.options.tokenizer=this.options.tokenizer||new it,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:ie,block:tt.normal,inline:Ie.normal};this.options.pedantic?(t.block=tt.pedantic,t.inline=Ie.pedantic):this.options.gfm&&(t.block=tt.gfm,this.options.breaks?t.inline=Ie.breaks:t.inline=Ie.gfm),this.tokenizer.rules=t}static get rules(){return{block:tt,inline:Ie}}static lex(e,t){return new le(t).lex(e)}static lexInline(e,t){return new le(t).inlineTokens(e)}lex(e){e=e.replace(ie.carriageReturn,`
49
+ `+p}!b&&!p.trim()&&(b=!0),d+=x+`
50
+ `,e=e.substring(x.length+1),h=S.slice(w)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(o=!0));let _=null,g;this.options.gfm&&(_=this.rules.other.listIsTask.exec(l),_&&(g=_[0]!=="[ ] ",l=l.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:d,task:!!_,checked:g,loose:!1,text:l,tokens:[]}),s.raw+=d}const a=s.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let u=0;u<s.items.length;u++)if(this.lexer.state.top=!1,s.items[u].tokens=this.lexer.blockTokens(s.items[u].text,[]),!s.loose){const d=s.items[u].tokens.filter(h=>h.type==="space"),l=d.length>0&&d.some(h=>this.rules.other.anyLine.test(h.raw));s.loose=l}if(s.loose)for(let u=0;u<s.items.length;u++)s.items[u].loose=!0;return s}}html(e){const t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){const t=this.rules.block.def.exec(e);if(t){const i=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",s=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:i,raw:t[0],href:n,title:s}}}table(e){const t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;const i=fi(t[1]),n=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
51
+ `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(i.length===n.length){for(const o of n)this.rules.other.tableAlignRight.test(o)?r.align.push("right"):this.rules.other.tableAlignCenter.test(o)?r.align.push("center"):this.rules.other.tableAlignLeft.test(o)?r.align.push("left"):r.align.push(null);for(let o=0;o<i.length;o++)r.header.push({text:i[o],tokens:this.lexer.inline(i[o]),header:!0,align:r.align[o]});for(const o of s)r.rows.push(fi(o,r.header.length).map((a,u)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[u]})));return r}}lheading(e){const t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){const t=this.rules.block.paragraph.exec(e);if(t){const i=t[1].charAt(t[1].length-1)===`
52
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:i,tokens:this.lexer.inline(i)}}}text(e){const t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){const t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){const t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const i=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(i)){if(!this.rules.other.endAngleBracket.test(i))return;const r=Oe(i.slice(0,-1),"\\");if((i.length-r.length)%2===0)return}else{const r=cn(t[2],"()");if(r===-2)return;if(r>-1){const a=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let n=t[2],s="";if(this.options.pedantic){const r=this.rules.other.pedanticHrefTitle.exec(n);r&&(n=r[1],s=r[3])}else s=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(i)?n=n.slice(1):n=n.slice(1,-1)),gi(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){const n=(i[2]||i[1]).replace(this.rules.other.multipleSpaceGlobal," "),s=t[n.toLowerCase()];if(!s){const r=i[0].charAt(0);return{type:"text",raw:r,text:r}}return gi(i,s,i[0],this.lexer,this.rules)}}emStrong(e,t,i=""){let n=this.rules.inline.emStrongLDelim.exec(e);if(!n||n[3]&&i.match(this.rules.other.unicodeAlphaNumeric))return;if(!(n[1]||n[2]||"")||!i||this.rules.inline.punctuation.exec(i)){const r=[...n[0]].length-1;let o,a,u=r,d=0;const l=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);(n=l.exec(t))!=null;){if(o=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!o)continue;if(a=[...o].length,n[3]||n[4]){u+=a;continue}else if((n[5]||n[6])&&r%3&&!((r+a)%3)){d+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+d);const h=[...n[0]][0].length,p=e.slice(0,r+n.index+h+a);if(Math.min(r,a)%2){const w=p.slice(1,-1);return{type:"em",raw:p,text:w,tokens:this.lexer.inlineTokens(w)}}const b=p.slice(2,-2);return{type:"strong",raw:p,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(this.rules.other.newLineCharGlobal," ");const n=this.rules.other.nonSpaceChar.test(i),s=this.rules.other.startingSpaceChar.test(i)&&this.rules.other.endingSpaceChar.test(i);return n&&s&&(i=i.substring(1,i.length-1)),{type:"codespan",raw:t[0],text:i}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){const t=this.rules.inline.autolink.exec(e);if(t){let i,n;return t[2]==="@"?(i=t[1],n="mailto:"+i):(i=t[1],n=i),{type:"link",raw:t[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let i,n;if(t[2]==="@")i=t[0],n="mailto:"+i;else{let s;do s=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(s!==t[0]);i=t[0],t[1]==="www."?n="http://"+t[0]:n=t[0]}return{type:"link",raw:t[0],text:i,href:n,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const t=this.rules.inline.text.exec(e);if(t){const i=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:i}}}}class le{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ke,this.options.tokenizer=this.options.tokenizer||new it,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={other:ie,block:tt.normal,inline:Ie.normal};this.options.pedantic?(t.block=tt.pedantic,t.inline=Ie.pedantic):this.options.gfm&&(t.block=tt.gfm,this.options.breaks?t.inline=Ie.breaks:t.inline=Ie.gfm),this.tokenizer.rules=t}static get rules(){return{block:tt,inline:Ie}}static lex(e,t){return new le(t).lex(e)}static lexInline(e,t){return new le(t).inlineTokens(e)}lex(e){e=e.replace(ie.carriageReturn,`
53
53
  `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){const i=this.inlineQueue[t];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],i=!1){for(this.options.pedantic&&(e=e.replace(ie.tabCharGlobal," ").replace(ie.spaceLine,""));e;){let n;if(this.options.extensions?.block?.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))continue;if(n=this.tokenizer.space(e)){e=e.substring(n.raw.length);const r=t.at(-1);n.raw.length===1&&r!==void 0?r.raw+=`
54
54
  `:t.push(n);continue}if(n=this.tokenizer.code(e)){e=e.substring(n.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
55
55
  `+n.raw,r.text+=`
56
56
  `+n.text,this.inlineQueue.at(-1).src=r.text):t.push(n);continue}if(n=this.tokenizer.fences(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.heading(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.hr(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.blockquote(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.list(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.html(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.def(e)){e=e.substring(n.raw.length);const r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=`
57
57
  `+n.raw,r.text+=`
58
- `+n.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startBlock){let r=1/0;const o=e.slice(1);let a;this.options.extensions.startBlock.forEach(d=>{a=d.call({lexer:this},o),typeof a=="number"&&a>=0&&(r=Math.min(r,a))}),r<1/0&&r>=0&&(s=e.substring(0,r+1))}if(this.state.top&&(n=this.tokenizer.paragraph(s))){const r=t.at(-1);i&&r?.type==="paragraph"?(r.raw+=`
58
+ `+n.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});continue}if(n=this.tokenizer.table(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.lheading(e)){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startBlock){let r=1/0;const o=e.slice(1);let a;this.options.extensions.startBlock.forEach(u=>{a=u.call({lexer:this},o),typeof a=="number"&&a>=0&&(r=Math.min(r,a))}),r<1/0&&r>=0&&(s=e.substring(0,r+1))}if(this.state.top&&(n=this.tokenizer.paragraph(s))){const r=t.at(-1);i&&r?.type==="paragraph"?(r.raw+=`
59
59
  `+n.raw,r.text+=`
60
60
  `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(n),i=s.length!==e.length,e=e.substring(n.raw.length);continue}if(n=this.tokenizer.text(e)){e=e.substring(n.raw.length);const r=t.at(-1);r?.type==="text"?(r.raw+=`
61
61
  `+n.raw,r.text+=`
62
- `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(n);continue}if(e){const r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i=e,n=null;if(this.tokens.links){const o=Object.keys(this.tokens.links);if(o.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)o.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let s=!1,r="";for(;e;){s||(r=""),s=!1;let o;if(this.options.extensions?.inline?.some(d=>(o=d.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const d=t.at(-1);o.type==="text"&&d?.type==="text"?(d.raw+=o.raw,d.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,i,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let d=1/0;const u=e.slice(1);let l;this.options.extensions.startInline.forEach(h=>{l=h.call({lexer:this},u),typeof l=="number"&&l>=0&&(d=Math.min(d,l))}),d<1/0&&d>=0&&(a=e.substring(0,d+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),s=!0;const d=t.at(-1);d?.type==="text"?(d.raw+=o.raw,d.text+=o.text):t.push(o);continue}if(e){const d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return t}}class st{options;parser;constructor(e){this.options=e||ke}space(e){return""}code({text:e,lang:t,escaped:i}){const n=(t||"").match(ie.notSpaceStart)?.[0],s=e.replace(ie.endingNewline,"")+`
62
+ `+n.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(n);continue}if(e){const r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i=e,n=null;if(this.tokens.links){const o=Object.keys(this.tokens.links);if(o.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)o.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(n=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(n=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let s=!1,r="";for(;e;){s||(r=""),s=!1;let o;if(this.options.extensions?.inline?.some(u=>(o=u.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);const u=t.at(-1);o.type==="text"&&u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,i,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let u=1/0;const d=e.slice(1);let l;this.options.extensions.startInline.forEach(h=>{l=h.call({lexer:this},d),typeof l=="number"&&l>=0&&(u=Math.min(u,l))}),u<1/0&&u>=0&&(a=e.substring(0,u+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),s=!0;const u=t.at(-1);u?.type==="text"?(u.raw+=o.raw,u.text+=o.text):t.push(o);continue}if(e){const u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw new Error(u)}}return t}}class st{options;parser;constructor(e){this.options=e||ke}space(e){return""}code({text:e,lang:t,escaped:i}){const n=(t||"").match(ie.notSpaceStart)?.[0],s=e.replace(ie.endingNewline,"")+`
63
63
  `;return n?'<pre><code class="language-'+de(n)+'">'+(i?s:de(s,!0))+`</code></pre>
64
64
  `:"<pre><code>"+(i?s:de(s,!0))+`</code></pre>
65
65
  `}blockquote({tokens:e}){return`<blockquote>
@@ -78,12 +78,12 @@ ${this.parser.parse(e)}</blockquote>
78
78
  ${e}</tr>
79
79
  `}tablecell(e){const t=this.parser.parseInline(e.tokens),i=e.header?"th":"td";return(e.align?`<${i} align="${e.align}">`:`<${i}>`)+t+`</${i}>
80
80
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${de(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:i}){const n=this.parser.parseInline(i),s=pi(e);if(s===null)return n;e=s;let r='<a href="'+e+'"';return t&&(r+=' title="'+de(t)+'"'),r+=">"+n+"</a>",r}image({href:e,title:t,text:i,tokens:n}){n&&(i=this.parser.parseInline(n,this.parser.textRenderer));const s=pi(e);if(s===null)return de(i);e=s;let r=`<img src="${e}" alt="${i}"`;return t&&(r+=` title="${de(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:de(e.text)}}class Ct{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}}class ae{options;renderer;textRenderer;constructor(e){this.options=e||ke,this.options.renderer=this.options.renderer||new st,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ct}static parse(e,t){return new ae(t).parse(e)}static parseInline(e,t){return new ae(t).parseInline(e)}parse(e,t=!0){let i="";for(let n=0;n<e.length;n++){const s=e[n];if(this.options.extensions?.renderers?.[s.type]){const o=s,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){i+=a||"";continue}}const r=s;switch(r.type){case"space":{i+=this.renderer.space(r);continue}case"hr":{i+=this.renderer.hr(r);continue}case"heading":{i+=this.renderer.heading(r);continue}case"code":{i+=this.renderer.code(r);continue}case"table":{i+=this.renderer.table(r);continue}case"blockquote":{i+=this.renderer.blockquote(r);continue}case"list":{i+=this.renderer.list(r);continue}case"html":{i+=this.renderer.html(r);continue}case"paragraph":{i+=this.renderer.paragraph(r);continue}case"text":{let o=r,a=this.renderer.text(o);for(;n+1<e.length&&e[n+1].type==="text";)o=e[++n],a+=`
81
- `+this.renderer.text(o);t?i+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:!0}]}):i+=a;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}parseInline(e,t=this.renderer){let i="";for(let n=0;n<e.length;n++){const s=e[n];if(this.options.extensions?.renderers?.[s.type]){const o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=o||"";continue}}const r=s;switch(r.type){case"escape":{i+=t.text(r);break}case"html":{i+=t.html(r);break}case"link":{i+=t.link(r);break}case"image":{i+=t.image(r);break}case"strong":{i+=t.strong(r);break}case"em":{i+=t.em(r);break}case"codespan":{i+=t.codespan(r);break}case"br":{i+=t.br(r);break}case"del":{i+=t.del(r);break}case"text":{i+=t.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}}class nt{options;block;constructor(e){this.options=e||ke}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}}class dn{defaults=yt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=st;TextRenderer=Ct;Lexer=le;Tokenizer=it;Hooks=nt;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const n of e)switch(i=i.concat(t.call(this,n)),n.type){case"table":{const s=n;for(const r of s.header)i=i.concat(this.walkTokens(r.tokens,t));for(const r of s.rows)for(const o of r)i=i.concat(this.walkTokens(o.tokens,t));break}case"list":{const s=n;i=i.concat(this.walkTokens(s.items,t));break}default:{const s=n;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(r=>{const o=s[r].flat(1/0);i=i.concat(this.walkTokens(o,t))}):s.tokens&&(i=i.concat(this.walkTokens(s.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(i=>{const n={...i};if(n.async=this.defaults.async||n.async||!1,i.extensions&&(i.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const r=t.renderers[s.name];r?t.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const r=t[s.level];r?r.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),n.extensions=t),i.renderer){const s=this.defaults.renderer||new st(this.defaults);for(const r in i.renderer){if(!(r in s))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const o=r,a=i.renderer[o],d=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=d.apply(s,u)),l||""}}n.renderer=s}if(i.tokenizer){const s=this.defaults.tokenizer||new it(this.defaults);for(const r in i.tokenizer){if(!(r in s))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const o=r,a=i.tokenizer[o],d=s[o];s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=d.apply(s,u)),l}}n.tokenizer=s}if(i.hooks){const s=this.defaults.hooks||new nt;for(const r in i.hooks){if(!(r in s))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const o=r,a=i.hooks[o],d=s[o];nt.passThroughHooks.has(r)?s[o]=u=>{if(this.defaults.async)return Promise.resolve(a.call(s,u)).then(h=>d.call(s,h));const l=a.call(s,u);return d.call(s,l)}:s[o]=(...u)=>{let l=a.apply(s,u);return l===!1&&(l=d.apply(s,u)),l}}n.hooks=s}if(i.walkTokens){const s=this.defaults.walkTokens,r=i.walkTokens;n.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return le.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}parseMarkdown(e){return(i,n)=>{const s={...n},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof i>"u"||i===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);const a=r.hooks?r.hooks.provideLexer():e?le.lex:le.lexInline,d=r.hooks?r.hooks.provideParser():e?ae.parse:ae.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(i):i).then(u=>a(u,r)).then(u=>r.hooks?r.hooks.processAllTokens(u):u).then(u=>r.walkTokens?Promise.all(this.walkTokens(u,r.walkTokens)).then(()=>u):u).then(u=>d(u,r)).then(u=>r.hooks?r.hooks.postprocess(u):u).catch(o);try{r.hooks&&(i=r.hooks.preprocess(i));let u=a(i,r);r.hooks&&(u=r.hooks.processAllTokens(u)),r.walkTokens&&this.walkTokens(u,r.walkTokens);let l=d(u,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(u){return o(u)}}}onError(e,t){return i=>{if(i.message+=`
81
+ `+this.renderer.text(o);t?i+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:!0}]}):i+=a;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}parseInline(e,t=this.renderer){let i="";for(let n=0;n<e.length;n++){const s=e[n];if(this.options.extensions?.renderers?.[s.type]){const o=this.options.extensions.renderers[s.type].call({parser:this},s);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=o||"";continue}}const r=s;switch(r.type){case"escape":{i+=t.text(r);break}case"html":{i+=t.html(r);break}case"link":{i+=t.link(r);break}case"image":{i+=t.image(r);break}case"strong":{i+=t.strong(r);break}case"em":{i+=t.em(r);break}case"codespan":{i+=t.codespan(r);break}case"br":{i+=t.br(r);break}case"del":{i+=t.del(r);break}case"text":{i+=t.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return i}}class nt{options;block;constructor(e){this.options=e||ke}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?le.lex:le.lexInline}provideParser(){return this.block?ae.parse:ae.parseInline}}class dn{defaults=yt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ae;Renderer=st;TextRenderer=Ct;Lexer=le;Tokenizer=it;Hooks=nt;constructor(...e){this.use(...e)}walkTokens(e,t){let i=[];for(const n of e)switch(i=i.concat(t.call(this,n)),n.type){case"table":{const s=n;for(const r of s.header)i=i.concat(this.walkTokens(r.tokens,t));for(const r of s.rows)for(const o of r)i=i.concat(this.walkTokens(o.tokens,t));break}case"list":{const s=n;i=i.concat(this.walkTokens(s.items,t));break}default:{const s=n;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(r=>{const o=s[r].flat(1/0);i=i.concat(this.walkTokens(o,t))}):s.tokens&&(i=i.concat(this.walkTokens(s.tokens,t)))}}return i}use(...e){const t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(i=>{const n={...i};if(n.async=this.defaults.async||n.async||!1,i.extensions&&(i.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const r=t.renderers[s.name];r?t.renderers[s.name]=function(...o){let a=s.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const r=t[s.level];r?r.unshift(s.tokenizer):t[s.level]=[s.tokenizer],s.start&&(s.level==="block"?t.startBlock?t.startBlock.push(s.start):t.startBlock=[s.start]:s.level==="inline"&&(t.startInline?t.startInline.push(s.start):t.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(t.childTokens[s.name]=s.childTokens)}),n.extensions=t),i.renderer){const s=this.defaults.renderer||new st(this.defaults);for(const r in i.renderer){if(!(r in s))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const o=r,a=i.renderer[o],u=s[o];s[o]=(...d)=>{let l=a.apply(s,d);return l===!1&&(l=u.apply(s,d)),l||""}}n.renderer=s}if(i.tokenizer){const s=this.defaults.tokenizer||new it(this.defaults);for(const r in i.tokenizer){if(!(r in s))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const o=r,a=i.tokenizer[o],u=s[o];s[o]=(...d)=>{let l=a.apply(s,d);return l===!1&&(l=u.apply(s,d)),l}}n.tokenizer=s}if(i.hooks){const s=this.defaults.hooks||new nt;for(const r in i.hooks){if(!(r in s))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const o=r,a=i.hooks[o],u=s[o];nt.passThroughHooks.has(r)?s[o]=d=>{if(this.defaults.async)return Promise.resolve(a.call(s,d)).then(h=>u.call(s,h));const l=a.call(s,d);return u.call(s,l)}:s[o]=(...d)=>{let l=a.apply(s,d);return l===!1&&(l=u.apply(s,d)),l}}n.hooks=s}if(i.walkTokens){const s=this.defaults.walkTokens,r=i.walkTokens;n.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),s&&(a=a.concat(s.call(this,o))),a}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return le.lex(e,t??this.defaults)}parser(e,t){return ae.parse(e,t??this.defaults)}parseMarkdown(e){return(i,n)=>{const s={...n},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof i>"u"||i===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(i)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);const a=r.hooks?r.hooks.provideLexer():e?le.lex:le.lexInline,u=r.hooks?r.hooks.provideParser():e?ae.parse:ae.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(i):i).then(d=>a(d,r)).then(d=>r.hooks?r.hooks.processAllTokens(d):d).then(d=>r.walkTokens?Promise.all(this.walkTokens(d,r.walkTokens)).then(()=>d):d).then(d=>u(d,r)).then(d=>r.hooks?r.hooks.postprocess(d):d).catch(o);try{r.hooks&&(i=r.hooks.preprocess(i));let d=a(i,r);r.hooks&&(d=r.hooks.processAllTokens(d)),r.walkTokens&&this.walkTokens(d,r.walkTokens);let l=u(d,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(d){return o(d)}}}onError(e,t){return i=>{if(i.message+=`
82
82
  Please report this to https://github.com/markedjs/marked.`,e){const n="<p>An error occurred:</p><pre>"+de(i.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(i);throw i}}}const _e=new dn;function z(c,e){return _e.parse(c,e)}z.options=z.setOptions=function(c){return _e.setOptions(c),z.defaults=_e.defaults,ei(z.defaults),z},z.getDefaults=yt,z.defaults=ke,z.use=function(...c){return _e.use(...c),z.defaults=_e.defaults,ei(z.defaults),z},z.walkTokens=function(c,e){return _e.walkTokens(c,e)},z.parseInline=_e.parseInline,z.Parser=ae,z.parser=ae.parse,z.Renderer=st,z.TextRenderer=Ct,z.Lexer=le,z.lexer=le.lex,z.Tokenizer=it,z.Hooks=nt,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,ae.parse,le.lex;class hn{constructor(e={},t){const i={lang:[]};this.builder=t,this.opts=Object.assign({},i,e)}async checkIntent(e,t,i){let n="You are an assistant",s="",r=`This is the user's request:
83
83
 
84
- ${e}`,o,a,d;if(i.image&&t==="openai")return r+=`
84
+ ${e}`,o,a,u;if(i.image&&t==="openai")return r+=`
85
85
  Extract some information.
86
- `,o=[{name:"check_request",description:"Check request and extract information.",parameters:{type:"object",properties:{prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},num_images:{type:"number",description:"The number of images to generate, only if specified."},size:{type:"string",description:"Choose specified size: auto, 1024x1024, 1536x1024, 1024x1536"},quality:{type:"string",description:"Choose: auto, low, medium, high"},background:{type:"string",description:"Choose: auto, transparent, opaque"},output_format:{type:"string",description:"Choose: png, jpeg, webp"}},required:[]}}],a=await this.builder.send(r,s,n,"",o),a?(d=JSON.parse(a),d):!1;if(i.image){if(r+=`
86
+ `,o=[{name:"check_request",description:"Check request and extract information.",parameters:{type:"object",properties:{prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},num_images:{type:"number",description:"The number of images to generate, only if specified."},size:{type:"string",description:"Choose specified size: auto, 1024x1024, 1536x1024, 1024x1536"},quality:{type:"string",description:"Choose: auto, low, medium, high"},background:{type:"string",description:"Choose: auto, transparent, opaque"},output_format:{type:"string",description:"Choose: png, jpeg, webp"}},required:[]}}],a=await this.builder.send(r,s,n,"",o),a?(u=JSON.parse(a),u):!1;if(i.image){if(r+=`
87
87
 
88
88
  Check the type of the request:
89
89
  - Text/Prompt to Image Generation
@@ -99,19 +99,19 @@ Check the type of the request:
99
99
  - Edit Area in Image
100
100
  - Generate Variation of an Image
101
101
  - Describe an image or ask questions about the image
102
- `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{text_to_image_generation:{type:"boolean",description:"Check if the request asks to create or generate an image based on the prompt."},text_to_2d_illustration_generation:{type:"boolean",description:"Check if the request asks to create or generate a 2D illustration based on the prompt."},text_to_digital_illustration_generation:{type:"boolean",description:"Check if the request asks to create or generate a digital illustration based on the prompt."},text_to_book_cover_generation:{type:"boolean",description:"Check if the request asks to create or generate a book cover based on the prompt."},upscale_image:{type:"boolean",description:"Check if the request asks to upscale or enlarge an image."},minimize_image:{type:"boolean",description:"Check if the request asks to minimize (compress) the size of an image."},edit_area_in_image:{type:"boolean",description:"Check if the request asks to edit an image."},describe_image:{type:"boolean",description:"Check if the request is asking to describe an image or asking questions about the image."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;d=JSON.parse(a)}else if(i.video){if(r+=`
102
+ `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{text_to_image_generation:{type:"boolean",description:"Check if the request asks to create or generate an image based on the prompt."},text_to_2d_illustration_generation:{type:"boolean",description:"Check if the request asks to create or generate a 2D illustration based on the prompt."},text_to_digital_illustration_generation:{type:"boolean",description:"Check if the request asks to create or generate a digital illustration based on the prompt."},text_to_book_cover_generation:{type:"boolean",description:"Check if the request asks to create or generate a book cover based on the prompt."},upscale_image:{type:"boolean",description:"Check if the request asks to upscale or enlarge an image."},minimize_image:{type:"boolean",description:"Check if the request asks to minimize (compress) the size of an image."},edit_area_in_image:{type:"boolean",description:"Check if the request asks to edit an image."},describe_image:{type:"boolean",description:"Check if the request is asking to describe an image or asking questions about the image."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;u=JSON.parse(a)}else if(i.video){if(r+=`
103
103
 
104
104
  Check the type of the request:
105
105
  - Image to Video Generation (generate a video based on image)
106
106
  - Prompt/text to Video Generation (generate a video based on prompt)
107
107
  - Upscale video
108
108
  - Add sound to video
109
- `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{image_to_video_generation:{type:"boolean",description:"Check if the request asked to create or generate a video based on image, not prompt."},text_to_video_generation:{type:"boolean",description:"Check if the request asked to create or generate a video based on prompt, not image."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;d=JSON.parse(a)}else if(i.audio){if(r+=`
109
+ `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{image_to_video_generation:{type:"boolean",description:"Check if the request asked to create or generate a video based on image, not prompt."},text_to_video_generation:{type:"boolean",description:"Check if the request asked to create or generate a video based on prompt, not image."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;u=JSON.parse(a)}else if(i.audio){if(r+=`
110
110
 
111
111
  Check the type of the request:
112
112
  - Prompt/text to Audio Generation (generate sound or audio based on prompt)
113
113
  - Text to Speech (generate speech from text)
114
- `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{text_to_speech:{type:"boolean",description:"heck if the request is asking to generate speech from text."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;d=JSON.parse(a)}return this.builder.settings.consoleLog&&console.log(d),this.extractInfo(d,t,e)}async extractInfo(e,t,i){const n=this.builder.settings.defaultModels;if(e.text_to_image_generation){const s="You are an assistant",o=`
114
+ `,o=[{name:"check_request",description:"Check request.",parameters:{type:"object",properties:{text_to_speech:{type:"boolean",description:"heck if the request is asking to generate speech from text."}},required:[]}}],a=await this.builder.send(r,s,n,"",o),!a)return!1;u=JSON.parse(a)}return this.builder.settings.consoleLog&&console.log(u),this.extractInfo(u,t,e)}async extractInfo(e,t,i){const n=this.builder.settings.defaultModels;if(e.text_to_image_generation){const s="You are an assistant",o=`
115
115
  Thie is the list of models:
116
116
  - ${n.text_to_image_generation[t].join(`
117
117
  - `)}
@@ -120,7 +120,7 @@ Thie is the list of models:
120
120
  ${i}
121
121
 
122
122
  Check the request and return the details.
123
- `;let d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},num_images:{type:"number",description:"The number of images to generate, only if specified."},width:{type:"number",description:"Return image width to generate, only if specified."},height:{type:"number",description:"Return image height to generate, only if specified."},aspect_ratio:{type:"string",description:"Return the aspect ration, only if specified. Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.image_to_video_generation){const s="You are an assistant",o=`
123
+ `;let u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},num_images:{type:"number",description:"The number of images to generate, only if specified."},width:{type:"number",description:"Return image width to generate, only if specified."},height:{type:"number",description:"Return image height to generate, only if specified."},aspect_ratio:{type:"string",description:"Return the aspect ration, only if specified. Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.image_to_video_generation){const s="You are an assistant",o=`
124
124
  Thie is the list of models:
125
125
  - ${n.image_to_video_generation[t].join(`
126
126
  - `)}
@@ -129,7 +129,7 @@ Thie is the list of models:
129
129
  ${i}
130
130
 
131
131
  Check the request and return the details.
132
- `;let d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},duration:{type:"number",description:"Return duration of the video to generate."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.text_to_video_generation){const s="You are an assistant",o=`
132
+ `;let u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},duration:{type:"number",description:"Return duration of the video to generate."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.text_to_video_generation){const s="You are an assistant",o=`
133
133
  Thie is the list of models:
134
134
  - ${n.text_to_video_generation[t].join(`
135
135
  - `)}
@@ -138,12 +138,12 @@ Thie is the list of models:
138
138
  ${i}
139
139
 
140
140
  Check the request and return the details.
141
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},duration:{type:"number",description:"Return duration of the video to generate. If not explicitely specified, return 5"}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.minimize_image){let s="You are an assistant",r="",o=`This is user's request:
141
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},duration:{type:"number",description:"Return duration of the video to generate. If not explicitely specified, return 5"}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.minimize_image){let s="You are an assistant",r="",o=`This is user's request:
142
142
 
143
143
  ${i}
144
144
 
145
145
  Check the request and return the details.
146
- `,a=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."}},required:["image_url"]}}],d=await this.builder.send(o,r,s,"",a);if(!d)return!1;let u=JSON.parse(d);return{...e,...u}}else if(e.upscale_image){const s="You are an assistant",o=`
146
+ `,a=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."}},required:["image_url"]}}],u=await this.builder.send(o,r,s,"",a);if(!u)return!1;let d=JSON.parse(u);return{...e,...d}}else if(e.upscale_image){const s="You are an assistant",o=`
147
147
  Thie is the list of models:
148
148
  - ${n.upscale_image[t].join(`
149
149
  - `)}
@@ -152,7 +152,7 @@ Thie is the list of models:
152
152
  ${i}
153
153
 
154
154
  Check the request and return the details.
155
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.describe_image){const s="You are an assistant",o=`
155
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.describe_image){const s="You are an assistant",o=`
156
156
  Thie is the list of models:
157
157
  - ${n.describe_image[t].join(`
158
158
  - `)}
@@ -161,7 +161,7 @@ Thie is the list of models:
161
161
  ${i}
162
162
 
163
163
  Check the request and return the details.
164
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."}},required:["image_url","prompt"]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.edit_area_in_image){const s="You are an assistant",r=n.edit_area_in_image[t];let o="";r&&(o=`
164
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."}},required:["image_url","prompt"]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.edit_area_in_image){const s="You are an assistant",r=n.edit_area_in_image[t];let o="";r&&(o=`
165
165
  Thie is the list of models:
166
166
  - ${r.join(`
167
167
  - `)}
@@ -170,7 +170,7 @@ Thie is the list of models:
170
170
  ${i}
171
171
 
172
172
  Check the request and return the details.
173
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},num_images:{type:"number",description:"The number of images to generate."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.text_to_2d_illustration_generation){const s="You are an assistant",o=`
173
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},image_url:{type:"string",description:"Return user's image reference URL (if JPG or PNG image URL is specified)."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the video."},num_images:{type:"number",description:"The number of images to generate."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.text_to_2d_illustration_generation){const s="You are an assistant",o=`
174
174
  Thie is the list of models:
175
175
  - ${n.text_to_2d_illustration_generation[t].join(`
176
176
  - `)}
@@ -179,7 +179,7 @@ Thie is the list of models:
179
179
  ${i}
180
180
 
181
181
  Check the request and return the details.
182
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration"'},style_id:{type:"string",description:"Return specified style_id for generating the image."},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.text_to_digital_illustration_generation){const s="You are an assistant",o=`
182
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration"'},style_id:{type:"string",description:"Return specified style_id for generating the image."},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.text_to_digital_illustration_generation){const s="You are an assistant",o=`
183
183
  Thie is the list of models:
184
184
  - ${n.text_to_digital_illustration_generation[t].join(`
185
185
  - `)}
@@ -188,7 +188,7 @@ Thie is the list of models:
188
188
  ${i}
189
189
 
190
190
  Check the request and return the details.
191
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration"'},style_id:{type:"string",description:"Return specified style_id for generating the image."},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.text_to_book_cover_generation){const s="You are an assistant",o=`
191
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration"'},style_id:{type:"string",description:"Return specified style_id for generating the image."},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.text_to_book_cover_generation){const s="You are an assistant",o=`
192
192
  Thie is the list of models:
193
193
  - ${n.text_to_book_cover_generation[t].join(`
194
194
  - `)}
@@ -197,7 +197,7 @@ Thie is the list of models:
197
197
  ${i}
198
198
 
199
199
  Check the request and return the details.
200
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration/cover"'},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}else if(e.text_to_speech){const s="You are an assistant",o=`
200
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},prompt:{type:"string",description:"Return user's instruction/prompt for generating the image."},style:{type:"string",description:'Return "digital_illustration/cover"'},num_images:{type:"number",description:"The number of images to generate."},width:{type:"number",description:"Return image width to generate."},height:{type:"number",description:"Return image height to generate."},aspect_ratio:{type:"string",description:"Example: 3:4, 16:9, etc"},color1_red:{type:"string",description:"Return red part from color1 rgb."},color1_green:{type:"string",description:"Return green part from color1 rgb."},color1_blue:{type:"string",description:"Return blue part from color1 rgb."},color2_red:{type:"string",description:"Return red part from color2 rgb."},color2_green:{type:"string",description:"Return green part from color2 rgb."},color2_blue:{type:"string",description:"Return blue part from color2 rgb."},color3_red:{type:"string",description:"Return red part from color3 rgb."},color3_green:{type:"string",description:"Return green part from color3 rgb."},color3_blue:{type:"string",description:"Return blue part from color3 rgb."},color4_red:{type:"string",description:"Return red part from color4 rgb."},color4_green:{type:"string",description:"Return green part from color4 rgb."},color4_blue:{type:"string",description:"Return blue part from color4 rgb."},color5_red:{type:"string",description:"Return red part from color5 rgb."},color5_green:{type:"string",description:"Return green part from color5 rgb."},color5_blue:{type:"string",description:"Return blue part from color5 rgb."}},required:[]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}else if(e.text_to_speech){const s="You are an assistant",o=`
201
201
  Thie is the list of models:
202
202
  - ${n.text_to_speech[t].join(`
203
203
  - `)}
@@ -206,12 +206,12 @@ Thie is the list of models:
206
206
  ${i}
207
207
 
208
208
  Check the request and return the details.
209
- `,d=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},text:{type:"string",description:"Return text or prompt to convert to speech."},voice:{type:"string",description:"Return the voice reference to use."},speed:{type:"string",description:"Return the speed."}},required:["text"]}}],u=await this.builder.send(a,o,s,"",d);if(!u)return!1;let l=JSON.parse(u);return{...e,...l}}return!1}async checkModel(e){let t="You are an assistant",i="",n=`This is the information:
209
+ `,u=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the chosen model name from the model list."},text:{type:"string",description:"Return text or prompt to convert to speech."},voice:{type:"string",description:"Return the voice reference to use."},speed:{type:"string",description:"Return the speed."}},required:["text"]}}],d=await this.builder.send(a,o,s,"",u);if(!d)return!1;let l=JSON.parse(d);return{...e,...l}}return!1}async checkModel(e){let t="You are an assistant",i="",n=`This is the information:
210
210
 
211
211
  ${e}
212
212
 
213
213
  Check the information and return the details.
214
- `,s=[{name:"check_request",description:"Check information.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the model name."}},required:["model"]}}],r=await this.builder.send(n,i,t,"",s);return r?JSON.parse(r):!1}getDimension(e){let t,i;return e?e==="1:1"?(t=1024,i=1024):e==="3:2"?(t=1216,i=832):e==="4:3"?(t=1152,i=896):e==="5:4"?(t=1088,i=896):e==="16:9"?(t=1344,i=768):e==="21:9"?(t=1536,i=640):e==="2:3"?(t=832,i=1216):e==="3:4"?(t=896,i=1152):e==="4:5"?(t=896,i=1088):e==="9:16"?(t=768,i=1344):e==="9:21"?(t=640,i=1536):(t=1344,i=768):(t=1344,i=768),{w:t,h:i}}getEndpoint(e,t,i){i=i.replace("{REQUEST_ID}",t);let n=e.split("/").slice(0,2).join("/");return i=i.replace("{MODEL}",n),i}async waitingResultFal(e,t,i,n){let s,r;e.request_id=t;const o=this.getEndpoint(e.model,t,this.builder.settings.falResultEndpoint);e.endpoint=o;let a={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:a,body:JSON.stringify(e)});let d=await s.text();try{r=JSON.parse(d)}catch{return{mediaGenerated:!1,status:"error",message:d}}if(this.builder.output.push(r),r.error)return this.builder.settings.consoleLog&&console.log(r.error),{mediaGenerated:!1,status:"error",message:r.error};{const u=r.data;let l="",h="",p,b=!1,w=[],_=[];return u.entries&&u.entries.forEach(g=>{p=g.url.split(".").pop().toLowerCase(),p==="mp4"?(l+=`
214
+ `,s=[{name:"check_request",description:"Check information.",parameters:{type:"object",properties:{model:{type:"string",description:"Return the model name."}},required:["model"]}}],r=await this.builder.send(n,i,t,"",s);return r?JSON.parse(r):!1}getDimension(e){let t,i;return e?e==="1:1"?(t=1024,i=1024):e==="3:2"?(t=1216,i=832):e==="4:3"?(t=1152,i=896):e==="5:4"?(t=1088,i=896):e==="16:9"?(t=1344,i=768):e==="21:9"?(t=1536,i=640):e==="2:3"?(t=832,i=1216):e==="3:4"?(t=896,i=1152):e==="4:5"?(t=896,i=1088):e==="9:16"?(t=768,i=1344):e==="9:21"?(t=640,i=1536):(t=1344,i=768):(t=1344,i=768),{w:t,h:i}}getEndpoint(e,t,i){i=i.replace("{REQUEST_ID}",t);let n=e.split("/").slice(0,2).join("/");return i=i.replace("{MODEL}",n),i}async waitingResultFal(e,t,i,n){let s,r;e.request_id=t;const o=this.getEndpoint(e.model,t,this.builder.settings.falResultEndpoint);e.endpoint=o;let a={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:a,body:JSON.stringify(e)});let u=await s.text();try{r=JSON.parse(u)}catch{return{mediaGenerated:!1,status:"error",message:u}}if(this.builder.output.push(r),r.error)return this.builder.settings.consoleLog&&console.log(r.error),{mediaGenerated:!1,status:"error",message:r.error};{const d=r.data;let l="",h="",p,b=!1,w=[],_=[];return d.entries&&d.entries.forEach(g=>{p=g.url.split(".").pop().toLowerCase(),p==="mp4"?(l+=`
215
215
  <p class="responsive-video">
216
216
  <video controls>
217
217
  <source src="${g.url}" type="video/mp4">
@@ -233,32 +233,32 @@ Check the information and return the details.
233
233
  <a class="link-download" href="${g.url}" download>${this.out("Download")}</a>
234
234
  </div>
235
235
  </div>
236
- `,h+=`![](${g.url})`,b=!0),w.push(g.url),_.push(g.file_url)}),b&&(l=`<div class="image-container">${l}</div>`),typeof u=="string"&&(l=u,h=u),n?(i.innerHTML="",i.remove()):(i.innerHTML=l,this.builder.outputHtml+=`<div class="result-container">${l}</div>`),{mediaGenerated:!0,status:"success",markdown:h,output:w,output2:_}}}async waitingResultReplicate(e,t,i,n){let s,r;e.request_id=t;let o=this.builder.settings.replicateStatusEndpoint;o=o.replace("{REQUEST_ID}",t),e.endpoint=o;let a={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:a,body:JSON.stringify(e)});let d=await s.text();try{r=JSON.parse(d)}catch{return{mediaGenerated:!1,status:"error",message:d}}if(this.builder.output.push(r),r.error)return this.builder.settings.consoleLog&&console.log(r.error),{mediaGenerated:!1,status:"error",message:r.error};{const u=r.data;let l=this.renderResult(u,i,n);return{mediaGenerated:!0,status:"success",markdown:l.markdown,output:l.output,output2:l.output2}}}async waitingReplicate(e,t,i,n){let s,r,o,a=e.model,d=this.builder.settings.replicateStatusEndpoint;d=d.replace("{REQUEST_ID}",t);let u={"Content-Type":"application/json",...this.builder.settings.headers},l={model:a,endpoint:d,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(l)}),o=await r.json(),o.ok&&(s=o.data.status),!s)return{mediaGenerated:!1,status:"error",result:o,message:o.error||o.data&&JSON.stringify(o.data)||this.out("Request failed.")};s==="succeeded"||s==="failed"||s==="canceled"||(this.builder.settings.consoleLog&&console.log(s),await new Promise(h=>setTimeout(h,5e3)))}while(!(s==="succeeded"||s==="failed"||s==="canceled"));return s==="succeeded"?await this.waitingResultReplicate(e,t,i,n):{mediaGenerated:!1,status:"error",result:o,message:o.data&&o.data.error||this.out("Request failed.")}}async waitingFal(e,t,i,n){let s,r,o,a=e.model;const d=this.getEndpoint(a,t,this.builder.settings.falStatusEndpoint);let u={"Content-Type":"application/json",...this.builder.settings.headers},l={model:a,endpoint:d,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(l)}),o=await r.json(),o.ok&&o.status)s=o.status;else if(o.data){let h=o.data;h.image||h.audio||h.audio_file||h.video?s="COMPLETED":h.detail&&typeof h.detail=="string"&&h.detail.startsWith("Request is still in progress")?s="IN_PROGRESS":h.status&&!h.error&&(s=h.status)}if(!s)return{mediaGenerated:!1,status:"error",result:o,message:o.error||o.data&&JSON.stringify(o.data)||this.out("Request failed.")};s!=="COMPLETED"&&(this.builder.settings.consoleLog&&console.log(s),this.builder.settings.consoleLog&&console.log(o),await new Promise(h=>setTimeout(h,5e3)))}while(s!=="COMPLETED");if(s==="COMPLETED")return await this.waitingResultFal(e,t,i,n)}renderResult(e,t,i){let n="",s="",r=[],o=[];if(e.entries){let a,d=!1;e.entries.forEach(u=>{a=u.url.split(".").pop().toLowerCase(),a==="mp4"?(n+=`
236
+ `,h+=`![](${g.url})`,b=!0),w.push(g.url),_.push(g.file_url)}),b&&(l=`<div class="image-container">${l}</div>`),typeof d=="string"&&(l=d,h=d),n?(i.innerHTML="",i.remove()):(i.innerHTML=l,this.builder.outputHtml+=`<div class="result-container">${l}</div>`),{mediaGenerated:!0,status:"success",markdown:h,output:w,output2:_}}}async waitingResultReplicate(e,t,i,n){let s,r;e.request_id=t;let o=this.builder.settings.replicateStatusEndpoint;o=o.replace("{REQUEST_ID}",t),e.endpoint=o;let a={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:a,body:JSON.stringify(e)});let u=await s.text();try{r=JSON.parse(u)}catch{return{mediaGenerated:!1,status:"error",message:u}}if(this.builder.output.push(r),r.error)return this.builder.settings.consoleLog&&console.log(r.error),{mediaGenerated:!1,status:"error",message:r.error};{const d=r.data;let l=this.renderResult(d,i,n);return{mediaGenerated:!0,status:"success",markdown:l.markdown,output:l.output,output2:l.output2}}}async waitingReplicate(e,t,i,n){let s,r,o,a=e.model,u=this.builder.settings.replicateStatusEndpoint;u=u.replace("{REQUEST_ID}",t);let d={"Content-Type":"application/json",...this.builder.settings.headers},l={model:a,endpoint:u,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(l)}),o=await r.json(),o.ok&&(s=o.data.status),!s)return{mediaGenerated:!1,status:"error",result:o,message:o.error||o.data&&JSON.stringify(o.data)||this.out("Request failed.")};s==="succeeded"||s==="failed"||s==="canceled"||(this.builder.settings.consoleLog&&console.log(s),await new Promise(h=>setTimeout(h,5e3)))}while(!(s==="succeeded"||s==="failed"||s==="canceled"));return s==="succeeded"?await this.waitingResultReplicate(e,t,i,n):{mediaGenerated:!1,status:"error",result:o,message:o.data&&o.data.error||this.out("Request failed.")}}async waitingFal(e,t,i,n){let s,r,o,a=e.model;const u=this.getEndpoint(a,t,this.builder.settings.falStatusEndpoint);let d={"Content-Type":"application/json",...this.builder.settings.headers},l={model:a,endpoint:u,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(l)}),o=await r.json(),o.ok&&o.status)s=o.status;else if(o.data){let h=o.data;h.image||h.audio||h.audio_file||h.video?s="COMPLETED":h.detail&&typeof h.detail=="string"&&h.detail.startsWith("Request is still in progress")?s="IN_PROGRESS":h.status&&!h.error&&(s=h.status)}if(!s)return{mediaGenerated:!1,status:"error",result:o,message:o.error||o.data&&JSON.stringify(o.data)||this.out("Request failed.")};s!=="COMPLETED"&&(this.builder.settings.consoleLog&&console.log(s),this.builder.settings.consoleLog&&console.log(o),await new Promise(h=>setTimeout(h,5e3)))}while(s!=="COMPLETED");if(s==="COMPLETED")return await this.waitingResultFal(e,t,i,n)}renderResult(e,t,i){let n="",s="",r=[],o=[];if(e.entries){let a,u=!1;e.entries.forEach(d=>{a=d.url.split(".").pop().toLowerCase(),a==="mp4"?(n+=`
237
237
  <p class="responsive-video">
238
238
  <video controls>
239
- <source src="${u.url}" type="video/mp4">
239
+ <source src="${d.url}" type="video/mp4">
240
240
  Your browser does not support the video tag.
241
241
  </video>
242
242
  </p>
243
- `,s+=`![](${u.url})`,r.push(u.url),o.push(u.file_url)):a==="wav"||a==="mp3"?(n+=`
243
+ `,s+=`![](${d.url})`,r.push(d.url),o.push(d.file_url)):a==="wav"||a==="mp3"?(n+=`
244
244
  <p class="responsive-audio">
245
245
  <audio controls>
246
- <source src="${u.url}" type="audio/mpeg">
246
+ <source src="${d.url}" type="audio/mpeg">
247
247
  Your browser does not support the audio tag.
248
248
  </audio>
249
249
  </p>
250
- `,s+=`![](${u.url})`,r.push(u.url),o.push(u.file_url)):(n+=`
250
+ `,s+=`![](${d.url})`,r.push(d.url),o.push(d.file_url)):(n+=`
251
251
  <div>
252
- <img src="${u.url}" />
252
+ <img src="${d.url}" />
253
253
  <div>
254
- <a class="link-view" href="${u.url}" target="_blank" rel="noopener noreferrer">${this.out("View")}</a>
255
- <a class="link-download" href="${u.url}" download>${this.out("Download")}</a>
254
+ <a class="link-view" href="${d.url}" target="_blank" rel="noopener noreferrer">${this.out("View")}</a>
255
+ <a class="link-download" href="${d.url}" download>${this.out("Download")}</a>
256
256
  </div>
257
257
  </div>
258
- `,s+=`![](${u.url})`,r.push(u.url),o.push(u.file_url),d=!0)}),d&&(n=`<div class="image-container">${n}</div>`)}else typeof e=="string"&&(n=`
258
+ `,s+=`![](${d.url})`,r.push(d.url),o.push(d.file_url),u=!0)}),u&&(n=`<div class="image-container">${n}</div>`)}else typeof e=="string"&&(n=`
259
259
  <p>
260
260
  ${e}
261
- </p>`,s=e);return i?(t.innerHTML="",t.remove()):(t.innerHTML=n,this.builder.outputHtml+=`<div class="result-container">${n}</div>`),{markdown:s,output:r,output2:o}}async generateReplicate(e,t,i){let n,s={};const r="replicate";if(e.text_to_image_generation){let a=this.validateModel(e.model,r,"text_to_image_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt;if(!d)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.aspect_ratio||"16:9",l=e.num_images||1;l>4&&(l=4),n={prompt:d,aspect_ratio:u,num_outputs:l},s.model=a,s.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let a=this.validateModel(e.model,l,"edit_area_in_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt;if(!d)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let l="replicate";const h=await this.builder.upload.getInputURLs(l,!0);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url],b=h[e.image_url+"_mask"];if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Image mask not found.")};n={prompt:d,image:p,mask:b},s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let a=this.validateModel(e.model,r,"text_to_digital_illustration_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt;if(!d)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.width||1280,l=e.height||768;e.num_images,n={prompt:d,size:`${u}x${l}`,style:"digital_illustration"},s.model=a,s.customData=this.builder.settings.customData}else if(e.upscale_image){let a=this.validateModel(e.model,u,"upscale_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let u="replicate";const l=await this.builder.upload.getInputURLs(u);if(l.error)return{mediaGenerated:!1,status:"error",message:l.error};let h=l[e.image_url];if(!h)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:h},s.model=a,s.customData=this.builder.settings.customData}else if(e.describe_image){let a=this.validateModel(e.model,l,"describe_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt;if(!d)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let l="replicate";const h=await this.builder.upload.getInputURLs(l);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url];if(!p)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:p,prompt:`${d}. No talk. Answer only.`},s.model=a,s.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let a=this.validateModel(e.model,l,"image_to_video_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt||"stunning video",u=e.duration||5;u>10&&(u=5);let l="replicate";const h=await this.builder.upload.getInputURLs(l);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url];if(!p)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};a==="kwaivgi/kling-v1.6-pro"&&(n={start_image:p,prompt:d,duration:u}),a==="kwaivgi/kling-v1.6-standard"&&(n={start_image:p,prompt:d,duration:u}),a==="minimax/video-01-live"&&(n={first_frame_image:p,prompt:d}),a==="luma/ray"&&(n={start_image_url:p,prompt:d}),s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let a=this.validateModel(e.model,r,"text_to_video_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let d=e.prompt;if(!d)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.duration||5;u>10&&(u=5),a==="kwaivgi/kling-v1.6-standard"&&(n={prompt:d,duration:u}),a==="minimax/video-01"&&(n={prompt:d}),a==="luma/ray"&&(n={prompt:d}),s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_speech){let a=this.validateModel(e.model,r,"text_to_speech");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(e.text.length>this.builder.settings.ttsMaxCharacters)return{mediaGenerated:!1,status:"error",message:this.out("The text exceeds the allowed limit.")};n={text:e.text,voice:e.voice||"af_nicole",speed:parseFloat(e.speed)||1},s.model=a,s.customData=this.builder.settings.customData}if(s.model.indexOf(":")!==-1){const d=s.model.split(":")[1];s.version=d;let u=this.builder.settings.replicateEndpoint1;s.endpoint=u,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 1")}else{let a=this.builder.settings.replicateEndpoint2;a=a.replace("{MODEL}",s.model),s.endpoint=a,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 2")}this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);let o=!1;if(this.builder.settings.generateMediaUrl_Replicate&&(o=!0),o){let a=this.builder.settings.generateMediaUrl_Replicate;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured.")};let d,u={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(s)})).json();if(h.ok){if(d=h.data.id,!d)return{mediaGenerated:!1,status:"error",message:h.data&&h.data.detail}}else return{mediaGenerated:!1,status:"error",message:h.error};const p=this.waitingReplicate(s,d,t,i);return this.builder.isMediaGenerating=!1,p}else{let a=this.builder.settings.generateMediaUrl;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl.")};let d={"Content-Type":"application/json",...this.builder.settings.headers};const l=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(s)})).json();if(this.builder.isMediaGenerating=!1,l.error)return this.builder.settings.consoleLog&&console.log(l.error),{mediaGenerated:!1,status:"error",message:l.error};{const h=l.data;let p=this.renderResult(h,t,i);return{mediaGenerated:!0,status:"success",markdown:p.markdown,output:p.output,output2:p.output2}}}}async generateOpenAI(e,t,i){let n,s={},o=this.validateModel(e.model,"openai","image_generation"),a=e.prompt;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};const d=new FormData;d.append("customData",JSON.stringify(this.builder.settings.customData)),d.append("model",o),d.append("prompt",a);let u=!1,l=this.builder.getFormValues();for(const f of l){if(f.value instanceof FileList&&f.type==="multifile"){const m=f.value;if(m.length>0)for(const y of m)d.append("file[]",y),u=!0}if(f.value instanceof FileList&&f.type==="file"){const m=f.value;if(m.length>0){const y=m[0];d.append("file[]",y),u=!0}}if(typeof f.value=="string"&&f.value.indexOf("base64")!==-1){let m=f.value.replace(/^data:image\/(png|svg\+xml|jpeg|gif|webp);base64,/,"");d.append("mask",m)}}if(this.builder.selectedFiles&&this.builder.selectedFiles.length>0)for(let f=0;f<this.builder.selectedFiles.length;f++){const m=this.builder.selectedFiles[f];d.append("file[]",m),u=!0}let h,p=e.size||"auto",b=e.quality||"auto",w=e.num_images||1;if(u){d.append("size",p),d.append("n",w),d.append("quality",b),n={prompt:a,size:p,quality:b,n:w},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s);let f=this.builder.settings.generateMediaUrl_OpenAI_CreateImageEdit;h=await fetch(f,{method:"POST",body:d})}else{let f=e.background||"auto",m=e.output_format||"png";n={prompt:a,background:f,output_format:m,size:p,quality:b,n:w},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const y=this.builder.settings.generateMediaUrl_OpenAI_CreateImage;let k={"Content-Type":"application/json",...this.builder.settings.headers};h=await fetch(y,{signal:this.builder.mediaSignal,method:"POST",headers:k,body:JSON.stringify(s)})}const _=await h.json();this.builder.settings.consoleLog&&console.log(_),this.builder.isMediaGenerating=!1;const g=_.data;this.builder.output.push(_);let v=this.renderResult(g,t,i);return{mediaGenerated:!0,status:"success",markdown:v.markdown,output:v.output,output2:v.output2}}async generateGoogle(e,t,i){let n,s={},o=this.validateModel(e.model,"google","edit_area_in_image");if(!o)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let a=e.prompt;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let d=[];d.push({text:a});let u=this.builder.getFormValues();if(!(u&&Object.keys(u).length===0)){for(const g of u)if(g.value instanceof FileList&&g.type==="multifile"){const v=g.value;if(v.length>0)for(const f of v){const m=await new Promise((y,k)=>{const x=new FileReader;x.onload=S=>{const E=S.target.result.split(",")[1];y(E)},x.onerror=k,x.readAsDataURL(f)});d.push({inlineData:{mimeType:"image/png",data:m}})}}}n={contents:d},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const l=this.builder.settings.generateMediaUrl_Google;let h={"Content-Type":"application/json",...this.builder.settings.headers};const b=await(await fetch(l,{signal:this.builder.mediaSignal,method:"POST",headers:h,body:JSON.stringify(s)})).json();this.builder.settings.consoleLog&&console.log(b),this.builder.isMediaGenerating=!1;const w=b.data;let _=this.renderResult(w,t,i);return{mediaGenerated:!0,status:"success",markdown:_.markdown,output:_.output,output2:_.output2}}async generateFal(e,t,i){let n="fal",s,r={};if(e.text_to_image_generation){let b=this.validateModel(e.model,n,"text_to_image_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.aspect_ratio,f=e.num_images||1;if(f>4&&(f=4),v){let{w:U,h:G}=this.getDimension(v);_=U,g=G}let m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M});let N=await(async()=>{let U=[],G=this.builder.getFormValues();for(const Y of G)if(Y.value instanceof FileList&&Y.type==="multifile"){const he=Y.value;if(he.length>0){let re=0;for(const ye of he){re++;const Me=new FormData;Me.append("file",ye),Me.append("customData",this.builder.settings.customData);let $e=this.builder.settings.uploadMediaUrl_Fal;const Ne=await(await fetch($e,{method:"POST",body:Me})).json();if(Ne.ok){const De=Ne.url;U.push(De),this.builder.filesUploaded["file_"+re]=De}}}}return U})();s={prompt:w,image_size:{width:_,height:g},num_images:f},b.indexOf("gemini")!==-1&&(s={prompt:w,input_image_urls:N}),b==="fal-ai/ideogram/v2a"&&(v=this.getClosestAspectRatio(_,g),s={prompt:w,aspect_ratio:v,num_images:f}),b.indexOf("recraft")!==-1&&(s={prompt:w,image_size:{width:_,height:g},num_images:f,colors:T}),r.model=b,r.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let b=this.validateModel(e.model,n,"edit_area_in_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url],f=g[e.image_url+"_mask"];if(s={image_url:v,mask_url:f,prompt:w},r.model=b,!f){s={image_url:v,prompt:w};let m=this.validateModel(e.model,n,"edit_image");r.model=m}r.customData=this.builder.settings.customData}else if(e.text_to_2d_illustration_generation){let b=this.validateModel(e.model,n,"text_to_2d_illustration_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.num_images||1;v>4&&(v=4);let f=e.style||"any",m=e.style_id||this.builder.settings._2dIllustrationStyleId,y=e.color1_red,k=e.color1_green,x=e.color1_blue,S=e.color2_red,E=e.color2_green,C=e.color2_blue,A=e.color3_red,L=e.color3_green,D=e.color3_blue,I=e.color4_red,O=e.color4_green,R=e.color4_blue,q=e.color5_red,M=e.color5_green,T=e.color5_blue,$=[];y&&k&&x&&!(y==="0"&&k==="0"&&x==="0")&&$.push({r:y,g:k,b:x}),S&&E&&C&&!(S==="0"&&E==="0"&&C==="0")&&$.push({r:S,g:E,b:C}),A&&L&&D&&!(A==="0"&&L==="0"&&D==="0")&&$.push({r:A,g:L,b:D}),I&&O&&R&&!(I==="0"&&O==="0"&&R==="0")&&$.push({r:I,g:O,b:R}),q&&M&&T&&!(q==="0"&&M==="0"&&T==="0")&&$.push({r:q,g:M,b:T}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,style_id:m,colors:$},r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let b=this.validateModel(e.model,n,"text_to_digital_illustration_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.num_images||1;v>4&&(v=4);let f=e.style||"digital_illustration",m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,colors:T},r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_book_cover_generation){let b=this.validateModel(e.model,n,"text_to_book_cover_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1024,g=e.height||1365,v=e.num_images||1;v>4&&(v=1);let f="digital_illustration/cover",m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,colors:T},r.model=b,r.customData=this.builder.settings.customData}else if(e.upscale_image){let b=this.validateModel(e.model,n,"upscale_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const _=await this.builder.upload.getInputURLs(n);if(_.error)return{mediaGenerated:!1,status:"error",message:_.error};let g=_[e.image_url];if(!g)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:g,upscale_factor:2},r.model=b,r.customData=this.builder.settings.customData}else if(e.describe_image){let b=this.validateModel(e.model,n,"describe_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url];if(!v)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:v,prompt:`${w}. No talk. Answer only.`},r.model=b,r.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let b=this.validateModel(e.model,n,"image_to_video_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;w=e.prompt||"stunning video";let _=e.duration||5;_>10&&(_=5);const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url];if(!v)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};s={prompt:w,image_url:v,duration:_,aspect_ratio:"16:9"},b.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let b=this.validateModel(e.model,n,"text_to_video_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.duration||5;_>10&&(_=5),s={prompt:w,duration:_,aspect_ratio:"16:9"},b.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_speech){let b=this.validateModel(e.model,n,"text_to_speech");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(e.text.length>this.builder.settings.ttsMaxCharacters)return{mediaGenerated:!1,status:"error",message:this.out("The text exceeds the allowed limit.")};s={text:e.text,voice:e.voice||"Matilda"},r.model=b,r.customData=this.builder.settings.customData}let o=`https://queue.fal.run/${r.model}`;r.endpoint=o,r.payload=s,this.builder.payloads.push(r),this.builder.settings.consoleLog&&console.log(r);let a=this.builder.settings.generateMediaUrl_Fal;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Fal.")};let d,u={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(r)})).json();if(h.ok)d=h.request_id;else return{mediaGenerated:!1,status:"error",message:h.error};const p=this.waitingFal(r,d,t,i);return this.builder.isMediaGenerating=!1,p}validateModel(e,t,i){const s=this.builder.settings.defaultModels[i][t];return this.builder.settings.modelFallback?s.length===1?(this.builder.settings.consoleLog&&console.log("Fixed model: "+s[0]),s[0]):e&&s&&s.includes(e)?(this.builder.settings.consoleLog&&console.log("Model is valid: "+e),e):s.length>=1?(this.builder.settings.consoleLog&&console.log("Use default: "+s[0]),s[0]):!1:e?e&&s&&s.includes(e)?(this.builder.settings.consoleLog&&console.log("Model is valid: "+e),e):!1:(this.builder.settings.consoleLog&&console.log("Fixed model: "+s[0]),s[0])}async generate_GoogleMediaByJSON(e,t,i,n){this.builder.isMediaGenerating=!0,this.mediaController=new AbortController,this.builder.mediaSignal=this.mediaController.signal;let s;if(e.trim().startsWith("{"))try{s=JSON.parse(e)}catch{return{mediaGenerated:!1,status:"error",message:this.out("Incorrect JSON format.")}}let r=t.trim();if(!r)return{mediaGenerated:!1,status:"error",message:this.out("Please provide model information in the context.")};let o={};o.model=r,o.customData=this.builder.settings.customData,o.payload=s,this.builder.payloads.push(o),this.builder.settings.consoleLog&&console.log(o);const a=this.builder.settings.generateMediaUrl_Google;let d={"Content-Type":"application/json",...this.builder.settings.headers};const l=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(o)})).json();this.builder.settings.consoleLog&&console.log(l);const h=l.data;let p=this.renderResult(h,i,n);return{mediaGenerated:!0,status:"success",markdown:p.markdown,output:p.output,output2:p.output2}}async uploadMultiple(){let e=[],t=this.builder.getFormValues();for(const i of t)if(i.value instanceof FileList&&i.type==="multifile"){const n={};if(n.name=i.name,n.files=[],this.builder.selectedFiles&&this.builder.selectedFiles.length>0){const r=[];for(let o=0;o<this.builder.selectedFiles.length;o++){const a=this.builder.selectedFiles[o],d=new FormData;d.append("file",a),d.append("customData",this.builder.settings.customData);let u=this.builder.settings.uploadMediaUrl_Fal;const h=await(await fetch(u,{method:"POST",body:d})).json();if(h.ok){const p=h.url;n.files.push(p),this.builder.filesUploaded["file_"+o]=p}r.push(n)}return r}const s=i.value;if(s.length>0){let r=0;for(const o of s){r++;const a=new FormData;a.append("file",o),a.append("customData",this.builder.settings.customData);let d=this.builder.settings.uploadMediaUrl_Fal;const l=await(await fetch(d,{method:"POST",body:a})).json();if(l.ok){const h=l.url;n.files.push(h),this.builder.filesUploaded["file_"+r]=h}}}e.push(n)}return e}async generate(e,t,i,n,s,r,o){if(i=i||this.builder.settings.defaultMediaGenerationProvider,i==="google"&&e.trim().startsWith("{"))return this.generate_GoogleMediaByJSON(e,t,r,o);this.builder.isMediaGenerating=!0,this.mediaController=new AbortController,this.builder.mediaSignal=this.mediaController.signal;let a,d=!1,u;if(e.trim().startsWith("{"))try{u=JSON.parse(e),u&&typeof u=="object"&&(d=!0)}catch{return{mediaGenerated:!1,status:"error",message:this.out("Incorrect JSON format.")}}if(d){let l=t.trim();if(!l)return{mediaGenerated:!1,status:"error",message:this.out("Please provide model information in the context.")};let h=await this.uploadMultiple();((g,v)=>{const f=m=>{if(Array.isArray(m)){const y=m[0],k=v.find(x=>x.name===y);if(k&&m.every(x=>x===y))return k.files;for(let x=0;x<m.length;x++)m[x]=f(m[x])}else if(typeof m=="object"&&m!==null)for(let y in m)m[y]=f(m[y]);return m};return f(g)})(u,h),i||(l.startsWith("fal")?i="fal":i="replicate");const b=g=>typeof g=="object"&&g!==null&&!Array.isArray(g),w=await this.builder.upload.getInputURLs(i);if(w.error)return{mediaGenerated:!1,status:"error",message:w.error};Object.keys(u).forEach(g=>{Object.keys(w).forEach(v=>{if(u[g]===v){let f=w[v];u[g]=f}if(Array.isArray(u[g])){for(let f=0;f<u[g].length;f++)if(u[g][f]===v){let m=w[v];u[g][f]=m}}})}),Object.keys(u).forEach(g=>{let v=u[g];if(b(v))for(const f in v)Object.prototype.hasOwnProperty.call(v,f)&&Object.keys(w).forEach(m=>{if(v[f]===m){let y=w[m];v[f]=y,m===y&&!y.startsWith("http")&&(v[f]="")}});if(Array.isArray(v)){for(let f=0;f<v.length;f++)if(b(v[f]))for(const m in v[f])Object.prototype.hasOwnProperty.call(v[f],m)&&Object.keys(w).forEach(y=>{if(v[f][m]===y){let k=w[y];v[f][m]=k,y===k&&!k.startsWith("http")&&(v[f][m]="")}});u[g]=[...v.filter(f=>f!=="")]}});let _={};if(_.model=l,_.customData=this.builder.settings.customData,i==="replicate"&&l.indexOf(":")!==-1){const g=l.split(":");_.version=g[1]}if(i==="replicate")if(l.indexOf(":")!==-1){let g=this.builder.settings.replicateEndpoint1;_.endpoint=g,_.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 1")}else{let g=this.builder.settings.replicateEndpoint2;g=g.replace("{MODEL}",_.model),_.endpoint=g,_.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 2")}else if(i==="fal"){let g=`https://queue.fal.run/${_.model}`;_.endpoint=g,_.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD")}return this.builder.payloads.push(_),this.builder.settings.consoleLog&&console.log(_),this.generateMediaByJSON(_,i,r,o)}try{if(a=await this.checkIntent(e,i,s),this.builder.settings.consoleLog&&console.log(a),!a)return{mediaGenerated:!1,status:"aborted",message:this.out("Request aborted.")};if(a.minimize_image){if(!a.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const h=await this.builder.upload.getInputURLs();if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let b={image_url:h[a.image_url]||a.image_url,customData:this.builder.settings.customData};this.builder.payloads.push(b),this.builder.settings.consoleLog&&console.log(b);let w={"Content-Type":"application/json",...this.builder.settings.headers};const g=await(await fetch(this.builder.settings.minimizeImageUrl,{signal:this.builder.mediaSignal,method:"POST",headers:w,body:JSON.stringify(b)})).json();if(this.builder.output.push(g),g.error)return this.builder.settings.consoleLog&&console.log(g.error),this.builder.isMediaGenerating=!1,{mediaGenerated:!1,status:"error",message:g.error};{const v=g.url,f=`
261
+ </p>`,s=e);return i?(t.innerHTML="",t.remove()):(t.innerHTML=n,this.builder.outputHtml+=`<div class="result-container">${n}</div>`),{markdown:s,output:r,output2:o}}async generateReplicate(e,t,i){let n,s={};const r="replicate";if(e.text_to_image_generation){let a=this.validateModel(e.model,r,"text_to_image_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt;if(!u)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let d=e.aspect_ratio||"16:9",l=e.num_images||1;l>4&&(l=4),n={prompt:u,aspect_ratio:d,num_outputs:l},s.model=a,s.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let a=this.validateModel(e.model,l,"edit_area_in_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt;if(!u)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let l="replicate";const h=await this.builder.upload.getInputURLs(l,!0);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url],b=h[e.image_url+"_mask"];if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Image mask not found.")};n={prompt:u,image:p,mask:b},s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let a=this.validateModel(e.model,r,"text_to_digital_illustration_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt;if(!u)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let d=e.width||1280,l=e.height||768;e.num_images,n={prompt:u,size:`${d}x${l}`,style:"digital_illustration"},s.model=a,s.customData=this.builder.settings.customData}else if(e.upscale_image){let a=this.validateModel(e.model,d,"upscale_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let d="replicate";const l=await this.builder.upload.getInputURLs(d);if(l.error)return{mediaGenerated:!1,status:"error",message:l.error};let h=l[e.image_url];if(!h)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:h},s.model=a,s.customData=this.builder.settings.customData}else if(e.describe_image){let a=this.validateModel(e.model,l,"describe_image");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt;if(!u)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};let l="replicate";const h=await this.builder.upload.getInputURLs(l);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url];if(!p)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:p,prompt:`${u}. No talk. Answer only.`},s.model=a,s.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let a=this.validateModel(e.model,l,"image_to_video_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt||"stunning video",d=e.duration||5;d>10&&(d=5);let l="replicate";const h=await this.builder.upload.getInputURLs(l);if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let p=h[e.image_url];if(!p)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};a==="kwaivgi/kling-v1.6-pro"&&(n={start_image:p,prompt:u,duration:d}),a==="kwaivgi/kling-v1.6-standard"&&(n={start_image:p,prompt:u,duration:d}),a==="minimax/video-01-live"&&(n={first_frame_image:p,prompt:u}),a==="luma/ray"&&(n={start_image_url:p,prompt:u}),s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let a=this.validateModel(e.model,r,"text_to_video_generation");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let u=e.prompt;if(!u)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let d=e.duration||5;d>10&&(d=5),a==="kwaivgi/kling-v1.6-standard"&&(n={prompt:u,duration:d}),a==="minimax/video-01"&&(n={prompt:u}),a==="luma/ray"&&(n={prompt:u}),s.model=a,s.customData=this.builder.settings.customData}else if(e.text_to_speech){let a=this.validateModel(e.model,r,"text_to_speech");if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(e.text.length>this.builder.settings.ttsMaxCharacters)return{mediaGenerated:!1,status:"error",message:this.out("The text exceeds the allowed limit.")};n={text:e.text,voice:e.voice||"af_nicole",speed:parseFloat(e.speed)||1},s.model=a,s.customData=this.builder.settings.customData}if(s.model.indexOf(":")!==-1){const u=s.model.split(":")[1];s.version=u;let d=this.builder.settings.replicateEndpoint1;s.endpoint=d,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 1")}else{let a=this.builder.settings.replicateEndpoint2;a=a.replace("{MODEL}",s.model),s.endpoint=a,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 2")}this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);let o=!1;if(this.builder.settings.generateMediaUrl_Replicate&&(o=!0),o){let a=this.builder.settings.generateMediaUrl_Replicate;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured.")};let u,d={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(s)})).json();if(h.ok){if(u=h.data.id,!u)return{mediaGenerated:!1,status:"error",message:h.data&&h.data.detail}}else return{mediaGenerated:!1,status:"error",message:h.error};const p=this.waitingReplicate(s,u,t,i);return this.builder.isMediaGenerating=!1,p}else{let a=this.builder.settings.generateMediaUrl;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl.")};let u={"Content-Type":"application/json",...this.builder.settings.headers};const l=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(s)})).json();if(this.builder.isMediaGenerating=!1,l.error)return this.builder.settings.consoleLog&&console.log(l.error),{mediaGenerated:!1,status:"error",message:l.error};{const h=l.data;let p=this.renderResult(h,t,i);return{mediaGenerated:!0,status:"success",markdown:p.markdown,output:p.output,output2:p.output2}}}}async generateOpenAI(e,t,i){let n,s={},o=this.validateModel(e.model,"openai","image_generation"),a=e.prompt;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};const u=new FormData;u.append("customData",JSON.stringify(this.builder.settings.customData)),u.append("model",o),u.append("prompt",a);let d=!1,l=this.builder.getFormValues();for(const f of l){if(f.value instanceof FileList&&f.type==="multifile"){const m=f.value;if(m.length>0)for(const y of m)u.append("file[]",y),d=!0}if(f.value instanceof FileList&&f.type==="file"){const m=f.value;if(m.length>0){const y=m[0];u.append("file[]",y),d=!0}}if(typeof f.value=="string"&&f.value.indexOf("base64")!==-1){let m=f.value.replace(/^data:image\/(png|svg\+xml|jpeg|gif|webp);base64,/,"");u.append("mask",m)}}if(this.builder.selectedFiles&&this.builder.selectedFiles.length>0)for(let f=0;f<this.builder.selectedFiles.length;f++){const m=this.builder.selectedFiles[f];u.append("file[]",m),d=!0}let h,p=e.size||"auto",b=e.quality||"auto",w=e.num_images||1;if(d){u.append("size",p),u.append("n",w),u.append("quality",b),n={prompt:a,size:p,quality:b,n:w},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s);let f=this.builder.settings.generateMediaUrl_OpenAI_CreateImageEdit;h=await fetch(f,{method:"POST",body:u})}else{let f=e.background||"auto",m=e.output_format||"png";n={prompt:a,background:f,output_format:m,size:p,quality:b,n:w},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const y=this.builder.settings.generateMediaUrl_OpenAI_CreateImage;let k={"Content-Type":"application/json",...this.builder.settings.headers};h=await fetch(y,{signal:this.builder.mediaSignal,method:"POST",headers:k,body:JSON.stringify(s)})}const _=await h.json();this.builder.settings.consoleLog&&console.log(_),this.builder.isMediaGenerating=!1;const g=_.data;this.builder.output.push(_);let v=this.renderResult(g,t,i);return{mediaGenerated:!0,status:"success",markdown:v.markdown,output:v.output,output2:v.output2}}async generateGoogle(e,t,i){let n,s={},o=this.validateModel(e.model,"google","edit_area_in_image");if(!o)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let a=e.prompt;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=[];u.push({text:a});let d=this.builder.getFormValues();if(!(d&&Object.keys(d).length===0)){for(const g of d)if(g.value instanceof FileList&&g.type==="multifile"){const v=g.value;if(v.length>0)for(const f of v){const m=await new Promise((y,k)=>{const x=new FileReader;x.onload=S=>{const E=S.target.result.split(",")[1];y(E)},x.onerror=k,x.readAsDataURL(f)});u.push({inlineData:{mimeType:"image/png",data:m}})}}}n={contents:u},s.model=o,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const l=this.builder.settings.generateMediaUrl_Google;let h={"Content-Type":"application/json",...this.builder.settings.headers};const b=await(await fetch(l,{signal:this.builder.mediaSignal,method:"POST",headers:h,body:JSON.stringify(s)})).json();this.builder.settings.consoleLog&&console.log(b),this.builder.isMediaGenerating=!1;const w=b.data;let _=this.renderResult(w,t,i);return{mediaGenerated:!0,status:"success",markdown:_.markdown,output:_.output,output2:_.output2}}async generateFal(e,t,i){let n="fal",s,r={};if(e.text_to_image_generation){let b=this.validateModel(e.model,n,"text_to_image_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.aspect_ratio,f=e.num_images||1;if(f>4&&(f=4),v){let{w:U,h:G}=this.getDimension(v);_=U,g=G}let m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M});let N=await(async()=>{let U=[],G=this.builder.getFormValues();for(const Y of G)if(Y.value instanceof FileList&&Y.type==="multifile"){const he=Y.value;if(he.length>0){let re=0;for(const ye of he){re++;const Me=new FormData;Me.append("file",ye),Me.append("customData",this.builder.settings.customData);let $e=this.builder.settings.uploadMediaUrl_Fal;const Ne=await(await fetch($e,{method:"POST",body:Me})).json();if(Ne.ok){const De=Ne.url;U.push(De),this.builder.filesUploaded["file_"+re]=De}}}}return U})();s={prompt:w,image_size:{width:_,height:g},num_images:f},b.indexOf("gemini")!==-1&&(s={prompt:w,input_image_urls:N}),b==="fal-ai/ideogram/v2a"&&(v=this.getClosestAspectRatio(_,g),s={prompt:w,aspect_ratio:v,num_images:f}),b.indexOf("recraft")!==-1&&(s={prompt:w,image_size:{width:_,height:g},num_images:f,colors:T}),r.model=b,r.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let b=this.validateModel(e.model,n,"edit_area_in_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url],f=g[e.image_url+"_mask"];if(s={image_url:v,mask_url:f,prompt:w},r.model=b,!f){s={image_url:v,prompt:w};let m=this.validateModel(e.model,n,"edit_image");r.model=m}r.customData=this.builder.settings.customData}else if(e.text_to_2d_illustration_generation){let b=this.validateModel(e.model,n,"text_to_2d_illustration_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.num_images||1;v>4&&(v=4);let f=e.style||"any",m=e.style_id||this.builder.settings._2dIllustrationStyleId,y=e.color1_red,k=e.color1_green,x=e.color1_blue,S=e.color2_red,E=e.color2_green,C=e.color2_blue,A=e.color3_red,L=e.color3_green,D=e.color3_blue,I=e.color4_red,O=e.color4_green,R=e.color4_blue,q=e.color5_red,M=e.color5_green,T=e.color5_blue,$=[];y&&k&&x&&!(y==="0"&&k==="0"&&x==="0")&&$.push({r:y,g:k,b:x}),S&&E&&C&&!(S==="0"&&E==="0"&&C==="0")&&$.push({r:S,g:E,b:C}),A&&L&&D&&!(A==="0"&&L==="0"&&D==="0")&&$.push({r:A,g:L,b:D}),I&&O&&R&&!(I==="0"&&O==="0"&&R==="0")&&$.push({r:I,g:O,b:R}),q&&M&&T&&!(q==="0"&&M==="0"&&T==="0")&&$.push({r:q,g:M,b:T}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,style_id:m,colors:$},r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let b=this.validateModel(e.model,n,"text_to_digital_illustration_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1280,g=e.height||768,v=e.num_images||1;v>4&&(v=4);let f=e.style||"digital_illustration",m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,colors:T},r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_book_cover_generation){let b=this.validateModel(e.model,n,"text_to_book_cover_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.width||1024,g=e.height||1365,v=e.num_images||1;v>4&&(v=1);let f="digital_illustration/cover",m=e.color1_red,y=e.color1_green,k=e.color1_blue,x=e.color2_red,S=e.color2_green,E=e.color2_blue,C=e.color3_red,A=e.color3_green,L=e.color3_blue,D=e.color4_red,I=e.color4_green,O=e.color4_blue,R=e.color5_red,q=e.color5_green,M=e.color5_blue,T=[];m&&y&&k&&!(m==="0"&&y==="0"&&k==="0")&&T.push({r:m,g:y,b:k}),x&&S&&E&&!(x==="0"&&S==="0"&&E==="0")&&T.push({r:x,g:S,b:E}),C&&A&&L&&!(C==="0"&&A==="0"&&L==="0")&&T.push({r:C,g:A,b:L}),D&&I&&O&&!(D==="0"&&I==="0"&&O==="0")&&T.push({r:D,g:I,b:O}),R&&q&&M&&!(R==="0"&&q==="0"&&M==="0")&&T.push({r:R,g:q,b:M}),s={prompt:w,image_size:{width:_,height:g},num_images:v,style:f,colors:T},r.model=b,r.customData=this.builder.settings.customData}else if(e.upscale_image){let b=this.validateModel(e.model,n,"upscale_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const _=await this.builder.upload.getInputURLs(n);if(_.error)return{mediaGenerated:!1,status:"error",message:_.error};let g=_[e.image_url];if(!g)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:g,upscale_factor:2},r.model=b,r.customData=this.builder.settings.customData}else if(e.describe_image){let b=this.validateModel(e.model,n,"describe_image");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};if(!e.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url];if(!v)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:v,prompt:`${w}. No talk. Answer only.`},r.model=b,r.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let b=this.validateModel(e.model,n,"image_to_video_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;w=e.prompt||"stunning video";let _=e.duration||5;_>10&&(_=5);const g=await this.builder.upload.getInputURLs(n);if(g.error)return{mediaGenerated:!1,status:"error",message:g.error};let v=g[e.image_url];if(!v)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};s={prompt:w,image_url:v,duration:_,aspect_ratio:"16:9"},b.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let b=this.validateModel(e.model,n,"text_to_video_generation");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let w=e.prompt;if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let _=e.duration||5;_>10&&(_=5),s={prompt:w,duration:_,aspect_ratio:"16:9"},b.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=b,r.customData=this.builder.settings.customData}else if(e.text_to_speech){let b=this.validateModel(e.model,n,"text_to_speech");if(!b)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};if(e.text.length>this.builder.settings.ttsMaxCharacters)return{mediaGenerated:!1,status:"error",message:this.out("The text exceeds the allowed limit.")};s={text:e.text,voice:e.voice||"Matilda"},r.model=b,r.customData=this.builder.settings.customData}let o=`https://queue.fal.run/${r.model}`;r.endpoint=o,r.payload=s,this.builder.payloads.push(r),this.builder.settings.consoleLog&&console.log(r);let a=this.builder.settings.generateMediaUrl_Fal;if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Fal.")};let u,d={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(r)})).json();if(h.ok)u=h.request_id;else return{mediaGenerated:!1,status:"error",message:h.error};const p=this.waitingFal(r,u,t,i);return this.builder.isMediaGenerating=!1,p}validateModel(e,t,i){const s=this.builder.settings.defaultModels[i][t];return this.builder.settings.modelFallback?s.length===1?(this.builder.settings.consoleLog&&console.log("Fixed model: "+s[0]),s[0]):e&&s&&s.includes(e)?(this.builder.settings.consoleLog&&console.log("Model is valid: "+e),e):s.length>=1?(this.builder.settings.consoleLog&&console.log("Use default: "+s[0]),s[0]):!1:e?e&&s&&s.includes(e)?(this.builder.settings.consoleLog&&console.log("Model is valid: "+e),e):!1:(this.builder.settings.consoleLog&&console.log("Fixed model: "+s[0]),s[0])}async generate_GoogleMediaByJSON(e,t,i,n){this.builder.isMediaGenerating=!0,this.mediaController=new AbortController,this.builder.mediaSignal=this.mediaController.signal;let s;if(e.trim().startsWith("{"))try{s=JSON.parse(e)}catch{return{mediaGenerated:!1,status:"error",message:this.out("Incorrect JSON format.")}}let r=t.trim();if(!r)return{mediaGenerated:!1,status:"error",message:this.out("Please provide model information in the context.")};let o={};o.model=r,o.customData=this.builder.settings.customData,o.payload=s,this.builder.payloads.push(o),this.builder.settings.consoleLog&&console.log(o);const a=this.builder.settings.generateMediaUrl_Google;let u={"Content-Type":"application/json",...this.builder.settings.headers};const l=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(o)})).json();this.builder.settings.consoleLog&&console.log(l);const h=l.data;let p=this.renderResult(h,i,n);return{mediaGenerated:!0,status:"success",markdown:p.markdown,output:p.output,output2:p.output2}}async uploadMultiple(){let e=[],t=this.builder.getFormValues();for(const i of t)if(i.value instanceof FileList&&i.type==="multifile"){const n={};if(n.name=i.name,n.files=[],this.builder.selectedFiles&&this.builder.selectedFiles.length>0){const r=[];for(let o=0;o<this.builder.selectedFiles.length;o++){const a=this.builder.selectedFiles[o],u=new FormData;u.append("file",a),u.append("customData",this.builder.settings.customData);let d=this.builder.settings.uploadMediaUrl_Fal;const h=await(await fetch(d,{method:"POST",body:u})).json();if(h.ok){const p=h.url;n.files.push(p),this.builder.filesUploaded["file_"+o]=p}r.push(n)}return r}const s=i.value;if(s.length>0){let r=0;for(const o of s){r++;const a=new FormData;a.append("file",o),a.append("customData",this.builder.settings.customData);let u=this.builder.settings.uploadMediaUrl_Fal;const l=await(await fetch(u,{method:"POST",body:a})).json();if(l.ok){const h=l.url;n.files.push(h),this.builder.filesUploaded["file_"+r]=h}}}e.push(n)}return e}async generate(e,t,i,n,s,r,o){if(i=i||this.builder.settings.defaultMediaGenerationProvider,i==="google"&&e.trim().startsWith("{"))return this.generate_GoogleMediaByJSON(e,t,r,o);this.builder.isMediaGenerating=!0,this.mediaController=new AbortController,this.builder.mediaSignal=this.mediaController.signal;let a,u=!1,d;if(e.trim().startsWith("{"))try{d=JSON.parse(e),d&&typeof d=="object"&&(u=!0)}catch{return{mediaGenerated:!1,status:"error",message:this.out("Incorrect JSON format.")}}if(u){let l=t.trim();if(!l)return{mediaGenerated:!1,status:"error",message:this.out("Please provide model information in the context.")};let h=await this.uploadMultiple();((g,v)=>{const f=m=>{if(Array.isArray(m)){const y=m[0],k=v.find(x=>x.name===y);if(k&&m.every(x=>x===y))return k.files;for(let x=0;x<m.length;x++)m[x]=f(m[x])}else if(typeof m=="object"&&m!==null)for(let y in m)m[y]=f(m[y]);return m};return f(g)})(d,h),i||(l.startsWith("fal")?i="fal":i="replicate");const b=g=>typeof g=="object"&&g!==null&&!Array.isArray(g),w=await this.builder.upload.getInputURLs(i);if(w.error)return{mediaGenerated:!1,status:"error",message:w.error};Object.keys(d).forEach(g=>{Object.keys(w).forEach(v=>{if(d[g]===v){let f=w[v];d[g]=f}if(Array.isArray(d[g])){for(let f=0;f<d[g].length;f++)if(d[g][f]===v){let m=w[v];d[g][f]=m}}})}),Object.keys(d).forEach(g=>{let v=d[g];if(b(v))for(const f in v)Object.prototype.hasOwnProperty.call(v,f)&&Object.keys(w).forEach(m=>{if(v[f]===m){let y=w[m];v[f]=y,m===y&&!y.startsWith("http")&&(v[f]="")}});if(Array.isArray(v)){for(let f=0;f<v.length;f++)if(b(v[f]))for(const m in v[f])Object.prototype.hasOwnProperty.call(v[f],m)&&Object.keys(w).forEach(y=>{if(v[f][m]===y){let k=w[y];v[f][m]=k,y===k&&!k.startsWith("http")&&(v[f][m]="")}});d[g]=[...v.filter(f=>f!=="")]}});let _={};if(_.model=l,_.customData=this.builder.settings.customData,i==="replicate"&&l.indexOf(":")!==-1){const g=l.split(":");_.version=g[1]}if(i==="replicate")if(l.indexOf(":")!==-1){let g=this.builder.settings.replicateEndpoint1;_.endpoint=g,_.payload=d,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 1")}else{let g=this.builder.settings.replicateEndpoint2;g=g.replace("{MODEL}",_.model),_.endpoint=g,_.payload=d,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 2")}else if(i==="fal"){let g=`https://queue.fal.run/${_.model}`;_.endpoint=g,_.payload=d,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD")}return this.builder.payloads.push(_),this.builder.settings.consoleLog&&console.log(_),this.generateMediaByJSON(_,i,r,o)}try{if(a=await this.checkIntent(e,i,s),this.builder.settings.consoleLog&&console.log(a),!a)return{mediaGenerated:!1,status:"aborted",message:this.out("Request aborted.")};if(a.minimize_image){if(!a.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const h=await this.builder.upload.getInputURLs();if(h.error)return{mediaGenerated:!1,status:"error",message:h.error};let b={image_url:h[a.image_url]||a.image_url,customData:this.builder.settings.customData};this.builder.payloads.push(b),this.builder.settings.consoleLog&&console.log(b);let w={"Content-Type":"application/json",...this.builder.settings.headers};const g=await(await fetch(this.builder.settings.minimizeImageUrl,{signal:this.builder.mediaSignal,method:"POST",headers:w,body:JSON.stringify(b)})).json();if(this.builder.output.push(g),g.error)return this.builder.settings.consoleLog&&console.log(g.error),this.builder.isMediaGenerating=!1,{mediaGenerated:!1,status:"error",message:g.error};{const v=g.url,f=`
262
262
  <div class="image-container">
263
263
  <div>
264
264
  <img src="${v}" />
@@ -267,25 +267,25 @@ Check the information and return the details.
267
267
  <a class="link-download" href="${v}" download>${this.out("Download")}</a>
268
268
  </div>
269
269
  </div>
270
- </div>`;let m=`![](${v})`;return o?(r.innerHTML="",r.remove()):(r.innerHTML=f,this.builder.outputHtml+=`<div class="result-container">${f}</div>`),this.builder.isMediaGenerating=!1,{mediaGenerated:!0,status:"success",markdown:m,output:[v]}}}else{if(i==="fal")return this.generateFal(a,r,o);if(i==="replicate")return this.generateReplicate(a,r,o);if(i==="google")return this.generateGoogle(a,r,o);if(i==="openai")return this.generateOpenAI(a,r,o)}}catch(l){return this.builder.settings.consoleLog&&console.log(l),this.builder.isMediaGenerating=!1,l.name==="AbortError"?{mediaGenerated:!1,status:"aborted",message:this.out("Request aborted.")}:{mediaGenerated:!1,status:"error",message:this.out("Request failed.")}}return this.builder.isMediaGenerating=!1,{mediaGenerated:!1,status:"error",message:this.out("Request failed.")}}async generateMediaByJSON(e,t,i,n){let s,r=!1;if(t==="replicate"&&this.builder.settings.generateMediaUrl){if(s=this.builder.settings.generateMediaUrl,!s)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl.")}}else if(t==="replicate"&&this.builder.settings.generateMediaUrl_Replicate){if(s=this.builder.settings.generateMediaUrl_Replicate,!s)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Replicate.")};r=!0}else if(t==="fal"&&(s=this.builder.settings.generateMediaUrl_Fal,!s))return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Fal.")};let o={"Content-Type":"application/json",...this.builder.settings.headers};const d=await(await fetch(s,{signal:this.builder.mediaSignal,method:"POST",headers:o,body:JSON.stringify(e)})).json();if(this.builder.isMediaGenerating=!1,t==="fal"){let u=d.request_id;return this.waitingFal(e,u,i,n)}if(d.error)return this.builder.settings.consoleLog&&console.log(d.error),{mediaGenerated:!1,status:"error",message:d.error};if(r){let u;if(d.ok){if(u=d.data.id,!u)return{mediaGenerated:!1,status:"error",message:d.data&&d.data.detail}}else return{mediaGenerated:!1,status:"error",message:d.error};return this.waitingReplicate(e,u,i,n)}else{const u=d.data;let l=this.renderResult(u,i,n);return{mediaGenerated:!0,status:"success",markdown:l.markdown,output:l.output,output2:l.output2}}}getClosestAspectRatio(e,t){if(t===0)return"3:2";const i=e/t,n=[{aspect:"10:16",ratio:10/16},{aspect:"16:10",ratio:16/10},{aspect:"9:16",ratio:9/16},{aspect:"16:9",ratio:16/9},{aspect:"4:3",ratio:4/3},{aspect:"3:4",ratio:3/4},{aspect:"1:1",ratio:1},{aspect:"1:3",ratio:1/3},{aspect:"3:1",ratio:3},{aspect:"3:2",ratio:3/2},{aspect:"2:3",ratio:2/3}];let s=n[0],r=Math.abs(i-n[0].ratio);for(let o=1;o<n.length;o++){const a=Math.abs(i-n[o].ratio);a<r&&(r=a,s=n[o])}return s.aspect}out(e){if(this.opts.lang){let t=this.opts.lang[e];return t||e}else return e}}class pn{constructor(e={},t){const i={lang:[]};this.builder=t,this.opts=Object.assign({},i,e)}async getInputURLs(e){let t=this.builder.getFormValues();const i=this.builder.filesUploaded;if(Object.keys(i).length!==0)return i;for(const n of t)if(n.value instanceof FileList){let s=await this.processMediaInput(n.name,e),r=s.url;n.name===s.url&&(r=""),i[n.name]=r}else{if(n.name.indexOf("_mask")!==-1){let s=await this.processMaskInput(n.name,e);if(s.error)return{error:s.error};{let r=s.url;i[n.name]=r}}if(n.name.indexOf("__url")!==-1){let s;this.builder.settings.isBuilder?s=document.querySelector(this.builder.settings.previewSelector):s=this.builder.element;const r=s.querySelector(`input[name="${n.name}"]`);if(r){const o=r.value;i[n.name]=o}}}return Object.keys(i).forEach(n=>{if(n.endsWith("__url")){const s=n.replace("__url","");Object.prototype.hasOwnProperty.call(i,s)&&(i[s]=i[n]),delete i[n]}}),i}async processMaskInput(e,t){let i;if(this.builder.settings.isBuilder){if(!this.builder.settings.previewSelector)return{error:this.out("previewSelector not set.")};i=document.querySelector(this.builder.settings.previewSelector)}else i=this.builder.element;const n=i.querySelector(`input[type="hidden"][name="${e}"]`);if(!n)return{error:this.out("Unable to perform the request.")};if(n.value==="")return{error:this.out("Please brush the area you want to edit.")};let s=n.value.replace(/^data:image\/(png|svg\+xml|jpeg|gif|webp);base64,/,"");if(s==="")return{error:this.out("Please brush over the areas to remove objects before continuing.")};let r,o=this.builder.getId(),a={image:s,filename:`${e}_${o}.png`,customData:this.builder.settings.customData},d;t==="replicate"?d=this.builder.settings.uploadBase64Url:t==="fal"?d=this.builder.settings.uploadBase64Url_Fal:d=this.builder.settings.uploadBase64Url_Fal||this.builder.settings.uploadBase64Url;let u={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(d,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(a)})).json();return h.ok&&(r=h.url),r?{url:r}:{error:this.out("Upload mask failed.")}}async processMediaInput(e,t){if(!e)return!1;let i;if(!this.isFullUrl(e)){let r=e;i=this.getFileInput(r)||this.getFileInput()}let n="",s;if(this.builder.photoBlob[e]){let r=this.builder.getId();const o=new FormData;o.append("file",this.builder.photoBlob[e],`photo_${r}.jpg`),o.append("customData",this.builder.settings.customData);let a;t==="replicate"?a=this.builder.settings.uploadMediaUrl:t==="fal"?a=this.builder.settings.uploadMediaUrl_Fal:a=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const u=await(await fetch(a,{method:"POST",body:o})).json();return u.ok?(s=u.url,n=u.filename,{filename:n,url:s}):{error:this.out("Upload file failed.")}}if(this.builder.selectedFiles&&this.builder.selectedFiles.length>0){const r=new FormData;r.append("file",this.builder.selectedFiles[0]),r.append("customData",this.builder.settings.customData);let o;t==="replicate"?o=this.builder.settings.uploadMediaUrl:t==="fal"?o=this.builder.settings.uploadMediaUrl_Fal:o=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const d=await(await fetch(o,{method:"POST",body:r})).json();return d.ok?(s=d.url,n=d.filename,{filename:n,url:s}):{error:this.out("Upload file failed.")}}if(i){const r=i.files[0];if(r){n=r.name;const o=new FormData;o.append("file",r),o.append("customData",this.builder.settings.customData);let a;t==="replicate"?a=this.builder.settings.uploadMediaUrl:t==="fal"?a=this.builder.settings.uploadMediaUrl_Fal:a=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const u=await(await fetch(a,{method:"POST",body:o})).json();if(u.ok)s=u.url,n=u.filename;else return{error:this.out("Upload file failed.")}}else s=e}else s=e;return{filename:n,url:s}}getFileInput(e){let t;if(this.builder.settings.isBuilder){if(!this.builder.settings.previewSelector)return console.log("previewSelector not set."),null;t=document.querySelector(this.builder.settings.previewSelector)}else t=this.builder.element;return t?e?t.querySelector(`input[type="file"][name="${e}"]`):t.querySelector('input[type="file"]'):null}isFullUrl(e){return e.indexOf("/")!==-1}out(e){if(this.opts.lang){let t=this.opts.lang[e];return t||e}else return e}}class fn{constructor(e,t={}){const i={lang:[]};this.settings=Object.assign({},i,t),this.empty=!0,this.element=e,this.init()}loadUrl(e){const t=this.element.querySelector("img");t.src=e,this.loaded()}loadImage(e){if(e){const t=new FileReader;t.onload=i=>{this.element.querySelector("img").setAttribute("src",i.target.result)},t.readAsDataURL(e)}}setImage(e){if(e){const t=this.element.querySelector("img");t.src=e}}clearImage(){this.element.style.display=""}out(e){let t=this.settings.lang[e];return t||e}init(){const e=this.element;e.className="imagemask-wrapper";const t=document.createElement("div");t.className="imagemask-overlay",e.appendChild(t);const i=document.createElement("button");i.className="btn-close-imagemask",i.title=this.out("Close"),i.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
270
+ </div>`;let m=`![](${v})`;return o?(r.innerHTML="",r.remove()):(r.innerHTML=f,this.builder.outputHtml+=`<div class="result-container">${f}</div>`),this.builder.isMediaGenerating=!1,{mediaGenerated:!0,status:"success",markdown:m,output:[v]}}}else{if(i==="fal")return this.generateFal(a,r,o);if(i==="replicate")return this.generateReplicate(a,r,o);if(i==="google")return this.generateGoogle(a,r,o);if(i==="openai")return this.generateOpenAI(a,r,o)}}catch(l){return this.builder.settings.consoleLog&&console.log(l),this.builder.isMediaGenerating=!1,l.name==="AbortError"?{mediaGenerated:!1,status:"aborted",message:this.out("Request aborted.")}:{mediaGenerated:!1,status:"error",message:this.out("Request failed.")}}return this.builder.isMediaGenerating=!1,{mediaGenerated:!1,status:"error",message:this.out("Request failed.")}}async generateMediaByJSON(e,t,i,n){let s,r=!1;if(t==="replicate"&&this.builder.settings.generateMediaUrl){if(s=this.builder.settings.generateMediaUrl,!s)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl.")}}else if(t==="replicate"&&this.builder.settings.generateMediaUrl_Replicate){if(s=this.builder.settings.generateMediaUrl_Replicate,!s)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Replicate.")};r=!0}else if(t==="fal"&&(s=this.builder.settings.generateMediaUrl_Fal,!s))return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Fal.")};let o={"Content-Type":"application/json",...this.builder.settings.headers};const u=await(await fetch(s,{signal:this.builder.mediaSignal,method:"POST",headers:o,body:JSON.stringify(e)})).json();if(this.builder.isMediaGenerating=!1,t==="fal"){let d=u.request_id;return this.waitingFal(e,d,i,n)}if(u.error)return this.builder.settings.consoleLog&&console.log(u.error),{mediaGenerated:!1,status:"error",message:u.error};if(r){let d;if(u.ok){if(d=u.data.id,!d)return{mediaGenerated:!1,status:"error",message:u.data&&u.data.detail}}else return{mediaGenerated:!1,status:"error",message:u.error};return this.waitingReplicate(e,d,i,n)}else{const d=u.data;let l=this.renderResult(d,i,n);return{mediaGenerated:!0,status:"success",markdown:l.markdown,output:l.output,output2:l.output2}}}getClosestAspectRatio(e,t){if(t===0)return"3:2";const i=e/t,n=[{aspect:"10:16",ratio:10/16},{aspect:"16:10",ratio:16/10},{aspect:"9:16",ratio:9/16},{aspect:"16:9",ratio:16/9},{aspect:"4:3",ratio:4/3},{aspect:"3:4",ratio:3/4},{aspect:"1:1",ratio:1},{aspect:"1:3",ratio:1/3},{aspect:"3:1",ratio:3},{aspect:"3:2",ratio:3/2},{aspect:"2:3",ratio:2/3}];let s=n[0],r=Math.abs(i-n[0].ratio);for(let o=1;o<n.length;o++){const a=Math.abs(i-n[o].ratio);a<r&&(r=a,s=n[o])}return s.aspect}out(e){if(this.opts.lang){let t=this.opts.lang[e];return t||e}else return e}}class pn{constructor(e={},t){const i={lang:[]};this.builder=t,this.opts=Object.assign({},i,e)}async getInputURLs(e){let t=this.builder.getFormValues();const i=this.builder.filesUploaded;if(Object.keys(i).length!==0)return i;for(const n of t)if(n.value instanceof FileList){let s=await this.processMediaInput(n.name,e),r=s.url;n.name===s.url&&(r=""),i[n.name]=r}else{if(n.name.indexOf("_mask")!==-1){let s=await this.processMaskInput(n.name,e);if(s.error)return{error:s.error};{let r=s.url;i[n.name]=r}}if(n.name.indexOf("__url")!==-1){let s;this.builder.settings.isBuilder?s=document.querySelector(this.builder.settings.previewSelector):s=this.builder.element;const r=s.querySelector(`input[name="${n.name}"]`);if(r){const o=r.value;i[n.name]=o}}}return Object.keys(i).forEach(n=>{if(n.endsWith("__url")){const s=n.replace("__url","");Object.prototype.hasOwnProperty.call(i,s)&&(i[s]=i[n]),delete i[n]}}),i}async processMaskInput(e,t){let i;if(this.builder.settings.isBuilder){if(!this.builder.settings.previewSelector)return{error:this.out("previewSelector not set.")};i=document.querySelector(this.builder.settings.previewSelector)}else i=this.builder.element;const n=i.querySelector(`input[type="hidden"][name="${e}"]`);if(!n)return{error:this.out("Unable to perform the request.")};if(n.value==="")return{error:this.out("Please brush the area you want to edit.")};let s=n.value.replace(/^data:image\/(png|svg\+xml|jpeg|gif|webp);base64,/,"");if(s==="")return{error:this.out("Please brush over the areas to remove objects before continuing.")};let r,o=this.builder.getId(),a={image:s,filename:`${e}_${o}.png`,customData:this.builder.settings.customData},u;t==="replicate"?u=this.builder.settings.uploadBase64Url:t==="fal"?u=this.builder.settings.uploadBase64Url_Fal:u=this.builder.settings.uploadBase64Url_Fal||this.builder.settings.uploadBase64Url;let d={"Content-Type":"application/json",...this.builder.settings.headers},h=await(await fetch(u,{signal:this.builder.mediaSignal,method:"POST",headers:d,body:JSON.stringify(a)})).json();return h.ok&&(r=h.url),r?{url:r}:{error:this.out("Upload mask failed.")}}async processMediaInput(e,t){if(!e)return!1;let i;if(!this.isFullUrl(e)){let r=e;i=this.getFileInput(r)||this.getFileInput()}let n="",s;if(this.builder.photoBlob[e]){let r=this.builder.getId();const o=new FormData;o.append("file",this.builder.photoBlob[e],`photo_${r}.jpg`),o.append("customData",this.builder.settings.customData);let a;t==="replicate"?a=this.builder.settings.uploadMediaUrl:t==="fal"?a=this.builder.settings.uploadMediaUrl_Fal:a=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const d=await(await fetch(a,{method:"POST",body:o})).json();return d.ok?(s=d.url,n=d.filename,{filename:n,url:s}):{error:this.out("Upload file failed.")}}if(this.builder.selectedFiles&&this.builder.selectedFiles.length>0){const r=new FormData;r.append("file",this.builder.selectedFiles[0]),r.append("customData",this.builder.settings.customData);let o;t==="replicate"?o=this.builder.settings.uploadMediaUrl:t==="fal"?o=this.builder.settings.uploadMediaUrl_Fal:o=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const u=await(await fetch(o,{method:"POST",body:r})).json();return u.ok?(s=u.url,n=u.filename,{filename:n,url:s}):{error:this.out("Upload file failed.")}}if(i){const r=i.files[0];if(r){n=r.name;const o=new FormData;o.append("file",r),o.append("customData",this.builder.settings.customData);let a;t==="replicate"?a=this.builder.settings.uploadMediaUrl:t==="fal"?a=this.builder.settings.uploadMediaUrl_Fal:a=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const d=await(await fetch(a,{method:"POST",body:o})).json();if(d.ok)s=d.url,n=d.filename;else return{error:this.out("Upload file failed.")}}else s=e}else s=e;return{filename:n,url:s}}getFileInput(e){let t;if(this.builder.settings.isBuilder){if(!this.builder.settings.previewSelector)return console.log("previewSelector not set."),null;t=document.querySelector(this.builder.settings.previewSelector)}else t=this.builder.element;return t?e?t.querySelector(`input[type="file"][name="${e}"]`):t.querySelector('input[type="file"]'):null}isFullUrl(e){return e.indexOf("/")!==-1}out(e){if(this.opts.lang){let t=this.opts.lang[e];return t||e}else return e}}class fn{constructor(e,t={}){const i={lang:[]};this.settings=Object.assign({},i,t),this.empty=!0,this.element=e,this.init()}loadUrl(e){const t=this.element.querySelector("img");t.src=e,this.loaded()}loadImage(e){if(e){const t=new FileReader;t.onload=i=>{this.element.querySelector("img").setAttribute("src",i.target.result)},t.readAsDataURL(e)}}setImage(e){if(e){const t=this.element.querySelector("img");t.src=e}}clearImage(){this.element.style.display=""}out(e){let t=this.settings.lang[e];return t||e}init(){const e=this.element;e.className="imagemask-wrapper";const t=document.createElement("div");t.className="imagemask-overlay",e.appendChild(t);const i=document.createElement("button");i.className="btn-close-imagemask",i.title=this.out("Close"),i.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"
271
271
  viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"
272
272
  stroke-linejoin="round" class="icon-close">
273
273
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
274
274
  <path d="M18 6l-12 12" /><path d="M6 6l12 12" />
275
275
  </svg>`,e.appendChild(i);const n=document.createElement("div");n.className="imagemask-body",e.appendChild(n);const s=document.createElement("div");s.className="imagemask-container",n.appendChild(s);const r=document.createElement("div");r.className="imagemask-controls",n.appendChild(r);const o=document.createElement("label");r.appendChild(o),o.innerHTML=`${this.out("Brush Size")}:
276
- <input type="range" class="brush-size" min="5" max="100" value="30">`;const a=o.querySelector(".brush-size"),d=document.createElement("button");d.className="btn-undobrush",d.title=this.out("Undo"),d.innerHTML=`
276
+ <input type="range" class="brush-size" min="5" max="100" value="30">`;const a=o.querySelector(".brush-size"),u=document.createElement("button");u.className="btn-undobrush",u.title=this.out("Undo"),u.innerHTML=`
277
277
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
278
278
  class="icon-undo">
279
279
  <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
280
280
  <path d="M9 14l-4 -4l4 -4"></path>
281
281
  <path d="M5 10h11a4 4 0 1 1 0 8h-1"></path>
282
- </svg>`,r.appendChild(d);const u=document.createElement("button");u.className="btn-redobrush",u.title=this.out("Redo"),u.innerHTML=`
282
+ </svg>`,r.appendChild(u);const d=document.createElement("button");d.className="btn-redobrush",d.title=this.out("Redo"),d.innerHTML=`
283
283
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
284
284
  class="icon-redo">
285
285
  <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
286
286
  <path d="M15 14l4 -4l-4 -4"></path>
287
287
  <path d="M19 10h-11a4 4 0 1 0 0 8h1"></path>
288
- </svg>`,r.appendChild(u);const l=document.createElement("button");l.className="btn-clearbrush",l.title=this.out("Clear"),l.innerHTML=`
288
+ </svg>`,r.appendChild(d);const l=document.createElement("button");l.className="btn-clearbrush",l.title=this.out("Clear"),l.innerHTML=`
289
289
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
290
290
  stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"
291
291
  class="icon-eraser">
@@ -300,36 +300,36 @@ Check the information and return the details.
300
300
  <path d="M8 20l-4 0l0 -4" /><path d="M4 20l6 -6" />
301
301
  <path d="M16 20l4 0l0 -4" /><path d="M14 14l6 6" />
302
302
  <path d="M8 4l-4 0l0 4" /><path d="M4 4l6 6" />
303
- </svg>`,r.appendChild(h);const p=document.createElement("input");p.type="hidden",p.name=this.settings.name,p.className="inp-imagemask",p.value="",n.appendChild(p);const b=document.createElement("canvas");b.className="imagemask";const w=b.getContext("2d",{willReadFrequently:!0}),_=document.createElement("canvas"),g=_.getContext("2d",{willReadFrequently:!0}),v=this.element.querySelector(".inp-imagemask"),f=T=>{const $=document.createElement("canvas"),N=$.getContext("2d",{willReadFrequently:!0});$.width=T.width,$.height=T.height,N.clearRect(0,0,T.width,T.height),N.fillStyle="black",N.fillRect(0,0,T.width,T.height),N.drawImage(T,0,0);const U=$.toDataURL("image/png");let G=document.querySelector(".imagemask-output");G||(G=document.createElement("img"),G.className="imagemask-output",document.body.appendChild(G)),G.src=U,this.empty||(v.value=U)};let m=[],y=[];const k=()=>{m.push(_.toDataURL()),m.length>10&&m.shift(),y=[]},x=T=>{const $=new Image;$.src=T,$.onload=()=>{w.clearRect(0,0,b.width,b.height),w.drawImage($,0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),g.drawImage($,0,0,_.width,_.height),f(_)}};b.addEventListener("mousedown",()=>{k()}),d.addEventListener("click",T=>{T.preventDefault(),m.length>0&&(y.push(b.toDataURL()),x(m.pop()))}),u.addEventListener("click",T=>{T.preventDefault(),y.length>0&&(m.push(b.toDataURL()),x(y.pop()))});const S=document.createElement("img");s.appendChild(S),s.appendChild(b),this.loaded=()=>{s.style.display="flex";const T=document.querySelector(".imagemask-controls");T.style.display="flex",e.style.display="flex",A(),m=[],y=[],w.clearRect(0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),this.empty=!0,v.value="";try{f(_)}catch{}},S.onload=()=>{this.loaded()};let E=null,C=null;const A=()=>{b.width>0&&b.height>0&&(E=w.getImageData(0,0,b.width,b.height),C=g.getImageData(0,0,_.width,_.height));const T=S.offsetWidth,$=S.offsetHeight,N=window.devicePixelRatio||1;b.width=T*N,b.height=$*N,w.scale(N,N),b.style.width=`${T}px`,b.style.height=`${$}px`;const U=S.naturalWidth,G=S.naturalHeight;if(_.width=U*N,_.height=G*N,g.scale(N,N),_.style.width=`${U}px`,_.style.height=`${G}px`,E){const Y=document.createElement("canvas");Y.width=E.width,Y.height=E.height,Y.getContext("2d").putImageData(E,0,0);const re=document.createElement("canvas");re.width=C.width,re.height=C.height,re.getContext("2d").putImageData(C,0,0),w.drawImage(Y,0,0,E.width,E.height,0,0,b.width,b.height),g.drawImage(re,0,0,C.width,C.height,0,0,_.width,_.height)}};let L=!1,D=parseInt(a.value,10);a.addEventListener("input",T=>{D=parseInt(T.target.value,10)});const I=T=>{const $=b.getBoundingClientRect();if(T.touches){const N=T.touches[0];return{x:N.clientX-$.left,y:N.clientY-$.top}}return{x:T.clientX-$.left,y:T.clientY-$.top}},O=T=>{L=!0,q(T)},R=()=>{L=!1,w.beginPath(),this.empty=!1,f(_)},q=T=>{if(!L)return;const{x:$,y:N}=I(T),U=_.width/b.width,G=_.height/b.height,Y=$*U,he=N*G;w.fillStyle="rgb(255, 255, 255)",w.beginPath(),w.arc($,N,D/2,0,Math.PI*2),w.fill(),g.fillStyle="rgb(255, 255, 255)",g.beginPath(),g.arc(Y,he,D/2*U,0,Math.PI*2),g.fill()};b.addEventListener("mousedown",O),b.addEventListener("mouseup",R),b.addEventListener("mousemove",q),b.addEventListener("touchstart",T=>{O(T),T.preventDefault()},{passive:!1}),b.addEventListener("touchend",T=>{R(),T.preventDefault()}),b.addEventListener("touchmove",T=>{q(T),T.preventDefault()},{passive:!1}),l.addEventListener("click",T=>{T.preventDefault(),k(),w.clearRect(0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),this.empty=!0,v.value="",f(_)}),window.addEventListener("resize",A);const M=T=>{T?(e.setAttribute("aria-modal","true"),e.setAttribute("role","dialog"),e.classList.add("fullscreen"),t.style.display="block",i.style.display="flex",h.style.display="none"):(e.removeAttribute("aria-modal"),e.removeAttribute("role"),e.classList.remove("fullscreen"),t.style.display="none",i.style.display="none",h.style.display=""),A()};h.addEventListener("click",T=>{T.preventDefault(),M(!0)}),i.addEventListener("click",T=>{T.preventDefault(),M(!1)}),document.addEventListener("keydown",T=>{T.key==="Escape"&&M(!1)})}}class gn{constructor(e,t={}){const i={lang:[],headers:{},fileUploadText:"Drag and drop your file here.",multiFileUploadText:"Drag and drop your files here.",model:"gpt-4o-mini",model2:"gpt-4o-mini",sendCommandUrl:"/sendcommand",sendCommandStreamUrl:"/getstream",consoleLog:!1,saveResults:!1,disableMediaGeneration:!1,disableMediaGenerationTitle:"Demo Info",disableMediaGenerationMessage:"This is an online demo and media generation is currently disabled. Get the full version for complete functionality.",submitText:"Submit",resetText:"Reset",scrapeProvider:"firecrawl",scrapeLimit:6,scrapeExclude:["youtube.com","reddit.com","microsoft.com","mozilla.org"],inputCost:.15,outputCost:.6,_2dIllustrationStyleId:"bcaa0104-98ef-4cb8-a012-124dad015756",templateFilters:["all","image","video","audio","text"],templatesConfig:{fal:!0,replicate:!1,web:!1},defaultMediaGenerationProvider:"fal",replicateEndpoint1:"https://api.replicate.com/v1/predictions",replicateEndpoint2:"https://api.replicate.com/v1/models/{MODEL}/predictions",falStatusEndpoint:"https://queue.fal.run/{MODEL}/requests/{REQUEST_ID}/status",falResultEndpoint:"https://queue.fal.run/{MODEL}/requests/{REQUEST_ID}",replicateStatusEndpoint:"https://api.replicate.com/v1/predictions/{REQUEST_ID}",modelFallback:!1,defaultModels:{image_generation:{openai:["gpt-image-1"]},image_variation_generation:{openai:["gpt-image-1"]},text_to_image_generation:{fal:["fal-ai/flux-1/schnell","fal-ai/flux-1/dev","fal-ai/flux-pro/v1.1","fal-ai/flux-pro/v1.1-ultra","fal-ai/recraft-v3","fal-ai/recraft-20b","fal-ai/ideogram/v2a","fal-ai/hidream-i1-fast","fal-ai/hidream-i1-dev","fal-ai/hidream-i1-full","fal-ai/gemini-flash-edit/multi"],replicate:["black-forest-labs/flux-schnell","black-forest-labs/flux-dev","black-forest-labs/flux-1.1-pro","black-forest-labs/flux-1.1-pro-ultra","recraft-ai/recraft-v3","ideogram-ai/ideogram-v2a"],google:["gemini-2.0-flash-exp-image-generation"],openai:["gpt-image-1"]},image_to_video_generation:{fal:["fal-ai/kling-video/v1.6/standard/image-to-video","fal-ai/kling-video/v1.6/pro/image-to-video","fal-ai/kling-video/v2.1/standard/image-to-video","fal-ai/kling-video/v2.1/pro/image-to-video","fal-ai/kling-video/v2.1/master/image-to-video","fal-ai/minimax/video-01-live/image-to-video","fal-ai/luma-dream-machine/ray-2/image-to-video"],replicate:["kwaivgi/kling-v1.6-standard","kwaivgi/kling-v1.6-pro","minimax/video-01-live","luma/ray"]},text_to_video_generation:{fal:["fal-ai/kling-video/v1.6/standard/text-to-video","fal-ai/kling-video/v2.1/master/text-to-video","fal-ai/minimax/video-01-live ","fal-ai/luma-dream-machine/ray-2"],replicate:["kwaivgi/kling-v1.6-standard","minimax/video-01","luma/ray"]},upscale_image:{fal:["fal-ai/clarity-upscaler"],replicate:["recraft-ai/recraft-crisp-upscale"]},describe_image:{fal:["fal-ai/any-llm/vision"],replicate:[]},edit_area_in_image:{fal:["fal-ai/flux-pro/v1/fill"],replicate:["black-forest-labs/flux-fill-pro"],google:["gemini-2.0-flash-exp-image-generation"],openai:["gpt-image-1"]},edit_image:{fal:["fal-ai/gemini-flash-edit"],replicate:[],openai:["gpt-image-1"]},text_to_2d_illustration_generation:{fal:["fal-ai/recraft-v3"],replicate:[]},text_to_digital_illustration_generation:{fal:["fal-ai/recraft-v3"],replicate:["recraft-ai/recraft-v3"]},text_to_book_cover_generation:{fal:["fal-ai/recraft-v3"],replicate:[]},text_to_speech:{fal:["fal-ai/elevenlabs/tts/multilingual-v2"],replicate:["jaaari/kokoro-82m:f559560eb822dc509045f3921a1921234918b91739db4bf3daab2169b71c7a13"]}},ttsMaxCharacters:3e3,alwaysVisibleSubmit:!1};this.settings=Object.assign({},i,t),this.listeners={},window._txt&&(this.settings.lang=window._txt),this.steps=[];let n=this.settings.onChange;if(this.settings.onChange=s=>{n&&n.call(this,s)},!e)throw new Error("A valid DOM element is required.");e.classList.add("formview-container"),e.classList.add("fb-ui"),this.element=e,this.media=new hn({lang:this.settings.lang},this),this.upload=new pn({lang:this.settings.lang},this)}on(e,t){return this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),this}off(e,t){this.listeners[e]&&this.listeners[e].delete(t)}trigger(e,t){this.listeners[e]&&this.listeners[e].forEach(i=>i(t))}async loadTemplates(){if(!this.settings.templatesUrl){console.log(this.out("Template URL is not set."));return}let e=document.querySelector(this.settings.templatesSelector);if(e){e.classList.remove("hidden"),e.classList.add("formtemplates-container"),e.classList.add("fb-ui");let n=(await(await fetch(this.settings.templatesUrl,{method:"GET"})).json()).data;e.innerHTML="",n=n.filter(l=>{const h=l.supports||[];if(h.length===0)return!0;const{fal:p,replicate:b,web:w,openai:_,google:g}=this.settings.templatesConfig;return!w&&h.includes("web")||!g&&h.includes("google")||!_&&h.includes("openai")?!1:!p&&!b?!(h.includes("fal")||h.includes("replicate")):!p&&h.includes("fal")?h.includes("replicate"):!b&&h.includes("replicate")?h.includes("fal"):!0});const r=this.settings.templateFilters,o={all:{desc:this.out("All")},image:{desc:this.out("Image")},video:{desc:this.out("Video")},audio:{desc:this.out("Audio")},web:{desc:this.out("Web")},text:{desc:this.out("Text")}},a=document.createElement("div");a.className="app-filters",e.appendChild(a);const d=document.createElement("ul");d.className="app-list",e.appendChild(d);const u=l=>{let h=n.filter(b=>l==="all"||b.categories.includes(l));const p=this.settings.templateOutput||["image","video","audio","text"];h=h.filter(b=>b.categories.every(w=>p.includes(w))),this.renderList(h,d)};r.forEach(l=>{const h=document.createElement("button");h.textContent=o[l].desc,h.setAttribute("data-value",l),l==="all"&&h.classList.add("active"),h.addEventListener("click",()=>{a.querySelectorAll("button").forEach(b=>b.classList.remove("active")),h.classList.add("active"),u(l)}),a.appendChild(h)}),u("all")}}async selectFile(e){const t=this.element.querySelector(".file-input-wrapper");if(!t)return;const i=t.querySelector('input[type="file"]');if(!i||!this.acceptsImagesOnly(i))return;let n;e.startsWith("http")?n=this.settings.viewFileUrl+"?url="+e:n=e;const r=await(await fetch(n)).blob(),o=new File([r],e.split("/").pop(),{type:r.type});this.element.querySelector(".div-selected-preview")||(this.selectedFiles=[]),i&&i.hasAttribute("multiple")?this.selectedFiles.some(u=>u.name===o.name)||this.selectedFiles.push(o):this.selectedFiles=[o],this.setSelectedFiles(this.selectedFiles),this.renderSelectedFiles(),t.closest(".image-mask")&&this.objImageMask&&this.objImageMask.loadImage(o)}setSelectedFiles(e){this.selectedFiles=e;const t=this.element.querySelector('input[type="file"]');t&&t.removeAttribute("required")}renderSelectedFiles(){const e=this.element.querySelector(".file-input-wrapper");if(!e)return;let t=this.element.querySelector(".div-selected-preview");t?t.innerHTML="":(t=document.createElement("div"),t.classList.add("div-selected-preview"),e.appendChild(t)),this.clearFileInput(),this.selectedFiles&&this.selectedFiles.forEach((i,n)=>{const s=document.createElement("div"),r=document.createElement("img");r.src=URL.createObjectURL(i);const o=document.createElement("button");o.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" class="">
303
+ </svg>`,r.appendChild(h);const p=document.createElement("input");p.type="hidden",p.name=this.settings.name,p.className="inp-imagemask",p.value="",n.appendChild(p);const b=document.createElement("canvas");b.className="imagemask";const w=b.getContext("2d",{willReadFrequently:!0}),_=document.createElement("canvas"),g=_.getContext("2d",{willReadFrequently:!0}),v=this.element.querySelector(".inp-imagemask"),f=T=>{const $=document.createElement("canvas"),N=$.getContext("2d",{willReadFrequently:!0});$.width=T.width,$.height=T.height,N.clearRect(0,0,T.width,T.height),N.fillStyle="black",N.fillRect(0,0,T.width,T.height),N.drawImage(T,0,0);const U=$.toDataURL("image/png");let G=document.querySelector(".imagemask-output");G||(G=document.createElement("img"),G.className="imagemask-output",document.body.appendChild(G)),G.src=U,this.empty||(v.value=U)};let m=[],y=[];const k=()=>{m.push(_.toDataURL()),m.length>10&&m.shift(),y=[]},x=T=>{const $=new Image;$.src=T,$.onload=()=>{w.clearRect(0,0,b.width,b.height),w.drawImage($,0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),g.drawImage($,0,0,_.width,_.height),f(_)}};b.addEventListener("mousedown",()=>{k()}),u.addEventListener("click",T=>{T.preventDefault(),m.length>0&&(y.push(b.toDataURL()),x(m.pop()))}),d.addEventListener("click",T=>{T.preventDefault(),y.length>0&&(m.push(b.toDataURL()),x(y.pop()))});const S=document.createElement("img");s.appendChild(S),s.appendChild(b),this.loaded=()=>{s.style.display="flex";const T=document.querySelector(".imagemask-controls");T.style.display="flex",e.style.display="flex",A(),m=[],y=[],w.clearRect(0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),this.empty=!0,v.value="";try{f(_)}catch{}},S.onload=()=>{this.loaded()};let E=null,C=null;const A=()=>{b.width>0&&b.height>0&&(E=w.getImageData(0,0,b.width,b.height),C=g.getImageData(0,0,_.width,_.height));const T=S.offsetWidth,$=S.offsetHeight,N=window.devicePixelRatio||1;b.width=T*N,b.height=$*N,w.scale(N,N),b.style.width=`${T}px`,b.style.height=`${$}px`;const U=S.naturalWidth,G=S.naturalHeight;if(_.width=U*N,_.height=G*N,g.scale(N,N),_.style.width=`${U}px`,_.style.height=`${G}px`,E){const Y=document.createElement("canvas");Y.width=E.width,Y.height=E.height,Y.getContext("2d").putImageData(E,0,0);const re=document.createElement("canvas");re.width=C.width,re.height=C.height,re.getContext("2d").putImageData(C,0,0),w.drawImage(Y,0,0,E.width,E.height,0,0,b.width,b.height),g.drawImage(re,0,0,C.width,C.height,0,0,_.width,_.height)}};let L=!1,D=parseInt(a.value,10);a.addEventListener("input",T=>{D=parseInt(T.target.value,10)});const I=T=>{const $=b.getBoundingClientRect();if(T.touches){const N=T.touches[0];return{x:N.clientX-$.left,y:N.clientY-$.top}}return{x:T.clientX-$.left,y:T.clientY-$.top}},O=T=>{L=!0,q(T)},R=()=>{L=!1,w.beginPath(),this.empty=!1,f(_)},q=T=>{if(!L)return;const{x:$,y:N}=I(T),U=_.width/b.width,G=_.height/b.height,Y=$*U,he=N*G;w.fillStyle="rgb(255, 255, 255)",w.beginPath(),w.arc($,N,D/2,0,Math.PI*2),w.fill(),g.fillStyle="rgb(255, 255, 255)",g.beginPath(),g.arc(Y,he,D/2*U,0,Math.PI*2),g.fill()};b.addEventListener("mousedown",O),b.addEventListener("mouseup",R),b.addEventListener("mousemove",q),b.addEventListener("touchstart",T=>{O(T),T.preventDefault()},{passive:!1}),b.addEventListener("touchend",T=>{R(),T.preventDefault()}),b.addEventListener("touchmove",T=>{q(T),T.preventDefault()},{passive:!1}),l.addEventListener("click",T=>{T.preventDefault(),k(),w.clearRect(0,0,b.width,b.height),g.clearRect(0,0,_.width,_.height),this.empty=!0,v.value="",f(_)}),window.addEventListener("resize",A);const M=T=>{T?(e.setAttribute("aria-modal","true"),e.setAttribute("role","dialog"),e.classList.add("fullscreen"),t.style.display="block",i.style.display="flex",h.style.display="none"):(e.removeAttribute("aria-modal"),e.removeAttribute("role"),e.classList.remove("fullscreen"),t.style.display="none",i.style.display="none",h.style.display=""),A()};h.addEventListener("click",T=>{T.preventDefault(),M(!0)}),i.addEventListener("click",T=>{T.preventDefault(),M(!1)}),document.addEventListener("keydown",T=>{T.key==="Escape"&&M(!1)})}}class gn{constructor(e,t={}){const i={lang:[],headers:{},fileUploadText:"Drag and drop your file here.",multiFileUploadText:"Drag and drop your files here.",model:"gpt-4o-mini",model2:"gpt-4o-mini",sendCommandUrl:"/sendcommand",sendCommandStreamUrl:"/getstream",consoleLog:!1,saveResults:!1,disableMediaGeneration:!1,disableMediaGenerationTitle:"Demo Info",disableMediaGenerationMessage:"This is an online demo and media generation is currently disabled. Get the full version for complete functionality.",submitText:"Submit",resetText:"Reset",scrapeProvider:"firecrawl",scrapeLimit:6,scrapeExclude:["youtube.com","reddit.com","microsoft.com","mozilla.org"],inputCost:.15,outputCost:.6,_2dIllustrationStyleId:"bcaa0104-98ef-4cb8-a012-124dad015756",templateFilters:["all","image","video","audio","text"],templatesConfig:{fal:!0,replicate:!1,web:!1},defaultMediaGenerationProvider:"fal",replicateEndpoint1:"https://api.replicate.com/v1/predictions",replicateEndpoint2:"https://api.replicate.com/v1/models/{MODEL}/predictions",falStatusEndpoint:"https://queue.fal.run/{MODEL}/requests/{REQUEST_ID}/status",falResultEndpoint:"https://queue.fal.run/{MODEL}/requests/{REQUEST_ID}",replicateStatusEndpoint:"https://api.replicate.com/v1/predictions/{REQUEST_ID}",modelFallback:!1,defaultModels:{image_generation:{openai:["gpt-image-1"]},image_variation_generation:{openai:["gpt-image-1"]},text_to_image_generation:{fal:["fal-ai/flux-1/schnell","fal-ai/flux-1/dev","fal-ai/flux-pro/v1.1","fal-ai/flux-pro/v1.1-ultra","fal-ai/recraft-v3","fal-ai/recraft-20b","fal-ai/ideogram/v2a","fal-ai/hidream-i1-fast","fal-ai/hidream-i1-dev","fal-ai/hidream-i1-full","fal-ai/gemini-flash-edit/multi"],replicate:["black-forest-labs/flux-schnell","black-forest-labs/flux-dev","black-forest-labs/flux-1.1-pro","black-forest-labs/flux-1.1-pro-ultra","recraft-ai/recraft-v3","ideogram-ai/ideogram-v2a"],google:["gemini-2.0-flash-exp-image-generation"],openai:["gpt-image-1"]},image_to_video_generation:{fal:["fal-ai/kling-video/v1.6/standard/image-to-video","fal-ai/kling-video/v1.6/pro/image-to-video","fal-ai/kling-video/v2.1/standard/image-to-video","fal-ai/kling-video/v2.1/pro/image-to-video","fal-ai/kling-video/v2.1/master/image-to-video","fal-ai/minimax/video-01-live/image-to-video","fal-ai/luma-dream-machine/ray-2/image-to-video"],replicate:["kwaivgi/kling-v1.6-standard","kwaivgi/kling-v1.6-pro","minimax/video-01-live","luma/ray"]},text_to_video_generation:{fal:["fal-ai/kling-video/v1.6/standard/text-to-video","fal-ai/kling-video/v2.1/master/text-to-video","fal-ai/minimax/video-01-live ","fal-ai/luma-dream-machine/ray-2"],replicate:["kwaivgi/kling-v1.6-standard","minimax/video-01","luma/ray"]},upscale_image:{fal:["fal-ai/clarity-upscaler"],replicate:["recraft-ai/recraft-crisp-upscale"]},describe_image:{fal:["fal-ai/any-llm/vision"],replicate:[]},edit_area_in_image:{fal:["fal-ai/flux-pro/v1/fill"],replicate:["black-forest-labs/flux-fill-pro"],google:["gemini-2.0-flash-exp-image-generation"],openai:["gpt-image-1"]},edit_image:{fal:["fal-ai/gemini-flash-edit"],replicate:[],openai:["gpt-image-1"]},text_to_2d_illustration_generation:{fal:["fal-ai/recraft-v3"],replicate:[]},text_to_digital_illustration_generation:{fal:["fal-ai/recraft-v3"],replicate:["recraft-ai/recraft-v3"]},text_to_book_cover_generation:{fal:["fal-ai/recraft-v3"],replicate:[]},text_to_speech:{fal:["fal-ai/elevenlabs/tts/multilingual-v2"],replicate:["jaaari/kokoro-82m:f559560eb822dc509045f3921a1921234918b91739db4bf3daab2169b71c7a13"]}},ttsMaxCharacters:3e3,alwaysVisibleSubmit:!1};this.settings=Object.assign({},i,t),this.listeners={},window._txt&&(this.settings.lang=window._txt),this.steps=[];let n=this.settings.onChange;if(this.settings.onChange=s=>{n&&n.call(this,s)},!e)throw new Error("A valid DOM element is required.");e.classList.add("formview-container"),e.classList.add("fb-ui"),this.element=e,this.media=new hn({lang:this.settings.lang},this),this.upload=new pn({lang:this.settings.lang},this)}on(e,t){return this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),this}off(e,t){this.listeners[e]&&this.listeners[e].delete(t)}trigger(e,t){this.listeners[e]&&this.listeners[e].forEach(i=>i(t))}async loadTemplates(){if(!this.settings.templatesUrl){console.log(this.out("Template URL is not set."));return}let e=document.querySelector(this.settings.templatesSelector);if(e){e.classList.remove("hidden"),e.classList.add("formtemplates-container"),e.classList.add("fb-ui");let n=(await(await fetch(this.settings.templatesUrl,{method:"GET"})).json()).data;e.innerHTML="",n=n.filter(l=>{const h=l.supports||[];if(h.length===0)return!0;const{fal:p,replicate:b,web:w,openai:_,google:g}=this.settings.templatesConfig;return!w&&h.includes("web")||!g&&h.includes("google")||!_&&h.includes("openai")?!1:!p&&!b?!(h.includes("fal")||h.includes("replicate")):!p&&h.includes("fal")?h.includes("replicate"):!b&&h.includes("replicate")?h.includes("fal"):!0});const r=this.settings.templateFilters,o={all:{desc:this.out("All")},image:{desc:this.out("Image")},video:{desc:this.out("Video")},audio:{desc:this.out("Audio")},web:{desc:this.out("Web")},text:{desc:this.out("Text")}},a=document.createElement("div");a.className="app-filters",e.appendChild(a);const u=document.createElement("ul");u.className="app-list",e.appendChild(u);const d=l=>{let h=n.filter(b=>l==="all"||b.categories.includes(l));const p=this.settings.templateOutput||["image","video","audio","text"];h=h.filter(b=>b.categories.every(w=>p.includes(w))),this.renderList(h,u)};r.forEach(l=>{const h=document.createElement("button");h.textContent=o[l].desc,h.setAttribute("data-value",l),l==="all"&&h.classList.add("active"),h.addEventListener("click",()=>{a.querySelectorAll("button").forEach(b=>b.classList.remove("active")),h.classList.add("active"),d(l)}),a.appendChild(h)}),d("all")}}async selectFile(e){const t=this.element.querySelector(".file-input-wrapper");if(!t)return;const i=t.querySelector('input[type="file"]');if(!i||!this.acceptsImagesOnly(i))return;let n;e.startsWith("http")?n=this.settings.viewFileUrl+"?url="+e:n=e;const r=await(await fetch(n)).blob(),o=new File([r],e.split("/").pop(),{type:r.type});this.element.querySelector(".div-selected-preview")||(this.selectedFiles=[]),i&&i.hasAttribute("multiple")?this.selectedFiles.some(d=>d.name===o.name)||this.selectedFiles.push(o):this.selectedFiles=[o],this.setSelectedFiles(this.selectedFiles),this.renderSelectedFiles(),t.closest(".image-mask")&&this.objImageMask&&this.objImageMask.loadImage(o)}setSelectedFiles(e){this.selectedFiles=e;const t=this.element.querySelector('input[type="file"]');t&&t.removeAttribute("required")}renderSelectedFiles(){const e=this.element.querySelector(".file-input-wrapper");if(!e)return;let t=this.element.querySelector(".div-selected-preview");t?t.innerHTML="":(t=document.createElement("div"),t.classList.add("div-selected-preview"),e.appendChild(t)),this.clearFileInput(),this.selectedFiles&&this.selectedFiles.forEach((i,n)=>{const s=document.createElement("div"),r=document.createElement("img");r.src=URL.createObjectURL(i);const o=document.createElement("button");o.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" class="">
304
304
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 7l16 0" /><path d="M10 11l0 6" /><path d="M14 11l0 6" /><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" />
305
- </svg>`,o.addEventListener("click",()=>{this.selectedFiles.splice(n,1),this.setSelectedFiles(this.selectedFiles),this.renderSelectedFiles(),e.closest(".image-mask")&&this.objImageMask&&this.objImageMask.clearImage()}),s.appendChild(r),s.appendChild(o),t.appendChild(s)})}clearSelectedFiles(){this.selectedFiles=[],this.setSelectedFiles(this.selectedFiles);let e=this.element.querySelector(".div-selected-preview");e&&(e.innerHTML="")}clearFileInput(){const e=this.element.querySelector(".file-input-wrapper");if(!e)return;const t=e.querySelector('input[type="file"]');if(!t)return;try{if(t.value="",t.files&&t.files.length>0){const a=new DataTransfer;t.files=a.files}}catch{}const i=e.querySelector(".file-drop-info-highlight");i&&(i.innerHTML="");const n=e.querySelector(".img-preview");n&&n.remove();const s=e.querySelector(".file-preview-container");s&&(s.innerHTML="");const r=e.querySelector(".btn-clearphoto");r&&r.click();const o=this.element.querySelector('input[type="file"]');o&&o.removeAttribute("required")}acceptsImagesOnly(e){const t=(e.getAttribute("accept")||"").split(",").map(i=>i.trim());return t.length===0?!1:t.every(i=>i.startsWith("image/")||i==="image/*")}renderList(e,t){t.innerHTML="",e.forEach(i=>{if(i.name){const n=document.createElement("li");t.appendChild(n);const s=document.createElement("a");s.setAttribute("href","#");let r=this.settings.assetsFolder,o=i.form.thumbnail,a="";if(r&&o){let h=r+o;a=`<img class="thumbnail" src="${h}" alt="${i.name}" />`,i.form.thumbnailFit&&(a=`<img class="thumbnail" style="object-fit:${i.form.thumbnailFit}" src="${h}" alt="${i.name}" />`)}const d=document.createElement("div");d.className="div-template-buttons";let u=!1,l=!1;if(this.settings.templateButtons&&this.settings.templateButtons.viewButton&&this.settings.templateButtons.viewButton.text){const h=document.createElement("button");h.className="btn-template-view",h.innerText=this.out(this.settings.templateButtons.viewButton.text),d.appendChild(h),h.addEventListener("click",p=>{if(p.preventDefault(),this.isGenerating){alert(this.out("Please wait until generation is complete."));return}this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateView",i)}),u=!0}if(this.settings.templateButtons&&this.settings.templateButtons.useButton&&this.settings.templateButtons.useButton.text){const h=document.createElement("button");h.className="btn-template-use",h.innerText=this.out(this.settings.templateButtons.useButton.text),d.appendChild(h),h.addEventListener("click",p=>{p.preventDefault(),this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateUse",i)}),l=!0}s.innerHTML=`
305
+ </svg>`,o.addEventListener("click",()=>{this.selectedFiles.splice(n,1),this.setSelectedFiles(this.selectedFiles),this.renderSelectedFiles(),e.closest(".image-mask")&&this.objImageMask&&this.objImageMask.clearImage()}),s.appendChild(r),s.appendChild(o),t.appendChild(s)})}clearSelectedFiles(){this.selectedFiles=[],this.setSelectedFiles(this.selectedFiles);let e=this.element.querySelector(".div-selected-preview");e&&(e.innerHTML="")}clearFileInput(){const e=this.element.querySelector(".file-input-wrapper");if(!e)return;const t=e.querySelector('input[type="file"]');if(!t)return;try{if(t.value="",t.files&&t.files.length>0){const a=new DataTransfer;t.files=a.files}}catch{}const i=e.querySelector(".file-drop-info-highlight");i&&(i.innerHTML="");const n=e.querySelector(".img-preview");n&&n.remove();const s=e.querySelector(".file-preview-container");s&&(s.innerHTML="");const r=e.querySelector(".btn-clearphoto");r&&r.click();const o=this.element.querySelector('input[type="file"]');o&&o.removeAttribute("required")}acceptsImagesOnly(e){const t=(e.getAttribute("accept")||"").split(",").map(i=>i.trim());return t.length===0?!1:t.every(i=>i.startsWith("image/")||i==="image/*")}renderList(e,t){t.innerHTML="",e.forEach(i=>{if(i.name){const n=document.createElement("li");t.appendChild(n);const s=document.createElement("a");s.setAttribute("href","#");let r=this.settings.assetsFolder,o=i.form.thumbnail,a="";if(r&&o){let h=r+o;a=`<img class="thumbnail" src="${h}" alt="${i.name}" />`,i.form.thumbnailFit&&(a=`<img class="thumbnail" style="object-fit:${i.form.thumbnailFit}" src="${h}" alt="${i.name}" />`)}const u=document.createElement("div");u.className="div-template-buttons";let d=!1,l=!1;if(this.settings.templateButtons&&this.settings.templateButtons.viewButton&&this.settings.templateButtons.viewButton.text){const h=document.createElement("button");h.className="btn-template-view",h.innerText=this.out(this.settings.templateButtons.viewButton.text),u.appendChild(h),h.addEventListener("click",p=>{if(p.preventDefault(),this.isGenerating){alert(this.out("Please wait until generation is complete."));return}this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateView",i)}),d=!0}if(this.settings.templateButtons&&this.settings.templateButtons.useButton&&this.settings.templateButtons.useButton.text){const h=document.createElement("button");h.className="btn-template-use",h.innerText=this.out(this.settings.templateButtons.useButton.text),u.appendChild(h),h.addEventListener("click",p=>{p.preventDefault(),this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateUse",i)}),l=!0}s.innerHTML=`
306
306
  ${a}
307
307
  <div class="card-text">
308
308
  <div class="title">${i.name}</div>
309
309
  <div class="description">${i.form.description}</div>
310
310
  ${i.info?` <div class="info mt-1">${i.info}</div>`:""}
311
311
  </div>
312
- `,u||l?(s.querySelector(".card-text").appendChild(d),s.classList.remove("cursor-pointer"),s.classList.add("cursor-default")):(s.classList.add("cursor-pointer"),s.classList.remove("cursor-default")),n.appendChild(s),u||l||s.addEventListener("click",h=>{if(h.preventDefault(),this.isGenerating){alert(this.out("Please wait until generation is complete."));return}this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateSelect",i)})}})}addResultTool(){const e=document.querySelector(this.settings.resultSelector);if(!e)return;let t=e.innerHTML;const n=new DOMParser().parseFromString(t,"text/html"),s=n.querySelector(".result-tool");s&&s.remove(),n.querySelectorAll(".link-view, .link-download, video, audio").forEach(h=>{h.remove()});let o=!1;n.body.innerText.trim()===""&&(o=!0);const d=document.createElement("div");d.className="result-tool",e.appendChild(d);const u=document.createElement("button");u.className="btn-result-tool",u.innerHTML=`
312
+ `,d||l?(s.querySelector(".card-text").appendChild(u),s.classList.remove("cursor-pointer"),s.classList.add("cursor-default")):(s.classList.add("cursor-pointer"),s.classList.remove("cursor-default")),n.appendChild(s),d||l||s.addEventListener("click",h=>{if(h.preventDefault(),this.isGenerating){alert(this.out("Please wait until generation is complete."));return}this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateSelect",i)})}})}addResultTool(){const e=document.querySelector(this.settings.resultSelector);if(!e)return;let t=e.innerHTML;const n=new DOMParser().parseFromString(t,"text/html"),s=n.querySelector(".result-tool");s&&s.remove(),n.querySelectorAll(".link-view, .link-download, video, audio").forEach(h=>{h.remove()});let o=!1;n.body.innerText.trim()===""&&(o=!0);const u=document.createElement("div");u.className="result-tool",e.appendChild(u);const d=document.createElement("button");d.className="btn-result-tool",d.innerHTML=`
313
313
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
314
314
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
315
315
  </svg>
316
316
  <span>${this.out("Copy")}</span>
317
- `,o||d.appendChild(u);const l=document.createElement("button");l.className="btn-result-tool",l.innerHTML=`
317
+ `,o||u.appendChild(d);const l=document.createElement("button");l.className="btn-result-tool",l.innerHTML=`
318
318
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
319
319
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 7l16 0" /><path d="M10 11l0 6" /><path d="M14 11l0 6" /><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12" /><path d="M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3" />
320
320
  </svg>
321
321
  <span>${this.out("Clear")}</span>
322
- `,d.appendChild(l),u&&u.addEventListener("click",h=>{h.preventDefault();const p=e.cloneNode(!0),b=p.querySelector(".result-tool");b&&b.remove(),p.querySelectorAll(".link-view, .link-download").forEach(g=>{g.remove()}),p.style.position="fixed",p.style.left="-9999px",document.body.appendChild(p);const _=p.innerText.trim();document.body.removeChild(p),navigator.clipboard.writeText(_),u.innerHTML=`
322
+ `,u.appendChild(l),d&&d.addEventListener("click",h=>{h.preventDefault();const p=e.cloneNode(!0),b=p.querySelector(".result-tool");b&&b.remove(),p.querySelectorAll(".link-view, .link-download").forEach(g=>{g.remove()}),p.style.position="fixed",p.style.left="-9999px",document.body.appendChild(p);const _=p.innerText.trim();document.body.removeChild(p),navigator.clipboard.writeText(_),d.innerHTML=`
323
323
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
324
324
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path stroke="none" d="M0 0h24v24H0z" /><path d="M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2 2 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" /><path d="M11 14l2 2l4 -4" />
325
325
  </svg>
326
326
  <span>${this.out("Copied")}</span>
327
- `,setTimeout(()=>{u.innerHTML=`
327
+ `,setTimeout(()=>{d.innerHTML=`
328
328
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
329
329
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
330
330
  </svg>
331
331
  <span>${this.out("Copy")}</span>
332
- `},600)}),l.addEventListener("click",h=>{h.preventDefault(),localStorage.removeItem("_results"),localStorage.removeItem("_results_html"),e.innerHTML=""})}getScrollableParent(e){for(;e.parentElement;){const i=window.getComputedStyle(e.parentElement).overflowY;if((i==="auto"||i==="scroll")&&e.parentElement.scrollHeight>e.parentElement.clientHeight)return e.parentElement;e=e.parentElement}return null}stickyElement(e){if(!this.settings.alwaysVisibleSubmit)return;const t=this.getScrollableParent(e);this._scrollListener&&(t?t.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._resizeListener));let i;const n=()=>{e.style.position="",t?i=e.offsetTop+e.offsetHeight-t.offsetTop:i=e.offsetTop+e.offsetHeight},s=()=>{if(t)if(t.offsetHeight+t.scrollTop>i)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}else if(window.innerHeight+window.scrollY>i)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}e.parentNode.offsetWidth!==0&&(e.style.width=`${e.parentNode.offsetWidth}px`)};this._scrollListener=s;let r;this._resizeListener=()=>{r&&clearTimeout(r),r=setTimeout(()=>{let o=null;const a=()=>{const d=e.offsetTop;d===o?(n(),s()):(o=d,requestAnimationFrame(a))};a()},200)},n(),s(),t?t.addEventListener("scroll",s):window.addEventListener("scroll",s),window.addEventListener("resize",this._resizeListener)}view(e){if(!e)return;let t;try{t=JSON.parse(e)}catch{console.log("Invalid JSON Form.");return}this.json=t,this.inputListener=()=>{clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)},300)},this.changeListener=()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)};let i;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}i=document.querySelector(this.settings.previewSelector)}else i=this.element;if(i){if(i.classList.remove("hidden"),i.classList.add("formview-container"),i.classList.add("fb-ui"),i.innerHTML="",!(t.hideHeader||!1)){const l=document.createElement("div");l.className="form-header",i.appendChild(l);const h=document.createElement("h1");h.className="form-title",h.innerText=t.title||this.out("Your Form Title Here"),l.appendChild(h);const p=document.createElement("p");p.className="form-desc",p.innerText=t.description||this.out("Your Description Here"),l.appendChild(p)}let r;this.settings.isBuilder?r=document.createElement("form"):r=document.createElement("div"),r.className="form-wrapper",r.style.flexFlow="wrap",i.appendChild(r);let o=1;t.elements&&t.elements.forEach(l=>{if(l.type==="spacer"){const g=document.createElement("div");g.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(g.style.height=l.spacerHeight+"px"),l.displayInOutput||r.appendChild(g);return}if(l.type==="separator"){const g=document.createElement("hr");g.style.borderTopColor=l.color,l.displayInOutput||r.appendChild(g);return}if(l.type==="html"){if(l.html){const g=document.createElement("div");g.innerHTML=l.html,l.displayInOutput||r.appendChild(g)}return}if(l.type==="heading"){const g=document.createElement(l.heading||"h2");g.innerHTML=l.headingText||this.out("Your Heading Here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="paragraph"){const g=document.createElement("p");g.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="media"){if(l.tag==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",g.appendChild(h),l.displayInOutput||r.appendChild(g)}else if(l.tag==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g)}else if(l.tag==="img"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g)}return}if(l.type==="image"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g);return}if(l.type==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="video/mp4",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}if(l.type==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}const p=document.createElement("div");p.className="form-field",l.type==="hidden"&&(p.className="hidden"),l.displayInOutput||r.appendChild(p),l.type==="color"&&p.classList.add("field-color");const b=l.type;let w=l.name;if(r.querySelector(`[name="${w}"]`)&&(o++,w=w+"_"+o),b==="short-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`short_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`short_text_label_${g}`,f.type="text",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="long-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`long_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("textarea");f.id=`long_text_label_${g}`,f.name=w,f.value=l.value||"",f.className="inp-base",f.style.height=l.height+"px",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="number"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`number_label_${g}`,f.type="number",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="slider"){p.classList.add("input-slider");let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const E=document.createElement("div");E.className="field-note",E.innerHTML=l.fieldNote,p.appendChild(E)}const f=document.createElement("div");f.className="slider-container",p.appendChild(f);const m=document.createElement("div");m.className="slider-values",f.appendChild(m);const y=document.createElement("span");m.appendChild(y),y.innerText=l.minValue;const k=document.createElement("span");m.appendChild(k),k.innerText=l.maxValue;const x=document.createElement("input");x.id=`number_label_${g}`,x.type="range",x.name=w,x.setAttribute("min",l.minValue),x.setAttribute("max",l.maxValue),x.setAttribute("step",l.step),x.setAttribute("value",l.value||0),f.appendChild(x);const S=document.createElement("div");S.className="current-value",f.appendChild(S),f.querySelector(".current-value").textContent=l.value||0,x.addEventListener("input",()=>{f.querySelector(".current-value").textContent=x.value})}if(b==="select"){let g=this.getId();const v=document.createElement("div");if(v.id=`radio_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`radio_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="radio",S.className="peer",S.id=`${g}_${y}`,S.name=w,S.value=m,x.appendChild(S),y===l.selected&&(S.checked=!0);const E=document.createElement("span");E.className="peer-span-rounded",x.appendChild(E);const C='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';E.innerHTML=C,y===0&&l.isRequired&&S.setAttribute("required","required");const A=document.createElement("span");A.innerText=k,x.appendChild(A),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="radio",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-rounded",m.appendChild(k);const x='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const C=document.createElement("input");C.type="text",C.name=w+"_other",C.className="inp-base",E.appendChild(C),y.addEventListener("change",this.changeListener),C.addEventListener("input",this.inputListener)}}if(b==="multi-select"){let g=this.getId();const v=document.createElement("div");if(v.id=`checkbox_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`checkbox_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="checkbox",S.className="peer",S.id=`${g}_${y}`,S.name=w+"[]",S.value=m,x.appendChild(S);const E=document.createElement("span");E.className="peer-span-square",x.appendChild(E);const C=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
332
+ `},600)}),l.addEventListener("click",h=>{h.preventDefault(),localStorage.removeItem("_results"),localStorage.removeItem("_results_html"),e.innerHTML=""})}getScrollableParent(e){for(;e.parentElement;){const i=window.getComputedStyle(e.parentElement).overflowY;if((i==="auto"||i==="scroll")&&e.parentElement.scrollHeight>e.parentElement.clientHeight)return e.parentElement;e=e.parentElement}return null}stickyElement(e){if(!this.settings.alwaysVisibleSubmit)return;const t=this.getScrollableParent(e);this._scrollListener&&(t?t.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._resizeListener));let i;const n=()=>{e.style.position="",t?i=e.offsetTop+e.offsetHeight-t.offsetTop:i=e.offsetTop+e.offsetHeight},s=()=>{if(t)if(t.offsetHeight+t.scrollTop>i)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}else if(window.innerHeight+window.scrollY>i)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}e.parentNode.offsetWidth!==0&&(e.style.width=`${e.parentNode.offsetWidth}px`)};this._scrollListener=s;let r;this._resizeListener=()=>{r&&clearTimeout(r),r=setTimeout(()=>{let o=null;const a=()=>{const u=e.offsetTop;u===o?(n(),s()):(o=u,requestAnimationFrame(a))};a()},200)},n(),s(),t?t.addEventListener("scroll",s):window.addEventListener("scroll",s),window.addEventListener("resize",this._resizeListener)}view(e){if(!e)return;let t;try{t=JSON.parse(e)}catch{console.log("Invalid JSON Form.");return}this.json=t,this.inputListener=()=>{clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)},300)},this.changeListener=()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)};let i;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}i=document.querySelector(this.settings.previewSelector)}else i=this.element;if(i){if(i.classList.remove("hidden"),i.classList.add("formview-container"),i.classList.add("fb-ui"),i.innerHTML="",!(t.hideHeader||!1)){const l=document.createElement("div");l.className="form-header",i.appendChild(l);const h=document.createElement("h1");h.className="form-title",h.innerText=t.title||this.out("Your Form Title Here"),l.appendChild(h);const p=document.createElement("p");p.className="form-desc",p.innerText=t.description||this.out("Your Description Here"),l.appendChild(p)}let r;this.settings.isBuilder?r=document.createElement("form"):r=document.createElement("div"),r.className="form-wrapper",r.style.flexFlow="wrap",i.appendChild(r);let o=1;t.elements&&t.elements.forEach(l=>{if(l.type==="spacer"){const g=document.createElement("div");g.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(g.style.height=l.spacerHeight+"px"),l.displayInOutput||r.appendChild(g);return}if(l.type==="separator"){const g=document.createElement("hr");g.style.borderTopColor=l.color,l.displayInOutput||r.appendChild(g);return}if(l.type==="html"){if(l.html){const g=document.createElement("div");g.innerHTML=l.html,l.displayInOutput||r.appendChild(g)}return}if(l.type==="heading"){const g=document.createElement(l.heading||"h2");g.innerHTML=l.headingText||this.out("Your Heading Here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="paragraph"){const g=document.createElement("p");g.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="media"){if(l.tag==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",g.appendChild(h),l.displayInOutput||r.appendChild(g)}else if(l.tag==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g)}else if(l.tag==="img"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g)}return}if(l.type==="image"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g);return}if(l.type==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="video/mp4",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}if(l.type==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}const p=document.createElement("div");p.className="form-field",l.type==="hidden"&&(p.className="hidden"),l.displayInOutput||r.appendChild(p),l.type==="color"&&p.classList.add("field-color");const b=l.type;let w=l.name;if(r.querySelector(`[name="${w}"]`)&&(o++,w=w+"_"+o),b==="short-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`short_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`short_text_label_${g}`,f.type="text",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="long-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`long_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("textarea");f.id=`long_text_label_${g}`,f.name=w,f.value=l.value||"",f.className="inp-base",f.style.height=l.height+"px",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="number"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`number_label_${g}`,f.type="number",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="slider"){p.classList.add("input-slider");let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const E=document.createElement("div");E.className="field-note",E.innerHTML=l.fieldNote,p.appendChild(E)}const f=document.createElement("div");f.className="slider-container",p.appendChild(f);const m=document.createElement("div");m.className="slider-values",f.appendChild(m);const y=document.createElement("span");m.appendChild(y),y.innerText=l.minValue;const k=document.createElement("span");m.appendChild(k),k.innerText=l.maxValue;const x=document.createElement("input");x.id=`number_label_${g}`,x.type="range",x.name=w,x.setAttribute("min",l.minValue),x.setAttribute("max",l.maxValue),x.setAttribute("step",l.step),x.setAttribute("value",l.value||0),f.appendChild(x);const S=document.createElement("div");S.className="current-value",f.appendChild(S),f.querySelector(".current-value").textContent=l.value||0,x.addEventListener("input",()=>{f.querySelector(".current-value").textContent=x.value})}if(b==="select"){let g=this.getId();const v=document.createElement("div");if(v.id=`radio_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`radio_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="radio",S.className="peer",S.id=`${g}_${y}`,S.name=w,S.value=m,x.appendChild(S),y===l.selected&&(S.checked=!0);const E=document.createElement("span");E.className="peer-span-rounded",x.appendChild(E);const C='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';E.innerHTML=C,y===0&&l.isRequired&&S.setAttribute("required","required");const A=document.createElement("span");A.innerText=k,x.appendChild(A),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="radio",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-rounded",m.appendChild(k);const x='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const C=document.createElement("input");C.type="text",C.name=w+"_other",C.className="inp-base",E.appendChild(C),y.addEventListener("change",this.changeListener),C.addEventListener("input",this.inputListener)}}if(b==="multi-select"){let g=this.getId();const v=document.createElement("div");if(v.id=`checkbox_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`checkbox_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="checkbox",S.className="peer",S.id=`${g}_${y}`,S.name=w+"[]",S.value=m,x.appendChild(S);const E=document.createElement("span");E.className="peer-span-square",x.appendChild(E);const C=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
333
333
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
334
334
  </svg>`;E.innerHTML=C;const A=document.createElement("span");A.innerText=k,x.appendChild(A),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="checkbox",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-square",m.appendChild(k);const x=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
335
335
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
@@ -391,25 +391,25 @@ Check the information and return the details.
391
391
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
392
392
  <path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
393
393
  </svg>
394
- `,ue.appendChild(pe),pe.addEventListener("click",j=>{const we=pe.closest(".image-item");we&&we.remove(),(yn=>{const mi=new DataTransfer,vn=y.files;Array.from(vn).forEach(bi=>{bi!==yn&&mi.items.add(bi)}),y.files=mi.files})(P);const He=document.querySelector(".formview-container .submit-container");He&&setTimeout(()=>{this.stickyElement(He)},1e3),j.preventDefault(),j.stopImmediatePropagation()}),P.type.startsWith("image/")){const j=new FileReader;j.onload=function(we){let Te=document.createElement("img");Te.className="img-preview",se.appendChild(Te),Te.src=we.target.result},j.readAsDataURL(P)}const K=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(K);const ve=document.querySelector(".formview-container .submit-container");ve&&setTimeout(()=>{this.stickyElement(ve)},1e3)}}}if(b==="email"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`email_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`email_label_${g}`,f.type="email",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="phone"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`phone_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`phone_label_${g}`,f.type="tel",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="url"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`url_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`url_label_${g}`,f.type="url",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="hidden"){let g=this.getId();const v=document.createElement("label");v.setAttribute("for",`hidden_label_${g}`),v.className="field-label hidden",v.innerText=l.title,p.appendChild(v);const f=document.createElement("input");f.id=`hidden_label_${g}`,f.type="hidden",f.name=w,f.value=l.value,p.appendChild(f)}});const a=r.closest("[data-site-token]");if(a){const l=a.getAttribute("data-site-token"),h=document.createElement("input");h.type="hidden",h.name="form_token",h.value=l,r.appendChild(h)}if(this.settings.isBuilder){const l=document.createElement("div");l.className="submit-container",r.appendChild(l);let h=!0;if("hideReset"in t&&(h=t.hideReset),!h){const _=document.createElement("button");_.className="btn-resetform";const g=t.resetText||this.settings.resetText;_.innerText=g,l.appendChild(_),_.addEventListener("click",f=>{f.preventDefault();const m=_.closest("form");m&&(m.reset(),m.querySelectorAll(".btn-clearfile").forEach(x=>{x.click()}),m.querySelectorAll(".slider-container").forEach(x=>{const S=x.querySelector("input");x.querySelector(".current-value").textContent=S.value}))}),(t.fullWidthButton||!1)&&_.classList.add("w-full")}const p=document.createElement("button");p.className="btn-submitform";const b=t.submitText||this.settings.submitText;p.innerText=b,l.appendChild(p),(t.fullWidthButton||!1)&&p.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&l.classList.add("always-visible"),this.stickyElement(l),r.addEventListener("submit",async _=>{_.preventDefault(),this.steps&&this.steps.length>0&&this.process()})}else{let l="Reference Code:",h="reference_code",p="reference_code";const b=document.createElement("div");b.className="form-field ",b.classList.add(p),r.appendChild(b);let w=this.getId();const _=document.createElement("label");_.setAttribute("for",`short_text_label_${w}`),_.className="field-label",_.innerHTML=l,b.appendChild(_);const g=document.createElement("input");if(g.id=`short_text_label_${w}`,g.type="text",g.name=h,g.autocomplete="off",g.setAttribute("aria-hidden","true"),g.setAttribute("tabindex","-1"),g.className="inp-base",b.appendChild(g),this.settings.captchaContainer){const v=this.settings.captchaContainerClassName,f=document.createElement("div");f.className="captcha-container",v&&f.classList.add(v),r.appendChild(f)}if(t.useSubmitButton){const v=document.createElement("div");v.className="submit-container",r.appendChild(v);let f=!0;if("hideReset"in t&&(f=t.hideReset),!f){const S=document.createElement("button");S.className="btn-resetform";const E=t.resetText||this.settings.resetText;S.innerText=E,v.appendChild(S),S.addEventListener("click",A=>{A.preventDefault();const L=S.closest("form");L&&(L.reset(),L.querySelectorAll(".btn-clearfile").forEach(O=>{O.click()}),L.querySelectorAll(".slider-container").forEach(O=>{const R=O.querySelector("input");O.querySelector(".current-value").textContent=R.value}))}),(t.fullWidthButton||!1)&&S.classList.add("w-full")}const m=document.createElement("button");m.className="btn-submitform";const y=t.submitText;m.innerText=y,v.appendChild(m),(t.fullWidthButton||!1)&&m.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&v.classList.add("always-visible"),this.stickyElement(v),m.addEventListener("click",async S=>{this.trigger("submit",S)});const x=r.closest("form");x?x.addEventListener("submit",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),S.stopImmediatePropagation(),this.process())}):m.addEventListener("click",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),this.process())})}}let d,u;this.settings.resultSelector&&(d=document.querySelector(this.settings.resultSelector),d.classList.add("result-wrapper"),d.innerHTML="",u=document.createElement("div"),u.classList.add("result-container"),d.appendChild(u)),t.elements&&d&&t.elements.forEach(l=>{if(l.displayInOutput){if(l.type==="spacer"){const p=document.createElement("div");p.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(p.style.height=l.spacerHeight+"px"),u.appendChild(p);return}if(l.type==="separator"){const p=document.createElement("hr");p.style.borderTopColor=l.color,u.appendChild(p);return}if(l.type==="html"){if(l.html){const p=document.createElement("div");p.innerHTML=l.html,u.appendChild(p)}return}if(l.type==="heading"){const p=document.createElement(l.heading||"h2");p.innerHTML=l.headingText||this.out("Your Heading Here!"),u.appendChild(p);return}if(l.type==="paragraph"){const p=document.createElement("p");p.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),u.appendChild(p);return}if(l.type==="media"){if(l.tag==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",p.appendChild(h),u.appendChild(p)}else if(l.tag==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p)}else if(l.tag==="img"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p)}return}if(l.type==="image"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p);return}if(l.type==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="video/mp4",p.appendChild(b),u.appendChild(p);return}if(l.type==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p);return}}})}if(this.settings.resultSelector&&document.querySelector(this.settings.resultSelector).classList.add("result-wrapper"),this.settings.saveResults&&this.settings.resultSelector&&localStorage.getItem("_results"))try{this.previousResults=JSON.parse(localStorage.getItem("_results"));let s=localStorage.getItem("_results_html");const r=document.querySelector(this.settings.resultSelector);r.innerHTML=s,this.addResultTool(),r.querySelectorAll(".link-download").forEach(a=>{a.addEventListener("click",async d=>{d.preventDefault();const u=d.target.href;try{const l=await fetch(u,{mode:"cors"});if(!l.ok)throw new Error("Failed to fetch the image.");const h=await l.blob(),p=u.substring(u.lastIndexOf("/")+1),b=document.createElement("a");b.href=URL.createObjectURL(h),b.download=p,b.click(),URL.revokeObjectURL(b.href)}catch(l){console.error("Error downloading the image:",l)}})})}catch{}const n=document.querySelector(".formview-container .submit-container");n&&setTimeout(()=>{this.stickyElement(n)},1e3)}abort(){this.controller&&this.controller.abort()}async search(e){let t={"Content-Type":"application/json",...this.settings.headers};try{const i=await fetch(this.settings.searchUrl,{method:"POST",headers:t,body:JSON.stringify({query:e,customData:this.settings.customData})});if(!i.ok)throw new Error("Failed to fetch data");const n=await i.json(),s=n.organic_results?"organic_results":"organic";return(n[s]||[]).map(r=>({title:r.title,link:r.link,snippet:r.snippet||r.description}))}catch(i){return console.error("Error in search:",i.message||i),[]}}async scrapeUrls(e){if(e.length===0)return{data:"",urls:[],failed:[]};this.settings.consoleLog&&console.log(e);let t={"Content-Type":"application/json",...this.settings.headers};const i=await fetch(this.settings.scrapeUrl,{method:"POST",headers:t,body:JSON.stringify({urls:e,customData:this.settings.customData})});if(!i.ok)throw new Error(`Error: ${i.statusText}`);let n="";const s=await i.json();if(this.settings.consoleLog&&console.log(s),s.error)return this.settings.consoleLog&&console.log(s.error),{data:"",urls:[],failed:[]};let r=[],o=[];if(this.settings.scrapeProvider==="firecrawl"&&s.forEach(a=>{if(a.success){const d=a.metadata.title,u=a.markdown,l=a.metadata.url;r.push(l),n+=`
394
+ `,ue.appendChild(pe),pe.addEventListener("click",j=>{const we=pe.closest(".image-item");we&&we.remove(),(yn=>{const mi=new DataTransfer,vn=y.files;Array.from(vn).forEach(bi=>{bi!==yn&&mi.items.add(bi)}),y.files=mi.files})(P);const He=document.querySelector(".formview-container .submit-container");He&&setTimeout(()=>{this.stickyElement(He)},1e3),j.preventDefault(),j.stopImmediatePropagation()}),P.type.startsWith("image/")){const j=new FileReader;j.onload=function(we){let Te=document.createElement("img");Te.className="img-preview",se.appendChild(Te),Te.src=we.target.result},j.readAsDataURL(P)}const K=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(K);const ve=document.querySelector(".formview-container .submit-container");ve&&setTimeout(()=>{this.stickyElement(ve)},1e3)}}}if(b==="email"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`email_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`email_label_${g}`,f.type="email",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="phone"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`phone_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`phone_label_${g}`,f.type="tel",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="url"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`url_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`url_label_${g}`,f.type="url",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="hidden"){let g=this.getId();const v=document.createElement("label");v.setAttribute("for",`hidden_label_${g}`),v.className="field-label hidden",v.innerText=l.title,p.appendChild(v);const f=document.createElement("input");f.id=`hidden_label_${g}`,f.type="hidden",f.name=w,f.value=l.value,p.appendChild(f)}});const a=r.closest("[data-site-token]");if(a){const l=a.getAttribute("data-site-token"),h=document.createElement("input");h.type="hidden",h.name="form_token",h.value=l,r.appendChild(h)}if(this.settings.isBuilder){const l=document.createElement("div");l.className="submit-container",r.appendChild(l);let h=!0;if("hideReset"in t&&(h=t.hideReset),!h){const _=document.createElement("button");_.className="btn-resetform";const g=t.resetText||this.settings.resetText;_.innerText=g,l.appendChild(_),_.addEventListener("click",f=>{f.preventDefault();const m=_.closest("form");m&&(m.reset(),m.querySelectorAll(".btn-clearfile").forEach(x=>{x.click()}),m.querySelectorAll(".slider-container").forEach(x=>{const S=x.querySelector("input");x.querySelector(".current-value").textContent=S.value}))}),(t.fullWidthButton||!1)&&_.classList.add("w-full")}const p=document.createElement("button");p.className="btn-submitform";const b=t.submitText||this.settings.submitText;p.innerText=b,l.appendChild(p),(t.fullWidthButton||!1)&&p.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&l.classList.add("always-visible"),this.stickyElement(l),r.addEventListener("submit",async _=>{_.preventDefault(),this.steps&&this.steps.length>0&&this.process()})}else{let l="Reference Code:",h="reference_code",p="reference_code";const b=document.createElement("div");b.className="form-field ",b.classList.add(p),r.appendChild(b);let w=this.getId();const _=document.createElement("label");_.setAttribute("for",`short_text_label_${w}`),_.className="field-label",_.innerHTML=l,b.appendChild(_);const g=document.createElement("input");if(g.id=`short_text_label_${w}`,g.type="text",g.name=h,g.autocomplete="off",g.setAttribute("aria-hidden","true"),g.setAttribute("tabindex","-1"),g.className="inp-base",b.appendChild(g),this.settings.captchaContainer){const v=this.settings.captchaContainerClassName,f=document.createElement("div");f.className="captcha-container",v&&f.classList.add(v),r.appendChild(f)}if(t.useSubmitButton){const v=document.createElement("div");v.className="submit-container",r.appendChild(v);let f=!0;if("hideReset"in t&&(f=t.hideReset),!f){const S=document.createElement("button");S.className="btn-resetform";const E=t.resetText||this.settings.resetText;S.innerText=E,v.appendChild(S),S.addEventListener("click",A=>{A.preventDefault();const L=S.closest("form");L&&(L.reset(),L.querySelectorAll(".btn-clearfile").forEach(O=>{O.click()}),L.querySelectorAll(".slider-container").forEach(O=>{const R=O.querySelector("input");O.querySelector(".current-value").textContent=R.value}))}),(t.fullWidthButton||!1)&&S.classList.add("w-full")}const m=document.createElement("button");m.className="btn-submitform";const y=t.submitText;m.innerText=y,v.appendChild(m),(t.fullWidthButton||!1)&&m.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&v.classList.add("always-visible"),this.stickyElement(v),m.addEventListener("click",async S=>{this.trigger("submit",S)});const x=r.closest("form");x?x.addEventListener("submit",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),S.stopImmediatePropagation(),this.process())}):m.addEventListener("click",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),this.process())})}}let u,d;this.settings.resultSelector&&(u=document.querySelector(this.settings.resultSelector),u.classList.add("result-wrapper"),u.innerHTML="",d=document.createElement("div"),d.classList.add("result-container"),u.appendChild(d)),t.elements&&u&&t.elements.forEach(l=>{if(l.displayInOutput){if(l.type==="spacer"){const p=document.createElement("div");p.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(p.style.height=l.spacerHeight+"px"),d.appendChild(p);return}if(l.type==="separator"){const p=document.createElement("hr");p.style.borderTopColor=l.color,d.appendChild(p);return}if(l.type==="html"){if(l.html){const p=document.createElement("div");p.innerHTML=l.html,d.appendChild(p)}return}if(l.type==="heading"){const p=document.createElement(l.heading||"h2");p.innerHTML=l.headingText||this.out("Your Heading Here!"),d.appendChild(p);return}if(l.type==="paragraph"){const p=document.createElement("p");p.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),d.appendChild(p);return}if(l.type==="media"){if(l.tag==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",p.appendChild(h),d.appendChild(p)}else if(l.tag==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),d.appendChild(p)}else if(l.tag==="img"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),d.appendChild(p)}return}if(l.type==="image"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),d.appendChild(p);return}if(l.type==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="video/mp4",p.appendChild(b),d.appendChild(p);return}if(l.type==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),d.appendChild(p);return}}})}if(this.settings.resultSelector&&document.querySelector(this.settings.resultSelector).classList.add("result-wrapper"),this.settings.saveResults&&this.settings.resultSelector&&localStorage.getItem("_results"))try{this.previousResults=JSON.parse(localStorage.getItem("_results"));let s=localStorage.getItem("_results_html");const r=document.querySelector(this.settings.resultSelector);r.innerHTML=s,this.addResultTool(),r.querySelectorAll(".link-download").forEach(a=>{a.addEventListener("click",async u=>{u.preventDefault();const d=u.target.href;try{const l=await fetch(d,{mode:"cors"});if(!l.ok)throw new Error("Failed to fetch the image.");const h=await l.blob(),p=d.substring(d.lastIndexOf("/")+1),b=document.createElement("a");b.href=URL.createObjectURL(h),b.download=p,b.click(),URL.revokeObjectURL(b.href)}catch(l){console.error("Error downloading the image:",l)}})})}catch{}const n=document.querySelector(".formview-container .submit-container");n&&setTimeout(()=>{this.stickyElement(n)},1e3)}abort(){this.controller&&this.controller.abort()}async search(e){let t={"Content-Type":"application/json",...this.settings.headers};try{const i=await fetch(this.settings.searchUrl,{method:"POST",headers:t,body:JSON.stringify({query:e,customData:this.settings.customData})});if(!i.ok)throw new Error("Failed to fetch data");const n=await i.json(),s=n.organic_results?"organic_results":"organic";return(n[s]||[]).map(r=>({title:r.title,link:r.link,snippet:r.snippet||r.description}))}catch(i){return console.error("Error in search:",i.message||i),[]}}async scrapeUrls(e){if(e.length===0)return{data:"",urls:[],failed:[]};this.settings.consoleLog&&console.log(e);let t={"Content-Type":"application/json",...this.settings.headers};const i=await fetch(this.settings.scrapeUrl,{method:"POST",headers:t,body:JSON.stringify({urls:e,customData:this.settings.customData})});if(!i.ok)throw new Error(`Error: ${i.statusText}`);let n="";const s=await i.json();if(this.settings.consoleLog&&console.log(s),s.error)return this.settings.consoleLog&&console.log(s.error),{data:"",urls:[],failed:[]};let r=[],o=[];if(this.settings.scrapeProvider==="firecrawl"&&s.forEach(a=>{if(a.success){const u=a.metadata.title,d=a.markdown,l=a.metadata.url;r.push(l),n+=`
395
395
 
396
396
 
397
- ## ${d}
397
+ ## ${u}
398
398
 
399
399
  Source: ${l}
400
400
 
401
- ${u}
401
+ ${d}
402
402
 
403
403
 
404
404
  ----------------
405
405
 
406
406
 
407
- `}else{let d=a.url;if(d){const u=a.url;o.push(u)}else d=a.url.link,o.push(d)}}),this.settings.scrapeProvider==="scrapingbee")for(let a=0;a<s.length;a++){let d=e[a];r.push(d);let u=s[a];n+=`
407
+ `}else{let u=a.url;if(u){const d=a.url;o.push(d)}else u=a.url.link,o.push(u)}}),this.settings.scrapeProvider==="scrapingbee")for(let a=0;a<s.length;a++){let u=e[a];r.push(u);let d=s[a];n+=`
408
408
 
409
409
 
410
- ## ${d}
410
+ ## ${u}
411
411
 
412
- ${u}
412
+ ${d}
413
413
 
414
414
 
415
415
  ----------------
@@ -426,7 +426,7 @@ Check if the request requires checking certain URLs. If so, returns the URLs.
426
426
  Also check if the request requires search to find answers by searching on the web to get the current relevant information.
427
427
  `,s=[{name:"check_request",description:"Check user request.",parameters:{type:"object",properties:{needscrape:{type:"boolean",description:"Check the if request requires search on the web or not."},url:{type:"string",description:"If request need to check certail URL, return the URL."},url2:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url3:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url4:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url5:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url6:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url7:{type:"string",description:"If the request needs to check a certail URL, return the URL."},url8:{type:"string",description:"If the request needs to check a certail URL, return the URL."},needsearch:{type:"boolean",description:"Check the if request requires search on the web or not."}},required:["needsearch","needscrape"]}}],r=await this.send(n,i,t,s);return r?JSON.parse(r):!1}async getRelevantInfo(e,t,i){if(!this.settings.searchUrl&&!this.settings.scrapeUrl)return{data:"",urls:[],failed:[]};const n=document.createElement("div");n.classList.add("status"),i.appendChild(n);let s="",r=await this.checkPrompt(`${t}
428
428
 
429
- ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needscrape&&this.settings.scrapeUrl){let d=document.createElement("p");d.innerHTML=this.out("Fetching data from the web..."),n.appendChild(d);let u=[];r.url&&u.push(r.url),r.url2&&u.push(r.url2),r.url3&&u.push(r.url3),r.url4&&u.push(r.url4),r.url5&&u.push(r.url5),r.url6&&u.push(r.url6),r.url7&&u.push(r.url7),r.url8&&u.push(r.url8);let l=await this.scrapeUrls(u);s+=l.data,o=l.urls,a=l.failed}else if(this.settings.searchUrl&&this.settings.scrapeUrl){let d=document.createElement("p");d.innerHTML=this.out("Searching the web.."),n.appendChild(d);let u=await this.search(e);const l=this.settings.scrapeExclude;let h=u.filter(g=>{let v=new URL(g.link).hostname;return!l.some(f=>v.includes(f))});const p=this.settings.scrapeLimit,b=h.slice(0,p);n.innerHTML="",d=document.createElement("p"),d.innerHTML=this.out("Getting more information..."),n.appendChild(d);let w=[];for(let g=0;g<b.length;g++)w.push(u[g].link);let _=await this.scrapeUrls(w);s+=_.data,o=_.urls,a=_.failed}return{data:s,urls:o,failed:a}}showDemoInfo(e){if(!this.settings.resultSelector){this.settings.consoleLog&&console.log("resultSelector not set.");return}const t=document.querySelector(this.settings.resultSelector);t.innerHTML="";const i=document.createElement("div");i.classList.add("result-container"),t.appendChild(i),i.innerHTML=`
429
+ ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needscrape&&this.settings.scrapeUrl){let u=document.createElement("p");u.innerHTML=this.out("Fetching data from the web..."),n.appendChild(u);let d=[];r.url&&d.push(r.url),r.url2&&d.push(r.url2),r.url3&&d.push(r.url3),r.url4&&d.push(r.url4),r.url5&&d.push(r.url5),r.url6&&d.push(r.url6),r.url7&&d.push(r.url7),r.url8&&d.push(r.url8);let l=await this.scrapeUrls(d);s+=l.data,o=l.urls,a=l.failed}else if(this.settings.searchUrl&&this.settings.scrapeUrl){let u=document.createElement("p");u.innerHTML=this.out("Searching the web.."),n.appendChild(u);let d=await this.search(e);const l=this.settings.scrapeExclude;let h=d.filter(g=>{let v=new URL(g.link).hostname;return!l.some(f=>v.includes(f))});const p=this.settings.scrapeLimit,b=h.slice(0,p);n.innerHTML="",u=document.createElement("p"),u.innerHTML=this.out("Getting more information..."),n.appendChild(u);let w=[];for(let g=0;g<b.length;g++)w.push(d[g].link);let _=await this.scrapeUrls(w);s+=_.data,o=_.urls,a=_.failed}return{data:s,urls:o,failed:a}}showDemoInfo(e){if(!this.settings.resultSelector){this.settings.consoleLog&&console.log("resultSelector not set.");return}const t=document.querySelector(this.settings.resultSelector);t.innerHTML="";const i=document.createElement("div");i.classList.add("result-container"),t.appendChild(i),i.innerHTML=`
430
430
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 20" width="27" height="20" fill="currentColor">
431
431
  <circle cx="15" cy="15" r="10">
432
432
  <animate attributeName="cy" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
@@ -463,7 +463,7 @@ ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needsc
463
463
  <p>
464
464
  <b>Web searching and scraping are currently disabled, so your request cannot be processed.</b>
465
465
  </p>
466
- </div>`,this.showDemoInfo(s);return}let r;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}r=document.querySelector(this.settings.previewSelector)}else r=this.element;let o=r.querySelector(".btn-submitform"),a=o.innerHTML;this.tokenInput=0,this.tokenOutput=0;let d=!1;if(e!=null&&(d=!0),this.singleStep=d,d||(this.filesUploaded={}),this.isNormal&&!d){if(this.isMediaGenerating){alert(this.out("The media generation process cannot be aborted."));return}this.abort(),o.innerHTML=a,o.removeAttribute("disabled"),this.isGenerating=!1;return}if(this.isNormal&&d||this.isSingle&&!d||this.isSingle&&d)return;this.isNormal=!1,this.isSingle=!1,d?(o.innerHTML=`
466
+ </div>`,this.showDemoInfo(s);return}let r;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}r=document.querySelector(this.settings.previewSelector)}else r=this.element;let o=r.querySelector(".btn-submitform"),a=o.innerHTML;this.tokenInput=0,this.tokenOutput=0;let u=!1;if(e!=null&&(u=!0),this.singleStep=u,u||(this.filesUploaded={}),this.isNormal&&!u){if(this.isMediaGenerating){alert(this.out("The media generation process cannot be aborted."));return}this.abort(),o.innerHTML=a,o.removeAttribute("disabled"),this.isGenerating=!1;return}if(this.isNormal&&u||this.isSingle&&!u||this.isSingle&&u)return;this.isNormal=!1,this.isSingle=!1,u?(o.innerHTML=`
467
467
  <span class="loading-icon">
468
468
  <svg class="animate-spin" style="margin: 0;margin-right: 0.6rem;width: 1rem;height: 1rem;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
469
469
  <circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
@@ -478,7 +478,7 @@ ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needsc
478
478
  </svg>
479
479
  </span>
480
480
  ${this.out("Abort")}
481
- `,this.isNormal=!0),this.isGenerating=!0;let u=(m,y)=>{if(m===void 0)return"";if(!isNaN(m))return m;let k=m;return y&&y.trim().startsWith("{")&&(k=JSON.stringify(m).slice(1,-1)),k};t.innerHTML="";let l=JSON.parse(JSON.stringify(this.steps)),h=this.getFormValues();if(!h)return;if(!(h&&Object.keys(h).length===0)){for(const m of l){let y=m.prompt;if(m.provider==="google"){for(const x of h)if(x.value instanceof FileList&&x.value.length>0){const E=x.value[0];if(!E)continue;const C=await new Promise((A,L)=>{const D=new FileReader;D.onload=I=>{const O=I.target.result.split(",")[1];A(O)},D.onerror=L,D.readAsDataURL(E)});y=y.replaceAll(`{{${x.name}}}`,C),y=y.replaceAll(`{{${x.name.toUpperCase()}}}`,C)}}m.prompt=y}l.forEach(m=>{let y=m.prompt;h.forEach(k=>{if(k.value===void 0&&(k.value=""),typeof k.value=="object"&&Array.isArray(k.value)){const x=k.value.join(", ");y=y.replaceAll(`{{${k.name}}}`,x),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,x)}else k.value instanceof FileList||typeof k.value=="string"&&k.value.indexOf("base64")!==-1?(y=y.replaceAll(`{{${k.name}}}`,k.name),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,k.name)):(y=y.replaceAll(`{{${k.name}}}`,u(k.value,m.prompt)),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,u(k.value,m.prompt)))}),m.prompt=y}),l.forEach(m=>{let y=m.context;h.forEach(k=>{if(k.value||(k.value=""),typeof k.value=="object"&&Array.isArray(k.value)){const x=k.value.join(", ");y=y.replaceAll(`{{${k.name}}}`,x),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,x)}else k.value instanceof FileList||typeof k.value=="string"&&k.value.indexOf("base64")!==-1?(y=y.replaceAll(`{{${k.name}}}`,k.name),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,k.name)):(y=y.replaceAll(`{{${k.name}}}`,u(k.value,m.prompt)),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,u(k.value,m.prompt)))}),m.context=y})}const p=async(m,y,k,x,S,E,C,A)=>{const L=document.createElement("div");L.classList.add("result-container"),t.appendChild(L),L.innerHTML=`
481
+ `,this.isNormal=!0),this.isGenerating=!0;let d=(m,y)=>{if(m===void 0)return"";if(!isNaN(m))return m;let k=m;return y&&y.trim().startsWith("{")&&(k=JSON.stringify(m).slice(1,-1)),k};t.innerHTML="";let l=JSON.parse(JSON.stringify(this.steps)),h=this.getFormValues();if(!h)return;if(!(h&&Object.keys(h).length===0)){for(const m of l){let y=m.prompt;if(m.provider==="google"){for(const x of h)if(x.value instanceof FileList&&x.value.length>0){const E=x.value[0];if(!E)continue;const C=await new Promise((A,L)=>{const D=new FileReader;D.onload=I=>{const O=I.target.result.split(",")[1];A(O)},D.onerror=L,D.readAsDataURL(E)});y=y.replaceAll(`{{${x.name}}}`,C),y=y.replaceAll(`{{${x.name.toUpperCase()}}}`,C)}}m.prompt=y}l.forEach(m=>{let y=m.prompt;h.forEach(k=>{if(k.value===void 0&&(k.value=""),typeof k.value=="object"&&Array.isArray(k.value)){const x=k.value.join(", ");y=y.replaceAll(`{{${k.name}}}`,x),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,x)}else k.value instanceof FileList||typeof k.value=="string"&&k.value.indexOf("base64")!==-1?(y=y.replaceAll(`{{${k.name}}}`,k.name),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,k.name)):(y=y.replaceAll(`{{${k.name}}}`,d(k.value,m.prompt)),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,d(k.value,m.prompt)))}),m.prompt=y}),l.forEach(m=>{let y=m.context;h.forEach(k=>{if(k.value||(k.value=""),typeof k.value=="object"&&Array.isArray(k.value)){const x=k.value.join(", ");y=y.replaceAll(`{{${k.name}}}`,x),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,x)}else k.value instanceof FileList||typeof k.value=="string"&&k.value.indexOf("base64")!==-1?(y=y.replaceAll(`{{${k.name}}}`,k.name),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,k.name)):(y=y.replaceAll(`{{${k.name}}}`,d(k.value,m.prompt)),y=y.replaceAll(`{{${k.name.toUpperCase()}}}`,d(k.value,m.prompt)))}),m.context=y})}const p=async(m,y,k,x,S,E,C,A)=>{const L=document.createElement("div");L.classList.add("result-container"),t.appendChild(L),L.innerHTML=`
482
482
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 20" width="27" height="20" fill="currentColor">
483
483
  <circle cx="15" cy="15" r="10">
484
484
  <animate attributeName="cy" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
@@ -490,7 +490,7 @@ ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needsc
490
490
  <animate attributeName="cy" begin="0.4s" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
491
491
  </circle>
492
492
  </svg>
493
- `;let D=!1,I;if(m.trim().startsWith("{"))try{I=JSON.parse(m),I&&typeof I=="object"&&(D=!0)}catch{return L.innerHTML=`<p>${this.out("Incorrect JSON format.")}</p>`,!1}(C&&(C.image||C.video||C.audio)||D)&&(d||(o.innerHTML=`&nbsp;
493
+ `;let D=!1,I;if(m.trim().startsWith("{"))try{I=JSON.parse(m),I&&typeof I=="object"&&(D=!0)}catch{return L.innerHTML=`<p>${this.out("Incorrect JSON format.")}</p>`,!1}(C&&(C.image||C.video||C.audio)||D)&&(u||(o.innerHTML=`&nbsp;
494
494
  <span class="loading-icon" style="width:60px;display:flex;align-items:center;justify-content:center">
495
495
  <svg class="animate-spin" style="margin: 0;width: 1.25rem;height: 1.25rem;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
496
496
  <circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
@@ -502,10 +502,10 @@ ${e}`);this.settings.consoleLog&&console.log(r);let o=[],a=[];if(r.url&&r.needsc
502
502
  Use the following information to answer the request:
503
503
 
504
504
  ${q.data}
505
- `)),C&&(C.image||C.video||C.audio)||D){const M=await this.media.generate(m,y,k,x,C,L,A);return this.needCleanup=!0,this.settings.consoleLog&&console.log(M),M.mediaGenerated?{media:M.output,media2:M.output2,markdown:M.markdown}:(L.innerHTML=`<p>${M.message}</p>`,!1)}if(this.settings.assistantId){if(this.settings.assistantStreamUrl)await this.assistantStream(m,y,S,E,async M=>{if(!(M&&typeof M=="object")){if(O+=M,!A){const T=z.parse(O);L.innerHTML=T,R+=T}await new Promise(T=>setTimeout(T,50))}}),await new Promise(M=>{const T=setInterval(()=>{L.innerHTML===z.parse(O)&&(clearInterval(T),M())},10)}),A&&(L.innerHTML="",L.remove()),this.outputHtml+=`<div class="result-container">${R}</div>`;else if(this.settings.assistantUrl){let M=await this.assistant(m,y,S,E);if(!M)return!1;if(O=M,A)L.innerHTML="",L.remove();else{const T=z.parse(M);L.innerHTML=T,this.outputHtml+=`<div class="result-container">${T}</div>`}}}else if(this.settings.sendCommandStreamUrl){let M="",T="",$="";const N=async U=>{let G=0;for(;G<U.length;){if($=M.slice(0,$.length+1),G++,!A){const Y=z.parse($);L.innerHTML=Y,T=Y}await new Promise(Y=>setTimeout(Y,50))}};await this.sendStream(m,y,S,x,E,async U=>{O+=U,M+=U,await N(U)}),await new Promise(U=>{const G=setInterval(()=>{$.length===M.length&&(clearInterval(G),U())},10)}),A&&(L.innerHTML="",L.remove()),this.outputHtml+=`<div class="result-container">${T}</div>`}else{let M=await this.send(m,y,S,x,E);if(!M)return!1;if(O=M,A)L.innerHTML="",L.remove();else{const T=z.parse(M);L.innerHTML=T,this.outputHtml+=`<div class="result-container">${T}</div>`}}if(!A){let M="";if(q&&q.urls.forEach($=>{let N=$;N.length>75&&(N=N.slice(0,75)+"..."),M+=`<div><a class="source_url" href="${$}">${N}</url></div>`}),q&&q.failed.forEach($=>{let N=$;N.length>75&&(N=N.slice(0,75)+"..."),M+=`<div><a class="source_url" style="opacity:0.5" href="${$}">${N}</url></div>`}),M!==""){const $=document.createElement("div");$.classList.add("result-container"),t.appendChild($),$.innerHTML=M}}return this.payloads.push({prompt:m,context:y}),this.output.push(O),{media:[],markdown:O}};d||await(async m=>{this.previousResults=[],this.outputHtml="";for(let y=0;y<m.length;y++){if(!this.isGenerating)return;let{prompt:k,context:x,provider:S,model:E,system:C,functs:A,tools:L,hideOutput:D}=m[y];S=S||"",x=x||"",C=C||"You are an assistant",A=A||[];let I=k;this.previousResults.forEach((R,q)=>{const M=`{{output_step_${q+1}}}`;I=I.replace(new RegExp(M,"g"),u(R,k)),I=I.replace(new RegExp(M.toUpperCase(),"g"),u(R,k))}),k=I,k=k.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(k),I=x,this.previousResults.forEach((R,q)=>{const M=`{{output_step_${q+1}}}`;I=I.replace(new RegExp(M,"g"),u(R,k)),I=I.replace(new RegExp(M.toUpperCase(),"g"),u(R,k))}),x=I,x=x.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim();let O=await p(k,x,S,E,C,A,L,D);if(!O)break;if(this.mediaGenerated.push(...O.media),O.media&&O.media.length===1){let R=O.media[0],q=O.media2&&O.media2.length===1&&O.media2[0];this.previousResults.push(q||R),D&&(this.filesUploaded[`output_step_${y}`]=R)}else this.previousResults.push(O.markdown)}})(l),d&&(e===0&&(this.previousResults=[]),await(async(y,k)=>{if(!this.isGenerating)return;let{prompt:x,context:S,provider:E,model:C,system:A,functs:L,tools:D,hideOutput:I}=y[k];S=S||"",A=A||"You are an assistant",L=L||[];let O=x;this.previousResults&&this.previousResults.forEach((q,M)=>{const T=`{{output_step_${M+1}}}`;O=O.replace(new RegExp(T,"g"),q),O=O.replace(new RegExp(T.toUpperCase(),"g"),q)}),x=O,x=x.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(x),O=S,this.previousResults&&this.previousResults.forEach((q,M)=>{const T=`{{output_step_${M+1}}}`;O=O.replace(new RegExp(T,"g"),q),O=O.replace(new RegExp(T.toUpperCase(),"g"),q)}),S=O,S=S.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(S);let R=await p(x,S,E,C,A,L,D,I);if(R&&(this.mediaGenerated.push(...R.media),!!this.previousResults))if(R.media&&R.media.length===1){let q=R.media[0],M=R.media2&&R.media2.length===1&&R.media2[0];this.previousResults[k]=M||q,I&&(this.filesUploaded[`output_step_${k}`]=q)}else this.previousResults[k]=R.markdown})(l,e)),o.innerHTML=a,o.removeAttribute("disabled"),this.isGenerating=!1;const w=this.calculateCost();this.settings.onUsage&&this.settings.onUsage(w),this.trigger("usage",w),this.isNormal=!1,this.isSingle=!1;const _=(m,y=100)=>{const k=document.createElement("div");if(k.innerHTML=m,k.querySelector("video"))return"Video";if(k.querySelector("img"))return"Image";if(k.querySelector("audio"))return"Audio";const x=k.textContent.trim();return x.length>y?x.substring(0,y)+"...":x},g=Object.keys(this.filesUploaded).length===0&&this.filesUploaded.constructor===Object;if(this.needCleanup&&!g){this.settings.consoleLog&&(console.log("Cleanup"),console.log(this.filesUploaded));let m={"Content-Type":"application/json",...this.settings.headers};await fetch(this.settings.cleanup,{method:"POST",headers:m,body:JSON.stringify(this.filesUploaded)})}let v=this.outputHtml;this.mediaGenerated=this.mediaGenerated.filter(m=>v.indexOf(m)!==-1),this.trigger("resultReady",{previewText:_(v),markdown:this.previousResults,html:v,media:this.mediaGenerated,input:this.payloads,output:this.output}),this.settings.saveResults&&(localStorage.setItem("_results",JSON.stringify(this.previousResults)),localStorage.setItem("_results_html",v)),this.addResultTool(),t.querySelectorAll(".link-download").forEach(m=>{m.addEventListener("click",async y=>{y.preventDefault();const k=y.target.href;try{const x=await fetch(k,{mode:"cors"});if(!x.ok)throw new Error("Failed to fetch the image.");const S=await x.blob(),E=k.substring(k.lastIndexOf("/")+1),C=document.createElement("a");C.href=URL.createObjectURL(S),C.download=E,C.click(),URL.revokeObjectURL(C.href)}catch(x){console.error("Error downloading the image:",x)}})})}calculateCost(){const e=this.settings.inputCost/1e6,t=this.settings.outputCost/1e6,i=this.tokenInput*e,n=this.tokenOutput*t;return i+n}loadWorkflow(e){if(!e)return;const i=JSON.parse(e).steps;i.forEach(n=>{Object.prototype.hasOwnProperty.call(n,"context")||(n.context="")}),this.steps=i}getFileInput(e){let t;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}t=document.querySelector(this.settings.previewSelector)}else t=this.element;return t?e?t.querySelector(`input[type="file"][name="${e}"]`):t.querySelector('input[type="file"]'):null}getFormValues(){const e=this.element;if(!e)return[];const t=e.querySelectorAll("[name]");if(t.length===0)return{};const i={};t.forEach(r=>{let{name:o,type:a,value:d,checked:u,files:l}=r;if(a==="checkbox")o=o.replace("[]",""),u&&(i[o]=i[o]||[],d==="other"&&(d=e.querySelector(`[name="${o+"_other"}"]`).value),i[o].push(d));else if(a==="radio")u&&(d==="other"&&(d=e.querySelector(`[name="${o+"_other"}"]`).value),i[o]=d);else if(a==="select-one")d==="other"&&(d=e.querySelector(`[name="${o+"_other"}"]`).value),i[o]=d;else if(a==="file")i[o]=l;else if(a==="select-multiple"){const h=Array.from(r.selectedOptions);i[o]=h.map(p=>p.value)}else if(a==="color"){i[o]=d;const h=this.hexToRgb(d);i[o+"_red"]=h.red,i[o+"_green"]=h.green,i[o+"_blue"]=h.blue}else i[o]=d});let n=[];return this.json.elements.forEach(r=>{let o=r.title,a=r.name,d=r.type;if(a==="")return;let u=i[a],l={questions:o,name:a,value:u,type:d};n.push(l);let h=a+"__url";u=i[h],u&&(l={questions:o,name:h,value:u},n.push(l)),r.useImageMask&&(a=a+"_mask",u=i[a],l={questions:o,name:a,value:u},n.push(l));let p=a+"_red";u=i[p],u!==void 0&&(l={questions:o,name:p,value:u},n.push(l));let b=a+"_green";u=i[b],u!==void 0&&(l={questions:o,name:b,value:u},n.push(l));let w=a+"_blue";u=i[w],u!==void 0&&(l={questions:o,name:w,value:u},n.push(l))}),this.settings.consoleLog&&console.log(n),n}setTheme(e,t){let i;if(!e)i={};else try{i=JSON.parse(e)}catch{i={}}this.themeData=e;const n=i.cssVariables;let s,r=document.documentElement;t&&(r=t),s=n&&n["--form-text-color"]||"",r.style.setProperty("--form-text-color",s),s=n&&n["--form-primary-color"]||"#3b82f6",r.style.setProperty("--form-primary-color",s),s=n&&n["--form-title-color"]||"",r.style.setProperty("--form-title-color",s),s=n&&n["--form-desc-color"]||"",r.style.setProperty("--form-desc-color",s),s=n&&n["--form-label-color"]||"",r.style.setProperty("--form-label-color",s),s=n&&n["--form-label-font-size"]||"",r.style.setProperty("--form-label-font-size",s),s=n&&n["--form-input-font-size"]||"",r.style.setProperty("--form-input-font-size",s),s=n&&n["--form-input-border-color"]||"",r.style.setProperty("--form-input-border-color",s),s=n&&n["--form-primary-border-width"]||"1px",r.style.setProperty("--form-primary-border-width",s),s=n&&n["--form-secondary-border-width"]||"2px",r.style.setProperty("--form-secondary-border-width",s),s=n&&n["--form-input-background-color"]||"",r.style.setProperty("--form-input-background-color",s),s=n&&n["--form-input-text-color"]||"",r.style.setProperty("--form-input-text-color",s),s=n&&n["--form-input-placeholder-color"]||"",r.style.setProperty("--form-input-placeholder-color",s),s=n&&n["--form-choice-border-color"]||"",r.style.setProperty("--form-choice-border-color",s),s=n&&n["--form-switch-background-color"]||"",r.style.setProperty("--form-switch-background-color",s),s=n&&n["--form-switch-knob-color"]||"",r.style.setProperty("--form-switch-knob-color",s),s=n&&n["--form-switch-focus-offset-color"]||"",r.style.setProperty("--form-switch-focus-offset-color",s),s=n&&n["--form-dropfile-border-color"]||"rgb(194 194 194)",r.style.setProperty("--form-dropfile-border-color",s),s=n&&n["--form-dropfile-hover-color"]||"",r.style.setProperty("--form-dropfile-hover-color",s),s=n&&n["--form-button-background-color"]||"",r.style.setProperty("--form-button-background-color",s),s=n&&n["--form-button-hover-background-color"]||"",r.style.setProperty("--form-button-hover-background-color",s),s=n&&n["--form-button-text-color"]||"",r.style.setProperty("--form-button-text-color",s),s=n&&n["--form-button-hover-text-color"]||"",r.style.setProperty("--form-button-hover-text-color",s),s=n&&n["--form-button-border-width"]||"1px",r.style.setProperty("--form-button-border-width",s),s=n&&n["--form-button-border-color"]||"",r.style.setProperty("--form-button-border-color",s),s=n&&n["--form-button-hover-border-color"]||"",r.style.setProperty("--form-button-hover-border-color",s),s=n&&n["--form-reset-background-color"]||"",r.style.setProperty("--form-reset-background-color",s),s=n&&n["--form-reset-hover-background-color"]||"",r.style.setProperty("--form-reset-hover-background-color",s),s=n&&n["--form-reset-text-color"]||"",r.style.setProperty("--form-reset-text-color",s),s=n&&n["--form-reset-hover-text-color"]||"",r.style.setProperty("--form-reset-hover-text-color",s),s=n&&n["--form-reset-border-width"]||"1px",r.style.setProperty("--form-reset-border-width",s),s=n&&n["--form-reset-border-color"]||"",r.style.setProperty("--form-reset-border-color",s),s=n&&n["--form-reset-hover-border-color"]||"",r.style.setProperty("--form-reset-hover-border-color",s)}async send(e,t,i,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,a=1;s||(s=[]),n=n||this.settings.model,s.length>0&&(n=this.settings.model2);const d={question:e,context:t,system:i,functs:s,temperature:r,topP:o,num:a,model:n,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.sendCommandUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(d)})).json();if(h.error)return console.log(`Error:
506
- `+h.error),!1;if(h.answer.usage&&(this.tokenInput+=h.answer.usage.prompt_tokens,this.tokenOutput+=h.answer.usage.completion_tokens),s.length===0){let p;return h.answer.choices.forEach(b=>{p=b.message.content}),p}else return h.answer}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}async sendStream(e,t,i,n,s,r){this.controller=new AbortController,this.signal=this.controller.signal;let o=.6,a=.9,d=1;s||(s=[]),n=n||this.settings.model;const u={question:e,context:t,system:i,functs:s,temperature:o,topP:a,num:d,model:n,customData:this.settings.customData};try{let l={"Content-Type":"application/json",...this.settings.headers};const h=await fetch(this.settings.sendCommandStreamUrl,{signal:this.signal,method:"POST",headers:l,body:JSON.stringify(u)});if(!h.ok)return console.error("Error:",h.statusText),!1;const p=h.body.getReader(),b=new TextDecoder;let w="",_=!1;for(;!_;){const{done:g,value:v}=await p.read();if(_=g,_)break;const f=b.decode(v,{stream:!0});w+=f;const m=w.split(`
505
+ `)),C&&(C.image||C.video||C.audio)||D){const M=await this.media.generate(m,y,k,x,C,L,A);return this.needCleanup=!0,this.settings.consoleLog&&console.log(M),M.mediaGenerated?{media:M.output,media2:M.output2,markdown:M.markdown}:(L.innerHTML=`<p>${M.message}</p>`,!1)}if(this.settings.assistantId){if(this.settings.assistantStreamUrl)await this.assistantStream(m,y,S,E,async M=>{if(!(M&&typeof M=="object")){if(O+=M,!A){const T=z.parse(O);L.innerHTML=T,R+=T}await new Promise(T=>setTimeout(T,50))}}),await new Promise(M=>{const T=setInterval(()=>{L.innerHTML===z.parse(O)&&(clearInterval(T),M())},10)}),A&&(L.innerHTML="",L.remove()),this.outputHtml+=`<div class="result-container">${R}</div>`;else if(this.settings.assistantUrl){let M=await this.assistant(m,y,S,E);if(!M)return!1;if(O=M,A)L.innerHTML="",L.remove();else{const T=z.parse(M);L.innerHTML=T,this.outputHtml+=`<div class="result-container">${T}</div>`}}}else if(this.settings.sendCommandStreamUrl){let M="",T="",$="";const N=async U=>{let G=0;for(;G<U.length;){if($=M.slice(0,$.length+1),G++,!A){const Y=z.parse($);L.innerHTML=Y,T=Y}await new Promise(Y=>setTimeout(Y,50))}};await this.sendStream(m,y,S,x,E,async U=>{O+=U,M+=U,await N(U)}),await new Promise(U=>{const G=setInterval(()=>{$.length===M.length&&(clearInterval(G),U())},10)}),A&&(L.innerHTML="",L.remove()),this.outputHtml+=`<div class="result-container">${T}</div>`}else{let M=await this.send(m,y,S,x,E);if(!M)return!1;if(O=M,A)L.innerHTML="",L.remove();else{const T=z.parse(M);L.innerHTML=T,this.outputHtml+=`<div class="result-container">${T}</div>`}}if(!A){let M="";if(q&&q.urls.forEach($=>{let N=$;N.length>75&&(N=N.slice(0,75)+"..."),M+=`<div><a class="source_url" href="${$}">${N}</url></div>`}),q&&q.failed.forEach($=>{let N=$;N.length>75&&(N=N.slice(0,75)+"..."),M+=`<div><a class="source_url" style="opacity:0.5" href="${$}">${N}</url></div>`}),M!==""){const $=document.createElement("div");$.classList.add("result-container"),t.appendChild($),$.innerHTML=M}}return this.payloads.push({prompt:m,context:y}),this.output.push(O),{media:[],markdown:O}};u||await(async m=>{this.previousResults=[],this.outputHtml="";for(let y=0;y<m.length;y++){if(!this.isGenerating)return;let{prompt:k,context:x,provider:S,model:E,system:C,functs:A,tools:L,hideOutput:D}=m[y];S=S||"",x=x||"",C=C||"You are an assistant",A=A||[];let I=k;this.previousResults.forEach((R,q)=>{const M=`{{output_step_${q+1}}}`;I=I.replace(new RegExp(M,"g"),d(R,k)),I=I.replace(new RegExp(M.toUpperCase(),"g"),d(R,k))}),k=I,k=k.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(k),I=x,this.previousResults.forEach((R,q)=>{const M=`{{output_step_${q+1}}}`;I=I.replace(new RegExp(M,"g"),d(R,k)),I=I.replace(new RegExp(M.toUpperCase(),"g"),d(R,k))}),x=I,x=x.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim();let O=await p(k,x,S,E,C,A,L,D);if(!O)break;if(this.mediaGenerated.push(...O.media),O.media&&O.media.length===1){let R=O.media[0],q=O.media2&&O.media2.length===1&&O.media2[0];this.previousResults.push(q||R),D&&(this.filesUploaded[`output_step_${y}`]=R)}else this.previousResults.push(O.markdown)}})(l),u&&(e===0&&(this.previousResults=[]),await(async(y,k)=>{if(!this.isGenerating)return;let{prompt:x,context:S,provider:E,model:C,system:A,functs:L,tools:D,hideOutput:I}=y[k];S=S||"",A=A||"You are an assistant",L=L||[];let O=x;this.previousResults&&this.previousResults.forEach((q,M)=>{const T=`{{output_step_${M+1}}}`;O=O.replace(new RegExp(T,"g"),q),O=O.replace(new RegExp(T.toUpperCase(),"g"),q)}),x=O,x=x.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(x),O=S,this.previousResults&&this.previousResults.forEach((q,M)=>{const T=`{{output_step_${M+1}}}`;O=O.replace(new RegExp(T,"g"),q),O=O.replace(new RegExp(T.toUpperCase(),"g"),q)}),S=O,S=S.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(S);let R=await p(x,S,E,C,A,L,D,I);if(R&&(this.mediaGenerated.push(...R.media),!!this.previousResults))if(R.media&&R.media.length===1){let q=R.media[0],M=R.media2&&R.media2.length===1&&R.media2[0];this.previousResults[k]=M||q,I&&(this.filesUploaded[`output_step_${k}`]=q)}else this.previousResults[k]=R.markdown})(l,e)),o.innerHTML=a,o.removeAttribute("disabled"),this.isGenerating=!1;const w=this.calculateCost();this.settings.onUsage&&this.settings.onUsage(w),this.trigger("usage",w),this.isNormal=!1,this.isSingle=!1;const _=(m,y=100)=>{const k=document.createElement("div");if(k.innerHTML=m,k.querySelector("video"))return"Video";if(k.querySelector("img"))return"Image";if(k.querySelector("audio"))return"Audio";const x=k.textContent.trim();return x.length>y?x.substring(0,y)+"...":x},g=Object.keys(this.filesUploaded).length===0&&this.filesUploaded.constructor===Object;if(this.needCleanup&&!g){this.settings.consoleLog&&(console.log("Cleanup"),console.log(this.filesUploaded));let m={"Content-Type":"application/json",...this.settings.headers};await fetch(this.settings.cleanup,{method:"POST",headers:m,body:JSON.stringify(this.filesUploaded)})}let v=this.outputHtml;this.mediaGenerated=this.mediaGenerated.filter(m=>v.indexOf(m)!==-1),this.trigger("resultReady",{previewText:_(v),markdown:this.previousResults,html:v,media:this.mediaGenerated,input:this.payloads,output:this.output}),this.settings.saveResults&&(localStorage.setItem("_results",JSON.stringify(this.previousResults)),localStorage.setItem("_results_html",v)),this.addResultTool(),t.querySelectorAll(".link-download").forEach(m=>{m.addEventListener("click",async y=>{y.preventDefault();const k=y.target.href;try{const x=await fetch(k,{mode:"cors"});if(!x.ok)throw new Error("Failed to fetch the image.");const S=await x.blob(),E=k.substring(k.lastIndexOf("/")+1),C=document.createElement("a");C.href=URL.createObjectURL(S),C.download=E,C.click(),URL.revokeObjectURL(C.href)}catch(x){console.error("Error downloading the image:",x)}})})}calculateCost(){const e=this.settings.inputCost/1e6,t=this.settings.outputCost/1e6,i=this.tokenInput*e,n=this.tokenOutput*t;return i+n}loadWorkflow(e){if(!e)return;const i=JSON.parse(e).steps;i.forEach(n=>{Object.prototype.hasOwnProperty.call(n,"context")||(n.context="")}),this.steps=i}getFileInput(e){let t;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}t=document.querySelector(this.settings.previewSelector)}else t=this.element;return t?e?t.querySelector(`input[type="file"][name="${e}"]`):t.querySelector('input[type="file"]'):null}getFormValues(){const e=this.element;if(!e)return[];const t=e.querySelectorAll("[name]");if(t.length===0)return{};const i={};t.forEach(r=>{let{name:o,type:a,value:u,checked:d,files:l}=r;if(a==="checkbox")o=o.replace("[]",""),d&&(i[o]=i[o]||[],u==="other"&&(u=e.querySelector(`[name="${o+"_other"}"]`).value),i[o].push(u));else if(a==="radio")d&&(u==="other"&&(u=e.querySelector(`[name="${o+"_other"}"]`).value),i[o]=u);else if(a==="select-one")u==="other"&&(u=e.querySelector(`[name="${o+"_other"}"]`).value),i[o]=u;else if(a==="file")i[o]=l;else if(a==="select-multiple"){const h=Array.from(r.selectedOptions);i[o]=h.map(p=>p.value)}else if(a==="color"){i[o]=u;const h=this.hexToRgb(u);i[o+"_red"]=h.red,i[o+"_green"]=h.green,i[o+"_blue"]=h.blue}else i[o]=u});let n=[];return this.json.elements.forEach(r=>{let o=r.title,a=r.name,u=r.type;if(a==="")return;let d=i[a],l={questions:o,name:a,value:d,type:u};n.push(l);let h=a+"__url";d=i[h],d&&(l={questions:o,name:h,value:d},n.push(l)),r.useImageMask&&(a=a+"_mask",d=i[a],l={questions:o,name:a,value:d},n.push(l));let p=a+"_red";d=i[p],d!==void 0&&(l={questions:o,name:p,value:d},n.push(l));let b=a+"_green";d=i[b],d!==void 0&&(l={questions:o,name:b,value:d},n.push(l));let w=a+"_blue";d=i[w],d!==void 0&&(l={questions:o,name:w,value:d},n.push(l))}),this.settings.consoleLog&&console.log(n),n}setTheme(e,t){let i;if(!e)i={};else try{i=JSON.parse(e)}catch{i={}}this.themeData=e;const n=i.cssVariables;let s,r=document.documentElement;t&&(r=t),s=n&&n["--form-text-color"]||"",r.style.setProperty("--form-text-color",s),s=n&&n["--form-primary-color"]||"#3b82f6",r.style.setProperty("--form-primary-color",s),s=n&&n["--form-title-color"]||"",r.style.setProperty("--form-title-color",s),s=n&&n["--form-desc-color"]||"",r.style.setProperty("--form-desc-color",s),s=n&&n["--form-label-color"]||"",r.style.setProperty("--form-label-color",s),s=n&&n["--form-label-font-size"]||"",r.style.setProperty("--form-label-font-size",s),s=n&&n["--form-input-font-size"]||"",r.style.setProperty("--form-input-font-size",s),s=n&&n["--form-input-border-color"]||"",r.style.setProperty("--form-input-border-color",s),s=n&&n["--form-primary-border-width"]||"1px",r.style.setProperty("--form-primary-border-width",s),s=n&&n["--form-secondary-border-width"]||"2px",r.style.setProperty("--form-secondary-border-width",s),s=n&&n["--form-input-background-color"]||"",r.style.setProperty("--form-input-background-color",s),s=n&&n["--form-input-text-color"]||"",r.style.setProperty("--form-input-text-color",s),s=n&&n["--form-input-placeholder-color"]||"",r.style.setProperty("--form-input-placeholder-color",s),s=n&&n["--form-choice-border-color"]||"",r.style.setProperty("--form-choice-border-color",s),s=n&&n["--form-switch-background-color"]||"",r.style.setProperty("--form-switch-background-color",s),s=n&&n["--form-switch-knob-color"]||"",r.style.setProperty("--form-switch-knob-color",s),s=n&&n["--form-switch-focus-offset-color"]||"",r.style.setProperty("--form-switch-focus-offset-color",s),s=n&&n["--form-dropfile-border-color"]||"rgb(194 194 194)",r.style.setProperty("--form-dropfile-border-color",s),s=n&&n["--form-dropfile-hover-color"]||"",r.style.setProperty("--form-dropfile-hover-color",s),s=n&&n["--form-button-background-color"]||"",r.style.setProperty("--form-button-background-color",s),s=n&&n["--form-button-hover-background-color"]||"",r.style.setProperty("--form-button-hover-background-color",s),s=n&&n["--form-button-text-color"]||"",r.style.setProperty("--form-button-text-color",s),s=n&&n["--form-button-hover-text-color"]||"",r.style.setProperty("--form-button-hover-text-color",s),s=n&&n["--form-button-border-width"]||"1px",r.style.setProperty("--form-button-border-width",s),s=n&&n["--form-button-border-color"]||"",r.style.setProperty("--form-button-border-color",s),s=n&&n["--form-button-hover-border-color"]||"",r.style.setProperty("--form-button-hover-border-color",s),s=n&&n["--form-reset-background-color"]||"",r.style.setProperty("--form-reset-background-color",s),s=n&&n["--form-reset-hover-background-color"]||"",r.style.setProperty("--form-reset-hover-background-color",s),s=n&&n["--form-reset-text-color"]||"",r.style.setProperty("--form-reset-text-color",s),s=n&&n["--form-reset-hover-text-color"]||"",r.style.setProperty("--form-reset-hover-text-color",s),s=n&&n["--form-reset-border-width"]||"1px",r.style.setProperty("--form-reset-border-width",s),s=n&&n["--form-reset-border-color"]||"",r.style.setProperty("--form-reset-border-color",s),s=n&&n["--form-reset-hover-border-color"]||"",r.style.setProperty("--form-reset-hover-border-color",s)}async send(e,t,i,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,a=1;s||(s=[]),n=n||this.settings.model,s.length>0&&(n=this.settings.model2);const u={question:e,context:t,system:i,functs:s,temperature:r,topP:o,num:a,model:n,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.sendCommandUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(u)})).json();if(h.error)return console.log(`Error:
506
+ `+h.error),!1;if(h.answer.usage&&(this.tokenInput+=h.answer.usage.prompt_tokens,this.tokenOutput+=h.answer.usage.completion_tokens),s.length===0){let p;return h.answer.choices.forEach(b=>{p=b.message.content}),p}else return h.answer}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}async sendStream(e,t,i,n,s,r){this.controller=new AbortController,this.signal=this.controller.signal;let o=.6,a=.9,u=1;s||(s=[]),n=n||this.settings.model;const d={question:e,context:t,system:i,functs:s,temperature:o,topP:a,num:u,model:n,customData:this.settings.customData};try{let l={"Content-Type":"application/json",...this.settings.headers};const h=await fetch(this.settings.sendCommandStreamUrl,{signal:this.signal,method:"POST",headers:l,body:JSON.stringify(d)});if(!h.ok)return console.error("Error:",h.statusText),!1;const p=h.body.getReader(),b=new TextDecoder;let w="",_=!1;for(;!_;){const{done:g,value:v}=await p.read();if(_=g,_)break;const f=b.decode(v,{stream:!0});w+=f;const m=w.split(`
507
507
  `);w="";let y=0,k=0;for(const x of m)if(x.trim()!==""&&x.startsWith("data:")){const S=x.slice(5).trim();if(S==="[DONE]"){this.settings.consoleLog&&console.log("Stream completed.");break}try{const E=JSON.parse(S);if(E.usage&&(y=E.usage.prompt_tokens,k=E.usage.completion_tokens),E.choices&&E.choices[0].delta&&E.choices[0].delta.content){const C=E.choices[0].delta.content;r&&r(C)}}catch{w+=x+`
508
- `}}this.tokenInput+=y,this.tokenOutput+=k}return!0}catch(l){return l.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",l),!1}}async assistant(e,t,i,n){this.controller=new AbortController,this.signal=this.controller.signal;let s=.6,r=.9,o=1;n||(n=[]);let a=this.settings.model;n.length>0&&(a=this.settings.model2);const d={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:s,topP:r,num:o,model:a,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(d)})).json();return h.error?(console.log(`Error:
509
- `+h.error),!1):(h.usage&&(this.tokenInput+=h.usage.prompt_tokens,this.tokenOutput+=h.usage.completion_tokens),h.answer.content[0].text.value)}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}async assistantStream(e,t,i,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,a=1;n||(n=[]);const d={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:r,topP:o,num:a,model:this.settings.model,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers};const l=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(d)});if(!l.ok)return console.error("Error:",l.statusText),!1;const h=l.body.getReader(),p=new TextDecoder;let b="",w=!1;for(;!w;){const{done:_,value:g}=await h.read();if(w=_,w)break;const v=p.decode(g,{stream:!0});b+=v;const f=b.split(`
508
+ `}}this.tokenInput+=y,this.tokenOutput+=k}return!0}catch(l){return l.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",l),!1}}async assistant(e,t,i,n){this.controller=new AbortController,this.signal=this.controller.signal;let s=.6,r=.9,o=1;n||(n=[]);let a=this.settings.model;n.length>0&&(a=this.settings.model2);const u={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:s,topP:r,num:o,model:a,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers},h=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(u)})).json();return h.error?(console.log(`Error:
509
+ `+h.error),!1):(h.usage&&(this.tokenInput+=h.usage.prompt_tokens,this.tokenOutput+=h.usage.completion_tokens),h.answer.content[0].text.value)}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}async assistantStream(e,t,i,n,s){this.controller=new AbortController,this.signal=this.controller.signal;let r=.6,o=.9,a=1;n||(n=[]);const u={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:r,topP:o,num:a,model:this.settings.model,customData:this.settings.customData};try{let d={"Content-Type":"application/json",...this.settings.headers};const l=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:d,body:JSON.stringify(u)});if(!l.ok)return console.error("Error:",l.statusText),!1;const h=l.body.getReader(),p=new TextDecoder;let b="",w=!1;for(;!w;){const{done:_,value:g}=await h.read();if(w=_,w)break;const v=p.decode(g,{stream:!0});b+=v;const f=b.split(`
510
510
  `);b="";for(const m of f)if(m.trim()!=="")if(m.startsWith("data:")){const y=m.slice(5).trim();y==="[DONE]"&&this.settings.consoleLog&&console.log("Stream completed.");try{const k=JSON.parse(y);if(k.choices&&k.choices[0].delta&&k.choices[0].delta.content){const x=k.choices[0].delta.content;s&&s(x)}}catch{b+=m+`
511
- `}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(u){return u.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",u),!1}}hexToRgb(e){const t=e.replace("#",""),i=parseInt(t,16),n=i>>16&255,s=i>>8&255,r=i&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,t){e&&t&&e.insertAdjacentHTML("beforeend",t)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(t=>{t.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(t=>{t.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const t=e.querySelector(".submit-container"),i=this.getScrollableParent(t);i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let t=this.settings.lang[e];return t||e}}class mn{constructor(e={}){this.config={plugins:{},autoLoad:!0,pluginBaseUrl:"",allowExternalPlugins:!0,trustedDomains:[],...e},this.plugins=new Map,this.loadedStyles=new Set,this.components=new Map,this.externalPlugins=new Map}async autoLoadPlugins(){const t=this.detectComponentTypes().filter(i=>this.config.plugins[i]&&!this.plugins.has(i));return t.length>0&&await Promise.all(t.map(i=>this.loadPlugin(i))),t}detectComponentTypes(){const e=new Set;return document.querySelectorAll("[data-cb-type]").forEach(t=>{e.add(t.dataset.cbType)}),document.querySelectorAll('[class*="cb-"]').forEach(t=>{t.classList.forEach(i=>{if(i.startsWith("cb-")){const n=i.replace("cb-","");e.add(n)}})}),Array.from(e)}async loadPlugin(e){if(this.plugins.has(e))return this.plugins.get(e);const t=this.config.plugins[e];if(!t)return console.warn(`[PluginManager] Plugin "${e}" not found in registry`),null;try{t.css&&this.loadCSS(this.resolveUrl(t.css));const i=this.resolveUrl(t.url),n=await this.importModule(i),s=n.default||n;return this.plugins.set(e,s),typeof s.init=="function"&&await s.init(this),this.emit("plugin-loaded",{name:e,plugin:s}),s}catch(i){return console.error(`[PluginManager] Failed to load plugin "${e}":`,i),null}}async importModule(e){return import(e)}loadCSS(e){if(this.loadedStyles.has(e))return;const t=document.createElement("link");t.rel="stylesheet",t.href=e,t.onload=()=>{this.emit("css-loaded",{url:e})},t.onerror=()=>{console.error(`[PluginManager] Failed to load CSS: ${e}`)},document.head.appendChild(t),this.loadedStyles.add(e)}resolveUrl(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")?e:this.config.pluginBaseUrl+e}initializeComponents(){return document.querySelectorAll("[data-cb-type]").forEach(t=>{const i=t.dataset.cbType,n=this.plugins.get(i);if(n&&typeof n.mount=="function")try{const s=this.parseOptions(t);t.hasAttribute("data-cb-original-content")||t.setAttribute("data-cb-original-content",t.innerHTML);const r=n.mount(t,s);this.components.set(t,r),t.setAttribute("data-cb-loaded","true")}catch(s){console.error(`[PluginManager] Failed to mount component "${i}":`,s)}}),this.components.size}parseOptions(e){const t={};return Array.from(e.attributes).forEach(i=>{if(i.name.startsWith("data-cb-")){const n=i.name.replace("data-cb-","").replace(/-([a-z])/g,(s,r)=>r.toUpperCase());t[n]=this.parseValue(i.value)}}),t}parseValue(e){if(e==="true")return!0;if(e==="false")return!1;if(!isNaN(e)&&e!=="")return Number(e);try{return JSON.parse(e)}catch{return e}}async use(e){return await this.loadPlugin(e)}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.entries())}hasPlugin(e){return this.plugins.has(e)}getComponent(e){return this.components.get(e)}async reinitialize(e=document){if(this.reinitializeInProgress)return clearTimeout(this.pendingReinitialize),new Promise(t=>{this.pendingReinitialize=setTimeout(async()=>{this.pendingReinitialize=null;const i=await this.reinitialize(e);t(i)},100)});this.reinitializeInProgress=!0;try{const t=[];this.components.forEach((o,a)=>{(e===document||e.contains(a))&&t.push({element:a,instance:o})}),t.forEach(({element:o,instance:a})=>{const d=o.dataset.cbType,u=this.plugins.get(d);u&&typeof u.unmount=="function"&&u.unmount(o,a),this.components.delete(o)});const n=this.detectComponentTypesInContainer(e).filter(o=>this.config.plugins[o]&&!this.plugins.has(o));n.length>0&&await Promise.all(n.map(o=>this.loadPlugin(o)));const s=e.querySelectorAll("[data-cb-type]");let r=0;for(const o of s){const a=o.dataset.cbType,d=this.plugins.get(a);if(d&&typeof d.mount=="function")try{const u=this.parseOptions(o);o.hasAttribute("data-cb-original-content")?o.innerHTML=o.getAttribute("data-cb-original-content"):o.setAttribute("data-cb-original-content",o.innerHTML);const l=await d.mount(o,u);this.components.set(o,l),o.setAttribute("data-cb-loaded","true"),r++}catch(u){console.error(`[PluginManager] Failed to mount component "${a}":`,u)}}return this.emit("reinitialized",{container:e,count:r}),r}finally{this.reinitializeInProgress=!1}}detectComponentTypesInContainer(e){const t=new Set;return e.querySelectorAll("[data-cb-type]").forEach(n=>{t.add(n.dataset.cbType)}),Array.from(t)}async loadExternalPlugin(e,t){if(!e||typeof e!="string")throw new Error("Plugin ID is required and must be a string");if(!t.url)throw new Error("Plugin URL is required");if(this.plugins.has(e))return console.warn(`[PluginManager] Plugin "${e}" is already loaded`),this.plugins.get(e);const i=this.validatePluginSource(t.url);if(!i.allowed)throw new Error(`Security: ${i.reason}`);i.warning&&(console.warn(`[PluginManager] ${i.warning}`),this.emit("plugin-security-warning",{pluginId:e,url:t.url,warning:i.warning}));try{this.config.plugins[e]={url:t.url,css:t.css||null,source:"external",loadedAt:new Date().toISOString()},this.externalPlugins.set(e,this.config.plugins[e]);const n=await this.loadPlugin(e);return this.emit("external-plugin-loaded",{pluginId:e,url:t.url}),n}catch(n){throw delete this.config.plugins[e],this.externalPlugins.delete(e),console.error(`[PluginManager] Failed to load external plugin "${e}":`,n),n}}validatePluginSource(e){const t=e.includes("localhost")||e.includes("127.0.0.1");if(!e.startsWith("https://")&&!t)return{allowed:!1,reason:"Only HTTPS URLs are allowed (except localhost for development)"};if(!this.config.allowExternalPlugins)return{allowed:!1,reason:"External plugins are disabled. Enable allowExternalPlugins in configuration."};if(this.config.trustedDomains.length>0){const n=new URL(e).hostname;if(!this.config.trustedDomains.some(r=>{if(r.startsWith("*.")){const o=r.slice(2);return n===o||n.endsWith("."+o)}return n===r}))return{allowed:!0,warning:`Loading plugin from external domain: ${n}. Only add plugins from sources you trust.`}}else return{allowed:!0,warning:`Loading external plugin from: ${new URL(e).hostname}. This plugin will have full access to your page.`};return{allowed:!0}}async loadExternalPlugins(e){const t=[];for(const[i,n]of Object.entries(e))try{const s=await this.loadExternalPlugin(i,n);t.push({pluginId:i,success:!0,plugin:s})}catch(s){t.push({pluginId:i,success:!1,error:s.message}),console.error(`[PluginManager] Failed to load external plugin "${i}":`,s)}return t}unregisterPlugin(e){if(!this.externalPlugins.has(e))return console.warn(`[PluginManager] Plugin "${e}" is not an external plugin`),!1;const t=this.plugins.get(e),i=[];return this.components.forEach((n,s)=>{s.dataset.cbType===e&&i.push({element:s,instance:n})}),i.forEach(({element:n,instance:s})=>{t&&typeof t.unmount=="function"&&t.unmount(n,s),this.components.delete(n)}),t&&typeof t.destroy=="function"&&t.destroy(this),this.plugins.delete(e),this.externalPlugins.delete(e),delete this.config.plugins[e],this.emit("plugin-unregistered",{pluginId:e}),!0}getExternalPlugins(){return Array.from(this.externalPlugins.entries()).map(([e,t])=>({id:e,...t}))}isExternalPlugin(e){return this.externalPlugins.has(e)}destroy(){this.components.forEach((e,t)=>{const i=t.dataset.cbType,n=this.plugins.get(i);n&&typeof n.unmount=="function"&&n.unmount(t,e)}),this.plugins.forEach((e,t)=>{typeof e.destroy=="function"&&e.destroy(this)}),this.components.clear(),this.plugins.clear()}emit(e,t){if(this.runtime&&typeof this.runtime.emit=="function")this.runtime.emit(e,t);else{const i=new CustomEvent(`contentbox:${e}`,{detail:t});document.dispatchEvent(i)}}setRuntime(e){this.runtime=e}}class bn{constructor(e={}){const t={skin:"light",plugins:{},autoLoadPlugins:!0,pluginBaseUrl:"",allowExternalPlugins:!0,trustedDomains:[]};this.settings={...t,...e},this.initialized=!1,this.pluginManager=new mn({plugins:this.settings.plugins,autoLoad:this.settings.autoLoadPlugins,pluginBaseUrl:this.settings.pluginBaseUrl,allowExternalPlugins:this.settings.allowExternalPlugins,trustedDomains:this.settings.trustedDomains}),this.pluginManager.setRuntime(this),window.Glide=Rs,window.FormViewer=gn}async use(e){return await this.pluginManager.use(e)}getPlugin(e){return this.pluginManager.getPlugin(e)}getPlugins(){return this.pluginManager.getAllPlugins()}hasPlugin(e){return this.pluginManager.hasPlugin(e)}getComponent(e){return this.pluginManager.getComponent(e)}getComponents(){return this.pluginManager.components}async reinitialize(e){const t=await this.pluginManager.reinitialize(e);return this.initCore(),t}async loadExternalPlugin(e,t){return await this.pluginManager.loadExternalPlugin(e,t)}async loadExternalPlugins(e){return await this.pluginManager.loadExternalPlugins(e)}unregisterPlugin(e){return this.pluginManager.unregisterPlugin(e)}emit(e,t){const i=new CustomEvent(`contentbox:${e}`,{detail:t});document.dispatchEvent(i)}on(e,t){document.addEventListener(`contentbox:${e}`,t)}off(e,t){document.removeEventListener(`contentbox:${e}`,t)}init(){this.initialized||(this.initCore(),this.initPlugins(),this.initialized=!0,this.emit("init"))}async initPlugins(){this.settings.autoLoadPlugins&&await this.pluginManager.autoLoadPlugins(),this.pluginManager.initializeComponents()}initCore(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{const n=s=>{let r=i.getAttribute("href")||i.getAttribute("data-modal-url");this.openLightbox(r,i,e),s.preventDefault(),s.stopImmediatePropagation()};i.addEventListener("click",n),i._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,t,i){let n=[],s=0;if(t){const o=t.closest("[data-gallery]");let a=[];o?a=o.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(u=>{u.closest("[data-gallery]")||a.push(u)}),a.forEach((d,u)=>{let l=d.getAttribute("href");l||(l=d.getAttribute("data-modal-url")),n.push({href:l}),e===l&&(s=u)})}const r=document.activeElement;r?.blur(),n.length>0?(this.glightbox.setElements(n),this.glightbox.openAt(s)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(i),r?.focus()})}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(t=>{t._lightboxHandler&&(t.removeEventListener("click",t._lightboxHandler),delete t._lightboxHandler)}),this.pluginManager.destroy(),this.initialized=!1,this.emit("destroy")}}return bn})();
511
+ `}}else{const y=JSON.parse(m);this.tokenInput+=y.prompt_tokens,this.tokenOutput+=y.completion_tokens;break}}return!0}catch(d){return d.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",d),!1}}hexToRgb(e){const t=e.replace("#",""),i=parseInt(t,16),n=i>>16&255,s=i>>8&255,r=i&255;return{red:n,green:s,blue:r}}getId(e="id"){return`${e}-${Math.random().toString(36).substr(2,9)}`}appendHtml(e,t){e&&t&&e.insertAdjacentHTML("beforeend",t)}cleanup(){if(this.element){let e=this.element.querySelectorAll('input[type="text"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], textarea');e.forEach(t=>{t.removeEventListener("input",this.inputListener)}),e=this.element.querySelectorAll('input[type="date"], input[type="radio"], input[type="checkbox"]'),e.forEach(t=>{t.removeEventListener("change",this.changeListener)}),this.debounceTimeout&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=null)}}destroy(){try{if(this._scrollListener){let e;this.settings.isBuilder?e=document.querySelector(this.settings.previewSelector):e=this.element;const t=e.querySelector(".submit-container"),i=this.getScrollableParent(t);i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._scrollListener)}}catch{}this.element&&(this.cleanup(),this.element.innerHTML="",this.element=null);for(const e in this.listeners)this.listeners[e].clear();this.listeners={}}out(e){let t=this.settings.lang[e];return t||e}}class mn{constructor(e={}){this.config={plugins:{},autoLoad:!0,pluginBaseUrl:"",allowExternalPlugins:!0,trustedDomains:[],...e},this.plugins=new Map,this.loadedStyles=new Set,this.components=new Map,this.externalPlugins=new Map}async autoLoadPlugins(){const t=this.detectComponentTypes().filter(i=>this.config.plugins[i]&&!this.plugins.has(i));return t.length>0&&await Promise.all(t.map(i=>this.loadPlugin(i))),t}detectComponentTypes(){const e=new Set;return document.querySelectorAll("[data-cb-type]").forEach(t=>{e.add(t.dataset.cbType)}),document.querySelectorAll('[class*="cb-"]').forEach(t=>{t.classList.forEach(i=>{if(i.startsWith("cb-")){const n=i.replace("cb-","");e.add(n)}})}),Array.from(e)}async loadPlugin(e){if(this.plugins.has(e))return this.plugins.get(e);const t=this.config.plugins[e];if(!t)return console.warn(`[PluginManager] Plugin "${e}" not found in registry`),null;try{t.css&&this.loadCSS(this.resolveUrl(t.css));const i=this.resolveUrl(t.url),n=await this.importModule(i),s=n.default||n;return this.plugins.set(e,s),typeof s.init=="function"&&await s.init(this),this.emit("plugin-loaded",{name:e,plugin:s}),s}catch(i){return console.error(`[PluginManager] Failed to load plugin "${e}":`,i),null}}async importModule(e){return import(e)}loadCSS(e){if(this.loadedStyles.has(e))return;const t=document.createElement("link");t.rel="stylesheet",t.href=e,t.onload=()=>{this.emit("css-loaded",{url:e})},t.onerror=()=>{console.error(`[PluginManager] Failed to load CSS: ${e}`)},document.head.appendChild(t),this.loadedStyles.add(e)}resolveUrl(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//")?e:this.config.pluginBaseUrl+e}initializeComponents(){return document.querySelectorAll("[data-cb-type]").forEach(t=>{const i=t.dataset.cbType,n=this.plugins.get(i);if(n&&typeof n.mount=="function")try{const s=this.parseOptions(t);let r=t.querySelector(".grid-sortable");r||t.classList.contains("grid-sortable")&&(r=t),r&&Array.from(r.children).forEach((a,u)=>{a.nodeType===1&&a.tagName!=="STYLE"&&a.tagName!=="SCRIPT"&&a.setAttribute("data-index",u)}),t.hasAttribute("data-cb-original-content")||t.setAttribute("data-cb-original-content",t.innerHTML);const o=n.mount(t,s);this.components.set(t,o),t.setAttribute("data-cb-loaded","true")}catch(s){console.error(`[PluginManager] Failed to mount component "${i}":`,s)}}),this.components.size}parseOptions(e){const t={};return Array.from(e.attributes).forEach(i=>{if(i.name.startsWith("data-cb-")){const n=i.name.replace("data-cb-","").replace(/-([a-z])/g,(s,r)=>r.toUpperCase());t[n]=this.parseValue(i.value)}}),t}parseValue(e){if(e==="true")return!0;if(e==="false")return!1;if(!isNaN(e)&&e!=="")return Number(e);try{return JSON.parse(e)}catch{return e}}async use(e){return await this.loadPlugin(e)}getPlugin(e){return this.plugins.get(e)}getAllPlugins(){return Array.from(this.plugins.entries())}hasPlugin(e){return this.plugins.has(e)}getComponent(e){return this.components.get(e)}async reinitialize(e=document){if(this.reinitializeInProgress)return clearTimeout(this.pendingReinitialize),new Promise(t=>{this.pendingReinitialize=setTimeout(async()=>{this.pendingReinitialize=null;const i=await this.reinitialize(e);t(i)},100)});this.reinitializeInProgress=!0;try{const t=[];this.components.forEach((o,a)=>{(e===document||e.contains(a))&&t.push({element:a,instance:o})}),t.forEach(({element:o,instance:a})=>{const u=o.dataset.cbType,d=this.plugins.get(u);d&&typeof d.unmount=="function"&&d.unmount(o,a),this.components.delete(o)});const n=this.detectComponentTypesInContainer(e).filter(o=>this.config.plugins[o]&&!this.plugins.has(o));n.length>0&&await Promise.all(n.map(o=>this.loadPlugin(o)));const s=e.querySelectorAll("[data-cb-type]");let r=0;for(const o of s){const a=o.dataset.cbType,u=this.plugins.get(a);if(u&&typeof u.mount=="function")try{const d=this.parseOptions(o);let l=o.querySelector(".grid-sortable");l||o.classList.contains("grid-sortable")&&(l=o),l&&Array.from(l.children).forEach((p,b)=>{p.nodeType===1&&p.tagName!=="STYLE"&&p.tagName!=="SCRIPT"&&p.setAttribute("data-index",b)}),o.hasAttribute("data-cb-original-content")?o.innerHTML=o.getAttribute("data-cb-original-content"):o.setAttribute("data-cb-original-content",o.innerHTML);const h=await u.mount(o,d);this.components.set(o,h),o.setAttribute("data-cb-loaded","true"),r++}catch(d){console.error(`[PluginManager] Failed to mount component "${a}":`,d)}}return this.emit("reinitialized",{container:e,count:r}),r}finally{this.reinitializeInProgress=!1}}detectComponentTypesInContainer(e){const t=new Set;return e.querySelectorAll("[data-cb-type]").forEach(n=>{t.add(n.dataset.cbType)}),Array.from(t)}async loadExternalPlugin(e,t){if(!e||typeof e!="string")throw new Error("Plugin ID is required and must be a string");if(!t.url)throw new Error("Plugin URL is required");if(this.plugins.has(e))return console.warn(`[PluginManager] Plugin "${e}" is already loaded`),this.plugins.get(e);const i=this.validatePluginSource(t.url);if(!i.allowed)throw new Error(`Security: ${i.reason}`);i.warning&&(console.warn(`[PluginManager] ${i.warning}`),this.emit("plugin-security-warning",{pluginId:e,url:t.url,warning:i.warning}));try{this.config.plugins[e]={url:t.url,css:t.css||null,source:"external",loadedAt:new Date().toISOString()},this.externalPlugins.set(e,this.config.plugins[e]);const n=await this.loadPlugin(e);return this.emit("external-plugin-loaded",{pluginId:e,url:t.url}),n}catch(n){throw delete this.config.plugins[e],this.externalPlugins.delete(e),console.error(`[PluginManager] Failed to load external plugin "${e}":`,n),n}}validatePluginSource(e){const t=e.includes("localhost")||e.includes("127.0.0.1");if(!e.startsWith("https://")&&!t)return{allowed:!1,reason:"Only HTTPS URLs are allowed (except localhost for development)"};if(!this.config.allowExternalPlugins)return{allowed:!1,reason:"External plugins are disabled. Enable allowExternalPlugins in configuration."};if(this.config.trustedDomains.length>0){const n=new URL(e).hostname;if(!this.config.trustedDomains.some(r=>{if(r.startsWith("*.")){const o=r.slice(2);return n===o||n.endsWith("."+o)}return n===r}))return{allowed:!0,warning:`Loading plugin from external domain: ${n}. Only add plugins from sources you trust.`}}else return{allowed:!0,warning:`Loading external plugin from: ${new URL(e).hostname}. This plugin will have full access to your page.`};return{allowed:!0}}async loadExternalPlugins(e){const t=[];for(const[i,n]of Object.entries(e))try{const s=await this.loadExternalPlugin(i,n);t.push({pluginId:i,success:!0,plugin:s})}catch(s){t.push({pluginId:i,success:!1,error:s.message}),console.error(`[PluginManager] Failed to load external plugin "${i}":`,s)}return t}unregisterPlugin(e){if(!this.externalPlugins.has(e))return console.warn(`[PluginManager] Plugin "${e}" is not an external plugin`),!1;const t=this.plugins.get(e),i=[];return this.components.forEach((n,s)=>{s.dataset.cbType===e&&i.push({element:s,instance:n})}),i.forEach(({element:n,instance:s})=>{t&&typeof t.unmount=="function"&&t.unmount(n,s),this.components.delete(n)}),t&&typeof t.destroy=="function"&&t.destroy(this),this.plugins.delete(e),this.externalPlugins.delete(e),delete this.config.plugins[e],this.emit("plugin-unregistered",{pluginId:e}),!0}getExternalPlugins(){return Array.from(this.externalPlugins.entries()).map(([e,t])=>({id:e,...t}))}isExternalPlugin(e){return this.externalPlugins.has(e)}destroy(){this.components.forEach((e,t)=>{const i=t.dataset.cbType,n=this.plugins.get(i);n&&typeof n.unmount=="function"&&n.unmount(t,e)}),this.plugins.forEach((e,t)=>{typeof e.destroy=="function"&&e.destroy(this)}),this.components.clear(),this.plugins.clear()}emit(e,t){if(this.runtime&&typeof this.runtime.emit=="function")this.runtime.emit(e,t);else{const i=new CustomEvent(`contentbox:${e}`,{detail:t});document.dispatchEvent(i)}}setRuntime(e){this.runtime=e}}class bn{constructor(e={}){const t={skin:"light",plugins:{},autoLoadPlugins:!0,pluginBaseUrl:"",allowExternalPlugins:!0,trustedDomains:[]};this.settings={...t,...e},this.initialized=!1,this.pluginManager=new mn({plugins:this.settings.plugins,autoLoad:this.settings.autoLoadPlugins,pluginBaseUrl:this.settings.pluginBaseUrl,allowExternalPlugins:this.settings.allowExternalPlugins,trustedDomains:this.settings.trustedDomains}),this.pluginManager.setRuntime(this),window.Glide=Rs,window.FormViewer=gn}async use(e){return await this.pluginManager.use(e)}getPlugin(e){return this.pluginManager.getPlugin(e)}getPlugins(){return this.pluginManager.getAllPlugins()}hasPlugin(e){return this.pluginManager.hasPlugin(e)}getComponent(e){return this.pluginManager.getComponent(e)}getComponents(){return this.pluginManager.components}async reinitialize(e){const t=await this.pluginManager.reinitialize(e);return this.initCore(),t}async loadExternalPlugin(e,t){return await this.pluginManager.loadExternalPlugin(e,t)}async loadExternalPlugins(e){return await this.pluginManager.loadExternalPlugins(e)}unregisterPlugin(e){return this.pluginManager.unregisterPlugin(e)}emit(e,t){const i=new CustomEvent(`contentbox:${e}`,{detail:t});document.dispatchEvent(i)}on(e,t){document.addEventListener(`contentbox:${e}`,t)}off(e,t){document.removeEventListener(`contentbox:${e}`,t)}init(){this.initialized||(this.initCore(),this.initPlugins(),this.initialized=!0,this.emit("init"))}async initPlugins(){this.settings.autoLoadPlugins&&await this.pluginManager.autoLoadPlugins(),this.pluginManager.initializeComponents()}initCore(){const e={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(e),document.querySelectorAll(".is-lightbox,.block-click").forEach(i=>{const n=s=>{let r=i.getAttribute("href")||i.getAttribute("data-modal-url");this.openLightbox(r,i,e),s.preventDefault(),s.stopImmediatePropagation()};i.addEventListener("click",n),i._lightboxHandler=n})}refreshLightbox(e){this.glightbox&&this.glightbox.destroy(),this.glightbox=new jt(e),window.GLightbox=jt.default}openLightbox(e,t,i){let n=[],s=0;if(t){const o=t.closest("[data-gallery]");let a=[];o?a=o.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(d=>{d.closest("[data-gallery]")||a.push(d)}),a.forEach((u,d)=>{let l=u.getAttribute("href");l||(l=u.getAttribute("data-modal-url")),n.push({href:l}),e===l&&(s=d)})}const r=document.activeElement;r?.blur(),n.length>0?(this.glightbox.setElements(n),this.glightbox.openAt(s)):(this.glightbox.setElements([{href:e}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(i),r?.focus()})}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(t=>{t._lightboxHandler&&(t.removeEventListener("click",t._lightboxHandler),delete t._lightboxHandler)}),this.pluginManager.destroy(),this.initialized=!1,this.emit("destroy")}}return bn})();