@innovastudio/contentbuilder-runtime 1.0.4 → 1.0.6
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";function ae(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ut={exports:{}},oe=ut.exports,Ht;function le(){return Ht||(Ht=1,(function(s,i){(function(a,r){s.exports=r()})(oe,(function(){function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,l(o.key),o)}}function c(t,e,n){return e&&r(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function l(t){var e=(function(n,o){if(typeof n!="object"||!n)return n;var u=n[Symbol.toPrimitive];if(u!==void 0){var f=u.call(n,o);if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)})(t,"string");return typeof e=="symbol"?e:e+""}function h(t){return(h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}var v=Date.now();function m(){var t={},e=!0,n=0,o=arguments.length;Object.prototype.toString.call(arguments[0])==="[object Boolean]"&&(e=arguments[0],n++);for(var u=function(d){for(var g in d)Object.prototype.hasOwnProperty.call(d,g)&&(e&&Object.prototype.toString.call(d[g])==="[object Object]"?t[g]=m(!0,t[g],d[g]):t[g]=d[g])};n<o;n++){var f=arguments[n];u(f)}return t}function p(t,e){if((J(t)||t===window||t===document)&&(t=[t]),Ut(t)||rt(t)||(t=[t]),Jt(t)!=0){if(Ut(t)&&!rt(t))for(var n=t.length,o=0;o<n&&e.call(t[o],t[o],o,t)!==!1;o++);else if(rt(t)){for(var u in t)if(H(t,u)&&e.call(t[u],t[u],u,t)===!1)break}}}function y(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,o=t[v]=t[v]||[],u={all:o,evt:null,found:null};return e&&n&&Jt(o)>0&&p(o,(function(f,d){if(f.eventName==e&&f.fn.toString()==n.toString())return u.found=!0,u.evt=d,!1})),u}function S(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.onElement,o=e.withCallback,u=e.avoidDuplicate,f=u===void 0||u,d=e.once,g=d!==void 0&&d,x=e.useCapture,w=x!==void 0&&x,T=arguments.length>2?arguments[2]:void 0,k=n||[];function E(O){P(o)&&o.call(T,O,this),g&&E.destroy()}return ot(k)&&(k=document.querySelectorAll(k)),E.destroy=function(){p(k,(function(O){var _=y(O,t,E);_.found&&_.all.splice(_.evt,1),O.removeEventListener&&O.removeEventListener(t,E,w)}))},p(k,(function(O){var _=y(O,t,E);(O.addEventListener&&f&&!_.found||!f)&&(O.addEventListener(t,E,w),_.all.push({eventName:t,fn:E}))})),E}function b(t,e){p(e.split(" "),(function(n){return t.classList.add(n)}))}function A(t,e){p(e.split(" "),(function(n){return t.classList.remove(n)}))}function C(t,e){return t.classList.contains(e)}function L(t,e){for(;t!==document.body;){if(!(t=t.parentElement))return!1;if(typeof t.matches=="function"?t.matches(e):t.msMatchesSelector(e))return t}}function B(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(!t||e==="")return!1;if(e==="none")return P(n)&&n(),!1;var o=Pt(),u=e.split(" ");p(u,(function(f){b(t,"g"+f)})),S(o,{onElement:t,avoidDuplicate:!1,once:!0,withCallback:function(f,d){p(u,(function(g){A(d,"g"+g)})),P(n)&&n()}})}function R(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(e==="")return t.style.webkitTransform="",t.style.MozTransform="",t.style.msTransform="",t.style.OTransform="",t.style.transform="",!1;t.style.webkitTransform=e,t.style.MozTransform=e,t.style.msTransform=e,t.style.OTransform=e,t.style.transform=e}function V(t){t.style.display="block"}function F(t){t.style.display="none"}function Z(t){var e=document.createDocumentFragment(),n=document.createElement("div");for(n.innerHTML=t;n.firstChild;)e.appendChild(n.firstChild);return e}function yt(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function Pt(){var t,e=document.createElement("fakeelement"),n={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in n)if(e.style[t]!==void 0)return n[t]}function It(t,e,n,o){if(t())e();else{var u;n||(n=100);var f=setInterval((function(){t()&&(clearInterval(f),u&&clearTimeout(u),e())}),n)}}function $t(t,e,n){if(Y(t))console.error("Inject assets error");else if(P(e)&&(n=e,e=!1),ot(e)&&e in window)P(n)&&n();else{var o;if(t.indexOf(".css")!==-1){if((o=document.querySelectorAll('link[href="'+t+'"]'))&&o.length>0)return void(P(n)&&n());var u=document.getElementsByTagName("head")[0],f=u.querySelectorAll('link[rel="stylesheet"]'),d=document.createElement("link");return d.rel="stylesheet",d.type="text/css",d.href=t,d.media="all",f?u.insertBefore(d,f[0]):u.appendChild(d),void(P(n)&&n())}if((o=document.querySelectorAll('script[src="'+t+'"]'))&&o.length>0){if(P(n)){if(ot(e))return It((function(){return window[e]!==void 0}),(function(){n()})),!1;n()}}else{var g=document.createElement("script");g.type="text/javascript",g.src=t,g.onload=function(){if(P(n)){if(ot(e))return It((function(){return window[e]!==void 0}),(function(){n()})),!1;n()}},document.body.appendChild(g)}}}function Mt(){return"navigator"in window&&window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i)}function P(t){return typeof t=="function"}function ot(t){return typeof t=="string"}function J(t){return!(!t||!t.nodeType||t.nodeType!=1)}function Kt(t){return Array.isArray(t)}function Ut(t){return t&&t.length&&isFinite(t.length)}function rt(t){return h(t)==="object"&&t!=null&&!P(t)&&!Kt(t)}function Y(t){return t==null}function H(t,e){return t!==null&&hasOwnProperty.call(t,e)}function Jt(t){if(rt(t)){if(t.keys)return t.keys().length;var e=0;for(var n in t)H(t,n)&&e++;return e}return t.length}function bt(t){return!isNaN(parseFloat(t))&&isFinite(t)}function Qt(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1,e=document.querySelectorAll(".gbtn[data-taborder]:not(.disabled)");if(!e.length)return!1;if(e.length==1)return e[0];typeof t=="string"&&(t=parseInt(t));var n=[];p(e,(function(g){n.push(g.getAttribute("data-taborder"))}));var o=Math.max.apply(Math,n.map((function(g){return parseInt(g)}))),u=t<0?1:t+1;u>o&&(u="1");var f=n.filter((function(g){return g>=parseInt(u)})),d=f.sort()[0];return document.querySelector('.gbtn[data-taborder="'.concat(d,'"]'))}function si(t){if(t.events.hasOwnProperty("keyboard"))return!1;t.events.keyboard=S("keydown",{onElement:window,withCallback:function(e,n){var o=(e=e||window.event).keyCode;if(o==9){var u=document.querySelector(".gbtn.focused");if(!u){var f=!(!document.activeElement||!document.activeElement.nodeName)&&document.activeElement.nodeName.toLocaleLowerCase();if(f=="input"||f=="textarea"||f=="button")return}e.preventDefault();var d=document.querySelectorAll(".gbtn[data-taborder]");if(!d||d.length<=0)return;if(!u){var g=Qt();return void(g&&(g.focus(),b(g,"focused")))}var x=Qt(u.getAttribute("data-taborder"));A(u,"focused"),x&&(x.focus(),b(x,"focused"))}o==39&&t.nextSlide(),o==37&&t.prevSlide(),o==27&&t.close()}})}var ri=c((function t(e,n){var o=this,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(a(this,t),this.img=e,this.slide=n,this.onclose=u,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",(function(f){return o.dragStart(f)}),!1),this.img.addEventListener("mouseup",(function(f){return o.dragEnd(f)}),!1),this.img.addEventListener("mousemove",(function(f){return o.drag(f)}),!1),this.img.addEventListener("click",(function(f){return o.slide.classList.contains("dragging-nav")?(o.zoomOut(),!1):o.zoomedIn?void(o.zoomedIn&&!o.dragging&&o.zoomOut()):o.zoomIn()}),!1),this.img.setZoomEvents=!0}),[{key:"zoomIn",value:function(){var t=this.widowWidth();if(!(this.zoomedIn||t<=768)){var e=this.img;if(e.setAttribute("data-style",e.getAttribute("style")),e.style.maxWidth=e.naturalWidth+"px",e.style.maxHeight=e.naturalHeight+"px",e.naturalWidth>t){var n=t/2-e.naturalWidth/2;this.setTranslate(this.img.parentNode,n,0)}this.slide.classList.add("zoomed"),this.zoomedIn=!0}}},{key:"zoomOut",value:function(){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()}},{key:"dragStart",value:function(t){t.preventDefault(),this.zoomedIn?(t.type==="touchstart"?(this.initialX=t.touches[0].clientX-this.xOffset,this.initialY=t.touches[0].clientY-this.yOffset):(this.initialX=t.clientX-this.xOffset,this.initialY=t.clientY-this.yOffset),t.target===this.img&&(this.active=!0,this.img.classList.add("dragging"))):this.active=!1}},{key:"dragEnd",value:function(t){var e=this;t.preventDefault(),this.initialX=this.currentX,this.initialY=this.currentY,this.active=!1,setTimeout((function(){e.dragging=!1,e.img.isDragging=!1,e.img.classList.remove("dragging")}),100)}},{key:"drag",value:function(t){this.active&&(t.preventDefault(),t.type==="touchmove"?(this.currentX=t.touches[0].clientX-this.initialX,this.currentY=t.touches[0].clientY-this.initialY):(this.currentX=t.clientX-this.initialX,this.currentY=t.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))}},{key:"onMove",value:function(t){if(this.zoomedIn){var e=t.clientX-this.img.naturalWidth/2,n=t.clientY-this.img.naturalHeight/2;this.setTranslate(this.img,e,n)}}},{key:"setTranslate",value:function(t,e,n){t.style.transform="translate3d("+e+"px, "+n+"px, 0)"}},{key:"widowWidth",value:function(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}]),Gt=c((function t(){var e=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};a(this,t);var o=n.dragEl,u=n.toleranceX,f=u===void 0?40:u,d=n.toleranceY,g=d===void 0?65:d,x=n.slide,w=x===void 0?null:x,T=n.instance,k=T===void 0?null:T;this.el=o,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=f,this.toleranceY=g,this.toleranceReached=!1,this.dragContainer=this.el,this.slide=w,this.instance=k,this.el.addEventListener("mousedown",(function(E){return e.dragStart(E)}),!1),this.el.addEventListener("mouseup",(function(E){return e.dragEnd(E)}),!1),this.el.addEventListener("mousemove",(function(E){return e.drag(E)}),!1)}),[{key:"dragStart",value:function(t){if(this.slide.classList.contains("zoomed"))this.active=!1;else{t.type==="touchstart"?(this.initialX=t.touches[0].clientX-this.xOffset,this.initialY=t.touches[0].clientY-this.yOffset):(this.initialX=t.clientX-this.xOffset,this.initialY=t.clientY-this.yOffset);var e=t.target.nodeName.toLowerCase();t.target.classList.contains("nodrag")||L(t.target,".nodrag")||["input","select","textarea","button","a"].indexOf(e)!==-1?this.active=!1:(t.preventDefault(),(t.target===this.el||e!=="img"&&L(t.target,".gslide-inline"))&&(this.active=!0,this.el.classList.add("dragging"),this.dragContainer=L(t.target,".ginner-container")))}}},{key:"dragEnd",value:function(t){var e=this;t&&t.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((function(){e.instance.preventOutsideClick=!1,e.toleranceReached=!1,e.lastDirection=null,e.dragging=!1,e.el.isDragging=!1,e.el.classList.remove("dragging"),e.slide.classList.remove("dragging-nav"),e.dragContainer.style.transform="",e.dragContainer.style.transition=""}),100)}},{key:"drag",value:function(t){if(this.active){t.preventDefault(),this.slide.classList.add("dragging-nav"),t.type==="touchmove"?(this.currentX=t.touches[0].clientX-this.initialX,this.currentY=t.touches[0].clientY-this.initialY):(this.currentX=t.clientX-this.initialX,this.currentY=t.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.el.isDragging=!0,this.dragging=!0,this.doSlideChange=!1,this.doSlideClose=!1;var e=Math.abs(this.currentX),n=Math.abs(this.currentY);if(e>0&&e>=Math.abs(this.currentY)&&(!this.lastDirection||this.lastDirection=="x")){this.yOffset=0,this.lastDirection="x",this.setTranslate(this.dragContainer,this.currentX,0);var o=this.shouldChange();if(!this.instance.settings.dragAutoSnap&&o&&(this.doSlideChange=o),this.instance.settings.dragAutoSnap&&o)return this.instance.preventOutsideClick=!0,this.toleranceReached=!0,this.active=!1,this.instance.preventOutsideClick=!0,this.dragEnd(null),o=="right"&&this.instance.prevSlide(),void(o=="left"&&this.instance.nextSlide())}if(this.toleranceY>0&&n>0&&n>=e&&(!this.lastDirection||this.lastDirection=="y")){this.xOffset=0,this.lastDirection="y",this.setTranslate(this.dragContainer,0,this.currentY);var u=this.shouldClose();return!this.instance.settings.dragAutoSnap&&u&&(this.doSlideClose=!0),void(this.instance.settings.dragAutoSnap&&u&&this.instance.close())}}}},{key:"shouldChange",value:function(){var t=!1;if(Math.abs(this.currentX)>=this.toleranceX){var e=this.currentX>0?"right":"left";(e=="left"&&this.slide!==this.slide.parentNode.lastChild||e=="right"&&this.slide!==this.slide.parentNode.firstChild)&&(t=e)}return t}},{key:"shouldClose",value:function(){var t=!1;return Math.abs(this.currentY)>=this.toleranceY&&(t=!0),t}},{key:"setTranslate",value:function(t,e,n){var o=arguments.length>3&&arguments[3]!==void 0&&arguments[3];t.style.transition=o?"all .2s ease":"",t.style.transform="translate3d(".concat(e,"px, ").concat(n,"px, 0)")}}]);function ai(t,e,n,o){var u=t.querySelector(".gslide-media"),f=new Image,d="gSlideTitle_"+n,g="gSlideDesc_"+n;f.addEventListener("load",(function(){P(o)&&o()}),!1),f.src=e.href,e.sizes!=""&&e.srcset!=""&&(f.sizes=e.sizes,f.srcset=e.srcset),f.alt="",Y(e.alt)||e.alt===""||(f.alt=e.alt),e.title!==""&&f.setAttribute("aria-labelledby",d),e.description!==""&&f.setAttribute("aria-describedby",g),e.hasOwnProperty("_hasCustomWidth")&&e._hasCustomWidth&&(f.style.width=e.width),e.hasOwnProperty("_hasCustomHeight")&&e._hasCustomHeight&&(f.style.height=e.height),u.insertBefore(f,u.firstChild)}function oi(t,e,n,o){var u=this,f=t.querySelector(".ginner-container"),d="gvideo"+n,g=t.querySelector(".gslide-media"),x=this.getAllPlayers();b(f,"gvideo-container"),g.insertBefore(Z('<div class="gvideo-wrapper"></div>'),g.firstChild);var w=t.querySelector(".gvideo-wrapper");$t(this.settings.plyr.css,"Plyr");var T=e.href,k=e?.videoProvider,E=!1;g.style.maxWidth=e.width,$t(this.settings.plyr.js,"Plyr",(function(){if(!k&&T.match(/vimeo\.com\/([0-9]*)/)&&(k="vimeo"),!k&&(T.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||T.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||T.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||T.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/))&&(k="youtube"),k==="local"||!k){k="local";var O='<video id="'+d+'" ';O+='style="background:#000; max-width: '.concat(e.width,';" '),O+='preload="metadata" ',O+='x-webkit-airplay="allow" ',O+="playsinline ",O+="controls ",O+='class="gvideo-local">',O+='<source src="'.concat(T,'">'),E=Z(O+="</video>")}var _=E||Z('<div id="'.concat(d,'" data-plyr-provider="').concat(k,'" data-plyr-embed-id="').concat(T,'"></div>'));b(w,"".concat(k,"-video gvideo")),w.appendChild(_),w.setAttribute("data-id",d),w.setAttribute("data-index",n);var z=H(u.settings.plyr,"config")?u.settings.plyr.config:{},j=new Plyr("#"+d,z);j.on("ready",(function(W){x[d]=W.detail.plyr,P(o)&&o()})),It((function(){return t.querySelector("iframe")&&t.querySelector("iframe").dataset.ready=="true"}),(function(){u.resize(t)})),j.on("enterfullscreen",te),j.on("exitfullscreen",te)}))}function te(t){var e=L(t.target,".gslide-media");t.type==="enterfullscreen"&&b(e,"fullscreen"),t.type==="exitfullscreen"&&A(e,"fullscreen")}function li(t,e,n,o){var u,f=this,d=t.querySelector(".gslide-media"),g=!(!H(e,"href")||!e.href)&&e.href.split("#").pop().trim(),x=!(!H(e,"content")||!e.content)&&e.content;if(x&&(ot(x)&&(u=Z('<div class="ginlined-content">'.concat(x,"</div>"))),J(x))){x.style.display=="none"&&(x.style.display="block");var w=document.createElement("div");w.className="ginlined-content",w.appendChild(x),u=w}if(g){var T=document.getElementById(g);if(!T)return!1;var k=T.cloneNode(!0);k.style.height=e.height,k.style.maxWidth=e.width,b(k,"ginlined-content"),u=k}if(!u)return console.error("Unable to append inline slide content",e),!1;d.style.height=e.height,d.style.width=e.width,d.appendChild(u),this.events["inlineclose"+g]=S("click",{onElement:d.querySelectorAll(".gtrigger-close"),withCallback:function(E){E.preventDefault(),f.close()}}),P(o)&&o()}function ui(t,e,n,o){var u=t.querySelector(".gslide-media"),f=(function(d){var g=d.url,x=d.allow,w=d.callback,T=d.appendTo,k=document.createElement("iframe");return k.className="vimeo-video gvideo",k.src=g,k.style.width="100%",k.style.height="100%",x&&k.setAttribute("allow",x),k.onload=function(){k.onload=null,b(k,"node-ready"),P(w)&&w()},T&&T.appendChild(k),k})({url:e.href,callback:o});u.parentNode.style.maxWidth=e.width,u.parentNode.style.height=e.height,u.appendChild(f)}var ci=c((function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};a(this,t),this.defaults={href:"",sizes:"",srcset:"",title:"",type:"",videoProvider:"",description:"",alt:"",descPosition:"bottom",effect:"",width:"",height:"",content:!1,zoomable:!0,draggable:!0},rt(e)&&(this.defaults=m(this.defaults,e))}),[{key:"sourceType",value:function(t){var e=t;return(t=t.toLowerCase()).match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/)!==null?"image":t.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||t.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||t.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||t.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||t.match(/vimeo\.com\/([0-9]*)/)||t.match(/\.(mp4|ogg|webm|mov)/)!==null?"video":t.match(/\.(mp3|wav|wma|aac|ogg)/)!==null?"audio":t.indexOf("#")>-1&&e.split("#").pop().trim()!==""?"inline":t.indexOf("goajax=true")>-1?"ajax":"external"}},{key:"parseConfig",value:function(t,e){var n=this,o=m({descPosition:e.descPosition},this.defaults);if(rt(t)&&!J(t)){H(t,"type")||(H(t,"content")&&t.content?t.type="inline":H(t,"href")&&(t.type=this.sourceType(t.href)));var u=m(o,t);return this.setSize(u,e),u}var f="",d=t.getAttribute("data-glightbox"),g=t.nodeName.toLowerCase();if(g==="a"&&(f=t.href),g==="img"&&(f=t.src,o.alt=t.alt),o.href=f,p(o,(function(O,_){H(e,_)&&_!=="width"&&(o[_]=e[_]);var z=t.dataset[_];Y(z)||(o[_]=n.sanitizeValue(z))})),o.content&&(o.type="inline"),!o.type&&f&&(o.type=this.sourceType(f)),Y(d)){if(!o.title&&g=="a"){var x=t.title;Y(x)||x===""||(o.title=x)}if(!o.title&&g=="img"){var w=t.alt;Y(w)||w===""||(o.title=w)}}else{var T=[];p(o,(function(O,_){T.push(";\\s?"+_)})),T=T.join("\\s?:|"),d.trim()!==""&&p(o,(function(O,_){var z=d,j=new RegExp("s?"+_+"s?:s?(.*?)("+T+"s?:|$)"),W=z.match(j);if(W&&W.length&&W[1]){var Q=W[1].trim().replace(/;\s*$/,"");o[_]=n.sanitizeValue(Q)}}))}if(o.description&&o.description.substring(0,1)==="."){var k;try{k=document.querySelector(o.description).innerHTML}catch(O){if(!(O instanceof DOMException))throw O}k&&(o.description=k)}if(!o.description){var E=t.querySelector(".glightbox-desc");E&&(o.description=E.innerHTML)}return this.setSize(o,e,t),this.slideConfig=o,o}},{key:"setSize",value:function(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,o=t.type=="video"?this.checkSize(e.videosWidth):this.checkSize(e.width),u=this.checkSize(e.height);return t.width=H(t,"width")&&t.width!==""?this.checkSize(t.width):o,t.height=H(t,"height")&&t.height!==""?this.checkSize(t.height):u,n&&t.type=="image"&&(t._hasCustomWidth=!!n.dataset.width,t._hasCustomHeight=!!n.dataset.height),t}},{key:"checkSize",value:function(t){return bt(t)?"".concat(t,"px"):t}},{key:"sanitizeValue",value:function(t){return t!=="true"&&t!=="false"?t:t==="true"}}]),wt=c((function t(e,n,o){a(this,t),this.element=e,this.instance=n,this.index=o}),[{key:"setContent",value:function(){var t=this,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(C(e,"loaded"))return!1;var o=this.instance.settings,u=this.slideConfig,f=Mt();P(o.beforeSlideLoad)&&o.beforeSlideLoad({index:this.index,slide:e,player:!1});var d=u.type,g=u.descPosition,x=e.querySelector(".gslide-media"),w=e.querySelector(".gslide-title"),T=e.querySelector(".gslide-desc"),k=e.querySelector(".gdesc-inner"),E=n,O="gSlideTitle_"+this.index,_="gSlideDesc_"+this.index;if(P(o.afterSlideLoad)&&(E=function(){P(n)&&n(),o.afterSlideLoad({index:t.index,slide:e,player:t.instance.getSlidePlayerInstance(t.index)})}),u.title==""&&u.description==""?k&&k.parentNode.parentNode.removeChild(k.parentNode):(w&&u.title!==""?(w.id=O,w.innerHTML=u.title):w.parentNode.removeChild(w),T&&u.description!==""?(T.id=_,f&&o.moreLength>0?(u.smallDescription=this.slideShortDesc(u.description,o.moreLength,o.moreText),T.innerHTML=u.smallDescription,this.descriptionEvents(T,u)):T.innerHTML=u.description):T.parentNode.removeChild(T),b(x.parentNode,"desc-".concat(g)),b(k.parentNode,"description-".concat(g))),b(x,"gslide-".concat(d)),b(e,"loaded"),d!=="video"){if(d!=="external")return d==="inline"?(li.apply(this.instance,[e,u,this.index,E]),void(u.draggable&&new Gt({dragEl:e.querySelector(".gslide-inline"),toleranceX:o.dragToleranceX,toleranceY:o.dragToleranceY,slide:e,instance:this.instance}))):void(d!=="image"?P(E)&&E():ai(e,u,this.index,(function(){var z=e.querySelector("img");u.draggable&&new Gt({dragEl:z,toleranceX:o.dragToleranceX,toleranceY:o.dragToleranceY,slide:e,instance:t.instance}),u.zoomable&&z.naturalWidth>z.offsetWidth&&(b(z,"zoomable"),new ri(z,e,(function(){t.instance.resize()}))),P(E)&&E()})));ui.apply(this,[e,u,this.index,E])}else oi.apply(this.instance,[e,u,this.index,E])}},{key:"slideShortDesc",value:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:50,n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],o=document.createElement("div");o.innerHTML=t;var u=o.innerText,f=n;if((t=u.trim()).length<=e)return t;var d=t.substr(0,e-1);return f?(o=null,d+'... <a href="#" class="desc-more">'+n+"</a>"):d}},{key:"descriptionEvents",value:function(t,e){var n=this,o=t.querySelector(".desc-more");if(!o)return!1;S("click",{onElement:o,withCallback:function(u,f){u.preventDefault();var d=document.body,g=L(f,".gslide-desc");if(!g)return!1;g.innerHTML=e.description,b(d,"gdesc-open");var x=S("click",{onElement:[d,L(g,".gslide-description")],withCallback:function(w,T){w.target.nodeName.toLowerCase()!=="a"&&(A(d,"gdesc-open"),b(d,"gdesc-closed"),g.innerHTML=e.smallDescription,n.descriptionEvents(g,e),setTimeout((function(){A(d,"gdesc-closed")}),400),x.destroy())}})}})}},{key:"create",value:function(){return Z(this.instance.settings.slideHTML)}},{key:"getConfig",value:function(){J(this.element)||this.element.hasOwnProperty("draggable")||(this.element.draggable=this.instance.settings.draggable);var t=new ci(this.instance.settings.slideExtraAttributes);return this.slideConfig=t.parseConfig(this.element,this.instance.settings),this.slideConfig}}]);function xt(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function hi(t,e){var n=(function(o,u){var f=xt(o)*xt(u);if(f===0)return 0;var d=(function(g,x){return g.x*x.x+g.y*x.y})(o,u)/f;return d>1&&(d=1),Math.acos(d)})(t,e);return(function(o,u){return o.x*u.y-u.x*o.y})(t,e)>0&&(n*=-1),180*n/Math.PI}var di=c((function t(e){a(this,t),this.handlers=[],this.el=e}),[{key:"add",value:function(t){this.handlers.push(t)}},{key:"del",value:function(t){t||(this.handlers=[]);for(var e=this.handlers.length;e>=0;e--)this.handlers[e]===t&&this.handlers.splice(e,1)}},{key:"dispatch",value:function(){for(var t=0,e=this.handlers.length;t<e;t++){var n=this.handlers[t];typeof n=="function"&&n.apply(this.el,arguments)}}}]);function q(t,e){var n=new di(t);return n.add(e),n}var fi=c((function t(e,n){a(this,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 o=function(){};this.rotate=q(this.element,n.rotate||o),this.touchStart=q(this.element,n.touchStart||o),this.multipointStart=q(this.element,n.multipointStart||o),this.multipointEnd=q(this.element,n.multipointEnd||o),this.pinch=q(this.element,n.pinch||o),this.swipe=q(this.element,n.swipe||o),this.tap=q(this.element,n.tap||o),this.doubleTap=q(this.element,n.doubleTap||o),this.longTap=q(this.element,n.longTap||o),this.singleTap=q(this.element,n.singleTap||o),this.pressMove=q(this.element,n.pressMove||o),this.twoFingerPressMove=q(this.element,n.twoFingerPressMove||o),this.touchMove=q(this.element,n.touchMove||o),this.touchEnd=q(this.element,n.touchEnd||o),this.touchCancel=q(this.element,n.touchCancel||o),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}}),[{key:"start",value:function(t){if(t.touches)if(t.target&&t.target.nodeName&&["a","button","input"].indexOf(t.target.nodeName.toLowerCase())>=0)console.log("ignore drag for this touched element",t.target.nodeName.toLowerCase());else{this.now=Date.now(),this.x1=t.touches[0].pageX,this.y1=t.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(t,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 e=this.preV;if(t.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var n={x:t.touches[1].pageX-this.x1,y:t.touches[1].pageY-this.y1};e.x=n.x,e.y=n.y,this.pinchStartLen=xt(e),this.multipointStart.dispatch(t,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout((function(){this.longTap.dispatch(t,this.element),this._preventTap=!0}).bind(this),750)}}},{key:"move",value:function(t){if(t.touches){var e=this.preV,n=t.touches.length,o=t.touches[0].pageX,u=t.touches[0].pageY;if(this.isDoubleTap=!1,n>1){var f=t.touches[1].pageX,d=t.touches[1].pageY,g={x:t.touches[1].pageX-o,y:t.touches[1].pageY-u};e.x!==null&&(this.pinchStartLen>0&&(t.zoom=xt(g)/this.pinchStartLen,this.pinch.dispatch(t,this.element)),t.angle=hi(g,e),this.rotate.dispatch(t,this.element)),e.x=g.x,e.y=g.y,this.x2!==null&&this.sx2!==null?(t.deltaX=(o-this.x2+f-this.sx2)/2,t.deltaY=(u-this.y2+d-this.sy2)/2):(t.deltaX=0,t.deltaY=0),this.twoFingerPressMove.dispatch(t,this.element),this.sx2=f,this.sy2=d}else{if(this.x2!==null){t.deltaX=o-this.x2,t.deltaY=u-this.y2;var x=Math.abs(this.x1-this.x2),w=Math.abs(this.y1-this.y2);(x>10||w>10)&&(this._preventTap=!0)}else t.deltaX=0,t.deltaY=0;this.pressMove.dispatch(t,this.element)}this.touchMove.dispatch(t,this.element),this._cancelLongTap(),this.x2=o,this.y2=u,n>1&&t.preventDefault()}}},{key:"end",value:function(t){if(t.changedTouches){this._cancelLongTap();var e=this;t.touches.length<2&&(this.multipointEnd.dispatch(t,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?(t.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){e.swipe.dispatch(t,e.element)}),0)):(this.tapTimeout=setTimeout((function(){e._preventTap||e.tap.dispatch(t,e.element),e.isDoubleTap&&(e.doubleTap.dispatch(t,e.element),e.isDoubleTap=!1)}),0),e.isDoubleTap||(e.singleTapTimeout=setTimeout((function(){e.singleTap.dispatch(t,e.element)}),250))),this.touchEnd.dispatch(t,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}}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"cancel",value:function(t){this.cancelAll(),this.touchCancel.dispatch(t,this.element)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(t,e,n,o){return Math.abs(t-e)>=Math.abs(n-o)?t-e>0?"Left":"Right":n-o>0?"Up":"Down"}},{key:"on",value:function(t,e){this[t]&&this[t].add(e)}},{key:"off",value:function(t,e){this[t]&&this[t].del(e)}},{key:"destroy",value:function(){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 zt(t){var e=(function(){var d,g=document.createElement("fakeelement"),x={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(d in x)if(g.style[d]!==void 0)return x[d]})(),n=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,o=C(t,"gslide-media")?t:t.querySelector(".gslide-media"),u=L(o,".ginner-container"),f=t.querySelector(".gslide-description");n>769&&(o=u),b(o,"greset"),R(o,"translate3d(0, 0, 0)"),S(e,{onElement:o,once:!0,withCallback:function(d,g){A(o,"greset")}}),o.style.opacity="",f&&(f.style.opacity="")}function gi(t){if(t.events.hasOwnProperty("touch"))return!1;var e,n,o,u=yt(),f=u.width,d=u.height,g=!1,x=null,w=null,T=null,k=!1,E=1,O=1,_=!1,z=!1,j=null,W=null,Q=null,N=null,G=0,tt=0,lt=!1,at=!1,$={},K={},se=0,re=0,pi=document.getElementById("glightbox-slider"),St=document.querySelector(".goverlay"),yi=new fi(pi,{touchStart:function(I){if(g=!0,(C(I.targetTouches[0].target,"ginner-container")||L(I.targetTouches[0].target,".gslide-desc")||I.targetTouches[0].target.nodeName.toLowerCase()=="a")&&(g=!1),L(I.targetTouches[0].target,".gslide-inline")&&!C(I.targetTouches[0].target.parentNode,"gslide-inline")&&(g=!1),g){if(K=I.targetTouches[0],$.pageX=I.targetTouches[0].pageX,$.pageY=I.targetTouches[0].pageY,se=I.targetTouches[0].clientX,re=I.targetTouches[0].clientY,x=t.activeSlide,w=x.querySelector(".gslide-media"),o=x.querySelector(".gslide-inline"),T=null,C(w,"gslide-image")&&(T=w.querySelector("img")),(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)>769&&(w=x.querySelector(".ginner-container")),A(St,"greset"),I.pageX>20&&I.pageX<window.innerWidth-20)return;I.preventDefault()}},touchMove:function(I){if(g&&(K=I.targetTouches[0],!_&&!z)){if(o&&o.offsetHeight>d){var X=$.pageX-K.pageX;if(Math.abs(X)<=13)return!1}k=!0;var it,Tt=I.targetTouches[0].clientX,bi=I.targetTouches[0].clientY,wi=se-Tt,xi=re-bi;if(Math.abs(wi)>Math.abs(xi)?(lt=!1,at=!0):(at=!1,lt=!0),e=K.pageX-$.pageX,G=100*e/f,n=K.pageY-$.pageY,tt=100*n/d,lt&&T&&(it=1-Math.abs(n)/d,St.style.opacity=it,t.settings.touchFollowAxis&&(G=0)),at&&(it=1-Math.abs(e)/f,w.style.opacity=it,t.settings.touchFollowAxis&&(tt=0)),!T)return R(w,"translate3d(".concat(G,"%, 0, 0)"));R(w,"translate3d(".concat(G,"%, ").concat(tt,"%, 0)"))}},touchEnd:function(){if(g){if(k=!1,z||_)return Q=j,void(N=W);var I=Math.abs(parseInt(tt)),X=Math.abs(parseInt(G));if(!(I>29&&T))return I<29&&X<25?(b(St,"greset"),St.style.opacity=1,zt(w)):void 0;t.close()}},multipointEnd:function(){setTimeout((function(){_=!1}),50)},multipointStart:function(){_=!0,E=O||1},pinch:function(I){if(!T||k)return!1;_=!0,T.scaleX=T.scaleY=E*I.zoom;var X=E*I.zoom;if(z=!0,X<=1)return z=!1,X=1,N=null,Q=null,j=null,W=null,void T.setAttribute("style","");X>4.5&&(X=4.5),T.style.transform="scale3d(".concat(X,", ").concat(X,", 1)"),O=X},pressMove:function(I){if(z&&!_){var X=K.pageX-$.pageX,it=K.pageY-$.pageY;Q&&(X+=Q),N&&(it+=N),j=X,W=it;var Tt="translate3d(".concat(X,"px, ").concat(it,"px, 0)");O&&(Tt+=" scale3d(".concat(O,", ").concat(O,", 1)")),R(T,Tt)}},swipe:function(I){if(!z)if(_)_=!1;else{if(I.direction=="Left"){if(t.index==t.elements.length-1)return zt(w);t.nextSlide()}if(I.direction=="Right"){if(t.index==0)return zt(w);t.prevSlide()}}}});t.events.touch=yi}var ee=Mt(),ie=Mt()!==null||document.createTouch!==void 0||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,ne=document.getElementsByTagName("html")[0],vi={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>'},slideHTML:`<div class="gslide">
|
|
1
|
+
var ContentBuilderRuntime=(function(){"use strict";function ui(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Qe={exports:{}},di=Qe.exports,It;function hi(){return It||(It=1,(function(f,e){(function(t,i){f.exports=i()})(di,(function(){function t(o,d){if(!(o instanceof d))throw new TypeError("Cannot call a class as a function")}function i(o,d){for(var b=0;b<d.length;b++){var k=d[b];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(o,s(k.key),k)}}function n(o,d,b){return d&&i(o.prototype,d),Object.defineProperty(o,"prototype",{writable:!1}),o}function s(o){var d=(function(b,k){if(typeof b!="object"||!b)return b;var T=b[Symbol.toPrimitive];if(T!==void 0){var R=T.call(b,k);if(typeof R!="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(b)})(o,"string");return typeof d=="symbol"?d:d+""}function r(o){return(r=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d})(o)}var l=Date.now();function c(){var o={},d=!0,b=0,k=arguments.length;Object.prototype.toString.call(arguments[0])==="[object Boolean]"&&(d=arguments[0],b++);for(var T=function(M){for(var A in M)Object.prototype.hasOwnProperty.call(M,A)&&(d&&Object.prototype.toString.call(M[A])==="[object Object]"?o[A]=c(!0,o[A],M[A]):o[A]=M[A])};b<k;b++){var R=arguments[b];T(R)}return o}function h(o,d){if((P(o)||o===window||o===document)&&(o=[o]),j(o)||B(o)||(o=[o]),z(o)!=0){if(j(o)&&!B(o))for(var b=o.length,k=0;k<b&&d.call(o[k],o[k],k,o)!==!1;k++);else if(B(o)){for(var T in o)if(D(o,T)&&d.call(o[T],o[T],T,o)===!1)break}}}function u(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,k=o[l]=o[l]||[],T={all:k,evt:null,found:null};return d&&b&&z(k)>0&&h(k,(function(R,M){if(R.eventName==d&&R.fn.toString()==b.toString())return T.found=!0,T.evt=M,!1})),T}function a(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=d.onElement,k=d.withCallback,T=d.avoidDuplicate,R=T===void 0||T,M=d.once,A=M!==void 0&&M,F=d.useCapture,U=F!==void 0&&F,Y=arguments.length>2?arguments[2]:void 0,X=b||[];function Z(K){I(k)&&k.call(Y,K,this),A&&Z.destroy()}return $(X)&&(X=document.querySelectorAll(X)),Z.destroy=function(){h(X,(function(K){var ee=u(K,o,Z);ee.found&&ee.all.splice(ee.evt,1),K.removeEventListener&&K.removeEventListener(o,Z,U)}))},h(X,(function(K){var ee=u(K,o,Z);(K.addEventListener&&R&&!ee.found||!R)&&(K.addEventListener(o,Z,U),ee.all.push({eventName:o,fn:Z}))})),Z}function p(o,d){h(d.split(" "),(function(b){return o.classList.add(b)}))}function m(o,d){h(d.split(" "),(function(b){return o.classList.remove(b)}))}function w(o,d){return o.classList.contains(d)}function S(o,d){for(;o!==document.body;){if(!(o=o.parentElement))return!1;if(typeof o.matches=="function"?o.matches(d):o.msMatchesSelector(d))return o}}function L(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",b=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(!o||d==="")return!1;if(d==="none")return I(b)&&b(),!1;var k=C(),T=d.split(" ");h(T,(function(R){p(o,"g"+R)})),a(k,{onElement:o,avoidDuplicate:!1,once:!0,withCallback:function(R,M){h(T,(function(A){m(M,"g"+A)})),I(b)&&b()}})}function y(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(d==="")return o.style.webkitTransform="",o.style.MozTransform="",o.style.msTransform="",o.style.OTransform="",o.style.transform="",!1;o.style.webkitTransform=d,o.style.MozTransform=d,o.style.msTransform=d,o.style.OTransform=d,o.style.transform=d}function x(o){o.style.display="block"}function g(o){o.style.display="none"}function v(o){var d=document.createDocumentFragment(),b=document.createElement("div");for(b.innerHTML=o;b.firstChild;)d.appendChild(b.firstChild);return d}function _(){return{width:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,height:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight}}function C(){var o,d=document.createElement("fakeelement"),b={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(o in b)if(d.style[o]!==void 0)return b[o]}function E(o,d,b,k){if(o())d();else{var T;b||(b=100);var R=setInterval((function(){o()&&(clearInterval(R),T&&clearTimeout(T),d())}),b)}}function q(o,d,b){if(G(o))console.error("Inject assets error");else if(I(d)&&(b=d,d=!1),$(d)&&d in window)I(b)&&b();else{var k;if(o.indexOf(".css")!==-1){if((k=document.querySelectorAll('link[href="'+o+'"]'))&&k.length>0)return void(I(b)&&b());var T=document.getElementsByTagName("head")[0],R=T.querySelectorAll('link[rel="stylesheet"]'),M=document.createElement("link");return M.rel="stylesheet",M.type="text/css",M.href=o,M.media="all",R?T.insertBefore(M,R[0]):T.appendChild(M),void(I(b)&&b())}if((k=document.querySelectorAll('script[src="'+o+'"]'))&&k.length>0){if(I(b)){if($(d))return E((function(){return window[d]!==void 0}),(function(){b()})),!1;b()}}else{var A=document.createElement("script");A.type="text/javascript",A.src=o,A.onload=function(){if(I(b)){if($(d))return E((function(){return window[d]!==void 0}),(function(){b()})),!1;b()}},document.body.appendChild(A)}}}function N(){return"navigator"in window&&window.navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i)}function I(o){return typeof o=="function"}function $(o){return typeof o=="string"}function P(o){return!(!o||!o.nodeType||o.nodeType!=1)}function J(o){return Array.isArray(o)}function j(o){return o&&o.length&&isFinite(o.length)}function B(o){return r(o)==="object"&&o!=null&&!I(o)&&!J(o)}function G(o){return o==null}function D(o,d){return o!==null&&hasOwnProperty.call(o,d)}function z(o){if(B(o)){if(o.keys)return o.keys().length;var d=0;for(var b in o)D(o,b)&&d++;return d}return o.length}function O(o){return!isNaN(parseFloat(o))&&isFinite(o)}function V(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1,d=document.querySelectorAll(".gbtn[data-taborder]:not(.disabled)");if(!d.length)return!1;if(d.length==1)return d[0];typeof o=="string"&&(o=parseInt(o));var b=[];h(d,(function(A){b.push(A.getAttribute("data-taborder"))}));var k=Math.max.apply(Math,b.map((function(A){return parseInt(A)}))),T=o<0?1:o+1;T>k&&(T="1");var R=b.filter((function(A){return A>=parseInt(T)})),M=R.sort()[0];return document.querySelector('.gbtn[data-taborder="'.concat(M,'"]'))}function W(o){if(o.events.hasOwnProperty("keyboard"))return!1;o.events.keyboard=a("keydown",{onElement:window,withCallback:function(d,b){var k=(d=d||window.event).keyCode;if(k==9){var T=document.querySelector(".gbtn.focused");if(!T){var R=!(!document.activeElement||!document.activeElement.nodeName)&&document.activeElement.nodeName.toLocaleLowerCase();if(R=="input"||R=="textarea"||R=="button")return}d.preventDefault();var M=document.querySelectorAll(".gbtn[data-taborder]");if(!M||M.length<=0)return;if(!T){var A=V();return void(A&&(A.focus(),p(A,"focused")))}var F=V(T.getAttribute("data-taborder"));m(T,"focused"),F&&(F.focus(),p(F,"focused"))}k==39&&o.nextSlide(),k==37&&o.prevSlide(),k==27&&o.close()}})}var se=n((function o(d,b){var k=this,T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(t(this,o),this.img=d,this.slide=b,this.onclose=T,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",(function(R){return k.dragStart(R)}),!1),this.img.addEventListener("mouseup",(function(R){return k.dragEnd(R)}),!1),this.img.addEventListener("mousemove",(function(R){return k.drag(R)}),!1),this.img.addEventListener("click",(function(R){return k.slide.classList.contains("dragging-nav")?(k.zoomOut(),!1):k.zoomedIn?void(k.zoomedIn&&!k.dragging&&k.zoomOut()):k.zoomIn()}),!1),this.img.setZoomEvents=!0}),[{key:"zoomIn",value:function(){var o=this.widowWidth();if(!(this.zoomedIn||o<=768)){var d=this.img;if(d.setAttribute("data-style",d.getAttribute("style")),d.style.maxWidth=d.naturalWidth+"px",d.style.maxHeight=d.naturalHeight+"px",d.naturalWidth>o){var b=o/2-d.naturalWidth/2;this.setTranslate(this.img.parentNode,b,0)}this.slide.classList.add("zoomed"),this.zoomedIn=!0}}},{key:"zoomOut",value:function(){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()}},{key:"dragStart",value:function(o){o.preventDefault(),this.zoomedIn?(o.type==="touchstart"?(this.initialX=o.touches[0].clientX-this.xOffset,this.initialY=o.touches[0].clientY-this.yOffset):(this.initialX=o.clientX-this.xOffset,this.initialY=o.clientY-this.yOffset),o.target===this.img&&(this.active=!0,this.img.classList.add("dragging"))):this.active=!1}},{key:"dragEnd",value:function(o){var d=this;o.preventDefault(),this.initialX=this.currentX,this.initialY=this.currentY,this.active=!1,setTimeout((function(){d.dragging=!1,d.img.isDragging=!1,d.img.classList.remove("dragging")}),100)}},{key:"drag",value:function(o){this.active&&(o.preventDefault(),o.type==="touchmove"?(this.currentX=o.touches[0].clientX-this.initialX,this.currentY=o.touches[0].clientY-this.initialY):(this.currentX=o.clientX-this.initialX,this.currentY=o.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))}},{key:"onMove",value:function(o){if(this.zoomedIn){var d=o.clientX-this.img.naturalWidth/2,b=o.clientY-this.img.naturalHeight/2;this.setTranslate(this.img,d,b)}}},{key:"setTranslate",value:function(o,d,b){o.style.transform="translate3d("+d+"px, "+b+"px, 0)"}},{key:"widowWidth",value:function(){return window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth}}]),re=n((function o(){var d=this,b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t(this,o);var k=b.dragEl,T=b.toleranceX,R=T===void 0?40:T,M=b.toleranceY,A=M===void 0?65:M,F=b.slide,U=F===void 0?null:F,Y=b.instance,X=Y===void 0?null:Y;this.el=k,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=R,this.toleranceY=A,this.toleranceReached=!1,this.dragContainer=this.el,this.slide=U,this.instance=X,this.el.addEventListener("mousedown",(function(Z){return d.dragStart(Z)}),!1),this.el.addEventListener("mouseup",(function(Z){return d.dragEnd(Z)}),!1),this.el.addEventListener("mousemove",(function(Z){return d.drag(Z)}),!1)}),[{key:"dragStart",value:function(o){if(this.slide.classList.contains("zoomed"))this.active=!1;else{o.type==="touchstart"?(this.initialX=o.touches[0].clientX-this.xOffset,this.initialY=o.touches[0].clientY-this.yOffset):(this.initialX=o.clientX-this.xOffset,this.initialY=o.clientY-this.yOffset);var d=o.target.nodeName.toLowerCase();o.target.classList.contains("nodrag")||S(o.target,".nodrag")||["input","select","textarea","button","a"].indexOf(d)!==-1?this.active=!1:(o.preventDefault(),(o.target===this.el||d!=="img"&&S(o.target,".gslide-inline"))&&(this.active=!0,this.el.classList.add("dragging"),this.dragContainer=S(o.target,".ginner-container")))}}},{key:"dragEnd",value:function(o){var d=this;o&&o.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((function(){d.instance.preventOutsideClick=!1,d.toleranceReached=!1,d.lastDirection=null,d.dragging=!1,d.el.isDragging=!1,d.el.classList.remove("dragging"),d.slide.classList.remove("dragging-nav"),d.dragContainer.style.transform="",d.dragContainer.style.transition=""}),100)}},{key:"drag",value:function(o){if(this.active){o.preventDefault(),this.slide.classList.add("dragging-nav"),o.type==="touchmove"?(this.currentX=o.touches[0].clientX-this.initialX,this.currentY=o.touches[0].clientY-this.initialY):(this.currentX=o.clientX-this.initialX,this.currentY=o.clientY-this.initialY),this.xOffset=this.currentX,this.yOffset=this.currentY,this.el.isDragging=!0,this.dragging=!0,this.doSlideChange=!1,this.doSlideClose=!1;var d=Math.abs(this.currentX),b=Math.abs(this.currentY);if(d>0&&d>=Math.abs(this.currentY)&&(!this.lastDirection||this.lastDirection=="x")){this.yOffset=0,this.lastDirection="x",this.setTranslate(this.dragContainer,this.currentX,0);var k=this.shouldChange();if(!this.instance.settings.dragAutoSnap&&k&&(this.doSlideChange=k),this.instance.settings.dragAutoSnap&&k)return this.instance.preventOutsideClick=!0,this.toleranceReached=!0,this.active=!1,this.instance.preventOutsideClick=!0,this.dragEnd(null),k=="right"&&this.instance.prevSlide(),void(k=="left"&&this.instance.nextSlide())}if(this.toleranceY>0&&b>0&&b>=d&&(!this.lastDirection||this.lastDirection=="y")){this.xOffset=0,this.lastDirection="y",this.setTranslate(this.dragContainer,0,this.currentY);var T=this.shouldClose();return!this.instance.settings.dragAutoSnap&&T&&(this.doSlideClose=!0),void(this.instance.settings.dragAutoSnap&&T&&this.instance.close())}}}},{key:"shouldChange",value:function(){var o=!1;if(Math.abs(this.currentX)>=this.toleranceX){var d=this.currentX>0?"right":"left";(d=="left"&&this.slide!==this.slide.parentNode.lastChild||d=="right"&&this.slide!==this.slide.parentNode.firstChild)&&(o=d)}return o}},{key:"shouldClose",value:function(){var o=!1;return Math.abs(this.currentY)>=this.toleranceY&&(o=!0),o}},{key:"setTranslate",value:function(o,d,b){var k=arguments.length>3&&arguments[3]!==void 0&&arguments[3];o.style.transition=k?"all .2s ease":"",o.style.transform="translate3d(".concat(d,"px, ").concat(b,"px, 0)")}}]);function le(o,d,b,k){var T=o.querySelector(".gslide-media"),R=new Image,M="gSlideTitle_"+b,A="gSlideDesc_"+b;R.addEventListener("load",(function(){I(k)&&k()}),!1),R.src=d.href,d.sizes!=""&&d.srcset!=""&&(R.sizes=d.sizes,R.srcset=d.srcset),R.alt="",G(d.alt)||d.alt===""||(R.alt=d.alt),d.title!==""&&R.setAttribute("aria-labelledby",M),d.description!==""&&R.setAttribute("aria-describedby",A),d.hasOwnProperty("_hasCustomWidth")&&d._hasCustomWidth&&(R.style.width=d.width),d.hasOwnProperty("_hasCustomHeight")&&d._hasCustomHeight&&(R.style.height=d.height),T.insertBefore(R,T.firstChild)}function xe(o,d,b,k){var T=this,R=o.querySelector(".ginner-container"),M="gvideo"+b,A=o.querySelector(".gslide-media"),F=this.getAllPlayers();p(R,"gvideo-container"),A.insertBefore(v('<div class="gvideo-wrapper"></div>'),A.firstChild);var U=o.querySelector(".gvideo-wrapper");q(this.settings.plyr.css,"Plyr");var Y=d.href,X=d?.videoProvider,Z=!1;A.style.maxWidth=d.width,q(this.settings.plyr.js,"Plyr",(function(){if(!X&&Y.match(/vimeo\.com\/([0-9]*)/)&&(X="vimeo"),!X&&(Y.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||Y.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||Y.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||Y.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/))&&(X="youtube"),X==="local"||!X){X="local";var K='<video id="'+M+'" ';K+='style="background:#000; max-width: '.concat(d.width,';" '),K+='preload="metadata" ',K+='x-webkit-airplay="allow" ',K+="playsinline ",K+="controls ",K+='class="gvideo-local">',K+='<source src="'.concat(Y,'">'),Z=v(K+="</video>")}var ee=Z||v('<div id="'.concat(M,'" data-plyr-provider="').concat(X,'" data-plyr-embed-id="').concat(Y,'"></div>'));p(U,"".concat(X,"-video gvideo")),U.appendChild(ee),U.setAttribute("data-id",M),U.setAttribute("data-index",b);var ce=D(T.settings.plyr,"config")?T.settings.plyr.config:{},_e=new Plyr("#"+M,ce);_e.on("ready",(function(ye){F[M]=ye.detail.plyr,I(k)&&k()})),E((function(){return o.querySelector("iframe")&&o.querySelector("iframe").dataset.ready=="true"}),(function(){T.resize(o)})),_e.on("enterfullscreen",he),_e.on("exitfullscreen",he)}))}function he(o){var d=S(o.target,".gslide-media");o.type==="enterfullscreen"&&p(d,"fullscreen"),o.type==="exitfullscreen"&&m(d,"fullscreen")}function Ee(o,d,b,k){var T,R=this,M=o.querySelector(".gslide-media"),A=!(!D(d,"href")||!d.href)&&d.href.split("#").pop().trim(),F=!(!D(d,"content")||!d.content)&&d.content;if(F&&($(F)&&(T=v('<div class="ginlined-content">'.concat(F,"</div>"))),P(F))){F.style.display=="none"&&(F.style.display="block");var U=document.createElement("div");U.className="ginlined-content",U.appendChild(F),T=U}if(A){var Y=document.getElementById(A);if(!Y)return!1;var X=Y.cloneNode(!0);X.style.height=d.height,X.style.maxWidth=d.width,p(X,"ginlined-content"),T=X}if(!T)return console.error("Unable to append inline slide content",d),!1;M.style.height=d.height,M.style.width=d.width,M.appendChild(T),this.events["inlineclose"+A]=a("click",{onElement:M.querySelectorAll(".gtrigger-close"),withCallback:function(Z){Z.preventDefault(),R.close()}}),I(k)&&k()}function $e(o,d,b,k){var T=o.querySelector(".gslide-media"),R=(function(M){var A=M.url,F=M.allow,U=M.callback,Y=M.appendTo,X=document.createElement("iframe");return X.className="vimeo-video gvideo",X.src=A,X.style.width="100%",X.style.height="100%",F&&X.setAttribute("allow",F),X.onload=function(){X.onload=null,p(X,"node-ready"),I(U)&&U()},Y&&Y.appendChild(X),X})({url:d.href,callback:k});T.parentNode.style.maxWidth=d.width,T.parentNode.style.height=d.height,T.appendChild(R)}var je=n((function o(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t(this,o),this.defaults={href:"",sizes:"",srcset:"",title:"",type:"",videoProvider:"",description:"",alt:"",descPosition:"bottom",effect:"",width:"",height:"",content:!1,zoomable:!0,draggable:!0},B(d)&&(this.defaults=c(this.defaults,d))}),[{key:"sourceType",value:function(o){var d=o;return(o=o.toLowerCase()).match(/\.(jpeg|jpg|jpe|gif|png|apn|webp|avif|svg)/)!==null?"image":o.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||o.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)||o.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/)||o.match(/(youtube\.com|youtube-nocookie\.com)\/shorts\/([a-zA-Z0-9\-_]+)/)||o.match(/vimeo\.com\/([0-9]*)/)||o.match(/\.(mp4|ogg|webm|mov)/)!==null?"video":o.match(/\.(mp3|wav|wma|aac|ogg)/)!==null?"audio":o.indexOf("#")>-1&&d.split("#").pop().trim()!==""?"inline":o.indexOf("goajax=true")>-1?"ajax":"external"}},{key:"parseConfig",value:function(o,d){var b=this,k=c({descPosition:d.descPosition},this.defaults);if(B(o)&&!P(o)){D(o,"type")||(D(o,"content")&&o.content?o.type="inline":D(o,"href")&&(o.type=this.sourceType(o.href)));var T=c(k,o);return this.setSize(T,d),T}var R="",M=o.getAttribute("data-glightbox"),A=o.nodeName.toLowerCase();if(A==="a"&&(R=o.href),A==="img"&&(R=o.src,k.alt=o.alt),k.href=R,h(k,(function(K,ee){D(d,ee)&&ee!=="width"&&(k[ee]=d[ee]);var ce=o.dataset[ee];G(ce)||(k[ee]=b.sanitizeValue(ce))})),k.content&&(k.type="inline"),!k.type&&R&&(k.type=this.sourceType(R)),G(M)){if(!k.title&&A=="a"){var F=o.title;G(F)||F===""||(k.title=F)}if(!k.title&&A=="img"){var U=o.alt;G(U)||U===""||(k.title=U)}}else{var Y=[];h(k,(function(K,ee){Y.push(";\\s?"+ee)})),Y=Y.join("\\s?:|"),M.trim()!==""&&h(k,(function(K,ee){var ce=M,_e=new RegExp("s?"+ee+"s?:s?(.*?)("+Y+"s?:|$)"),ye=ce.match(_e);if(ye&&ye.length&&ye[1]){var Ie=ye[1].trim().replace(/;\s*$/,"");k[ee]=b.sanitizeValue(Ie)}}))}if(k.description&&k.description.substring(0,1)==="."){var X;try{X=document.querySelector(k.description).innerHTML}catch(K){if(!(K instanceof DOMException))throw K}X&&(k.description=X)}if(!k.description){var Z=o.querySelector(".glightbox-desc");Z&&(k.description=Z.innerHTML)}return this.setSize(k,d,o),this.slideConfig=k,k}},{key:"setSize",value:function(o,d){var b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,k=o.type=="video"?this.checkSize(d.videosWidth):this.checkSize(d.width),T=this.checkSize(d.height);return o.width=D(o,"width")&&o.width!==""?this.checkSize(o.width):k,o.height=D(o,"height")&&o.height!==""?this.checkSize(o.height):T,b&&o.type=="image"&&(o._hasCustomWidth=!!b.dataset.width,o._hasCustomHeight=!!b.dataset.height),o}},{key:"checkSize",value:function(o){return O(o)?"".concat(o,"px"):o}},{key:"sanitizeValue",value:function(o){return o!=="true"&&o!=="false"?o:o==="true"}}]),De=n((function o(d,b,k){t(this,o),this.element=d,this.instance=b,this.index=k}),[{key:"setContent",value:function(){var o=this,d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,b=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(w(d,"loaded"))return!1;var k=this.instance.settings,T=this.slideConfig,R=N();I(k.beforeSlideLoad)&&k.beforeSlideLoad({index:this.index,slide:d,player:!1});var M=T.type,A=T.descPosition,F=d.querySelector(".gslide-media"),U=d.querySelector(".gslide-title"),Y=d.querySelector(".gslide-desc"),X=d.querySelector(".gdesc-inner"),Z=b,K="gSlideTitle_"+this.index,ee="gSlideDesc_"+this.index;if(I(k.afterSlideLoad)&&(Z=function(){I(b)&&b(),k.afterSlideLoad({index:o.index,slide:d,player:o.instance.getSlidePlayerInstance(o.index)})}),T.title==""&&T.description==""?X&&X.parentNode.parentNode.removeChild(X.parentNode):(U&&T.title!==""?(U.id=K,U.innerHTML=T.title):U.parentNode.removeChild(U),Y&&T.description!==""?(Y.id=ee,R&&k.moreLength>0?(T.smallDescription=this.slideShortDesc(T.description,k.moreLength,k.moreText),Y.innerHTML=T.smallDescription,this.descriptionEvents(Y,T)):Y.innerHTML=T.description):Y.parentNode.removeChild(Y),p(F.parentNode,"desc-".concat(A)),p(X.parentNode,"description-".concat(A))),p(F,"gslide-".concat(M)),p(d,"loaded"),M!=="video"){if(M!=="external")return M==="inline"?(Ee.apply(this.instance,[d,T,this.index,Z]),void(T.draggable&&new re({dragEl:d.querySelector(".gslide-inline"),toleranceX:k.dragToleranceX,toleranceY:k.dragToleranceY,slide:d,instance:this.instance}))):void(M!=="image"?I(Z)&&Z():le(d,T,this.index,(function(){var ce=d.querySelector("img");T.draggable&&new re({dragEl:ce,toleranceX:k.dragToleranceX,toleranceY:k.dragToleranceY,slide:d,instance:o.instance}),T.zoomable&&ce.naturalWidth>ce.offsetWidth&&(p(ce,"zoomable"),new se(ce,d,(function(){o.instance.resize()}))),I(Z)&&Z()})));$e.apply(this,[d,T,this.index,Z])}else xe.apply(this.instance,[d,T,this.index,Z])}},{key:"slideShortDesc",value:function(o){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:50,b=arguments.length>2&&arguments[2]!==void 0&&arguments[2],k=document.createElement("div");k.innerHTML=o;var T=k.innerText,R=b;if((o=T.trim()).length<=d)return o;var M=o.substr(0,d-1);return R?(k=null,M+'... <a href="#" class="desc-more">'+b+"</a>"):M}},{key:"descriptionEvents",value:function(o,d){var b=this,k=o.querySelector(".desc-more");if(!k)return!1;a("click",{onElement:k,withCallback:function(T,R){T.preventDefault();var M=document.body,A=S(R,".gslide-desc");if(!A)return!1;A.innerHTML=d.description,p(M,"gdesc-open");var F=a("click",{onElement:[M,S(A,".gslide-description")],withCallback:function(U,Y){U.target.nodeName.toLowerCase()!=="a"&&(m(M,"gdesc-open"),p(M,"gdesc-closed"),A.innerHTML=d.smallDescription,b.descriptionEvents(A,d),setTimeout((function(){m(M,"gdesc-closed")}),400),F.destroy())}})}})}},{key:"create",value:function(){return v(this.instance.settings.slideHTML)}},{key:"getConfig",value:function(){P(this.element)||this.element.hasOwnProperty("draggable")||(this.element.draggable=this.instance.settings.draggable);var o=new je(this.instance.settings.slideExtraAttributes);return this.slideConfig=o.parseConfig(this.element,this.instance.settings),this.slideConfig}}]);function Ce(o){return Math.sqrt(o.x*o.x+o.y*o.y)}function Be(o,d){var b=(function(k,T){var R=Ce(k)*Ce(T);if(R===0)return 0;var M=(function(A,F){return A.x*F.x+A.y*F.y})(k,T)/R;return M>1&&(M=1),Math.acos(M)})(o,d);return(function(k,T){return k.x*T.y-T.x*k.y})(o,d)>0&&(b*=-1),180*b/Math.PI}var H=n((function o(d){t(this,o),this.handlers=[],this.el=d}),[{key:"add",value:function(o){this.handlers.push(o)}},{key:"del",value:function(o){o||(this.handlers=[]);for(var d=this.handlers.length;d>=0;d--)this.handlers[d]===o&&this.handlers.splice(d,1)}},{key:"dispatch",value:function(){for(var o=0,d=this.handlers.length;o<d;o++){var b=this.handlers[o];typeof b=="function"&&b.apply(this.el,arguments)}}}]);function Q(o,d){var b=new H(o);return b.add(d),b}var pe=n((function o(d,b){t(this,o),this.element=typeof d=="string"?document.querySelector(d):d,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 k=function(){};this.rotate=Q(this.element,b.rotate||k),this.touchStart=Q(this.element,b.touchStart||k),this.multipointStart=Q(this.element,b.multipointStart||k),this.multipointEnd=Q(this.element,b.multipointEnd||k),this.pinch=Q(this.element,b.pinch||k),this.swipe=Q(this.element,b.swipe||k),this.tap=Q(this.element,b.tap||k),this.doubleTap=Q(this.element,b.doubleTap||k),this.longTap=Q(this.element,b.longTap||k),this.singleTap=Q(this.element,b.singleTap||k),this.pressMove=Q(this.element,b.pressMove||k),this.twoFingerPressMove=Q(this.element,b.twoFingerPressMove||k),this.touchMove=Q(this.element,b.touchMove||k),this.touchEnd=Q(this.element,b.touchEnd||k),this.touchCancel=Q(this.element,b.touchCancel||k),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}}),[{key:"start",value:function(o){if(o.touches)if(o.target&&o.target.nodeName&&["a","button","input"].indexOf(o.target.nodeName.toLowerCase())>=0)console.log("ignore drag for this touched element",o.target.nodeName.toLowerCase());else{this.now=Date.now(),this.x1=o.touches[0].pageX,this.y1=o.touches[0].pageY,this.delta=this.now-(this.last||this.now),this.touchStart.dispatch(o,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 d=this.preV;if(o.touches.length>1){this._cancelLongTap(),this._cancelSingleTap();var b={x:o.touches[1].pageX-this.x1,y:o.touches[1].pageY-this.y1};d.x=b.x,d.y=b.y,this.pinchStartLen=Ce(d),this.multipointStart.dispatch(o,this.element)}this._preventTap=!1,this.longTapTimeout=setTimeout((function(){this.longTap.dispatch(o,this.element),this._preventTap=!0}).bind(this),750)}}},{key:"move",value:function(o){if(o.touches){var d=this.preV,b=o.touches.length,k=o.touches[0].pageX,T=o.touches[0].pageY;if(this.isDoubleTap=!1,b>1){var R=o.touches[1].pageX,M=o.touches[1].pageY,A={x:o.touches[1].pageX-k,y:o.touches[1].pageY-T};d.x!==null&&(this.pinchStartLen>0&&(o.zoom=Ce(A)/this.pinchStartLen,this.pinch.dispatch(o,this.element)),o.angle=Be(A,d),this.rotate.dispatch(o,this.element)),d.x=A.x,d.y=A.y,this.x2!==null&&this.sx2!==null?(o.deltaX=(k-this.x2+R-this.sx2)/2,o.deltaY=(T-this.y2+M-this.sy2)/2):(o.deltaX=0,o.deltaY=0),this.twoFingerPressMove.dispatch(o,this.element),this.sx2=R,this.sy2=M}else{if(this.x2!==null){o.deltaX=k-this.x2,o.deltaY=T-this.y2;var F=Math.abs(this.x1-this.x2),U=Math.abs(this.y1-this.y2);(F>10||U>10)&&(this._preventTap=!0)}else o.deltaX=0,o.deltaY=0;this.pressMove.dispatch(o,this.element)}this.touchMove.dispatch(o,this.element),this._cancelLongTap(),this.x2=k,this.y2=T,b>1&&o.preventDefault()}}},{key:"end",value:function(o){if(o.changedTouches){this._cancelLongTap();var d=this;o.touches.length<2&&(this.multipointEnd.dispatch(o,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?(o.direction=this._swipeDirection(this.x1,this.x2,this.y1,this.y2),this.swipeTimeout=setTimeout((function(){d.swipe.dispatch(o,d.element)}),0)):(this.tapTimeout=setTimeout((function(){d._preventTap||d.tap.dispatch(o,d.element),d.isDoubleTap&&(d.doubleTap.dispatch(o,d.element),d.isDoubleTap=!1)}),0),d.isDoubleTap||(d.singleTapTimeout=setTimeout((function(){d.singleTap.dispatch(o,d.element)}),250))),this.touchEnd.dispatch(o,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}}},{key:"cancelAll",value:function(){this._preventTap=!0,clearTimeout(this.singleTapTimeout),clearTimeout(this.tapTimeout),clearTimeout(this.longTapTimeout),clearTimeout(this.swipeTimeout)}},{key:"cancel",value:function(o){this.cancelAll(),this.touchCancel.dispatch(o,this.element)}},{key:"_cancelLongTap",value:function(){clearTimeout(this.longTapTimeout)}},{key:"_cancelSingleTap",value:function(){clearTimeout(this.singleTapTimeout)}},{key:"_swipeDirection",value:function(o,d,b,k){return Math.abs(o-d)>=Math.abs(b-k)?o-d>0?"Left":"Right":b-k>0?"Up":"Down"}},{key:"on",value:function(o,d){this[o]&&this[o].add(d)}},{key:"off",value:function(o,d){this[o]&&this[o].del(d)}},{key:"destroy",value:function(){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 ge(o){var d=(function(){var M,A=document.createElement("fakeelement"),F={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(M in F)if(A.style[M]!==void 0)return F[M]})(),b=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,k=w(o,"gslide-media")?o:o.querySelector(".gslide-media"),T=S(k,".ginner-container"),R=o.querySelector(".gslide-description");b>769&&(k=T),p(k,"greset"),y(k,"translate3d(0, 0, 0)"),a(d,{onElement:k,once:!0,withCallback:function(M,A){m(k,"greset")}}),k.style.opacity="",R&&(R.style.opacity="")}function Ae(o){if(o.events.hasOwnProperty("touch"))return!1;var d,b,k,T=_(),R=T.width,M=T.height,A=!1,F=null,U=null,Y=null,X=!1,Z=1,K=1,ee=!1,ce=!1,_e=null,ye=null,Ie=null,fe=null,Oe=0,Ne=0,Ze=!1,Ve=!1,Re={},Me={},li=0,ci=0,Ys=document.getElementById("glightbox-slider"),ft=document.querySelector(".goverlay"),Ws=new pe(Ys,{touchStart:function(oe){if(A=!0,(w(oe.targetTouches[0].target,"ginner-container")||S(oe.targetTouches[0].target,".gslide-desc")||oe.targetTouches[0].target.nodeName.toLowerCase()=="a")&&(A=!1),S(oe.targetTouches[0].target,".gslide-inline")&&!w(oe.targetTouches[0].target.parentNode,"gslide-inline")&&(A=!1),A){if(Me=oe.targetTouches[0],Re.pageX=oe.targetTouches[0].pageX,Re.pageY=oe.targetTouches[0].pageY,li=oe.targetTouches[0].clientX,ci=oe.targetTouches[0].clientY,F=o.activeSlide,U=F.querySelector(".gslide-media"),k=F.querySelector(".gslide-inline"),Y=null,w(U,"gslide-image")&&(Y=U.querySelector("img")),(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth)>769&&(U=F.querySelector(".ginner-container")),m(ft,"greset"),oe.pageX>20&&oe.pageX<window.innerWidth-20)return;oe.preventDefault()}},touchMove:function(oe){if(A&&(Me=oe.targetTouches[0],!ee&&!ce)){if(k&&k.offsetHeight>M){var ve=Re.pageX-Me.pageX;if(Math.abs(ve)<=13)return!1}X=!0;var He,mt=oe.targetTouches[0].clientX,Xs=oe.targetTouches[0].clientY,Js=li-mt,Zs=ci-Xs;if(Math.abs(Js)>Math.abs(Zs)?(Ze=!1,Ve=!0):(Ve=!1,Ze=!0),d=Me.pageX-Re.pageX,Oe=100*d/R,b=Me.pageY-Re.pageY,Ne=100*b/M,Ze&&Y&&(He=1-Math.abs(b)/M,ft.style.opacity=He,o.settings.touchFollowAxis&&(Oe=0)),Ve&&(He=1-Math.abs(d)/R,U.style.opacity=He,o.settings.touchFollowAxis&&(Ne=0)),!Y)return y(U,"translate3d(".concat(Oe,"%, 0, 0)"));y(U,"translate3d(".concat(Oe,"%, ").concat(Ne,"%, 0)"))}},touchEnd:function(){if(A){if(X=!1,ce||ee)return Ie=_e,void(fe=ye);var oe=Math.abs(parseInt(Ne)),ve=Math.abs(parseInt(Oe));if(!(oe>29&&Y))return oe<29&&ve<25?(p(ft,"greset"),ft.style.opacity=1,ge(U)):void 0;o.close()}},multipointEnd:function(){setTimeout((function(){ee=!1}),50)},multipointStart:function(){ee=!0,Z=K||1},pinch:function(oe){if(!Y||X)return!1;ee=!0,Y.scaleX=Y.scaleY=Z*oe.zoom;var ve=Z*oe.zoom;if(ce=!0,ve<=1)return ce=!1,ve=1,fe=null,Ie=null,_e=null,ye=null,void Y.setAttribute("style","");ve>4.5&&(ve=4.5),Y.style.transform="scale3d(".concat(ve,", ").concat(ve,", 1)"),K=ve},pressMove:function(oe){if(ce&&!ee){var ve=Me.pageX-Re.pageX,He=Me.pageY-Re.pageY;Ie&&(ve+=Ie),fe&&(He+=fe),_e=ve,ye=He;var mt="translate3d(".concat(ve,"px, ").concat(He,"px, 0)");K&&(mt+=" scale3d(".concat(K,", ").concat(K,", 1)")),y(Y,mt)}},swipe:function(oe){if(!ce)if(ee)ee=!1;else{if(oe.direction=="Left"){if(o.index==o.elements.length-1)return ge(U);o.nextSlide()}if(oe.direction=="Right"){if(o.index==0)return ge(U);o.prevSlide()}}}});o.events.touch=Ws}var be=N(),ue=N()!==null||document.createTouch!==void 0||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,Se=document.getElementsByTagName("html")[0],ie={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>'},slideHTML:`<div class="gslide">
|
|
2
2
|
<div class="gslide-inner-content">
|
|
3
3
|
<div class="ginner-container">
|
|
4
4
|
<div class="gslide-media">
|
|
@@ -20,8 +20,492 @@ var ContentBuilderRuntime=(function(){"use strict";function ae(s){return s&&s.__
|
|
|
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>`},mi=c((function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};a(this,t),this.customOptions=e,this.settings=m(vi,e),this.effectsClasses=this.getAnimationClasses(),this.videoPlayers={},this.apiEvents=[],this.fullElementsList=!1}),[{key:"init",value:function(){var t=this,e=this.getSelector();e&&(this.baseEvents=S("click",{onElement:e,withCallback:function(n,o){n.preventDefault(),t.open(o)}})),this.elements=this.getElements()}},{key:"open",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.elements.length===0)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;var n=bt(e)?e:this.settings.startAt;if(J(t)){var o=t.getAttribute("data-gallery");o&&(this.fullElementsList=this.elements,this.elements=this.getGalleryElements(this.elements,o)),Y(n)&&(n=this.getElementIndex(t))<0&&(n=0)}bt(n)||(n=0),this.build(),B(this.overlay,this.settings.openEffect==="none"?"none":this.settings.cssEfects.fade.in);var u=document.body,f=window.innerWidth-document.documentElement.clientWidth;if(f>0){var d=document.createElement("style");d.type="text/css",d.className="gcss-styles",d.innerText=".gscrollbar-fixer {margin-right: ".concat(f,"px}"),document.head.appendChild(d),b(u,"gscrollbar-fixer")}b(u,"glightbox-open"),b(ne,"glightbox-open"),ee&&(b(document.body,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(n,!0),this.elements.length===1?(b(this.prevButton,"glightbox-button-hidden"),b(this.nextButton,"glightbox-button-hidden")):(A(this.prevButton,"glightbox-button-hidden"),A(this.nextButton,"glightbox-button-hidden")),this.lightboxOpen=!0,this.trigger("open"),P(this.settings.onOpen)&&this.settings.onOpen(),ie&&this.settings.touchNavigation&&gi(this),this.settings.keyboardNavigation&&si(this)}},{key:"openAt",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.open(null,t)}},{key:"showSlide",value:function(){var t=this,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];V(this.loader),this.index=parseInt(e);var o=this.slidesContainer.querySelector(".current");o&&A(o,"current"),this.slideAnimateOut();var u=this.slidesContainer.querySelectorAll(".gslide")[e];if(C(u,"loaded"))this.slideAnimateIn(u,n),F(this.loader);else{V(this.loader);var f=this.elements[e],d={index:this.index,slide:u,slideNode:u,slideConfig:f.slideConfig,slideIndex:this.index,trigger:f.node,player:null};this.trigger("slide_before_load",d),f.instance.setContent(u,(function(){F(t.loader),t.resize(),t.slideAnimateIn(u,n),t.trigger("slide_after_load",d)}))}this.slideDescription=u.querySelector(".gslide-description"),this.slideDescriptionContained=this.slideDescription&&C(this.slideDescription.parentNode,"gslide-media"),this.settings.preload&&(this.preloadSlide(e+1),this.preloadSlide(e-1)),this.updateNavigationClasses(),this.activeSlide=u}},{key:"preloadSlide",value:function(t){var e=this;if(t<0||t>this.elements.length-1||Y(this.elements[t]))return!1;var n=this.slidesContainer.querySelectorAll(".gslide")[t];if(C(n,"loaded"))return!1;var o=this.elements[t],u=o.type,f={index:t,slide:n,slideNode:n,slideConfig:o.slideConfig,slideIndex:t,trigger:o.node,player:null};this.trigger("slide_before_load",f),u==="video"||u==="external"?setTimeout((function(){o.instance.setContent(n,(function(){e.trigger("slide_after_load",f)}))}),200):o.instance.setContent(n,(function(){e.trigger("slide_after_load",f)}))}},{key:"prevSlide",value:function(){this.goToSlide(this.index-1)}},{key:"nextSlide",value:function(){this.goToSlide(this.index+1)}},{key:"goToSlide",value:function(){var t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,!this.loop()&&(t<0||t>this.elements.length-1))return!1;t<0?t=this.elements.length-1:t>=this.elements.length&&(t=0),this.showSlide(t)}},{key:"insertSlide",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1;e<0&&(e=this.elements.length);var n=new wt(t,this,e),o=n.getConfig(),u=m({},o),f=n.create(),d=this.elements.length-1;u.index=e,u.node=!1,u.instance=n,u.slideConfig=o,this.elements.splice(e,0,u);var g=null,x=null;if(this.slidesContainer){if(e>d)this.slidesContainer.appendChild(f);else{var w=this.slidesContainer.querySelectorAll(".gslide")[e];this.slidesContainer.insertBefore(f,w)}(this.settings.preload&&this.index==0&&e==0||this.index-1==e||this.index+1==e)&&this.preloadSlide(e),this.index===0&&e===0&&(this.index=1),this.updateNavigationClasses(),g=this.slidesContainer.querySelectorAll(".gslide")[e],x=this.getSlidePlayerInstance(e),u.slideNode=g}this.trigger("slide_inserted",{index:e,slide:g,slideNode:g,slideConfig:o,slideIndex:e,trigger:null,player:x}),P(this.settings.slideInserted)&&this.settings.slideInserted({index:e,slide:g,player:x})}},{key:"removeSlide",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1;if(t<0||t>this.elements.length-1)return!1;var e=this.slidesContainer&&this.slidesContainer.querySelectorAll(".gslide")[t];e&&(this.getActiveSlideIndex()==t&&(t==this.elements.length-1?this.prevSlide():this.nextSlide()),e.parentNode.removeChild(e)),this.elements.splice(t,1),this.trigger("slide_removed",t),P(this.settings.slideRemoved)&&this.settings.slideRemoved(t)}},{key:"slideAnimateIn",value:function(t,e){var n=this,o=t.querySelector(".gslide-media"),u=t.querySelector(".gslide-description"),f={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlide,slideConfig:Y(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:Y(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},d={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(o.offsetWidth>0&&u&&(F(u),u.style.display=""),A(t,this.effectsClasses),e)B(t,this.settings.cssEfects[this.settings.openEffect].in,(function(){n.settings.autoplayVideos&&n.slidePlayerPlay(t),n.trigger("slide_changed",{prev:f,current:d}),P(n.settings.afterSlideChange)&&n.settings.afterSlideChange.apply(n,[f,d])}));else{var g=this.settings.slideEffect,x=g!=="none"?this.settings.cssEfects[g].in:g;this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(x=this.settings.cssEfects.slideBack.in),B(t,x,(function(){n.settings.autoplayVideos&&n.slidePlayerPlay(t),n.trigger("slide_changed",{prev:f,current:d}),P(n.settings.afterSlideChange)&&n.settings.afterSlideChange.apply(n,[f,d])}))}setTimeout((function(){n.resize(t)}),100),b(t,"current")}},{key:"slideAnimateOut",value:function(){if(!this.prevActiveSlide)return!1;var t=this.prevActiveSlide;A(t,this.effectsClasses),b(t,"prev");var e=this.settings.slideEffect,n=e!=="none"?this.settings.cssEfects[e].out:e;this.slidePlayerPause(t),this.trigger("slide_before_change",{prev:{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlideIndex,slideConfig:Y(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:Y(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)}}),P(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"&&(n=this.settings.cssEfects.slideBack.out),B(t,n,(function(){var o=t.querySelector(".ginner-container"),u=t.querySelector(".gslide-media"),f=t.querySelector(".gslide-description");o.style.transform="",u.style.transform="",A(u,"greset"),u.style.opacity="",f&&(f.style.opacity=""),A(t,"prev")}))}},{key:"getAllPlayers",value:function(){return this.videoPlayers}},{key:"getSlidePlayerInstance",value:function(t){var e="gvideo"+t,n=this.getAllPlayers();return!(!H(n,e)||!n[e])&&n[e]}},{key:"stopSlideVideo",value:function(t){if(J(t)){var e=t.querySelector(".gvideo-wrapper");e&&(t=e.getAttribute("data-index"))}console.log("stopSlideVideo is deprecated, use slidePlayerPause");var n=this.getSlidePlayerInstance(t);n&&n.playing&&n.pause()}},{key:"slidePlayerPause",value:function(t){if(J(t)){var e=t.querySelector(".gvideo-wrapper");e&&(t=e.getAttribute("data-index"))}var n=this.getSlidePlayerInstance(t);n&&n.playing&&n.pause()}},{key:"playSlideVideo",value:function(t){if(J(t)){var e=t.querySelector(".gvideo-wrapper");e&&(t=e.getAttribute("data-index"))}console.log("playSlideVideo is deprecated, use slidePlayerPlay");var n=this.getSlidePlayerInstance(t);n&&!n.playing&&n.play()}},{key:"slidePlayerPlay",value:function(t){var e;if(!ee||(e=this.settings.plyr.config)!==null&&e!==void 0&&e.muted){if(J(t)){var n=t.querySelector(".gvideo-wrapper");n&&(t=n.getAttribute("data-index"))}var o=this.getSlidePlayerInstance(t);o&&!o.playing&&(o.play(),this.settings.autofocusVideos&&o.elements.container.focus())}}},{key:"setElements",value:function(t){var e=this;this.settings.elements=!1;var n=[];t&&t.length&&p(t,(function(o,u){var f=new wt(o,e,u),d=f.getConfig(),g=m({},d);g.slideConfig=d,g.instance=f,g.index=u,n.push(g)})),this.elements=n,this.lightboxOpen&&(this.slidesContainer.innerHTML="",this.elements.length&&(p(this.elements,(function(){var o=Z(e.settings.slideHTML);e.slidesContainer.appendChild(o)})),this.showSlide(0,!0)))}},{key:"getElementIndex",value:function(t){var e=!1;return p(this.elements,(function(n,o){if(H(n,"node")&&n.node==t)return e=o,!0})),e}},{key:"getElements",value:function(){var t=this,e=[];this.elements=this.elements?this.elements:[],!Y(this.settings.elements)&&Kt(this.settings.elements)&&this.settings.elements.length&&p(this.settings.elements,(function(o,u){var f=new wt(o,t,u),d=f.getConfig(),g=m({},d);g.node=!1,g.index=u,g.instance=f,g.slideConfig=d,e.push(g)}));var n=!1;return this.getSelector()&&(n=document.querySelectorAll(this.getSelector())),n&&p(n,(function(o,u){var f=new wt(o,t,u),d=f.getConfig(),g=m({},d);g.node=o,g.index=u,g.instance=f,g.slideConfig=d,g.gallery=o.getAttribute("data-gallery"),e.push(g)})),e}},{key:"getGalleryElements",value:function(t,e){return t.filter((function(n){return n.gallery==e}))}},{key:"getSelector",value:function(){return!this.settings.elements&&(this.settings.selector&&this.settings.selector.substring(0,5)=="data-"?"*[".concat(this.settings.selector,"]"):this.settings.selector)}},{key:"getActiveSlide",value:function(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}},{key:"getActiveSlideIndex",value:function(){return this.index}},{key:"getAnimationClasses",value:function(){var t=[];for(var e in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(e)){var n=this.settings.cssEfects[e];t.push("g".concat(n.in)),t.push("g".concat(n.out))}return t.join(" ")}},{key:"build",value:function(){var t=this;if(this.built)return!1;var e=document.body.childNodes,n=[];p(e,(function(w){w.parentNode==document.body&&w.nodeName.charAt(0)!=="#"&&w.hasAttribute&&!w.hasAttribute("aria-hidden")&&(n.push(w),w.setAttribute("aria-hidden","true"))}));var o=H(this.settings.svg,"next")?this.settings.svg.next:"",u=H(this.settings.svg,"prev")?this.settings.svg.prev:"",f=H(this.settings.svg,"close")?this.settings.svg.close:"",d=this.settings.lightboxHTML;d=Z(d=(d=(d=d.replace(/{nextSVG}/g,o)).replace(/{prevSVG}/g,u)).replace(/{closeSVG}/g,f)),document.body.appendChild(d);var g=document.getElementById("glightbox-body");this.modal=g;var x=g.querySelector(".gclose");this.prevButton=g.querySelector(".gprev"),this.nextButton=g.querySelector(".gnext"),this.overlay=g.querySelector(".goverlay"),this.loader=g.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.bodyHiddenChildElms=n,this.events={},b(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&x&&(this.events.close=S("click",{onElement:x,withCallback:function(w,T){w.preventDefault(),t.close()}})),x&&!this.settings.closeButton&&x.parentNode.removeChild(x),this.nextButton&&(this.events.next=S("click",{onElement:this.nextButton,withCallback:function(w,T){w.preventDefault(),t.nextSlide()}})),this.prevButton&&(this.events.prev=S("click",{onElement:this.prevButton,withCallback:function(w,T){w.preventDefault(),t.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=S("click",{onElement:g,withCallback:function(w,T){t.preventOutsideClick||C(document.body,"glightbox-mobile")||L(w.target,".ginner-container")||L(w.target,".gbtn")||C(w.target,"gnext")||C(w.target,"gprev")||t.close()}})),p(this.elements,(function(w,T){t.slidesContainer.appendChild(w.instance.create()),w.slideNode=t.slidesContainer.querySelectorAll(".gslide")[T]})),ie&&b(document.body,"glightbox-touch"),this.events.resize=S("resize",{onElement:window,withCallback:function(){t.resize()}}),this.built=!0}},{key:"resize",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;if((t=t||this.activeSlide)&&!C(t,"zoomed")){var e=yt(),n=t.querySelector(".gvideo-wrapper"),o=t.querySelector(".gslide-image"),u=this.slideDescription,f=e.width,d=e.height;if(f<=768?b(document.body,"glightbox-mobile"):A(document.body,"glightbox-mobile"),n||o){var g=!1;if(u&&(C(u,"description-bottom")||C(u,"description-top"))&&!C(u,"gabsolute")&&(g=!0),o){if(f<=768)o.querySelector("img");else if(g){var x,w,T=u.offsetHeight,k=o.querySelector("img"),E=(x=this.elements[this.index])===null||x===void 0?void 0:x.node,O="100vh";E&&(O=(w=E.getAttribute("data-height"))!==null&&w!==void 0?w:O),k.setAttribute("style","max-height: calc(".concat(O," - ").concat(T,"px)")),u.setAttribute("style","max-width: ".concat(k.offsetWidth,"px;"))}}if(n){var _=H(this.settings.plyr.config,"ratio")?this.settings.plyr.config.ratio:"";if(!_){var z=n.clientWidth,j=n.clientHeight,W=z/j;_="".concat(z/W,":").concat(j/W)}var Q=_.split(":"),N=this.settings.videosWidth,G=this.settings.videosWidth,tt=(G=bt(N)||N.indexOf("px")!==-1?parseInt(N):N.indexOf("vw")!==-1?f*parseInt(N)/100:N.indexOf("vh")!==-1?d*parseInt(N)/100:N.indexOf("%")!==-1?f*parseInt(N)/100:parseInt(n.clientWidth))/(parseInt(Q[0])/parseInt(Q[1]));if(tt=Math.floor(tt),g&&(d-=u.offsetHeight),G>f||tt>d||d<tt&&f>G){var lt=n.offsetWidth,at=n.offsetHeight,$=d/at,K={width:lt*$,height:at*$};n.parentNode.setAttribute("style","max-width: ".concat(K.width,"px")),g&&u.setAttribute("style","max-width: ".concat(K.width,"px;"))}else n.parentNode.style.maxWidth="".concat(N),g&&u.setAttribute("style","max-width: ".concat(N,";"))}}}}},{key:"reload",value:function(){this.init()}},{key:"updateNavigationClasses",value:function(){var t=this.loop();A(this.nextButton,"disabled"),A(this.prevButton,"disabled"),this.index==0&&this.elements.length-1==0?(b(this.prevButton,"disabled"),b(this.nextButton,"disabled")):this.index!==0||t?this.index!==this.elements.length-1||t||b(this.nextButton,"disabled"):b(this.prevButton,"disabled")}},{key:"loop",value:function(){var t=H(this.settings,"loopAtEnd")?this.settings.loopAtEnd:null;return t=H(this.settings,"loop")?this.settings.loop:t,t}},{key:"close",value:function(){var t=this;if(!this.lightboxOpen){if(this.events){for(var 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&&p(this.bodyHiddenChildElms,(function(n){n.removeAttribute("aria-hidden")})),b(this.modal,"glightbox-closing"),B(this.overlay,this.settings.openEffect=="none"?"none":this.settings.cssEfects.fade.out),B(this.activeSlide,this.settings.cssEfects[this.settings.closeEffect].out,(function(){if(t.activeSlide=null,t.prevActiveSlideIndex=null,t.prevActiveSlide=null,t.built=!1,t.events){for(var n in t.events)t.events.hasOwnProperty(n)&&t.events[n].destroy();t.events=null}var o=document.body;A(ne,"glightbox-open"),A(o,"glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer"),t.modal.parentNode.removeChild(t.modal),t.trigger("close"),P(t.settings.onClose)&&t.settings.onClose();var u=document.querySelector(".gcss-styles");u&&u.parentNode.removeChild(u),t.lightboxOpen=!1,t.closing=null}))}},{key:"destroy",value:function(){this.close(),this.clearAllEvents(),this.baseEvents&&this.baseEvents.destroy()}},{key:"on",value:function(t,e){var n=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(!t||!P(e))throw new TypeError("Event name and callback must be defined");this.apiEvents.push({evt:t,once:n,callback:e})}},{key:"once",value:function(t,e){this.on(t,e,!0)}},{key:"trigger",value:function(t){var e=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,o=[];p(this.apiEvents,(function(u,f){var d=u.evt,g=u.once,x=u.callback;d==t&&(x(n),g&&o.push(f))})),o.length&&p(o,(function(u){return e.apiEvents.splice(u,1)}))}},{key:"clearAllEvents",value:function(){this.apiEvents.splice(0,this.apiEvents.length)}},{key:"version",value:function(){return"3.3.1"}}]);return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=new mi(t);return e.init(),e}}))})(ut)),ut.exports}var ue=le();const Dt=ae(ue);/*!
|
|
23
|
+
</div>`},Le=n((function o(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t(this,o),this.customOptions=d,this.settings=c(ie,d),this.effectsClasses=this.getAnimationClasses(),this.videoPlayers={},this.apiEvents=[],this.fullElementsList=!1}),[{key:"init",value:function(){var o=this,d=this.getSelector();d&&(this.baseEvents=a("click",{onElement:d,withCallback:function(b,k){b.preventDefault(),o.open(k)}})),this.elements=this.getElements()}},{key:"open",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.elements.length===0)return!1;this.activeSlide=null,this.prevActiveSlideIndex=null,this.prevActiveSlide=null;var b=O(d)?d:this.settings.startAt;if(P(o)){var k=o.getAttribute("data-gallery");k&&(this.fullElementsList=this.elements,this.elements=this.getGalleryElements(this.elements,k)),G(b)&&(b=this.getElementIndex(o))<0&&(b=0)}O(b)||(b=0),this.build(),L(this.overlay,this.settings.openEffect==="none"?"none":this.settings.cssEfects.fade.in);var T=document.body,R=window.innerWidth-document.documentElement.clientWidth;if(R>0){var M=document.createElement("style");M.type="text/css",M.className="gcss-styles",M.innerText=".gscrollbar-fixer {margin-right: ".concat(R,"px}"),document.head.appendChild(M),p(T,"gscrollbar-fixer")}p(T,"glightbox-open"),p(Se,"glightbox-open"),be&&(p(document.body,"glightbox-mobile"),this.settings.slideEffect="slide"),this.showSlide(b,!0),this.elements.length===1?(p(this.prevButton,"glightbox-button-hidden"),p(this.nextButton,"glightbox-button-hidden")):(m(this.prevButton,"glightbox-button-hidden"),m(this.nextButton,"glightbox-button-hidden")),this.lightboxOpen=!0,this.trigger("open"),I(this.settings.onOpen)&&this.settings.onOpen(),ue&&this.settings.touchNavigation&&Ae(this),this.settings.keyboardNavigation&&W(this)}},{key:"openAt",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.open(null,o)}},{key:"showSlide",value:function(){var o=this,d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,b=arguments.length>1&&arguments[1]!==void 0&&arguments[1];x(this.loader),this.index=parseInt(d);var k=this.slidesContainer.querySelector(".current");k&&m(k,"current"),this.slideAnimateOut();var T=this.slidesContainer.querySelectorAll(".gslide")[d];if(w(T,"loaded"))this.slideAnimateIn(T,b),g(this.loader);else{x(this.loader);var R=this.elements[d],M={index:this.index,slide:T,slideNode:T,slideConfig:R.slideConfig,slideIndex:this.index,trigger:R.node,player:null};this.trigger("slide_before_load",M),R.instance.setContent(T,(function(){g(o.loader),o.resize(),o.slideAnimateIn(T,b),o.trigger("slide_after_load",M)}))}this.slideDescription=T.querySelector(".gslide-description"),this.slideDescriptionContained=this.slideDescription&&w(this.slideDescription.parentNode,"gslide-media"),this.settings.preload&&(this.preloadSlide(d+1),this.preloadSlide(d-1)),this.updateNavigationClasses(),this.activeSlide=T}},{key:"preloadSlide",value:function(o){var d=this;if(o<0||o>this.elements.length-1||G(this.elements[o]))return!1;var b=this.slidesContainer.querySelectorAll(".gslide")[o];if(w(b,"loaded"))return!1;var k=this.elements[o],T=k.type,R={index:o,slide:b,slideNode:b,slideConfig:k.slideConfig,slideIndex:o,trigger:k.node,player:null};this.trigger("slide_before_load",R),T==="video"||T==="external"?setTimeout((function(){k.instance.setContent(b,(function(){d.trigger("slide_after_load",R)}))}),200):k.instance.setContent(b,(function(){d.trigger("slide_after_load",R)}))}},{key:"prevSlide",value:function(){this.goToSlide(this.index-1)}},{key:"nextSlide",value:function(){this.goToSlide(this.index+1)}},{key:"goToSlide",value:function(){var o=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.prevActiveSlide=this.activeSlide,this.prevActiveSlideIndex=this.index,!this.loop()&&(o<0||o>this.elements.length-1))return!1;o<0?o=this.elements.length-1:o>=this.elements.length&&(o=0),this.showSlide(o)}},{key:"insertSlide",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1;d<0&&(d=this.elements.length);var b=new De(o,this,d),k=b.getConfig(),T=c({},k),R=b.create(),M=this.elements.length-1;T.index=d,T.node=!1,T.instance=b,T.slideConfig=k,this.elements.splice(d,0,T);var A=null,F=null;if(this.slidesContainer){if(d>M)this.slidesContainer.appendChild(R);else{var U=this.slidesContainer.querySelectorAll(".gslide")[d];this.slidesContainer.insertBefore(R,U)}(this.settings.preload&&this.index==0&&d==0||this.index-1==d||this.index+1==d)&&this.preloadSlide(d),this.index===0&&d===0&&(this.index=1),this.updateNavigationClasses(),A=this.slidesContainer.querySelectorAll(".gslide")[d],F=this.getSlidePlayerInstance(d),T.slideNode=A}this.trigger("slide_inserted",{index:d,slide:A,slideNode:A,slideConfig:k,slideIndex:d,trigger:null,player:F}),I(this.settings.slideInserted)&&this.settings.slideInserted({index:d,slide:A,player:F})}},{key:"removeSlide",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1;if(o<0||o>this.elements.length-1)return!1;var d=this.slidesContainer&&this.slidesContainer.querySelectorAll(".gslide")[o];d&&(this.getActiveSlideIndex()==o&&(o==this.elements.length-1?this.prevSlide():this.nextSlide()),d.parentNode.removeChild(d)),this.elements.splice(o,1),this.trigger("slide_removed",o),I(this.settings.slideRemoved)&&this.settings.slideRemoved(o)}},{key:"slideAnimateIn",value:function(o,d){var b=this,k=o.querySelector(".gslide-media"),T=o.querySelector(".gslide-description"),R={index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlide,slideConfig:G(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:G(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].node,player:this.getSlidePlayerInstance(this.prevActiveSlideIndex)},M={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(k.offsetWidth>0&&T&&(g(T),T.style.display=""),m(o,this.effectsClasses),d)L(o,this.settings.cssEfects[this.settings.openEffect].in,(function(){b.settings.autoplayVideos&&b.slidePlayerPlay(o),b.trigger("slide_changed",{prev:R,current:M}),I(b.settings.afterSlideChange)&&b.settings.afterSlideChange.apply(b,[R,M])}));else{var A=this.settings.slideEffect,F=A!=="none"?this.settings.cssEfects[A].in:A;this.prevActiveSlideIndex>this.index&&this.settings.slideEffect=="slide"&&(F=this.settings.cssEfects.slideBack.in),L(o,F,(function(){b.settings.autoplayVideos&&b.slidePlayerPlay(o),b.trigger("slide_changed",{prev:R,current:M}),I(b.settings.afterSlideChange)&&b.settings.afterSlideChange.apply(b,[R,M])}))}setTimeout((function(){b.resize(o)}),100),p(o,"current")}},{key:"slideAnimateOut",value:function(){if(!this.prevActiveSlide)return!1;var o=this.prevActiveSlide;m(o,this.effectsClasses),p(o,"prev");var d=this.settings.slideEffect,b=d!=="none"?this.settings.cssEfects[d].out:d;this.slidePlayerPause(o),this.trigger("slide_before_change",{prev:{index:this.prevActiveSlideIndex,slide:this.prevActiveSlide,slideNode:this.prevActiveSlide,slideIndex:this.prevActiveSlideIndex,slideConfig:G(this.prevActiveSlideIndex)?null:this.elements[this.prevActiveSlideIndex].slideConfig,trigger:G(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)}}),I(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"&&(b=this.settings.cssEfects.slideBack.out),L(o,b,(function(){var k=o.querySelector(".ginner-container"),T=o.querySelector(".gslide-media"),R=o.querySelector(".gslide-description");k.style.transform="",T.style.transform="",m(T,"greset"),T.style.opacity="",R&&(R.style.opacity=""),m(o,"prev")}))}},{key:"getAllPlayers",value:function(){return this.videoPlayers}},{key:"getSlidePlayerInstance",value:function(o){var d="gvideo"+o,b=this.getAllPlayers();return!(!D(b,d)||!b[d])&&b[d]}},{key:"stopSlideVideo",value:function(o){if(P(o)){var d=o.querySelector(".gvideo-wrapper");d&&(o=d.getAttribute("data-index"))}console.log("stopSlideVideo is deprecated, use slidePlayerPause");var b=this.getSlidePlayerInstance(o);b&&b.playing&&b.pause()}},{key:"slidePlayerPause",value:function(o){if(P(o)){var d=o.querySelector(".gvideo-wrapper");d&&(o=d.getAttribute("data-index"))}var b=this.getSlidePlayerInstance(o);b&&b.playing&&b.pause()}},{key:"playSlideVideo",value:function(o){if(P(o)){var d=o.querySelector(".gvideo-wrapper");d&&(o=d.getAttribute("data-index"))}console.log("playSlideVideo is deprecated, use slidePlayerPlay");var b=this.getSlidePlayerInstance(o);b&&!b.playing&&b.play()}},{key:"slidePlayerPlay",value:function(o){var d;if(!be||(d=this.settings.plyr.config)!==null&&d!==void 0&&d.muted){if(P(o)){var b=o.querySelector(".gvideo-wrapper");b&&(o=b.getAttribute("data-index"))}var k=this.getSlidePlayerInstance(o);k&&!k.playing&&(k.play(),this.settings.autofocusVideos&&k.elements.container.focus())}}},{key:"setElements",value:function(o){var d=this;this.settings.elements=!1;var b=[];o&&o.length&&h(o,(function(k,T){var R=new De(k,d,T),M=R.getConfig(),A=c({},M);A.slideConfig=M,A.instance=R,A.index=T,b.push(A)})),this.elements=b,this.lightboxOpen&&(this.slidesContainer.innerHTML="",this.elements.length&&(h(this.elements,(function(){var k=v(d.settings.slideHTML);d.slidesContainer.appendChild(k)})),this.showSlide(0,!0)))}},{key:"getElementIndex",value:function(o){var d=!1;return h(this.elements,(function(b,k){if(D(b,"node")&&b.node==o)return d=k,!0})),d}},{key:"getElements",value:function(){var o=this,d=[];this.elements=this.elements?this.elements:[],!G(this.settings.elements)&&J(this.settings.elements)&&this.settings.elements.length&&h(this.settings.elements,(function(k,T){var R=new De(k,o,T),M=R.getConfig(),A=c({},M);A.node=!1,A.index=T,A.instance=R,A.slideConfig=M,d.push(A)}));var b=!1;return this.getSelector()&&(b=document.querySelectorAll(this.getSelector())),b&&h(b,(function(k,T){var R=new De(k,o,T),M=R.getConfig(),A=c({},M);A.node=k,A.index=T,A.instance=R,A.slideConfig=M,A.gallery=k.getAttribute("data-gallery"),d.push(A)})),d}},{key:"getGalleryElements",value:function(o,d){return o.filter((function(b){return b.gallery==d}))}},{key:"getSelector",value:function(){return!this.settings.elements&&(this.settings.selector&&this.settings.selector.substring(0,5)=="data-"?"*[".concat(this.settings.selector,"]"):this.settings.selector)}},{key:"getActiveSlide",value:function(){return this.slidesContainer.querySelectorAll(".gslide")[this.index]}},{key:"getActiveSlideIndex",value:function(){return this.index}},{key:"getAnimationClasses",value:function(){var o=[];for(var d in this.settings.cssEfects)if(this.settings.cssEfects.hasOwnProperty(d)){var b=this.settings.cssEfects[d];o.push("g".concat(b.in)),o.push("g".concat(b.out))}return o.join(" ")}},{key:"build",value:function(){var o=this;if(this.built)return!1;var d=document.body.childNodes,b=[];h(d,(function(U){U.parentNode==document.body&&U.nodeName.charAt(0)!=="#"&&U.hasAttribute&&!U.hasAttribute("aria-hidden")&&(b.push(U),U.setAttribute("aria-hidden","true"))}));var k=D(this.settings.svg,"next")?this.settings.svg.next:"",T=D(this.settings.svg,"prev")?this.settings.svg.prev:"",R=D(this.settings.svg,"close")?this.settings.svg.close:"",M=this.settings.lightboxHTML;M=v(M=(M=(M=M.replace(/{nextSVG}/g,k)).replace(/{prevSVG}/g,T)).replace(/{closeSVG}/g,R)),document.body.appendChild(M);var A=document.getElementById("glightbox-body");this.modal=A;var F=A.querySelector(".gclose");this.prevButton=A.querySelector(".gprev"),this.nextButton=A.querySelector(".gnext"),this.overlay=A.querySelector(".goverlay"),this.loader=A.querySelector(".gloader"),this.slidesContainer=document.getElementById("glightbox-slider"),this.bodyHiddenChildElms=b,this.events={},p(this.modal,"glightbox-"+this.settings.skin),this.settings.closeButton&&F&&(this.events.close=a("click",{onElement:F,withCallback:function(U,Y){U.preventDefault(),o.close()}})),F&&!this.settings.closeButton&&F.parentNode.removeChild(F),this.nextButton&&(this.events.next=a("click",{onElement:this.nextButton,withCallback:function(U,Y){U.preventDefault(),o.nextSlide()}})),this.prevButton&&(this.events.prev=a("click",{onElement:this.prevButton,withCallback:function(U,Y){U.preventDefault(),o.prevSlide()}})),this.settings.closeOnOutsideClick&&(this.events.outClose=a("click",{onElement:A,withCallback:function(U,Y){o.preventOutsideClick||w(document.body,"glightbox-mobile")||S(U.target,".ginner-container")||S(U.target,".gbtn")||w(U.target,"gnext")||w(U.target,"gprev")||o.close()}})),h(this.elements,(function(U,Y){o.slidesContainer.appendChild(U.instance.create()),U.slideNode=o.slidesContainer.querySelectorAll(".gslide")[Y]})),ue&&p(document.body,"glightbox-touch"),this.events.resize=a("resize",{onElement:window,withCallback:function(){o.resize()}}),this.built=!0}},{key:"resize",value:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;if((o=o||this.activeSlide)&&!w(o,"zoomed")){var d=_(),b=o.querySelector(".gvideo-wrapper"),k=o.querySelector(".gslide-image"),T=this.slideDescription,R=d.width,M=d.height;if(R<=768?p(document.body,"glightbox-mobile"):m(document.body,"glightbox-mobile"),b||k){var A=!1;if(T&&(w(T,"description-bottom")||w(T,"description-top"))&&!w(T,"gabsolute")&&(A=!0),k){if(R<=768)k.querySelector("img");else if(A){var F,U,Y=T.offsetHeight,X=k.querySelector("img"),Z=(F=this.elements[this.index])===null||F===void 0?void 0:F.node,K="100vh";Z&&(K=(U=Z.getAttribute("data-height"))!==null&&U!==void 0?U:K),X.setAttribute("style","max-height: calc(".concat(K," - ").concat(Y,"px)")),T.setAttribute("style","max-width: ".concat(X.offsetWidth,"px;"))}}if(b){var ee=D(this.settings.plyr.config,"ratio")?this.settings.plyr.config.ratio:"";if(!ee){var ce=b.clientWidth,_e=b.clientHeight,ye=ce/_e;ee="".concat(ce/ye,":").concat(_e/ye)}var Ie=ee.split(":"),fe=this.settings.videosWidth,Oe=this.settings.videosWidth,Ne=(Oe=O(fe)||fe.indexOf("px")!==-1?parseInt(fe):fe.indexOf("vw")!==-1?R*parseInt(fe)/100:fe.indexOf("vh")!==-1?M*parseInt(fe)/100:fe.indexOf("%")!==-1?R*parseInt(fe)/100:parseInt(b.clientWidth))/(parseInt(Ie[0])/parseInt(Ie[1]));if(Ne=Math.floor(Ne),A&&(M-=T.offsetHeight),Oe>R||Ne>M||M<Ne&&R>Oe){var Ze=b.offsetWidth,Ve=b.offsetHeight,Re=M/Ve,Me={width:Ze*Re,height:Ve*Re};b.parentNode.setAttribute("style","max-width: ".concat(Me.width,"px")),A&&T.setAttribute("style","max-width: ".concat(Me.width,"px;"))}else b.parentNode.style.maxWidth="".concat(fe),A&&T.setAttribute("style","max-width: ".concat(fe,";"))}}}}},{key:"reload",value:function(){this.init()}},{key:"updateNavigationClasses",value:function(){var o=this.loop();m(this.nextButton,"disabled"),m(this.prevButton,"disabled"),this.index==0&&this.elements.length-1==0?(p(this.prevButton,"disabled"),p(this.nextButton,"disabled")):this.index!==0||o?this.index!==this.elements.length-1||o||p(this.nextButton,"disabled"):p(this.prevButton,"disabled")}},{key:"loop",value:function(){var o=D(this.settings,"loopAtEnd")?this.settings.loopAtEnd:null;return o=D(this.settings,"loop")?this.settings.loop:o,o}},{key:"close",value:function(){var o=this;if(!this.lightboxOpen){if(this.events){for(var d in this.events)this.events.hasOwnProperty(d)&&this.events[d].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&&h(this.bodyHiddenChildElms,(function(b){b.removeAttribute("aria-hidden")})),p(this.modal,"glightbox-closing"),L(this.overlay,this.settings.openEffect=="none"?"none":this.settings.cssEfects.fade.out),L(this.activeSlide,this.settings.cssEfects[this.settings.closeEffect].out,(function(){if(o.activeSlide=null,o.prevActiveSlideIndex=null,o.prevActiveSlide=null,o.built=!1,o.events){for(var b in o.events)o.events.hasOwnProperty(b)&&o.events[b].destroy();o.events=null}var k=document.body;m(Se,"glightbox-open"),m(k,"glightbox-open touching gdesc-open glightbox-touch glightbox-mobile gscrollbar-fixer"),o.modal.parentNode.removeChild(o.modal),o.trigger("close"),I(o.settings.onClose)&&o.settings.onClose();var T=document.querySelector(".gcss-styles");T&&T.parentNode.removeChild(T),o.lightboxOpen=!1,o.closing=null}))}},{key:"destroy",value:function(){this.close(),this.clearAllEvents(),this.baseEvents&&this.baseEvents.destroy()}},{key:"on",value:function(o,d){var b=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(!o||!I(d))throw new TypeError("Event name and callback must be defined");this.apiEvents.push({evt:o,once:b,callback:d})}},{key:"once",value:function(o,d){this.on(o,d,!0)}},{key:"trigger",value:function(o){var d=this,b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,k=[];h(this.apiEvents,(function(T,R){var M=T.evt,A=T.once,F=T.callback;M==o&&(F(b),A&&k.push(R))})),k.length&&h(k,(function(T){return d.apiEvents.splice(T,1)}))}},{key:"clearAllEvents",value:function(){this.apiEvents.splice(0,this.apiEvents.length)}},{key:"version",value:function(){return"3.3.1"}}]);return function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},d=new Le(o);return d.init(),d}}))})(Qe)),Qe.exports}var pi=hi();const Ot=ui(pi);/*!
|
|
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 Nt(s,i){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);i&&(r=r.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),a.push.apply(a,r)}return a}function Bt(s){for(var i=1;i<arguments.length;i++){var a=arguments[i]!=null?arguments[i]:{};i%2?Nt(Object(a),!0).forEach(function(r){he(s,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):Nt(Object(a)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(a,r))})}return s}function ct(s){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ct=function(i){return typeof i}:ct=function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},ct(s)}function ht(s,i){if(!(s instanceof i))throw new TypeError("Cannot call a class as a function")}function ce(s,i){for(var a=0;a<i.length;a++){var r=i[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(s,r.key,r)}}function dt(s,i,a){return i&&ce(s.prototype,i),s}function he(s,i,a){return i in s?Object.defineProperty(s,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[i]=a,s}function de(s,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(i&&i.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),i&&kt(s,i)}function nt(s){return nt=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},nt(s)}function kt(s,i){return kt=Object.setPrototypeOf||function(r,c){return r.__proto__=c,r},kt(s,i)}function fe(){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 ge(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function ve(s,i){if(i&&(typeof i=="object"||typeof i=="function"))return i;if(i!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ge(s)}function me(s){var i=fe();return function(){var r=nt(s),c;if(i){var l=nt(this).constructor;c=Reflect.construct(r,arguments,l)}else c=r.apply(this,arguments);return ve(this,c)}}function pe(s,i){for(;!Object.prototype.hasOwnProperty.call(s,i)&&(s=nt(s),s!==null););return s}function ft(){return typeof Reflect<"u"&&Reflect.get?ft=Reflect.get:ft=function(i,a,r){var c=pe(i,a);if(c){var l=Object.getOwnPropertyDescriptor(c,a);return l.get?l.get.call(arguments.length<3?i:r):l.value}},ft.apply(this,arguments)}var ye={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 U(s){console.error("[Glide warn]: ".concat(s))}function D(s){return parseInt(s)}function be(s){return parseFloat(s)}function At(s){return typeof s=="string"}function st(s){var i=ct(s);return i==="function"||i==="object"&&!!s}function gt(s){return typeof s=="function"}function qt(s){return typeof s>"u"}function Et(s){return s.constructor===Array}function we(s,i,a){var r={};for(var c in i)gt(i[c])?r[c]=i[c](s,r,a):U("Extension must be a function");for(var l in r)gt(r[l].mount)&&r[l].mount();return r}function M(s,i,a){Object.defineProperty(s,i,a)}function xe(s){return Object.keys(s).sort().reduce(function(i,a){return i[a]=s[a],i[a],i},{})}function Ot(s,i){var a=Object.assign({},s,i);if(i.hasOwnProperty("classes")){a.classes=Object.assign({},s.classes,i.classes);var r=["direction","type","slide","arrow","nav"];r.forEach(function(c){i.classes.hasOwnProperty(c)&&(a.classes[c]=Bt(Bt({},s.classes[c]),i.classes[c]))})}return i.hasOwnProperty("breakpoints")&&(a.breakpoints=Object.assign({},s.breakpoints,i.breakpoints)),a}var Se=(function(){function s(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(this,s),this.events=i,this.hop=i.hasOwnProperty}return dt(s,[{key:"on",value:function(a,r){if(Et(a)){for(var c=0;c<a.length;c++)this.on(a[c],r);return}this.hop.call(this.events,a)||(this.events[a]=[]);var l=this.events[a].push(r)-1;return{remove:function(){delete this.events[a][l]}}}},{key:"emit",value:function(a,r){if(Et(a)){for(var c=0;c<a.length;c++)this.emit(a[c],r);return}this.hop.call(this.events,a)&&this.events[a].forEach(function(l){l(r||{})})}}]),s})(),Te=(function(){function s(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ht(this,s),this._c={},this._t=[],this._e=new Se,this.disabled=!1,this.selector=i,this.settings=Ot(ye,a),this.index=this.settings.startAt}return dt(s,[{key:"mount",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this._e.emit("mount.before"),st(a)?this._c=we(this,a,this._e):U("You need to provide a object on `mount()`"),this._e.emit("mount.after"),this}},{key:"mutate",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return Et(a)?this._t=a:U("You need to provide a array on `mutate()`"),this}},{key:"update",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this.settings=Ot(this.settings,a),a.hasOwnProperty("startAt")&&(this.index=a.startAt),this._e.emit("update"),this}},{key:"go",value:function(a){return this._c.Run.make(a),this}},{key:"move",value:function(a){return this._c.Transition.disable(),this._c.Move.make(a),this}},{key:"destroy",value:function(){return this._e.emit("destroy"),this}},{key:"play",value:function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;return a&&(this.settings.autoplay=a),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(a,r){return this._e.on(a,r),this}},{key:"isType",value:function(a){return this.settings.type===a}},{key:"settings",get:function(){return this._o},set:function(a){st(a)?this._o=a:U("Options must be an `object` instance.")}},{key:"index",get:function(){return this._i},set:function(a){this._i=D(a)}},{key:"type",get:function(){return this.settings.type}},{key:"disabled",get:function(){return this._d},set:function(a){this._d=!!a}}]),s})();function ke(s,i,a){var r={mount:function(){this._o=!1},make:function(p){var y=this;s.disabled||(!s.settings.waitForTransition||s.disable(),this.move=p,a.emit("run.before",this.move),this.calculate(),a.emit("run",this.move),i.Transition.after(function(){y.isStart()&&a.emit("run.start",y.move),y.isEnd()&&a.emit("run.end",y.move),y.isOffset()&&(y._o=!1,a.emit("run.offset",y.move)),a.emit("run.after",y.move),s.enable()}))},calculate:function(){var p=this.move,y=this.length,S=p.steps,b=p.direction,A=1;if(b==="="){if(s.settings.bound&&D(S)>y){s.index=y;return}s.index=S;return}if(b===">"&&S===">"){s.index=y;return}if(b==="<"&&S==="<"){s.index=0;return}if(b==="|"&&(A=s.settings.perView||1),b===">"||b==="|"&&S===">"){var C=c(A);C>y&&(this._o=!0),s.index=l(C,A);return}if(b==="<"||b==="|"&&S==="<"){var L=h(A);L<0&&(this._o=!0),s.index=v(L,A);return}U("Invalid direction pattern [".concat(b).concat(S,"] has been used"))},isStart:function(){return s.index<=0},isEnd:function(){return s.index>=this.length},isOffset:function(){var p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return p?this._o?p==="|>"?this.move.direction==="|"&&this.move.steps===">":p==="|<"?this.move.direction==="|"&&this.move.steps==="<":this.move.direction===p:!1:this._o},isBound:function(){return s.isType("slider")&&s.settings.focusAt!=="center"&&s.settings.bound}};function c(m){var p=s.index;return s.isType("carousel")?p+m:p+(m-p%m)}function l(m,p){var y=r.length;return m<=y?m:s.isType("carousel")?m-(y+1):s.settings.rewind?r.isBound()&&!r.isEnd()?y:0:r.isBound()?y:Math.floor(y/p)*p}function h(m){var p=s.index;if(s.isType("carousel"))return p-m;var y=Math.ceil(p/m);return(y-1)*m}function v(m,p){var y=r.length;return m>=0?m:s.isType("carousel")?m+(y+1):s.settings.rewind?r.isBound()&&r.isStart()?y:Math.floor(y/p)*p:0}return M(r,"move",{get:function(){return this._m},set:function(p){var y=p.substr(1);this._m={direction:p.substr(0,1),steps:y?D(y)?D(y):y:0}}}),M(r,"length",{get:function(){var p=s.settings,y=i.Html.slides.length;return this.isBound()?y-1-(D(p.perView)-1)+D(p.focusAt):y-1}}),M(r,"offset",{get:function(){return this._o}}),r}function Xt(){return new Date().getTime()}function vt(s,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,c,l,h,v=0,m=function(){v=a.leading===!1?0:Xt(),r=null,h=s.apply(c,l),r||(c=l=null)},p=function(){var S=Xt();!v&&a.leading===!1&&(v=S);var b=i-(S-v);return c=this,l=arguments,b<=0||b>i?(r&&(clearTimeout(r),r=null),v=S,h=s.apply(c,l),r||(c=l=null)):!r&&a.trailing!==!1&&(r=setTimeout(m,b)),h};return p.cancel=function(){clearTimeout(r),v=0,r=c=l=null},p}var mt={ltr:["marginLeft","marginRight"],rtl:["marginRight","marginLeft"]};function Ae(s,i,a){var r={apply:function(l){for(var h=0,v=l.length;h<v;h++){var m=l[h].style,p=i.Direction.value;h!==0?m[mt[p][0]]="".concat(this.value/2,"px"):m[mt[p][0]]="",h!==l.length-1?m[mt[p][1]]="".concat(this.value/2,"px"):m[mt[p][1]]=""}},remove:function(l){for(var h=0,v=l.length;h<v;h++){var m=l[h].style;m.marginLeft="",m.marginRight=""}}};return M(r,"value",{get:function(){return D(s.settings.gap)}}),M(r,"grow",{get:function(){return r.value*i.Sizes.length}}),M(r,"reductor",{get:function(){var l=s.settings.perView;return r.value*(l-1)/l}}),a.on(["build.after","update"],vt(function(){r.apply(i.Html.wrapper.children)},30)),a.on("destroy",function(){r.remove(i.Html.wrapper.children)}),r}function Rt(s){if(s&&s.parentNode){for(var i=s.parentNode.firstChild,a=[];i;i=i.nextSibling)i.nodeType===1&&i!==s&&a.push(i);return a}return[]}function _t(s){return Array.prototype.slice.call(s)}var Ee='[data-glide-el="track"]';function Oe(s,i,a){var r={mount:function(){this.root=s.selector,this.track=this.root.querySelector(Ee),this.collectSlides()},collectSlides:function(){this.slides=_t(this.wrapper.children).filter(function(l){return!l.classList.contains(s.settings.classes.slide.clone)})}};return M(r,"root",{get:function(){return r._r},set:function(l){At(l)&&(l=document.querySelector(l)),l!==null?r._r=l:U("Root element must be a existing Html node")}}),M(r,"track",{get:function(){return r._t},set:function(l){r._t=l}}),M(r,"wrapper",{get:function(){return r.track.children[0]}}),a.on("update",function(){r.collectSlides()}),r}function _e(s,i,a){var r={mount:function(){this.value=s.settings.peek}};return M(r,"value",{get:function(){return r._v},set:function(l){st(l)?(l.before=D(l.before),l.after=D(l.after)):l=D(l),r._v=l}}),M(r,"reductor",{get:function(){var l=r.value,h=s.settings.perView;return st(l)?l.before/h+l.after/h:l*2/h}}),a.on(["resize","update"],function(){r.mount()}),r}function Ce(s,i,a){var r={mount:function(){this._o=0},make:function(){var l=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this.offset=h,a.emit("move",{movement:this.value}),i.Transition.after(function(){a.emit("move.after",{movement:l.value})})}};return M(r,"offset",{get:function(){return r._o},set:function(l){r._o=qt(l)?0:D(l)}}),M(r,"translate",{get:function(){return i.Sizes.slideWidth*s.index}}),M(r,"value",{get:function(){var l=this.offset,h=this.translate;return i.Direction.is("rtl")?h+l:h-l}}),a.on(["build.before","run"],function(){r.make()}),r}function Le(s,i,a){var r={setupSlides:function(){for(var l="".concat(this.slideWidth,"px"),h=i.Html.slides,v=0;v<h.length;v++)h[v].style.width=l},setupWrapper:function(){i.Html.wrapper.style.width="".concat(this.wrapperSize,"px")},remove:function(){for(var l=i.Html.slides,h=0;h<l.length;h++)l[h].style.width="";i.Html.wrapper.style.width=""}};return M(r,"length",{get:function(){return i.Html.slides.length}}),M(r,"width",{get:function(){return i.Html.track.offsetWidth}}),M(r,"wrapperSize",{get:function(){return r.slideWidth*r.length+i.Gaps.grow+i.Clones.grow}}),M(r,"slideWidth",{get:function(){return r.width/s.settings.perView-i.Peek.reductor-i.Gaps.reductor}}),a.on(["build.before","resize","update"],function(){r.setupSlides(),r.setupWrapper()}),a.on("destroy",function(){r.remove()}),r}function Pe(s,i,a){var r={mount:function(){a.emit("build.before"),this.typeClass(),this.activeClass(),a.emit("build.after")},typeClass:function(){i.Html.root.classList.add(s.settings.classes.type[s.settings.type])},activeClass:function(){var l=s.settings.classes,h=i.Html.slides[s.index];h&&(h.classList.add(l.slide.active),Rt(h).forEach(function(v){v.classList.remove(l.slide.active)}))},removeClasses:function(){var l=s.settings.classes,h=l.type,v=l.slide;i.Html.root.classList.remove(h[s.settings.type]),i.Html.slides.forEach(function(m){m.classList.remove(v.active)})}};return a.on(["destroy","update"],function(){r.removeClasses()}),a.on(["resize","update"],function(){r.mount()}),a.on("move.after",function(){r.activeClass()}),r}function Ie(s,i,a){var r={mount:function(){this.items=[],s.isType("carousel")&&(this.items=this.collect())},collect:function(){var l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],h=i.Html.slides,v=s.settings,m=v.perView,p=v.classes,y=v.cloningRatio;if(h.length>0)for(var S=+!!s.settings.peek,b=m+S+Math.round(m/2),A=h.slice(0,b).reverse(),C=h.slice(b*-1),L=0;L<Math.max(y,Math.floor(m/h.length));L++){for(var B=0;B<A.length;B++){var R=A[B].cloneNode(!0);R.classList.add(p.slide.clone),l.push(R)}for(var V=0;V<C.length;V++){var F=C[V].cloneNode(!0);F.classList.add(p.slide.clone),l.unshift(F)}}return l},append:function(){for(var l=this.items,h=i.Html,v=h.wrapper,m=h.slides,p=Math.floor(l.length/2),y=l.slice(0,p).reverse(),S=l.slice(p*-1).reverse(),b="".concat(i.Sizes.slideWidth,"px"),A=0;A<S.length;A++)v.appendChild(S[A]);for(var C=0;C<y.length;C++)v.insertBefore(y[C],m[0]);for(var L=0;L<l.length;L++)l[L].style.width=b},remove:function(){for(var l=this.items,h=0;h<l.length;h++)i.Html.wrapper.removeChild(l[h])}};return M(r,"grow",{get:function(){return(i.Sizes.slideWidth+i.Gaps.value)*r.items.length}}),a.on("update",function(){r.remove(),r.mount(),r.append()}),a.on("build.before",function(){s.isType("carousel")&&r.append()}),a.on("destroy",function(){r.remove()}),r}var et=(function(){function s(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(this,s),this.listeners=i}return dt(s,[{key:"on",value:function(a,r,c){var l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;At(a)&&(a=[a]);for(var h=0;h<a.length;h++)this.listeners[a[h]]=c,r.addEventListener(a[h],this.listeners[a[h]],l)}},{key:"off",value:function(a,r){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;At(a)&&(a=[a]);for(var l=0;l<a.length;l++)r.removeEventListener(a[l],this.listeners[a[l]],c)}},{key:"destroy",value:function(){delete this.listeners}}]),s})();function Me(s,i,a){var r=new et,c={mount:function(){this.bind()},bind:function(){r.on("resize",window,vt(function(){a.emit("resize")},s.settings.throttle))},unbind:function(){r.off("resize",window)}};return a.on("destroy",function(){c.unbind(),r.destroy()}),c}var ze=["ltr","rtl"],He={">":"<","<":">","=":"="};function De(s,i,a){var r={mount:function(){this.value=s.settings.direction},resolve:function(l){var h=l.slice(0,1);return this.is("rtl")?l.split(h).join(He[h]):l},is:function(l){return this.value===l},addClass:function(){i.Html.root.classList.add(s.settings.classes.direction[this.value])},removeClass:function(){i.Html.root.classList.remove(s.settings.classes.direction[this.value])}};return M(r,"value",{get:function(){return r._v},set:function(l){ze.indexOf(l)>-1?r._v=l:U("Direction value must be `ltr` or `rtl`")}}),a.on(["destroy","update"],function(){r.removeClass()}),a.on("update",function(){r.mount()}),a.on(["build.before","update"],function(){r.addClass()}),r}function Ne(s,i){return{modify:function(r){return i.Direction.is("rtl")?-r:r}}}function Be(s,i){return{modify:function(r){var c=Math.floor(r/i.Sizes.slideWidth);return r+i.Gaps.value*c}}}function qe(s,i){return{modify:function(r){return r+i.Clones.grow/2}}}function Xe(s,i){return{modify:function(r){if(s.settings.focusAt>=0){var c=i.Peek.value;return st(c)?r-c.before:r-c}return r}}}function Re(s,i){return{modify:function(r){var c=i.Gaps.value,l=i.Sizes.width,h=s.settings.focusAt,v=i.Sizes.slideWidth;return h==="center"?r-(l/2-v/2):r-v*h-c*h}}}function Ye(s,i,a){var r=[Be,qe,Xe,Re].concat(s._t,[Ne]);return{mutate:function(l){for(var h=0;h<r.length;h++){var v=r[h];gt(v)&>(v().modify)?l=v(s,i,a).modify(l):U("Transformer should be a function that returns an object with `modify()` method")}return l}}}function We(s,i,a){var r={set:function(l){var h=Ye(s,i).mutate(l),v="translate3d(".concat(-1*h,"px, 0px, 0px)");i.Html.wrapper.style.mozTransform=v,i.Html.wrapper.style.webkitTransform=v,i.Html.wrapper.style.transform=v},remove:function(){i.Html.wrapper.style.transform=""},getStartIndex:function(){var l=i.Sizes.length,h=s.index,v=s.settings.perView;return i.Run.isOffset(">")||i.Run.isOffset("|>")?l+(h-v):(h+v)%l},getTravelDistance:function(){var l=i.Sizes.slideWidth*s.settings.perView;return i.Run.isOffset(">")||i.Run.isOffset("|>")?l*-1:l}};return a.on("move",function(c){if(!s.isType("carousel")||!i.Run.isOffset())return r.set(c.movement);i.Transition.after(function(){a.emit("translate.jump"),r.set(i.Sizes.slideWidth*s.index)});var l=i.Sizes.slideWidth*i.Translate.getStartIndex();return r.set(l-i.Translate.getTravelDistance())}),a.on("destroy",function(){r.remove()}),r}function je(s,i,a){var r=!1,c={compose:function(h){var v=s.settings;return r?"".concat(h," 0ms ").concat(v.animationTimingFunc):"".concat(h," ").concat(this.duration,"ms ").concat(v.animationTimingFunc)},set:function(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";i.Html.wrapper.style.transition=this.compose(h)},remove:function(){i.Html.wrapper.style.transition=""},after:function(h){setTimeout(function(){h()},this.duration)},enable:function(){r=!1,this.set()},disable:function(){r=!0,this.set()}};return M(c,"duration",{get:function(){var h=s.settings;return s.isType("slider")&&i.Run.offset?h.rewindDuration:h.animationDuration}}),a.on("move",function(){c.set()}),a.on(["build.before","resize","translate.jump"],function(){c.disable()}),a.on("run",function(){c.enable()}),a.on("destroy",function(){c.remove()}),c}var Yt=!1;try{var Wt=Object.defineProperty({},"passive",{get:function(){Yt=!0}});window.addEventListener("testPassive",null,Wt),window.removeEventListener("testPassive",null,Wt)}catch{}var Ct=Yt,pt=["touchstart","mousedown"],jt=["touchmove","mousemove"],Vt=["touchend","touchcancel","mouseup","mouseleave"],Ft=["mousedown","mousemove","mouseup","mouseleave"];function Ve(s,i,a){var r=new et,c=0,l=0,h=0,v=!1,m=Ct?{passive:!0}:!1,p={mount:function(){this.bindSwipeStart()},start:function(S){if(!v&&!s.disabled){this.disable();var b=this.touches(S);c=null,l=D(b.pageX),h=D(b.pageY),this.bindSwipeMove(),this.bindSwipeEnd(),a.emit("swipe.start")}},move:function(S){if(!s.disabled){var b=s.settings,A=b.touchAngle,C=b.touchRatio,L=b.classes,B=this.touches(S),R=D(B.pageX)-l,V=D(B.pageY)-h,F=Math.abs(R<<2),Z=Math.abs(V<<2),yt=Math.sqrt(F+Z),Pt=Math.sqrt(Z);if(c=Math.asin(Pt/yt),c*180/Math.PI<A)S.stopPropagation(),i.Move.make(R*be(C)),i.Html.root.classList.add(L.dragging),a.emit("swipe.move");else return!1}},end:function(S){if(!s.disabled){var b=s.settings,A=b.perSwipe,C=b.touchAngle,L=b.classes,B=this.touches(S),R=this.threshold(S),V=B.pageX-l,F=c*180/Math.PI;this.enable(),V>R&&F<C?i.Run.make(i.Direction.resolve("".concat(A,"<"))):V<-R&&F<C?i.Run.make(i.Direction.resolve("".concat(A,">"))):i.Move.make(),i.Html.root.classList.remove(L.dragging),this.unbindSwipeMove(),this.unbindSwipeEnd(),a.emit("swipe.end")}},bindSwipeStart:function(){var S=this,b=s.settings,A=b.swipeThreshold,C=b.dragThreshold;A&&r.on(pt[0],i.Html.wrapper,function(L){S.start(L)},m),C&&r.on(pt[1],i.Html.wrapper,function(L){S.start(L)},m)},unbindSwipeStart:function(){r.off(pt[0],i.Html.wrapper,m),r.off(pt[1],i.Html.wrapper,m)},bindSwipeMove:function(){var S=this;r.on(jt,i.Html.wrapper,vt(function(b){S.move(b)},s.settings.throttle),m)},unbindSwipeMove:function(){r.off(jt,i.Html.wrapper,m)},bindSwipeEnd:function(){var S=this;r.on(Vt,i.Html.wrapper,function(b){S.end(b)})},unbindSwipeEnd:function(){r.off(Vt,i.Html.wrapper)},touches:function(S){return Ft.indexOf(S.type)>-1?S:S.touches[0]||S.changedTouches[0]},threshold:function(S){var b=s.settings;return Ft.indexOf(S.type)>-1?b.dragThreshold:b.swipeThreshold},enable:function(){return v=!1,i.Transition.enable(),this},disable:function(){return v=!0,i.Transition.disable(),this}};return a.on("build.after",function(){i.Html.root.classList.add(s.settings.classes.swipeable)}),a.on("destroy",function(){p.unbindSwipeStart(),p.unbindSwipeMove(),p.unbindSwipeEnd(),r.destroy()}),p}function Fe(s,i,a){var r=new et,c={mount:function(){this.bind()},bind:function(){r.on("dragstart",i.Html.wrapper,this.dragstart)},unbind:function(){r.off("dragstart",i.Html.wrapper)},dragstart:function(h){h.preventDefault()}};return a.on("destroy",function(){c.unbind(),r.destroy()}),c}function Ze(s,i,a){var r=new et,c=!1,l=!1,h={mount:function(){this._a=i.Html.wrapper.querySelectorAll("a"),this.bind()},bind:function(){r.on("click",i.Html.wrapper,this.click)},unbind:function(){r.off("click",i.Html.wrapper)},click:function(m){l&&(m.stopPropagation(),m.preventDefault())},detach:function(){if(l=!0,!c){for(var m=0;m<this.items.length;m++)this.items[m].draggable=!1;c=!0}return this},attach:function(){if(l=!1,c){for(var m=0;m<this.items.length;m++)this.items[m].draggable=!0;c=!1}return this}};return M(h,"items",{get:function(){return h._a}}),a.on("swipe.move",function(){h.detach()}),a.on("swipe.end",function(){i.Transition.after(function(){h.attach()})}),a.on("destroy",function(){h.attach(),h.unbind(),r.destroy()}),h}var $e='[data-glide-el="controls[nav]"]',Lt='[data-glide-el^="controls"]',Ke="".concat(Lt,' [data-glide-dir*="<"]'),Ue="".concat(Lt,' [data-glide-dir*=">"]');function Je(s,i,a){var r=new et,c=Ct?{passive:!0}:!1,l={mount:function(){this._n=i.Html.root.querySelectorAll($e),this._c=i.Html.root.querySelectorAll(Lt),this._arrowControls={previous:i.Html.root.querySelectorAll(Ke),next:i.Html.root.querySelectorAll(Ue)},this.addBindings()},setActive:function(){for(var v=0;v<this._n.length;v++)this.addClass(this._n[v].children)},removeActive:function(){for(var v=0;v<this._n.length;v++)this.removeClass(this._n[v].children)},addClass:function(v){var m=s.settings,p=v[s.index];p&&(p.classList.add(m.classes.nav.active),Rt(p).forEach(function(y){y.classList.remove(m.classes.nav.active)}))},removeClass:function(v){var m=v[s.index];m?.classList.remove(s.settings.classes.nav.active)},setArrowState:function(){if(!s.settings.rewind){var v=l._arrowControls.next,m=l._arrowControls.previous;this.resetArrowState(v,m),s.index===0&&this.disableArrow(m),s.index===i.Run.length&&this.disableArrow(v)}},resetArrowState:function(){for(var v=s.settings,m=arguments.length,p=new Array(m),y=0;y<m;y++)p[y]=arguments[y];p.forEach(function(S){_t(S).forEach(function(b){b.classList.remove(v.classes.arrow.disabled)})})},disableArrow:function(){for(var v=s.settings,m=arguments.length,p=new Array(m),y=0;y<m;y++)p[y]=arguments[y];p.forEach(function(S){_t(S).forEach(function(b){b.classList.add(v.classes.arrow.disabled)})})},addBindings:function(){for(var v=0;v<this._c.length;v++)this.bind(this._c[v].children)},removeBindings:function(){for(var v=0;v<this._c.length;v++)this.unbind(this._c[v].children)},bind:function(v){for(var m=0;m<v.length;m++)r.on("click",v[m],this.click),r.on("touchstart",v[m],this.click,c)},unbind:function(v){for(var m=0;m<v.length;m++)r.off(["click","touchstart"],v[m])},click:function(v){!Ct&&v.type==="touchstart"&&v.preventDefault();var m=v.currentTarget.getAttribute("data-glide-dir");i.Run.make(i.Direction.resolve(m))}};return M(l,"items",{get:function(){return l._c}}),a.on(["mount.after","move.after"],function(){l.setActive()}),a.on(["mount.after","run"],function(){l.setArrowState()}),a.on("destroy",function(){l.removeBindings(),l.removeActive(),r.destroy()}),l}function Qe(s,i,a){var r=new et,c={mount:function(){s.settings.keyboard&&this.bind()},bind:function(){r.on("keyup",document,this.press)},unbind:function(){r.off("keyup",document)},press:function(h){var v=s.settings.perSwipe,m={ArrowRight:">",ArrowLeft:"<"};["ArrowRight","ArrowLeft"].includes(h.code)&&i.Run.make(i.Direction.resolve("".concat(v).concat(m[h.code])))}};return a.on(["destroy","update"],function(){c.unbind()}),a.on("update",function(){c.mount()}),a.on("destroy",function(){r.destroy()}),c}function Ge(s,i,a){var r=new et,c={mount:function(){this.enable(),this.start(),s.settings.hoverpause&&this.bind()},enable:function(){this._e=!0},disable:function(){this._e=!1},start:function(){var h=this;this._e&&(this.enable(),s.settings.autoplay&&qt(this._i)&&(this._i=setInterval(function(){h.stop(),i.Run.make(">"),h.start(),a.emit("autoplay")},this.time)))},stop:function(){this._i=clearInterval(this._i)},bind:function(){var h=this;r.on("mouseover",i.Html.root,function(){h._e&&h.stop()}),r.on("mouseout",i.Html.root,function(){h._e&&h.start()})},unbind:function(){r.off(["mouseover","mouseout"],i.Html.root)}};return M(c,"time",{get:function(){var h=i.Html.slides[s.index].getAttribute("data-glide-autoplay");return D(h||s.settings.autoplay)}}),a.on(["destroy","update"],function(){c.unbind()}),a.on(["run.before","swipe.start","update"],function(){c.stop()}),a.on(["pause","destroy"],function(){c.disable(),c.stop()}),a.on(["run.after","swipe.end"],function(){c.start()}),a.on(["play"],function(){c.enable(),c.start()}),a.on("update",function(){c.mount()}),a.on("destroy",function(){r.destroy()}),c}function Zt(s){return st(s)?xe(s):(U("Breakpoints option must be an object"),{})}function ti(s,i,a){var r=new et,c=s.settings,l=Zt(c.breakpoints),h=Object.assign({},c),v={match:function(p){if(typeof window.matchMedia<"u"){for(var y in p)if(p.hasOwnProperty(y)&&window.matchMedia("(max-width: ".concat(y,"px)")).matches)return p[y]}return h}};return Object.assign(c,v.match(l)),r.on("resize",window,vt(function(){s.settings=Ot(c,v.match(l))},s.settings.throttle)),a.on("update",function(){l=Zt(l),h=Object.assign({},c)}),a.on("destroy",function(){r.off("resize",window)}),v}var ei={Html:Oe,Translate:We,Transition:je,Direction:De,Peek:_e,Sizes:Le,Gaps:Ae,Move:Ce,Clones:Ie,Resize:Me,Build:Pe,Run:ke,Swipe:Ve,Images:Fe,Anchors:Ze,Controls:Je,Keyboard:Qe,Autoplay:Ge,Breakpoints:ti},ii=(function(s){de(a,s);var i=me(a);function a(){return ht(this,a),i.apply(this,arguments)}return dt(a,[{key:"mount",value:function(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ft(nt(a.prototype),"mount",this).call(this,Object.assign({},ei,c))}}]),a})(Te);class ni{constructor(i={}){const a={skin:"light"};this.settings=Object.assign(this,a,i),window.Glide=ii}init(){const i={touchNavigation:!0,selector:".glightbox",loop:!0,autoplayVideos:!0,zoomable:!0,slideEffect:"slide",descPosition:"bottom",skin:this.settings.skin};this.refreshLightbox(i),document.querySelectorAll(".is-lightbox,.block-click").forEach(r=>{const c=l=>{let h=r.getAttribute("href")||r.getAttribute("data-modal-url");this.openLightbox(h,r,i),l.preventDefault(),l.stopImmediatePropagation()};r.addEventListener("click",c),r._lightboxHandler=c})}refreshLightbox(i){this.glightbox&&this.glightbox.destroy(),this.glightbox=Dt(i),window.GLightbox=Dt}openLightbox(i,a,r){let c=[],l=0;if(a){const h=a.closest("[data-gallery]");let v=[];h?v=h.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(p=>{p.closest("[data-gallery]")||v.push(p)}),v.forEach((m,p)=>{let y=m.getAttribute("href");y||(y=m.getAttribute("data-modal-url")),c.push({href:y}),i===y&&(l=p)})}c.length>0?(this.glightbox.setElements(c),this.glightbox.openAt(l)):(this.glightbox.setElements([{href:i}]),this.glightbox.open()),this.glightbox.on("close",()=>{this.refreshLightbox(r)})}destroy(){this.glightbox&&(this.glightbox.destroy(),this.glightbox=null),document.querySelectorAll(".is-lightbox,.block-click").forEach(a=>{a._lightboxHandler&&(a.removeEventListener("click",a._lightboxHandler),delete a._lightboxHandler)})}}return ni})();
|
|
27
|
+
*/function Nt(f,e){var t=Object.keys(f);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(f);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(f,n).enumerable})),t.push.apply(t,i)}return t}function Pt(f){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Nt(Object(t),!0).forEach(function(i){mi(f,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(t)):Nt(Object(t)).forEach(function(i){Object.defineProperty(f,i,Object.getOwnPropertyDescriptor(t,i))})}return f}function Ke(f){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ke=function(e){return typeof e}:Ke=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ke(f)}function et(f,e){if(!(f instanceof e))throw new TypeError("Cannot call a class as a function")}function fi(f,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(f,i.key,i)}}function tt(f,e,t){return e&&fi(f.prototype,e),f}function mi(f,e,t){return e in f?Object.defineProperty(f,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):f[e]=t,f}function gi(f,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");f.prototype=Object.create(e&&e.prototype,{constructor:{value:f,writable:!0,configurable:!0}}),e&>(f,e)}function Fe(f){return Fe=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Fe(f)}function gt(f,e){return gt=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},gt(f,e)}function vi(){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 bi(f){if(f===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f}function yi(f,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 bi(f)}function wi(f){var e=vi();return function(){var i=Fe(f),n;if(e){var s=Fe(this).constructor;n=Reflect.construct(i,arguments,s)}else n=i.apply(this,arguments);return yi(this,n)}}function ki(f,e){for(;!Object.prototype.hasOwnProperty.call(f,e)&&(f=Fe(f),f!==null););return f}function it(){return typeof Reflect<"u"&&Reflect.get?it=Reflect.get:it=function(e,t,i){var n=ki(e,t);if(n){var s=Object.getOwnPropertyDescriptor(n,t);return s.get?s.get.call(arguments.length<3?e:i):s.value}},it.apply(this,arguments)}var xi={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 qe(f){console.error("[Glide warn]: ".concat(f))}function de(f){return parseInt(f)}function _i(f){return parseFloat(f)}function vt(f){return typeof f=="string"}function Ge(f){var e=Ke(f);return e==="function"||e==="object"&&!!f}function st(f){return typeof f=="function"}function $t(f){return typeof f>"u"}function bt(f){return f.constructor===Array}function Si(f,e,t){var i={};for(var n in e)st(e[n])?i[n]=e[n](f,i,t):qe("Extension must be a function");for(var s in i)st(i[s].mount)&&i[s].mount();return i}function ae(f,e,t){Object.defineProperty(f,e,t)}function Ti(f){return Object.keys(f).sort().reduce(function(e,t){return e[t]=f[t],e[t],e},{})}function yt(f,e){var t=Object.assign({},f,e);if(e.hasOwnProperty("classes")){t.classes=Object.assign({},f.classes,e.classes);var i=["direction","type","slide","arrow","nav"];i.forEach(function(n){e.classes.hasOwnProperty(n)&&(t.classes[n]=Pt(Pt({},f.classes[n]),e.classes[n]))})}return e.hasOwnProperty("breakpoints")&&(t.breakpoints=Object.assign({},f.breakpoints,e.breakpoints)),t}var Ei=(function(){function f(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};et(this,f),this.events=e,this.hop=e.hasOwnProperty}return tt(f,[{key:"on",value:function(t,i){if(bt(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(bt(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||{})})}}]),f})(),Ci=(function(){function f(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};et(this,f),this._c={},this._t=[],this._e=new Ei,this.disabled=!1,this.selector=e,this.settings=yt(xi,t),this.index=this.settings.startAt}return tt(f,[{key:"mount",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return this._e.emit("mount.before"),Ge(t)?this._c=Si(this,t,this._e):qe("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 bt(t)?this._t=t:qe("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=yt(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){Ge(t)?this._o=t:qe("Options must be an `object` instance.")}},{key:"index",get:function(){return this._i},set:function(t){this._i=de(t)}},{key:"type",get:function(){return this.settings.type}},{key:"disabled",get:function(){return this._d},set:function(t){this._d=!!t}}]),f})();function Li(f,e,t){var i={mount:function(){this._o=!1},make:function(h){var u=this;f.disabled||(!f.settings.waitForTransition||f.disable(),this.move=h,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),f.enable()}))},calculate:function(){var h=this.move,u=this.length,a=h.steps,p=h.direction,m=1;if(p==="="){if(f.settings.bound&&de(a)>u){f.index=u;return}f.index=a;return}if(p===">"&&a===">"){f.index=u;return}if(p==="<"&&a==="<"){f.index=0;return}if(p==="|"&&(m=f.settings.perView||1),p===">"||p==="|"&&a===">"){var w=n(m);w>u&&(this._o=!0),f.index=s(w,m);return}if(p==="<"||p==="|"&&a==="<"){var S=r(m);S<0&&(this._o=!0),f.index=l(S,m);return}qe("Invalid direction pattern [".concat(p).concat(a,"] has been used"))},isStart:function(){return f.index<=0},isEnd:function(){return f.index>=this.length},isOffset:function(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return h?this._o?h==="|>"?this.move.direction==="|"&&this.move.steps===">":h==="|<"?this.move.direction==="|"&&this.move.steps==="<":this.move.direction===h:!1:this._o},isBound:function(){return f.isType("slider")&&f.settings.focusAt!=="center"&&f.settings.bound}};function n(c){var h=f.index;return f.isType("carousel")?h+c:h+(c-h%c)}function s(c,h){var u=i.length;return c<=u?c:f.isType("carousel")?c-(u+1):f.settings.rewind?i.isBound()&&!i.isEnd()?u:0:i.isBound()?u:Math.floor(u/h)*h}function r(c){var h=f.index;if(f.isType("carousel"))return h-c;var u=Math.ceil(h/c);return(u-1)*c}function l(c,h){var u=i.length;return c>=0?c:f.isType("carousel")?c+(u+1):f.settings.rewind?i.isBound()&&i.isStart()?u:Math.floor(u/h)*h:0}return ae(i,"move",{get:function(){return this._m},set:function(h){var u=h.substr(1);this._m={direction:h.substr(0,1),steps:u?de(u)?de(u):u:0}}}),ae(i,"length",{get:function(){var h=f.settings,u=e.Html.slides.length;return this.isBound()?u-1-(de(h.perView)-1)+de(h.focusAt):u-1}}),ae(i,"offset",{get:function(){return this._o}}),i}function Dt(){return new Date().getTime()}function nt(f,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i,n,s,r,l=0,c=function(){l=t.leading===!1?0:Dt(),i=null,r=f.apply(n,s),i||(n=s=null)},h=function(){var a=Dt();!l&&t.leading===!1&&(l=a);var p=e-(a-l);return n=this,s=arguments,p<=0||p>e?(i&&(clearTimeout(i),i=null),l=a,r=f.apply(n,s),i||(n=s=null)):!i&&t.trailing!==!1&&(i=setTimeout(c,p)),r};return h.cancel=function(){clearTimeout(i),l=0,i=n=s=null},h}var rt={ltr:["marginLeft","marginRight"],rtl:["marginRight","marginLeft"]};function Ri(f,e,t){var i={apply:function(s){for(var r=0,l=s.length;r<l;r++){var c=s[r].style,h=e.Direction.value;r!==0?c[rt[h][0]]="".concat(this.value/2,"px"):c[rt[h][0]]="",r!==s.length-1?c[rt[h][1]]="".concat(this.value/2,"px"):c[rt[h][1]]=""}},remove:function(s){for(var r=0,l=s.length;r<l;r++){var c=s[r].style;c.marginLeft="",c.marginRight=""}}};return ae(i,"value",{get:function(){return de(f.settings.gap)}}),ae(i,"grow",{get:function(){return i.value*e.Sizes.length}}),ae(i,"reductor",{get:function(){var s=f.settings.perView;return i.value*(s-1)/s}}),t.on(["build.after","update"],nt(function(){i.apply(e.Html.wrapper.children)},30)),t.on("destroy",function(){i.remove(e.Html.wrapper.children)}),i}function Ht(f){if(f&&f.parentNode){for(var e=f.parentNode.firstChild,t=[];e;e=e.nextSibling)e.nodeType===1&&e!==f&&t.push(e);return t}return[]}function wt(f){return Array.prototype.slice.call(f)}var Mi='[data-glide-el="track"]';function qi(f,e,t){var i={mount:function(){this.root=f.selector,this.track=this.root.querySelector(Mi),this.collectSlides()},collectSlides:function(){this.slides=wt(this.wrapper.children).filter(function(s){return!s.classList.contains(f.settings.classes.slide.clone)})}};return ae(i,"root",{get:function(){return i._r},set:function(s){vt(s)&&(s=document.querySelector(s)),s!==null?i._r=s:qe("Root element must be a existing Html node")}}),ae(i,"track",{get:function(){return i._t},set:function(s){i._t=s}}),ae(i,"wrapper",{get:function(){return i.track.children[0]}}),t.on("update",function(){i.collectSlides()}),i}function Ai(f,e,t){var i={mount:function(){this.value=f.settings.peek}};return ae(i,"value",{get:function(){return i._v},set:function(s){Ge(s)?(s.before=de(s.before),s.after=de(s.after)):s=de(s),i._v=s}}),ae(i,"reductor",{get:function(){var s=i.value,r=f.settings.perView;return Ge(s)?s.before/r+s.after/r:s*2/r}}),t.on(["resize","update"],function(){i.mount()}),i}function Ii(f,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 ae(i,"offset",{get:function(){return i._o},set:function(s){i._o=$t(s)?0:de(s)}}),ae(i,"translate",{get:function(){return e.Sizes.slideWidth*f.index}}),ae(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 Oi(f,e,t){var i={setupSlides:function(){for(var s="".concat(this.slideWidth,"px"),r=e.Html.slides,l=0;l<r.length;l++)r[l].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 ae(i,"length",{get:function(){return e.Html.slides.length}}),ae(i,"width",{get:function(){return e.Html.track.offsetWidth}}),ae(i,"wrapperSize",{get:function(){return i.slideWidth*i.length+e.Gaps.grow+e.Clones.grow}}),ae(i,"slideWidth",{get:function(){return i.width/f.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 Ni(f,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(f.settings.classes.type[f.settings.type])},activeClass:function(){var s=f.settings.classes,r=e.Html.slides[f.index];r&&(r.classList.add(s.slide.active),Ht(r).forEach(function(l){l.classList.remove(s.slide.active)}))},removeClasses:function(){var s=f.settings.classes,r=s.type,l=s.slide;e.Html.root.classList.remove(r[f.settings.type]),e.Html.slides.forEach(function(c){c.classList.remove(l.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 Pi(f,e,t){var i={mount:function(){this.items=[],f.isType("carousel")&&(this.items=this.collect())},collect:function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=e.Html.slides,l=f.settings,c=l.perView,h=l.classes,u=l.cloningRatio;if(r.length>0)for(var a=+!!f.settings.peek,p=c+a+Math.round(c/2),m=r.slice(0,p).reverse(),w=r.slice(p*-1),S=0;S<Math.max(u,Math.floor(c/r.length));S++){for(var L=0;L<m.length;L++){var y=m[L].cloneNode(!0);y.classList.add(h.slide.clone),s.push(y)}for(var x=0;x<w.length;x++){var g=w[x].cloneNode(!0);g.classList.add(h.slide.clone),s.unshift(g)}}return s},append:function(){for(var s=this.items,r=e.Html,l=r.wrapper,c=r.slides,h=Math.floor(s.length/2),u=s.slice(0,h).reverse(),a=s.slice(h*-1).reverse(),p="".concat(e.Sizes.slideWidth,"px"),m=0;m<a.length;m++)l.appendChild(a[m]);for(var w=0;w<u.length;w++)l.insertBefore(u[w],c[0]);for(var S=0;S<s.length;S++)s[S].style.width=p},remove:function(){for(var s=this.items,r=0;r<s.length;r++)e.Html.wrapper.removeChild(s[r])}};return ae(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(){f.isType("carousel")&&i.append()}),t.on("destroy",function(){i.remove()}),i}var Pe=(function(){function f(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};et(this,f),this.listeners=e}return tt(f,[{key:"on",value:function(t,i,n){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;vt(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;vt(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}}]),f})();function $i(f,e,t){var i=new Pe,n={mount:function(){this.bind()},bind:function(){i.on("resize",window,nt(function(){t.emit("resize")},f.settings.throttle))},unbind:function(){i.off("resize",window)}};return t.on("destroy",function(){n.unbind(),i.destroy()}),n}var Di=["ltr","rtl"],Hi={">":"<","<":">","=":"="};function zi(f,e,t){var i={mount:function(){this.value=f.settings.direction},resolve:function(s){var r=s.slice(0,1);return this.is("rtl")?s.split(r).join(Hi[r]):s},is:function(s){return this.value===s},addClass:function(){e.Html.root.classList.add(f.settings.classes.direction[this.value])},removeClass:function(){e.Html.root.classList.remove(f.settings.classes.direction[this.value])}};return ae(i,"value",{get:function(){return i._v},set:function(s){Di.indexOf(s)>-1?i._v=s:qe("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 Ui(f,e){return{modify:function(i){return e.Direction.is("rtl")?-i:i}}}function ji(f,e){return{modify:function(i){var n=Math.floor(i/e.Sizes.slideWidth);return i+e.Gaps.value*n}}}function Bi(f,e){return{modify:function(i){return i+e.Clones.grow/2}}}function Fi(f,e){return{modify:function(i){if(f.settings.focusAt>=0){var n=e.Peek.value;return Ge(n)?i-n.before:i-n}return i}}}function Gi(f,e){return{modify:function(i){var n=e.Gaps.value,s=e.Sizes.width,r=f.settings.focusAt,l=e.Sizes.slideWidth;return r==="center"?i-(s/2-l/2):i-l*r-n*r}}}function Vi(f,e,t){var i=[ji,Bi,Fi,Gi].concat(f._t,[Ui]);return{mutate:function(s){for(var r=0;r<i.length;r++){var l=i[r];st(l)&&st(l().modify)?s=l(f,e,t).modify(s):qe("Transformer should be a function that returns an object with `modify()` method")}return s}}}function Yi(f,e,t){var i={set:function(s){var r=Vi(f,e).mutate(s),l="translate3d(".concat(-1*r,"px, 0px, 0px)");e.Html.wrapper.style.mozTransform=l,e.Html.wrapper.style.webkitTransform=l,e.Html.wrapper.style.transform=l},remove:function(){e.Html.wrapper.style.transform=""},getStartIndex:function(){var s=e.Sizes.length,r=f.index,l=f.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s+(r-l):(r+l)%s},getTravelDistance:function(){var s=e.Sizes.slideWidth*f.settings.perView;return e.Run.isOffset(">")||e.Run.isOffset("|>")?s*-1:s}};return t.on("move",function(n){if(!f.isType("carousel")||!e.Run.isOffset())return i.set(n.movement);e.Transition.after(function(){t.emit("translate.jump"),i.set(e.Sizes.slideWidth*f.index)});var s=e.Sizes.slideWidth*e.Translate.getStartIndex();return i.set(s-e.Translate.getTravelDistance())}),t.on("destroy",function(){i.remove()}),i}function Wi(f,e,t){var i=!1,n={compose:function(r){var l=f.settings;return i?"".concat(r," 0ms ").concat(l.animationTimingFunc):"".concat(r," ").concat(this.duration,"ms ").concat(l.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 ae(n,"duration",{get:function(){var r=f.settings;return f.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 zt=!1;try{var Ut=Object.defineProperty({},"passive",{get:function(){zt=!0}});window.addEventListener("testPassive",null,Ut),window.removeEventListener("testPassive",null,Ut)}catch{}var kt=zt,ot=["touchstart","mousedown"],jt=["touchmove","mousemove"],Bt=["touchend","touchcancel","mouseup","mouseleave"],Ft=["mousedown","mousemove","mouseup","mouseleave"];function Xi(f,e,t){var i=new Pe,n=0,s=0,r=0,l=!1,c=kt?{passive:!0}:!1,h={mount:function(){this.bindSwipeStart()},start:function(a){if(!l&&!f.disabled){this.disable();var p=this.touches(a);n=null,s=de(p.pageX),r=de(p.pageY),this.bindSwipeMove(),this.bindSwipeEnd(),t.emit("swipe.start")}},move:function(a){if(!f.disabled){var p=f.settings,m=p.touchAngle,w=p.touchRatio,S=p.classes,L=this.touches(a),y=de(L.pageX)-s,x=de(L.pageY)-r,g=Math.abs(y<<2),v=Math.abs(x<<2),_=Math.sqrt(g+v),C=Math.sqrt(v);if(n=Math.asin(C/_),n*180/Math.PI<m)a.stopPropagation(),e.Move.make(y*_i(w)),e.Html.root.classList.add(S.dragging),t.emit("swipe.move");else return!1}},end:function(a){if(!f.disabled){var p=f.settings,m=p.perSwipe,w=p.touchAngle,S=p.classes,L=this.touches(a),y=this.threshold(a),x=L.pageX-s,g=n*180/Math.PI;this.enable(),x>y&&g<w?e.Run.make(e.Direction.resolve("".concat(m,"<"))):x<-y&&g<w?e.Run.make(e.Direction.resolve("".concat(m,">"))):e.Move.make(),e.Html.root.classList.remove(S.dragging),this.unbindSwipeMove(),this.unbindSwipeEnd(),t.emit("swipe.end")}},bindSwipeStart:function(){var a=this,p=f.settings,m=p.swipeThreshold,w=p.dragThreshold;m&&i.on(ot[0],e.Html.wrapper,function(S){a.start(S)},c),w&&i.on(ot[1],e.Html.wrapper,function(S){a.start(S)},c)},unbindSwipeStart:function(){i.off(ot[0],e.Html.wrapper,c),i.off(ot[1],e.Html.wrapper,c)},bindSwipeMove:function(){var a=this;i.on(jt,e.Html.wrapper,nt(function(p){a.move(p)},f.settings.throttle),c)},unbindSwipeMove:function(){i.off(jt,e.Html.wrapper,c)},bindSwipeEnd:function(){var a=this;i.on(Bt,e.Html.wrapper,function(p){a.end(p)})},unbindSwipeEnd:function(){i.off(Bt,e.Html.wrapper)},touches:function(a){return Ft.indexOf(a.type)>-1?a:a.touches[0]||a.changedTouches[0]},threshold:function(a){var p=f.settings;return Ft.indexOf(a.type)>-1?p.dragThreshold:p.swipeThreshold},enable:function(){return l=!1,e.Transition.enable(),this},disable:function(){return l=!0,e.Transition.disable(),this}};return t.on("build.after",function(){e.Html.root.classList.add(f.settings.classes.swipeable)}),t.on("destroy",function(){h.unbindSwipeStart(),h.unbindSwipeMove(),h.unbindSwipeEnd(),i.destroy()}),h}function Ji(f,e,t){var i=new Pe,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 Zi(f,e,t){var i=new Pe,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(c){s&&(c.stopPropagation(),c.preventDefault())},detach:function(){if(s=!0,!n){for(var c=0;c<this.items.length;c++)this.items[c].draggable=!1;n=!0}return this},attach:function(){if(s=!1,n){for(var c=0;c<this.items.length;c++)this.items[c].draggable=!0;n=!1}return this}};return ae(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 Qi='[data-glide-el="controls[nav]"]',xt='[data-glide-el^="controls"]',Ki="".concat(xt,' [data-glide-dir*="<"]'),es="".concat(xt,' [data-glide-dir*=">"]');function ts(f,e,t){var i=new Pe,n=kt?{passive:!0}:!1,s={mount:function(){this._n=e.Html.root.querySelectorAll(Qi),this._c=e.Html.root.querySelectorAll(xt),this._arrowControls={previous:e.Html.root.querySelectorAll(Ki),next:e.Html.root.querySelectorAll(es)},this.addBindings()},setActive:function(){for(var l=0;l<this._n.length;l++)this.addClass(this._n[l].children)},removeActive:function(){for(var l=0;l<this._n.length;l++)this.removeClass(this._n[l].children)},addClass:function(l){var c=f.settings,h=l[f.index];h&&(h.classList.add(c.classes.nav.active),Ht(h).forEach(function(u){u.classList.remove(c.classes.nav.active)}))},removeClass:function(l){var c=l[f.index];c?.classList.remove(f.settings.classes.nav.active)},setArrowState:function(){if(!f.settings.rewind){var l=s._arrowControls.next,c=s._arrowControls.previous;this.resetArrowState(l,c),f.index===0&&this.disableArrow(c),f.index===e.Run.length&&this.disableArrow(l)}},resetArrowState:function(){for(var l=f.settings,c=arguments.length,h=new Array(c),u=0;u<c;u++)h[u]=arguments[u];h.forEach(function(a){wt(a).forEach(function(p){p.classList.remove(l.classes.arrow.disabled)})})},disableArrow:function(){for(var l=f.settings,c=arguments.length,h=new Array(c),u=0;u<c;u++)h[u]=arguments[u];h.forEach(function(a){wt(a).forEach(function(p){p.classList.add(l.classes.arrow.disabled)})})},addBindings:function(){for(var l=0;l<this._c.length;l++)this.bind(this._c[l].children)},removeBindings:function(){for(var l=0;l<this._c.length;l++)this.unbind(this._c[l].children)},bind:function(l){for(var c=0;c<l.length;c++)i.on("click",l[c],this.click),i.on("touchstart",l[c],this.click,n)},unbind:function(l){for(var c=0;c<l.length;c++)i.off(["click","touchstart"],l[c])},click:function(l){!kt&&l.type==="touchstart"&&l.preventDefault();var c=l.currentTarget.getAttribute("data-glide-dir");e.Run.make(e.Direction.resolve(c))}};return ae(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 is(f,e,t){var i=new Pe,n={mount:function(){f.settings.keyboard&&this.bind()},bind:function(){i.on("keyup",document,this.press)},unbind:function(){i.off("keyup",document)},press:function(r){var l=f.settings.perSwipe,c={ArrowRight:">",ArrowLeft:"<"};["ArrowRight","ArrowLeft"].includes(r.code)&&e.Run.make(e.Direction.resolve("".concat(l).concat(c[r.code])))}};return t.on(["destroy","update"],function(){n.unbind()}),t.on("update",function(){n.mount()}),t.on("destroy",function(){i.destroy()}),n}function ss(f,e,t){var i=new Pe,n={mount:function(){this.enable(),this.start(),f.settings.hoverpause&&this.bind()},enable:function(){this._e=!0},disable:function(){this._e=!1},start:function(){var r=this;this._e&&(this.enable(),f.settings.autoplay&&$t(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 ae(n,"time",{get:function(){var r=e.Html.slides[f.index].getAttribute("data-glide-autoplay");return de(r||f.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 Gt(f){return Ge(f)?Ti(f):(qe("Breakpoints option must be an object"),{})}function ns(f,e,t){var i=new Pe,n=f.settings,s=Gt(n.breakpoints),r=Object.assign({},n),l={match:function(h){if(typeof window.matchMedia<"u"){for(var u in h)if(h.hasOwnProperty(u)&&window.matchMedia("(max-width: ".concat(u,"px)")).matches)return h[u]}return r}};return Object.assign(n,l.match(s)),i.on("resize",window,nt(function(){f.settings=yt(n,l.match(s))},f.settings.throttle)),t.on("update",function(){s=Gt(s),r=Object.assign({},n)}),t.on("destroy",function(){i.off("resize",window)}),l}var rs={Html:qi,Translate:Yi,Transition:Wi,Direction:zi,Peek:Ai,Sizes:Oi,Gaps:Ri,Move:Ii,Clones:Pi,Resize:$i,Build:Ni,Run:Li,Swipe:Xi,Images:Ji,Anchors:Zi,Controls:ts,Keyboard:is,Autoplay:ss,Breakpoints:ns},os=(function(f){gi(t,f);var e=wi(t);function t(){return et(this,t),e.apply(this,arguments)}return tt(t,[{key:"mount",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return it(Fe(t.prototype),"mount",this).call(this,Object.assign({},rs,n))}}]),t})(Ci);function _t(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let ze=_t();function Vt(f){ze=f}const Ye={exec:()=>null};function ne(f,e=""){let t=typeof f=="string"?f:f.source;const i={replace:(n,s)=>{let r=typeof s=="string"?s:s.source;return r=r.replace(me.caret,"$1"),t=t.replace(n,r),i},getRegex:()=>new RegExp(t,e)};return i}const me={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:f=>new RegExp(`^( {0,3}${f})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:f=>new RegExp(`^ {0,${Math.min(3,f-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:f=>new RegExp(`^ {0,${Math.min(3,f-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:f=>new RegExp(`^ {0,${Math.min(3,f-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:f=>new RegExp(`^ {0,${Math.min(3,f-1)}}#`),htmlBeginRegex:f=>new RegExp(`^ {0,${Math.min(3,f-1)}}<(?:[a-z].*>|!--)`,"i")},as=/^(?:[ \t]*(?:\n|$))+/,ls=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,cs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,We=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,us=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,St=/(?:[*+-]|\d{1,9}[.)])/,Yt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wt=ne(Yt).replace(/bull/g,St).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(),ds=ne(Yt).replace(/bull/g,St).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(),Tt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,hs=/^[^\n]+/,Et=/(?!\s*\])(?:\\.|[^\[\]\\])+/,ps=ne(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Et).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fs=ne(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,St).getRegex(),at="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",Ct=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ms=ne("^ {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",Ct).replace("tag",at).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Xt=ne(Tt).replace("hr",We).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",at).getRegex(),Lt={blockquote:ne(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Xt).getRegex(),code:ls,def:ps,fences:cs,heading:us,hr:We,html:ms,lheading:Wt,list:fs,newline:as,paragraph:Xt,table:Ye,text:hs},Jt=ne("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",We).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",at).getRegex(),gs={...Lt,lheading:ds,table:Jt,paragraph:ne(Tt).replace("hr",We).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Jt).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",at).getRegex()},vs={...Lt,html:ne(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ct).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:Ye,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ne(Tt).replace("hr",We).replace("heading",` *#{1,6} *[^
|
|
28
|
+
]`).replace("lheading",Wt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},bs=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ys=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Zt=/^( {2,}|\\)\n(?!\s*$)/,ws=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,lt=/[\p{P}\p{S}]/u,Rt=/[\s\p{P}\p{S}]/u,Qt=/[^\s\p{P}\p{S}]/u,ks=ne(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Rt).getRegex(),Kt=/(?!~)[\p{P}\p{S}]/u,xs=/(?!~)[\s\p{P}\p{S}]/u,_s=/(?:[^\s\p{P}\p{S}]|~)/u,Ss=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,ei=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ts=ne(ei,"u").replace(/punct/g,lt).getRegex(),Es=ne(ei,"u").replace(/punct/g,Kt).getRegex(),ti="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Cs=ne(ti,"gu").replace(/notPunctSpace/g,Qt).replace(/punctSpace/g,Rt).replace(/punct/g,lt).getRegex(),Ls=ne(ti,"gu").replace(/notPunctSpace/g,_s).replace(/punctSpace/g,xs).replace(/punct/g,Kt).getRegex(),Rs=ne("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Qt).replace(/punctSpace/g,Rt).replace(/punct/g,lt).getRegex(),Ms=ne(/\\(punct)/,"gu").replace(/punct/g,lt).getRegex(),qs=ne(/^<(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(),As=ne(Ct).replace("(?:-->|$)","-->").getRegex(),Is=ne("^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",As).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ct=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Os=ne(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ct).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ii=ne(/^!?\[(label)\]\[(ref)\]/).replace("label",ct).replace("ref",Et).getRegex(),si=ne(/^!?\[(ref)\](?:\[\])?/).replace("ref",Et).getRegex(),Ns=ne("reflink|nolink(?!\\()","g").replace("reflink",ii).replace("nolink",si).getRegex(),Mt={_backpedal:Ye,anyPunctuation:Ms,autolink:qs,blockSkip:Ss,br:Zt,code:ys,del:Ye,emStrongLDelim:Ts,emStrongRDelimAst:Cs,emStrongRDelimUnd:Rs,escape:bs,link:Os,nolink:si,punctuation:ks,reflink:ii,reflinkSearch:Ns,tag:Is,text:ws,url:Ye},Ps={...Mt,link:ne(/^!?\[(label)\]\((.*?)\)/).replace("label",ct).getRegex(),reflink:ne(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ct).getRegex()},qt={...Mt,emStrongRDelimAst:Ls,emStrongLDelim:Es,url:ne(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},$s={...qt,br:ne(Zt).replace("{2,}","*").getRegex(),text:ne(qt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ut={normal:Lt,gfm:gs,pedantic:vs},Xe={normal:Mt,gfm:qt,breaks:$s,pedantic:Ps},Ds={"&":"&","<":"<",">":">",'"':""","'":"'"},ni=f=>Ds[f];function Te(f,e){if(e){if(me.escapeTest.test(f))return f.replace(me.escapeReplace,ni)}else if(me.escapeTestNoEncode.test(f))return f.replace(me.escapeReplaceNoEncode,ni);return f}function ri(f){try{f=encodeURI(f).replace(me.percentDecode,"%")}catch{return null}return f}function oi(f,e){const t=f.replace(me.findPipe,(s,r,l)=>{let c=!1,h=r;for(;--h>=0&&l[h]==="\\";)c=!c;return c?"|":" |"}),i=t.split(me.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(me.slashPipe,"|");return i}function Je(f,e,t){const i=f.length;if(i===0)return"";let n=0;for(;n<i&&f.charAt(i-n-1)===e;)n++;return f.slice(0,i-n)}function Hs(f,e){if(f.indexOf(e[1])===-1)return-1;let t=0;for(let i=0;i<f.length;i++)if(f[i]==="\\")i++;else if(f[i]===e[0])t++;else if(f[i]===e[1]&&(t--,t<0))return i;return t>0?-2:-1}function ai(f,e,t,i,n){const s=e.href,r=e.title||null,l=f[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;const c={type:f[0].charAt(0)==="!"?"image":"link",raw:t,href:s,title:r,text:l,tokens:i.inlineTokens(l)};return i.state.inLink=!1,c}function zs(f,e,t){const i=f.match(t.other.indentCodeCompensation);if(i===null)return e;const n=i[1];return e.split(`
|
|
29
|
+
`).map(s=>{const r=s.match(t.other.beginningSpace);if(r===null)return s;const[l]=r;return l.length>=n.length?s.slice(n.length):s}).join(`
|
|
30
|
+
`)}class dt{options;rules;lexer;constructor(e){this.options=e||ze}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:Je(i,`
|
|
31
|
+
`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const i=t[0],n=zs(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=Je(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:Je(t[0],`
|
|
32
|
+
`)}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){let i=Je(t[0],`
|
|
33
|
+
`).split(`
|
|
34
|
+
`),n="",s="";const r=[];for(;i.length>0;){let l=!1;const c=[];let h;for(h=0;h<i.length;h++)if(this.rules.other.blockquoteStart.test(i[h]))c.push(i[h]),l=!0;else if(!l)c.push(i[h]);else break;i=i.slice(h);const u=c.join(`
|
|
35
|
+
`),a=u.replace(this.rules.other.blockquoteSetextReplace,`
|
|
36
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
37
|
+
${u}`:u,s=s?`${s}
|
|
38
|
+
${a}`:a;const p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(a,r,!0),this.lexer.state.top=p,i.length===0)break;const m=r.at(-1);if(m?.type==="code")break;if(m?.type==="blockquote"){const w=m,S=w.raw+`
|
|
39
|
+
`+i.join(`
|
|
40
|
+
`),L=this.blockquote(S);r[r.length-1]=L,n=n.substring(0,n.length-w.raw.length)+L.raw,s=s.substring(0,s.length-w.text.length)+L.text;break}else if(m?.type==="list"){const w=m,S=w.raw+`
|
|
41
|
+
`+i.join(`
|
|
42
|
+
`),L=this.list(S);r[r.length-1]=L,n=n.substring(0,n.length-m.raw.length)+L.raw,s=s.substring(0,s.length-w.raw.length)+L.raw,i=S.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 l=!1;for(;e;){let h=!1,u="",a="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;u=t[0],e=e.substring(u.length);let p=t[2].split(`
|
|
44
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,x=>" ".repeat(3*x.length)),m=e.split(`
|
|
45
|
+
`,1)[0],w=!p.trim(),S=0;if(this.options.pedantic?(S=2,a=p.trimStart()):w?S=t[1].length+1:(S=t[2].search(this.rules.other.nonSpaceChar),S=S>4?1:S,a=p.slice(S),S+=t[1].length),w&&this.rules.other.blankLine.test(m)&&(u+=m+`
|
|
46
|
+
`,e=e.substring(m.length+1),h=!0),!h){const x=this.rules.other.nextBulletRegex(S),g=this.rules.other.hrRegex(S),v=this.rules.other.fencesBeginRegex(S),_=this.rules.other.headingBeginRegex(S),C=this.rules.other.htmlBeginRegex(S);for(;e;){const E=e.split(`
|
|
47
|
+
`,1)[0];let q;if(m=E,this.options.pedantic?(m=m.replace(this.rules.other.listReplaceNesting," "),q=m):q=m.replace(this.rules.other.tabCharGlobal," "),v.test(m)||_.test(m)||C.test(m)||x.test(m)||g.test(m))break;if(q.search(this.rules.other.nonSpaceChar)>=S||!m.trim())a+=`
|
|
48
|
+
`+q.slice(S);else{if(w||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||v.test(p)||_.test(p)||g.test(p))break;a+=`
|
|
49
|
+
`+m}!w&&!m.trim()&&(w=!0),u+=E+`
|
|
50
|
+
`,e=e.substring(E.length+1),p=q.slice(S)}}s.loose||(l?s.loose=!0:this.rules.other.doubleBlankLine.test(u)&&(l=!0));let L=null,y;this.options.gfm&&(L=this.rules.other.listIsTask.exec(a),L&&(y=L[0]!=="[ ] ",a=a.replace(this.rules.other.listReplaceTask,""))),s.items.push({type:"list_item",raw:u,task:!!L,checked:y,loose:!1,text:a,tokens:[]}),s.raw+=u}const c=s.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let h=0;h<s.items.length;h++)if(this.lexer.state.top=!1,s.items[h].tokens=this.lexer.blockTokens(s.items[h].text,[]),!s.loose){const u=s.items[h].tokens.filter(p=>p.type==="space"),a=u.length>0&&u.some(p=>this.rules.other.anyLine.test(p.raw));s.loose=a}if(s.loose)for(let h=0;h<s.items.length;h++)s.items[h].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=oi(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 l of n)this.rules.other.tableAlignRight.test(l)?r.align.push("right"):this.rules.other.tableAlignCenter.test(l)?r.align.push("center"):this.rules.other.tableAlignLeft.test(l)?r.align.push("left"):r.align.push(null);for(let l=0;l<i.length;l++)r.header.push({text:i[l],tokens:this.lexer.inline(i[l]),header:!0,align:r.align[l]});for(const l of s)r.rows.push(oi(l,r.header.length).map((c,h)=>({text:c,tokens:this.lexer.inline(c),header:!1,align:r.align[h]})));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=Je(i.slice(0,-1),"\\");if((i.length-r.length)%2===0)return}else{const r=Hs(t[2],"()");if(r===-2)return;if(r>-1){const c=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,c).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)),ai(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 ai(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 l,c,h=r,u=0;const a=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+r);(n=a.exec(t))!=null;){if(l=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!l)continue;if(c=[...l].length,n[3]||n[4]){h+=c;continue}else if((n[5]||n[6])&&r%3&&!((r+c)%3)){u+=c;continue}if(h-=c,h>0)continue;c=Math.min(c,c+h+u);const p=[...n[0]][0].length,m=e.slice(0,r+n.index+p+c);if(Math.min(r,c)%2){const S=m.slice(1,-1);return{type:"em",raw:m,text:S,tokens:this.lexer.inlineTokens(S)}}const w=m.slice(2,-2);return{type:"strong",raw:m,text:w,tokens:this.lexer.inlineTokens(w)}}}}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 we{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ze,this.options.tokenizer=this.options.tokenizer||new dt,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:me,block:ut.normal,inline:Xe.normal};this.options.pedantic?(t.block=ut.pedantic,t.inline=Xe.pedantic):this.options.gfm&&(t.block=ut.gfm,this.options.breaks?t.inline=Xe.breaks:t.inline=Xe.gfm),this.tokenizer.rules=t}static get rules(){return{block:ut,inline:Xe}}static lex(e,t){return new we(t).lex(e)}static lexInline(e,t){return new we(t).inlineTokens(e)}lex(e){e=e.replace(me.carriageReturn,`
|
|
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(me.tabCharGlobal," ").replace(me.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
|
+
`: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
|
+
`+n.raw,r.text+=`
|
|
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
|
+
`+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 l=e.slice(1);let c;this.options.extensions.startBlock.forEach(h=>{c=h.call({lexer:this},l),typeof c=="number"&&c>=0&&(r=Math.min(r,c))}),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
|
+
`+n.raw,r.text+=`
|
|
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
|
+
`+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 l=Object.keys(this.tokens.links);if(l.length>0)for(;(n=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)l.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 l;if(this.options.extensions?.inline?.some(h=>(l=h.call({lexer:this},e,t))?(e=e.substring(l.raw.length),t.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);const h=t.at(-1);l.type==="text"&&h?.type==="text"?(h.raw+=l.raw,h.text+=l.text):t.push(l);continue}if(l=this.tokenizer.emStrong(e,i,r)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.del(e)){e=e.substring(l.raw.length),t.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),t.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),t.push(l);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0;const u=e.slice(1);let a;this.options.extensions.startInline.forEach(p=>{a=p.call({lexer:this},u),typeof a=="number"&&a>=0&&(h=Math.min(h,a))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(l=this.tokenizer.inlineText(c)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(r=l.raw.slice(-1)),s=!0;const h=t.at(-1);h?.type==="text"?(h.raw+=l.raw,h.text+=l.text):t.push(l);continue}if(e){const h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}}class ht{options;parser;constructor(e){this.options=e||ze}space(e){return""}code({text:e,lang:t,escaped:i}){const n=(t||"").match(me.notSpaceStart)?.[0],s=e.replace(me.endingNewline,"")+`
|
|
63
|
+
`;return n?'<pre><code class="language-'+Te(n)+'">'+(i?s:Te(s,!0))+`</code></pre>
|
|
64
|
+
`:"<pre><code>"+(i?s:Te(s,!0))+`</code></pre>
|
|
65
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
66
|
+
${this.parser.parse(e)}</blockquote>
|
|
67
|
+
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
68
|
+
`}hr(e){return`<hr>
|
|
69
|
+
`}list(e){const t=e.ordered,i=e.start;let n="";for(let l=0;l<e.items.length;l++){const c=e.items[l];n+=this.listitem(c)}const s=t?"ol":"ul",r=t&&i!==1?' start="'+i+'"':"";return"<"+s+r+`>
|
|
70
|
+
`+n+"</"+s+`>
|
|
71
|
+
`}listitem(e){let t="";if(e.task){const i=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=i+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=i+" "+Te(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:i+" ",text:i+" ",escaped:!0}):t+=i+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
72
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
73
|
+
`}table(e){let t="",i="";for(let s=0;s<e.header.length;s++)i+=this.tablecell(e.header[s]);t+=this.tablerow({text:i});let n="";for(let s=0;s<e.rows.length;s++){const r=e.rows[s];i="";for(let l=0;l<r.length;l++)i+=this.tablecell(r[l]);n+=this.tablerow({text:i})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
74
|
+
<thead>
|
|
75
|
+
`+t+`</thead>
|
|
76
|
+
`+n+`</table>
|
|
77
|
+
`}tablerow({text:e}){return`<tr>
|
|
78
|
+
${e}</tr>
|
|
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
|
+
`}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>${Te(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=ri(e);if(s===null)return n;e=s;let r='<a href="'+e+'"';return t&&(r+=' title="'+Te(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=ri(e);if(s===null)return Te(i);e=s;let r=`<img src="${e}" alt="${i}"`;return t&&(r+=` title="${Te(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Te(e.text)}}class At{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 ke{options;renderer;textRenderer;constructor(e){this.options=e||ze,this.options.renderer=this.options.renderer||new ht,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new At}static parse(e,t){return new ke(t).parse(e)}static parseInline(e,t){return new ke(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 l=s,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){i+=c||"";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 l=r,c=this.renderer.text(l);for(;n+1<e.length&&e[n+1].type==="text";)l=e[++n],c+=`
|
|
81
|
+
`+this.renderer.text(l);t?i+=this.renderer.paragraph({type:"paragraph",raw:c,text:c,tokens:[{type:"text",raw:c,text:c,escaped:!0}]}):i+=c;continue}default:{const l='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}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 l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=l||"";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 l='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return i}}class pt{options;block;constructor(e){this.options=e||ze}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?we.lex:we.lexInline}provideParser(){return this.block?ke.parse:ke.parseInline}}class Us{defaults=_t();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ke;Renderer=ht;TextRenderer=At;Lexer=we;Tokenizer=dt;Hooks=pt;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 l of r)i=i.concat(this.walkTokens(l.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 l=s[r].flat(1/0);i=i.concat(this.walkTokens(l,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(...l){let c=s.renderer.apply(this,l);return c===!1&&(c=r.apply(this,l)),c}: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 ht(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 l=r,c=i.renderer[l],h=s[l];s[l]=(...u)=>{let a=c.apply(s,u);return a===!1&&(a=h.apply(s,u)),a||""}}n.renderer=s}if(i.tokenizer){const s=this.defaults.tokenizer||new dt(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 l=r,c=i.tokenizer[l],h=s[l];s[l]=(...u)=>{let a=c.apply(s,u);return a===!1&&(a=h.apply(s,u)),a}}n.tokenizer=s}if(i.hooks){const s=this.defaults.hooks||new pt;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 l=r,c=i.hooks[l],h=s[l];pt.passThroughHooks.has(r)?s[l]=u=>{if(this.defaults.async)return Promise.resolve(c.call(s,u)).then(p=>h.call(s,p));const a=c.call(s,u);return h.call(s,a)}:s[l]=(...u)=>{let a=c.apply(s,u);return a===!1&&(a=h.apply(s,u)),a}}n.hooks=s}if(i.walkTokens){const s=this.defaults.walkTokens,r=i.walkTokens;n.walkTokens=function(l){let c=[];return c.push(r.call(this,l)),s&&(c=c.concat(s.call(this,l))),c}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return we.lex(e,t??this.defaults)}parser(e,t){return ke.parse(e,t??this.defaults)}parseMarkdown(e){return(i,n)=>{const s={...n},r={...this.defaults,...s},l=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return l(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 l(new Error("marked(): input parameter is undefined or null"));if(typeof i!="string")return l(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 c=r.hooks?r.hooks.provideLexer():e?we.lex:we.lexInline,h=r.hooks?r.hooks.provideParser():e?ke.parse:ke.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(i):i).then(u=>c(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=>h(u,r)).then(u=>r.hooks?r.hooks.postprocess(u):u).catch(l);try{r.hooks&&(i=r.hooks.preprocess(i));let u=c(i,r);r.hooks&&(u=r.hooks.processAllTokens(u)),r.walkTokens&&this.walkTokens(u,r.walkTokens);let a=h(u,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(u){return l(u)}}}onError(e,t){return i=>{if(i.message+=`
|
|
82
|
+
Please report this to https://github.com/markedjs/marked.`,e){const n="<p>An error occurred:</p><pre>"+Te(i.message+"",!0)+"</pre>";return t?Promise.resolve(n):n}if(t)return Promise.reject(i);throw i}}}const Ue=new Us;function te(f,e){return Ue.parse(f,e)}te.options=te.setOptions=function(f){return Ue.setOptions(f),te.defaults=Ue.defaults,Vt(te.defaults),te},te.getDefaults=_t,te.defaults=ze,te.use=function(...f){return Ue.use(...f),te.defaults=Ue.defaults,Vt(te.defaults),te},te.walkTokens=function(f,e){return Ue.walkTokens(f,e)},te.parseInline=Ue.parseInline,te.Parser=ke,te.parser=ke.parse,te.Renderer=ht,te.TextRenderer=At,te.Lexer=we,te.lexer=we.lex,te.Tokenizer=dt,te.Hooks=pt,te.parse=te,te.options,te.setOptions,te.use,te.walkTokens,te.parseInline,ke.parse,we.lex;class js{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
|
+
|
|
84
|
+
${e}`,l,c,h;if(i.image&&t==="openai")return r+=`
|
|
85
|
+
Extract some information.
|
|
86
|
+
`,l=[{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:[]}}],c=await this.builder.send(r,s,n,"",l),c?(h=JSON.parse(c),h):!1;if(i.image){if(r+=`
|
|
87
|
+
|
|
88
|
+
Check the type of the request:
|
|
89
|
+
- Text/Prompt to Image Generation
|
|
90
|
+
- Text/Prompt to 2D Illustration Generation
|
|
91
|
+
- Text/Prompt to Digital Illustration Generation
|
|
92
|
+
- Text/Prompt to Book Cover Generation
|
|
93
|
+
- Upscale Image
|
|
94
|
+
- Upscale Video
|
|
95
|
+
- Minimize Image
|
|
96
|
+
- Remove Background of an Image
|
|
97
|
+
- Change/Replace Background of an Image
|
|
98
|
+
- Erase/Remove Unwanted Objects from Image
|
|
99
|
+
- Edit Area in Image
|
|
100
|
+
- Generate Variation of an Image
|
|
101
|
+
- Describe an image or ask questions about the image
|
|
102
|
+
`,l=[{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:[]}}],c=await this.builder.send(r,s,n,"",l),!c)return!1;h=JSON.parse(c)}else if(i.video){if(r+=`
|
|
103
|
+
|
|
104
|
+
Check the type of the request:
|
|
105
|
+
- Image to Video Generation (generate a video based on image)
|
|
106
|
+
- Prompt/text to Video Generation (generate a video based on prompt)
|
|
107
|
+
- Upscale video
|
|
108
|
+
- Add sound to video
|
|
109
|
+
`,l=[{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:[]}}],c=await this.builder.send(r,s,n,"",l),!c)return!1;h=JSON.parse(c)}else if(i.audio){if(r+=`
|
|
110
|
+
|
|
111
|
+
Check the type of the request:
|
|
112
|
+
- Prompt/text to Audio Generation (generate sound or audio based on prompt)
|
|
113
|
+
- Text to Speech (generate speech from text)
|
|
114
|
+
`,l=[{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:[]}}],c=await this.builder.send(r,s,n,"",l),!c)return!1;h=JSON.parse(c)}return this.builder.settings.consoleLog&&console.log(h),this.extractInfo(h,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",l=`
|
|
115
|
+
Thie is the list of models:
|
|
116
|
+
- ${n.text_to_image_generation[t].join(`
|
|
117
|
+
- `)}
|
|
118
|
+
`,c=`This is user's request:
|
|
119
|
+
|
|
120
|
+
${i}
|
|
121
|
+
|
|
122
|
+
Check the request and return the details.
|
|
123
|
+
`;let h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.image_to_video_generation){const s="You are an assistant",l=`
|
|
124
|
+
Thie is the list of models:
|
|
125
|
+
- ${n.image_to_video_generation[t].join(`
|
|
126
|
+
- `)}
|
|
127
|
+
`,c=`This is user's request:
|
|
128
|
+
|
|
129
|
+
${i}
|
|
130
|
+
|
|
131
|
+
Check the request and return the details.
|
|
132
|
+
`;let h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.text_to_video_generation){const s="You are an assistant",l=`
|
|
133
|
+
Thie is the list of models:
|
|
134
|
+
- ${n.text_to_video_generation[t].join(`
|
|
135
|
+
- `)}
|
|
136
|
+
`;let c=`This is user's request:
|
|
137
|
+
|
|
138
|
+
${i}
|
|
139
|
+
|
|
140
|
+
Check the request and return the details.
|
|
141
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.minimize_image){let s="You are an assistant",r="",l=`This is user's request:
|
|
142
|
+
|
|
143
|
+
${i}
|
|
144
|
+
|
|
145
|
+
Check the request and return the details.
|
|
146
|
+
`,c=[{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"]}}],h=await this.builder.send(l,r,s,"",c);if(!h)return!1;let u=JSON.parse(h);return{...e,...u}}else if(e.upscale_image){const s="You are an assistant",l=`
|
|
147
|
+
Thie is the list of models:
|
|
148
|
+
- ${n.upscale_image[t].join(`
|
|
149
|
+
- `)}
|
|
150
|
+
`;let c=`This is user's request:
|
|
151
|
+
|
|
152
|
+
${i}
|
|
153
|
+
|
|
154
|
+
Check the request and return the details.
|
|
155
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.describe_image){const s="You are an assistant",l=`
|
|
156
|
+
Thie is the list of models:
|
|
157
|
+
- ${n.describe_image[t].join(`
|
|
158
|
+
- `)}
|
|
159
|
+
`;let c=`This is user's request:
|
|
160
|
+
|
|
161
|
+
${i}
|
|
162
|
+
|
|
163
|
+
Check the request and return the details.
|
|
164
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.edit_area_in_image){const s="You are an assistant",r=n.edit_area_in_image[t];let l="";r&&(l=`
|
|
165
|
+
Thie is the list of models:
|
|
166
|
+
- ${r.join(`
|
|
167
|
+
- `)}
|
|
168
|
+
`);let c=`This is user's request:
|
|
169
|
+
|
|
170
|
+
${i}
|
|
171
|
+
|
|
172
|
+
Check the request and return the details.
|
|
173
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.text_to_2d_illustration_generation){const s="You are an assistant",l=`
|
|
174
|
+
Thie is the list of models:
|
|
175
|
+
- ${n.text_to_2d_illustration_generation[t].join(`
|
|
176
|
+
- `)}
|
|
177
|
+
`;let c=`This is user's request:
|
|
178
|
+
|
|
179
|
+
${i}
|
|
180
|
+
|
|
181
|
+
Check the request and return the details.
|
|
182
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.text_to_digital_illustration_generation){const s="You are an assistant",l=`
|
|
183
|
+
Thie is the list of models:
|
|
184
|
+
- ${n.text_to_digital_illustration_generation[t].join(`
|
|
185
|
+
- `)}
|
|
186
|
+
`;let c=`This is user's request:
|
|
187
|
+
|
|
188
|
+
${i}
|
|
189
|
+
|
|
190
|
+
Check the request and return the details.
|
|
191
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.text_to_book_cover_generation){const s="You are an assistant",l=`
|
|
192
|
+
Thie is the list of models:
|
|
193
|
+
- ${n.text_to_book_cover_generation[t].join(`
|
|
194
|
+
- `)}
|
|
195
|
+
`;let c=`This is user's request:
|
|
196
|
+
|
|
197
|
+
${i}
|
|
198
|
+
|
|
199
|
+
Check the request and return the details.
|
|
200
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}else if(e.text_to_speech){const s="You are an assistant",l=`
|
|
201
|
+
Thie is the list of models:
|
|
202
|
+
- ${n.text_to_speech[t].join(`
|
|
203
|
+
- `)}
|
|
204
|
+
`;let c=`This is user's request:
|
|
205
|
+
|
|
206
|
+
${i}
|
|
207
|
+
|
|
208
|
+
Check the request and return the details.
|
|
209
|
+
`,h=[{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(c,l,s,"",h);if(!u)return!1;let a=JSON.parse(u);return{...e,...a}}return!1}async checkModel(e){let t="You are an assistant",i="",n=`This is the information:
|
|
210
|
+
|
|
211
|
+
${e}
|
|
212
|
+
|
|
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 l=this.getEndpoint(e.model,t,this.builder.settings.falResultEndpoint);e.endpoint=l;let c={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:c,body:JSON.stringify(e)});let h=await s.text();try{r=JSON.parse(h)}catch{return{mediaGenerated:!1,status:"error",message:h}}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 a="",p="",m,w=!1,S=[],L=[];return u.entries&&u.entries.forEach(y=>{m=y.url.split(".").pop().toLowerCase(),m==="mp4"?(a+=`
|
|
215
|
+
<p class="responsive-video">
|
|
216
|
+
<video controls>
|
|
217
|
+
<source src="${y.url}" type="video/mp4">
|
|
218
|
+
Your browser does not support the video tag.
|
|
219
|
+
</video>
|
|
220
|
+
</p>
|
|
221
|
+
`,p+=``):m==="wav"||m==="mp3"?(a+=`
|
|
222
|
+
<p class="responsive-audio">
|
|
223
|
+
<audio controls>
|
|
224
|
+
<source src="${y.url}" type="audio/mpeg">
|
|
225
|
+
Your browser does not support the audio tag.
|
|
226
|
+
</audio>
|
|
227
|
+
</p>
|
|
228
|
+
`,p+=``):(a+=`
|
|
229
|
+
<div>
|
|
230
|
+
<img src="${y.url}" />
|
|
231
|
+
<div>
|
|
232
|
+
<a class="link-view" href="${y.url}" target="_blank" rel="noopener noreferrer">${this.out("View")}</a>
|
|
233
|
+
<a class="link-download" href="${y.url}" download>${this.out("Download")}</a>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
`,p+=``,w=!0),S.push(y.url),L.push(y.file_url)}),w&&(a=`<div class="image-container">${a}</div>`),typeof u=="string"&&(a=u,p=u),n?(i.innerHTML="",i.remove()):(i.innerHTML=a,this.builder.outputHtml+=`<div class="result-container">${a}</div>`),{mediaGenerated:!0,status:"success",markdown:p,output:S,output2:L}}}async waitingResultReplicate(e,t,i,n){let s,r;e.request_id=t;let l=this.builder.settings.replicateStatusEndpoint;l=l.replace("{REQUEST_ID}",t),e.endpoint=l;let c={"Content-Type":"application/json",...this.builder.settings.headers};s=await fetch(this.builder.settings.getResultUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:c,body:JSON.stringify(e)});let h=await s.text();try{r=JSON.parse(h)}catch{return{mediaGenerated:!1,status:"error",message:h}}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 a=this.renderResult(u,i,n);return{mediaGenerated:!0,status:"success",markdown:a.markdown,output:a.output,output2:a.output2}}}async waitingReplicate(e,t,i,n){let s,r,l,c=e.model,h=this.builder.settings.replicateStatusEndpoint;h=h.replace("{REQUEST_ID}",t);let u={"Content-Type":"application/json",...this.builder.settings.headers},a={model:c,endpoint:h,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Replicate,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(a)}),l=await r.json(),l.ok&&(s=l.data.status),!s)return{mediaGenerated:!1,status:"error",result:l,message:l.error||l.data&&JSON.stringify(l.data)||this.out("Request failed.")};s==="succeeded"||s==="failed"||s==="canceled"||(this.builder.settings.consoleLog&&console.log(s),await new Promise(p=>setTimeout(p,5e3)))}while(!(s==="succeeded"||s==="failed"||s==="canceled"));return s==="succeeded"?await this.waitingResultReplicate(e,t,i,n):{mediaGenerated:!1,status:"error",result:l,message:l.data&&l.data.error||this.out("Request failed.")}}async waitingFal(e,t,i,n){let s,r,l,c=e.model;const h=this.getEndpoint(c,t,this.builder.settings.falStatusEndpoint);let u={"Content-Type":"application/json",...this.builder.settings.headers},a={model:c,endpoint:h,request_id:t};do{if(r=await fetch(this.builder.settings.checkRequestStatusUrl_Fal,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(a)}),l=await r.json(),l.ok&&l.status)s=l.status;else if(l.data){let p=l.data;p.image||p.audio||p.audio_file||p.video?s="COMPLETED":p.detail&&typeof p.detail=="string"&&p.detail.startsWith("Request is still in progress")?s="IN_PROGRESS":p.status&&!p.error&&(s=p.status)}if(!s)return{mediaGenerated:!1,status:"error",result:l,message:l.error||l.data&&JSON.stringify(l.data)||this.out("Request failed.")};s!=="COMPLETED"&&(this.builder.settings.consoleLog&&console.log(s),this.builder.settings.consoleLog&&console.log(l),await new Promise(p=>setTimeout(p,5e3)))}while(s!=="COMPLETED");if(s==="COMPLETED")return await this.waitingResultFal(e,t,i,n)}renderResult(e,t,i){let n="",s="",r=[],l=[];if(e.entries){let c,h=!1;e.entries.forEach(u=>{c=u.url.split(".").pop().toLowerCase(),c==="mp4"?(n+=`
|
|
237
|
+
<p class="responsive-video">
|
|
238
|
+
<video controls>
|
|
239
|
+
<source src="${u.url}" type="video/mp4">
|
|
240
|
+
Your browser does not support the video tag.
|
|
241
|
+
</video>
|
|
242
|
+
</p>
|
|
243
|
+
`,s+=``,r.push(u.url),l.push(u.file_url)):c==="wav"||c==="mp3"?(n+=`
|
|
244
|
+
<p class="responsive-audio">
|
|
245
|
+
<audio controls>
|
|
246
|
+
<source src="${u.url}" type="audio/mpeg">
|
|
247
|
+
Your browser does not support the audio tag.
|
|
248
|
+
</audio>
|
|
249
|
+
</p>
|
|
250
|
+
`,s+=``,r.push(u.url),l.push(u.file_url)):(n+=`
|
|
251
|
+
<div>
|
|
252
|
+
<img src="${u.url}" />
|
|
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>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
`,s+=``,r.push(u.url),l.push(u.file_url),h=!0)}),h&&(n=`<div class="image-container">${n}</div>`)}else typeof e=="string"&&(n=`
|
|
259
|
+
<p>
|
|
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:l}}async generateReplicate(e,t,i){let n,s={};const r="replicate";if(e.text_to_image_generation){let c=this.validateModel(e.model,r,"text_to_image_generation");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt;if(!h)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.aspect_ratio||"16:9",a=e.num_images||1;a>4&&(a=4),n={prompt:h,aspect_ratio:u,num_outputs:a},s.model=c,s.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let c=this.validateModel(e.model,a,"edit_area_in_image");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt;if(!h)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 a="replicate";const p=await this.builder.upload.getInputURLs(a,!0);if(p.error)return{mediaGenerated:!1,status:"error",message:p.error};let m=p[e.image_url],w=p[e.image_url+"_mask"];if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Image mask not found.")};n={prompt:h,image:m,mask:w},s.model=c,s.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let c=this.validateModel(e.model,r,"text_to_digital_illustration_generation");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt;if(!h)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.width||1280,a=e.height||768;e.num_images,n={prompt:h,size:`${u}x${a}`,style:"digital_illustration"},s.model=c,s.customData=this.builder.settings.customData}else if(e.upscale_image){let c=this.validateModel(e.model,u,"upscale_image");if(!c)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 a=await this.builder.upload.getInputURLs(u);if(a.error)return{mediaGenerated:!1,status:"error",message:a.error};let p=a[e.image_url];if(!p)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:p},s.model=c,s.customData=this.builder.settings.customData}else if(e.describe_image){let c=this.validateModel(e.model,a,"describe_image");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt;if(!h)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 a="replicate";const p=await this.builder.upload.getInputURLs(a);if(p.error)return{mediaGenerated:!1,status:"error",message:p.error};let m=p[e.image_url];if(!m)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};n={image:m,prompt:`${h}. No talk. Answer only.`},s.model=c,s.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let c=this.validateModel(e.model,a,"image_to_video_generation");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt||"stunning video",u=e.duration||5;u>10&&(u=5);let a="replicate";const p=await this.builder.upload.getInputURLs(a);if(p.error)return{mediaGenerated:!1,status:"error",message:p.error};let m=p[e.image_url];if(!m)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};c==="kwaivgi/kling-v1.6-pro"&&(n={start_image:m,prompt:h,duration:u}),c==="kwaivgi/kling-v1.6-standard"&&(n={start_image:m,prompt:h,duration:u}),c==="minimax/video-01-live"&&(n={first_frame_image:m,prompt:h}),c==="luma/ray"&&(n={start_image_url:m,prompt:h}),s.model=c,s.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let c=this.validateModel(e.model,r,"text_to_video_generation");if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let h=e.prompt;if(!h)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let u=e.duration||5;u>10&&(u=5),c==="kwaivgi/kling-v1.6-standard"&&(n={prompt:h,duration:u}),c==="minimax/video-01"&&(n={prompt:h}),c==="luma/ray"&&(n={prompt:h}),s.model=c,s.customData=this.builder.settings.customData}else if(e.text_to_speech){let c=this.validateModel(e.model,r,"text_to_speech");if(!c)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=c,s.customData=this.builder.settings.customData}if(s.model.indexOf(":")!==-1){const h=s.model.split(":")[1];s.version=h;let u=this.builder.settings.replicateEndpoint1;s.endpoint=u,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 1")}else{let c=this.builder.settings.replicateEndpoint2;c=c.replace("{MODEL}",s.model),s.endpoint=c,s.payload=n,this.builder.settings.consoleLog&&console.log("PAYLOAD 2")}this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);let l=!1;if(this.builder.settings.generateMediaUrl_Replicate&&(l=!0),l){let c=this.builder.settings.generateMediaUrl_Replicate;if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured.")};let h,u={"Content-Type":"application/json",...this.builder.settings.headers},p=await(await fetch(c,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(s)})).json();if(p.ok){if(h=p.data.id,!h)return{mediaGenerated:!1,status:"error",message:p.data&&p.data.detail}}else return{mediaGenerated:!1,status:"error",message:p.error};const m=this.waitingReplicate(s,h,t,i);return this.builder.isMediaGenerating=!1,m}else{let c=this.builder.settings.generateMediaUrl;if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl.")};let h={"Content-Type":"application/json",...this.builder.settings.headers};const a=await(await fetch(c,{signal:this.builder.mediaSignal,method:"POST",headers:h,body:JSON.stringify(s)})).json();if(this.builder.isMediaGenerating=!1,a.error)return this.builder.settings.consoleLog&&console.log(a.error),{mediaGenerated:!1,status:"error",message:a.error};{const p=a.data;let m=this.renderResult(p,t,i);return{mediaGenerated:!0,status:"success",markdown:m.markdown,output:m.output,output2:m.output2}}}}async generateOpenAI(e,t,i){let n,s={},l=this.validateModel(e.model,"openai","image_generation"),c=e.prompt;if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};const h=new FormData;h.append("customData",JSON.stringify(this.builder.settings.customData)),h.append("model",l),h.append("prompt",c);let u=!1,a=this.builder.getFormValues();for(const g of a){if(g.value instanceof FileList&&g.type==="multifile"){const v=g.value;if(v.length>0)for(const _ of v)h.append("file[]",_),u=!0}if(g.value instanceof FileList&&g.type==="file"){const v=g.value;if(v.length>0){const _=v[0];h.append("file[]",_),u=!0}}if(typeof g.value=="string"&&g.value.indexOf("base64")!==-1){let v=g.value.replace(/^data:image\/(png|svg\+xml|jpeg|gif|webp);base64,/,"");h.append("mask",v)}}if(this.builder.selectedFiles&&this.builder.selectedFiles.length>0)for(let g=0;g<this.builder.selectedFiles.length;g++){const v=this.builder.selectedFiles[g];h.append("file[]",v),u=!0}let p,m=e.size||"auto",w=e.quality||"auto",S=e.num_images||1;if(u){h.append("size",m),h.append("n",S),h.append("quality",w),n={prompt:c,size:m,quality:w,n:S},s.model=l,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s);let g=this.builder.settings.generateMediaUrl_OpenAI_CreateImageEdit;p=await fetch(g,{method:"POST",body:h})}else{let g=e.background||"auto",v=e.output_format||"png";n={prompt:c,background:g,output_format:v,size:m,quality:w,n:S},s.model=l,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const _=this.builder.settings.generateMediaUrl_OpenAI_CreateImage;let C={"Content-Type":"application/json",...this.builder.settings.headers};p=await fetch(_,{signal:this.builder.mediaSignal,method:"POST",headers:C,body:JSON.stringify(s)})}const L=await p.json();this.builder.settings.consoleLog&&console.log(L),this.builder.isMediaGenerating=!1;const y=L.data;this.builder.output.push(L);let x=this.renderResult(y,t,i);return{mediaGenerated:!0,status:"success",markdown:x.markdown,output:x.output,output2:x.output2}}async generateGoogle(e,t,i){let n,s={},l=this.validateModel(e.model,"google","edit_area_in_image");if(!l)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let c=e.prompt;if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let h=[];h.push({text:c});let u=this.builder.getFormValues();if(!(u&&Object.keys(u).length===0)){for(const y of u)if(y.value instanceof FileList&&y.type==="multifile"){const x=y.value;if(x.length>0)for(const g of x){const v=await new Promise((_,C)=>{const E=new FileReader;E.onload=q=>{const N=q.target.result.split(",")[1];_(N)},E.onerror=C,E.readAsDataURL(g)});h.push({inlineData:{mimeType:"image/png",data:v}})}}}n={contents:h},s.model=l,s.customData=this.builder.settings.customData,s.payload=n,this.builder.payloads.push(s),this.builder.settings.consoleLog&&console.log(s);const a=this.builder.settings.generateMediaUrl_Google;let p={"Content-Type":"application/json",...this.builder.settings.headers};const w=await(await fetch(a,{signal:this.builder.mediaSignal,method:"POST",headers:p,body:JSON.stringify(s)})).json();this.builder.settings.consoleLog&&console.log(w),this.builder.isMediaGenerating=!1;const S=w.data;let L=this.renderResult(S,t,i);return{mediaGenerated:!0,status:"success",markdown:L.markdown,output:L.output,output2:L.output2}}async generateFal(e,t,i){let n="fal",s,r={};if(e.text_to_image_generation){let w=this.validateModel(e.model,n,"text_to_image_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let L=e.width||1280,y=e.height||768,x=e.aspect_ratio,g=e.num_images||1;if(g>4&&(g=4),x){let{w:se,h:re}=this.getDimension(x);L=se,y=re}let v=e.color1_red,_=e.color1_green,C=e.color1_blue,E=e.color2_red,q=e.color2_green,N=e.color2_blue,I=e.color3_red,$=e.color3_green,P=e.color3_blue,J=e.color4_red,j=e.color4_green,B=e.color4_blue,G=e.color5_red,D=e.color5_green,z=e.color5_blue,O=[];v&&_&&C&&!(v==="0"&&_==="0"&&C==="0")&&O.push({r:v,g:_,b:C}),E&&q&&N&&!(E==="0"&&q==="0"&&N==="0")&&O.push({r:E,g:q,b:N}),I&&$&&P&&!(I==="0"&&$==="0"&&P==="0")&&O.push({r:I,g:$,b:P}),J&&j&&B&&!(J==="0"&&j==="0"&&B==="0")&&O.push({r:J,g:j,b:B}),G&&D&&z&&!(G==="0"&&D==="0"&&z==="0")&&O.push({r:G,g:D,b:z});let W=await(async()=>{let se=[],re=this.builder.getFormValues();for(const le of re)if(le.value instanceof FileList&&le.type==="multifile"){const xe=le.value;if(xe.length>0){let he=0;for(const Ee of xe){he++;const $e=new FormData;$e.append("file",Ee),$e.append("customData",this.builder.settings.customData);let je=this.builder.settings.uploadMediaUrl_Fal;const Ce=await(await fetch(je,{method:"POST",body:$e})).json();if(Ce.ok){const Be=Ce.url;se.push(Be),this.builder.filesUploaded["file_"+he]=Be}}}}return se})();s={prompt:S,image_size:{width:L,height:y},num_images:g},w.indexOf("gemini")!==-1&&(s={prompt:S,input_image_urls:W}),w==="fal-ai/ideogram/v2a"&&(x=this.getClosestAspectRatio(L,y),s={prompt:S,aspect_ratio:x,num_images:g}),w.indexOf("recraft")!==-1&&(s={prompt:S,image_size:{width:L,height:y},num_images:g,colors:O}),r.model=w,r.customData=this.builder.settings.customData}else if(e.edit_area_in_image){let w=this.validateModel(e.model,n,"edit_area_in_image");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)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 y=await this.builder.upload.getInputURLs(n);if(y.error)return{mediaGenerated:!1,status:"error",message:y.error};let x=y[e.image_url],g=y[e.image_url+"_mask"];if(s={image_url:x,mask_url:g,prompt:S},r.model=w,!g){s={image_url:x,prompt:S};let v=this.validateModel(e.model,n,"edit_image");r.model=v}r.customData=this.builder.settings.customData}else if(e.text_to_2d_illustration_generation){let w=this.validateModel(e.model,n,"text_to_2d_illustration_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let L=e.width||1280,y=e.height||768,x=e.num_images||1;x>4&&(x=4);let g=e.style||"any",v=e.style_id||this.builder.settings._2dIllustrationStyleId,_=e.color1_red,C=e.color1_green,E=e.color1_blue,q=e.color2_red,N=e.color2_green,I=e.color2_blue,$=e.color3_red,P=e.color3_green,J=e.color3_blue,j=e.color4_red,B=e.color4_green,G=e.color4_blue,D=e.color5_red,z=e.color5_green,O=e.color5_blue,V=[];_&&C&&E&&!(_==="0"&&C==="0"&&E==="0")&&V.push({r:_,g:C,b:E}),q&&N&&I&&!(q==="0"&&N==="0"&&I==="0")&&V.push({r:q,g:N,b:I}),$&&P&&J&&!($==="0"&&P==="0"&&J==="0")&&V.push({r:$,g:P,b:J}),j&&B&&G&&!(j==="0"&&B==="0"&&G==="0")&&V.push({r:j,g:B,b:G}),D&&z&&O&&!(D==="0"&&z==="0"&&O==="0")&&V.push({r:D,g:z,b:O}),s={prompt:S,image_size:{width:L,height:y},num_images:x,style:g,style_id:v,colors:V},r.model=w,r.customData=this.builder.settings.customData}else if(e.text_to_digital_illustration_generation){let w=this.validateModel(e.model,n,"text_to_digital_illustration_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let L=e.width||1280,y=e.height||768,x=e.num_images||1;x>4&&(x=4);let g=e.style||"digital_illustration",v=e.color1_red,_=e.color1_green,C=e.color1_blue,E=e.color2_red,q=e.color2_green,N=e.color2_blue,I=e.color3_red,$=e.color3_green,P=e.color3_blue,J=e.color4_red,j=e.color4_green,B=e.color4_blue,G=e.color5_red,D=e.color5_green,z=e.color5_blue,O=[];v&&_&&C&&!(v==="0"&&_==="0"&&C==="0")&&O.push({r:v,g:_,b:C}),E&&q&&N&&!(E==="0"&&q==="0"&&N==="0")&&O.push({r:E,g:q,b:N}),I&&$&&P&&!(I==="0"&&$==="0"&&P==="0")&&O.push({r:I,g:$,b:P}),J&&j&&B&&!(J==="0"&&j==="0"&&B==="0")&&O.push({r:J,g:j,b:B}),G&&D&&z&&!(G==="0"&&D==="0"&&z==="0")&&O.push({r:G,g:D,b:z}),s={prompt:S,image_size:{width:L,height:y},num_images:x,style:g,colors:O},r.model=w,r.customData=this.builder.settings.customData}else if(e.text_to_book_cover_generation){let w=this.validateModel(e.model,n,"text_to_book_cover_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let L=e.width||1024,y=e.height||1365,x=e.num_images||1;x>4&&(x=1);let g="digital_illustration/cover",v=e.color1_red,_=e.color1_green,C=e.color1_blue,E=e.color2_red,q=e.color2_green,N=e.color2_blue,I=e.color3_red,$=e.color3_green,P=e.color3_blue,J=e.color4_red,j=e.color4_green,B=e.color4_blue,G=e.color5_red,D=e.color5_green,z=e.color5_blue,O=[];v&&_&&C&&!(v==="0"&&_==="0"&&C==="0")&&O.push({r:v,g:_,b:C}),E&&q&&N&&!(E==="0"&&q==="0"&&N==="0")&&O.push({r:E,g:q,b:N}),I&&$&&P&&!(I==="0"&&$==="0"&&P==="0")&&O.push({r:I,g:$,b:P}),J&&j&&B&&!(J==="0"&&j==="0"&&B==="0")&&O.push({r:J,g:j,b:B}),G&&D&&z&&!(G==="0"&&D==="0"&&z==="0")&&O.push({r:G,g:D,b:z}),s={prompt:S,image_size:{width:L,height:y},num_images:x,style:g,colors:O},r.model=w,r.customData=this.builder.settings.customData}else if(e.upscale_image){let w=this.validateModel(e.model,n,"upscale_image");if(!w)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 L=await this.builder.upload.getInputURLs(n);if(L.error)return{mediaGenerated:!1,status:"error",message:L.error};let y=L[e.image_url];if(!y)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:y,upscale_factor:2},r.model=w,r.customData=this.builder.settings.customData}else if(e.describe_image){let w=this.validateModel(e.model,n,"describe_image");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)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 y=await this.builder.upload.getInputURLs(n);if(y.error)return{mediaGenerated:!1,status:"error",message:y.error};let x=y[e.image_url];if(!x)return{mediaGenerated:!1,status:"error",message:this.out("Image not provided.")};s={image_url:x,prompt:`${S}. No talk. Answer only.`},r.model=w,r.customData=this.builder.settings.customData}else if(e.image_to_video_generation){let w=this.validateModel(e.model,n,"image_to_video_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;S=e.prompt||"stunning video";let L=e.duration||5;L>10&&(L=5);const y=await this.builder.upload.getInputURLs(n);if(y.error)return{mediaGenerated:!1,status:"error",message:y.error};let x=y[e.image_url];if(!x)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};s={prompt:S,image_url:x,duration:L,aspect_ratio:"16:9"},w.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=w,r.customData=this.builder.settings.customData}else if(e.text_to_video_generation){let w=this.validateModel(e.model,n,"text_to_video_generation");if(!w)return{mediaGenerated:!1,status:"error",message:this.out("Model not found.")};let S=e.prompt;if(!S)return{mediaGenerated:!1,status:"error",message:this.out("Please input a prompt.")};let L=e.duration||5;L>10&&(L=5),s={prompt:S,duration:L,aspect_ratio:"16:9"},w.indexOf("fal-ai/luma-dream-machine")!==-1&&delete s.duration,r.model=w,r.customData=this.builder.settings.customData}else if(e.text_to_speech){let w=this.validateModel(e.model,n,"text_to_speech");if(!w)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=w,r.customData=this.builder.settings.customData}let l=`https://queue.fal.run/${r.model}`;r.endpoint=l,r.payload=s,this.builder.payloads.push(r),this.builder.settings.consoleLog&&console.log(r);let c=this.builder.settings.generateMediaUrl_Fal;if(!c)return{mediaGenerated:!1,status:"error",message:this.out("Endpoint not configured: generateMediaUrl_Fal.")};let h,u={"Content-Type":"application/json",...this.builder.settings.headers},p=await(await fetch(c,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(r)})).json();if(p.ok)h=p.request_id;else return{mediaGenerated:!1,status:"error",message:p.error};const m=this.waitingFal(r,h,t,i);return this.builder.isMediaGenerating=!1,m}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 l={};l.model=r,l.customData=this.builder.settings.customData,l.payload=s,this.builder.payloads.push(l),this.builder.settings.consoleLog&&console.log(l);const c=this.builder.settings.generateMediaUrl_Google;let h={"Content-Type":"application/json",...this.builder.settings.headers};const a=await(await fetch(c,{signal:this.builder.mediaSignal,method:"POST",headers:h,body:JSON.stringify(l)})).json();this.builder.settings.consoleLog&&console.log(a);const p=a.data;let m=this.renderResult(p,i,n);return{mediaGenerated:!0,status:"success",markdown:m.markdown,output:m.output,output2:m.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 l=0;l<this.builder.selectedFiles.length;l++){const c=this.builder.selectedFiles[l],h=new FormData;h.append("file",c),h.append("customData",this.builder.settings.customData);let u=this.builder.settings.uploadMediaUrl_Fal;const p=await(await fetch(u,{method:"POST",body:h})).json();if(p.ok){const m=p.url;n.files.push(m),this.builder.filesUploaded["file_"+l]=m}r.push(n)}return r}const s=i.value;if(s.length>0){let r=0;for(const l of s){r++;const c=new FormData;c.append("file",l),c.append("customData",this.builder.settings.customData);let h=this.builder.settings.uploadMediaUrl_Fal;const a=await(await fetch(h,{method:"POST",body:c})).json();if(a.ok){const p=a.url;n.files.push(p),this.builder.filesUploaded["file_"+r]=p}}}e.push(n)}return e}async generate(e,t,i,n,s,r,l){if(i=i||this.builder.settings.defaultMediaGenerationProvider,i==="google"&&e.trim().startsWith("{"))return this.generate_GoogleMediaByJSON(e,t,r,l);this.builder.isMediaGenerating=!0,this.mediaController=new AbortController,this.builder.mediaSignal=this.mediaController.signal;let c,h=!1,u;if(e.trim().startsWith("{"))try{u=JSON.parse(e),u&&typeof u=="object"&&(h=!0)}catch{return{mediaGenerated:!1,status:"error",message:this.out("Incorrect JSON format.")}}if(h){let a=t.trim();if(!a)return{mediaGenerated:!1,status:"error",message:this.out("Please provide model information in the context.")};let p=await this.uploadMultiple();((y,x)=>{const g=v=>{if(Array.isArray(v)){const _=v[0],C=x.find(E=>E.name===_);if(C&&v.every(E=>E===_))return C.files;for(let E=0;E<v.length;E++)v[E]=g(v[E])}else if(typeof v=="object"&&v!==null)for(let _ in v)v[_]=g(v[_]);return v};return g(y)})(u,p),i||(a.startsWith("fal")?i="fal":i="replicate");const w=y=>typeof y=="object"&&y!==null&&!Array.isArray(y),S=await this.builder.upload.getInputURLs(i);if(S.error)return{mediaGenerated:!1,status:"error",message:S.error};Object.keys(u).forEach(y=>{Object.keys(S).forEach(x=>{if(u[y]===x){let g=S[x];u[y]=g}if(Array.isArray(u[y])){for(let g=0;g<u[y].length;g++)if(u[y][g]===x){let v=S[x];u[y][g]=v}}})}),Object.keys(u).forEach(y=>{let x=u[y];if(w(x))for(const g in x)Object.prototype.hasOwnProperty.call(x,g)&&Object.keys(S).forEach(v=>{if(x[g]===v){let _=S[v];x[g]=_,v===_&&!_.startsWith("http")&&(x[g]="")}});if(Array.isArray(x)){for(let g=0;g<x.length;g++)if(w(x[g]))for(const v in x[g])Object.prototype.hasOwnProperty.call(x[g],v)&&Object.keys(S).forEach(_=>{if(x[g][v]===_){let C=S[_];x[g][v]=C,_===C&&!C.startsWith("http")&&(x[g][v]="")}});u[y]=[...x.filter(g=>g!=="")]}});let L={};if(L.model=a,L.customData=this.builder.settings.customData,i==="replicate"&&a.indexOf(":")!==-1){const y=a.split(":");L.version=y[1]}if(i==="replicate")if(a.indexOf(":")!==-1){let y=this.builder.settings.replicateEndpoint1;L.endpoint=y,L.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 1")}else{let y=this.builder.settings.replicateEndpoint2;y=y.replace("{MODEL}",L.model),L.endpoint=y,L.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD 2")}else if(i==="fal"){let y=`https://queue.fal.run/${L.model}`;L.endpoint=y,L.payload=u,this.builder.settings.consoleLog&&console.log("JSON PAYLOAD")}return this.builder.payloads.push(L),this.builder.settings.consoleLog&&console.log(L),this.generateMediaByJSON(L,i,r,l)}try{if(c=await this.checkIntent(e,i,s),this.builder.settings.consoleLog&&console.log(c),!c)return{mediaGenerated:!1,status:"aborted",message:this.out("Request aborted.")};if(c.minimize_image){if(!c.image_url)return{mediaGenerated:!1,status:"error",message:this.out("Image reference not found.")};const p=await this.builder.upload.getInputURLs();if(p.error)return{mediaGenerated:!1,status:"error",message:p.error};let w={image_url:p[c.image_url]||c.image_url,customData:this.builder.settings.customData};this.builder.payloads.push(w),this.builder.settings.consoleLog&&console.log(w);let S={"Content-Type":"application/json",...this.builder.settings.headers};const y=await(await fetch(this.builder.settings.minimizeImageUrl,{signal:this.builder.mediaSignal,method:"POST",headers:S,body:JSON.stringify(w)})).json();if(this.builder.output.push(y),y.error)return this.builder.settings.consoleLog&&console.log(y.error),this.builder.isMediaGenerating=!1,{mediaGenerated:!1,status:"error",message:y.error};{const x=y.url,g=`
|
|
262
|
+
<div class="image-container">
|
|
263
|
+
<div>
|
|
264
|
+
<img src="${x}" />
|
|
265
|
+
<div>
|
|
266
|
+
<a class="link-view" href="${x}" target="_blank" rel="noopener noreferrer">${this.out("View")}</a>
|
|
267
|
+
<a class="link-download" href="${x}" download>${this.out("Download")}</a>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
</div>`;let v=``;return l?(r.innerHTML="",r.remove()):(r.innerHTML=g,this.builder.outputHtml+=`<div class="result-container">${g}</div>`),this.builder.isMediaGenerating=!1,{mediaGenerated:!0,status:"success",markdown:v,output:[x]}}}else{if(i==="fal")return this.generateFal(c,r,l);if(i==="replicate")return this.generateReplicate(c,r,l);if(i==="google")return this.generateGoogle(c,r,l);if(i==="openai")return this.generateOpenAI(c,r,l)}}catch(a){return this.builder.settings.consoleLog&&console.log(a),this.builder.isMediaGenerating=!1,a.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 l={"Content-Type":"application/json",...this.builder.settings.headers};const h=await(await fetch(s,{signal:this.builder.mediaSignal,method:"POST",headers:l,body:JSON.stringify(e)})).json();if(this.builder.isMediaGenerating=!1,t==="fal"){let u=h.request_id;return this.waitingFal(e,u,i,n)}if(h.error)return this.builder.settings.consoleLog&&console.log(h.error),{mediaGenerated:!1,status:"error",message:h.error};if(r){let u;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};return this.waitingReplicate(e,u,i,n)}else{const u=h.data;let a=this.renderResult(u,i,n);return{mediaGenerated:!0,status:"success",markdown:a.markdown,output:a.output,output2:a.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 l=1;l<n.length;l++){const c=Math.abs(i-n[l].ratio);c<r&&(r=c,s=n[l])}return s.aspect}out(e){if(this.opts.lang){let t=this.opts.lang[e];return t||e}else return e}}class Bs{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 l=r.value;i[n.name]=l}}}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,l=this.builder.getId(),c={image:s,filename:`${e}_${l}.png`,customData:this.builder.settings.customData},h;t==="replicate"?h=this.builder.settings.uploadBase64Url:t==="fal"?h=this.builder.settings.uploadBase64Url_Fal:h=this.builder.settings.uploadBase64Url_Fal||this.builder.settings.uploadBase64Url;let u={"Content-Type":"application/json",...this.builder.settings.headers},p=await(await fetch(h,{signal:this.builder.mediaSignal,method:"POST",headers:u,body:JSON.stringify(c)})).json();return p.ok&&(r=p.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 l=new FormData;l.append("file",this.builder.photoBlob[e],`photo_${r}.jpg`),l.append("customData",this.builder.settings.customData);let c;t==="replicate"?c=this.builder.settings.uploadMediaUrl:t==="fal"?c=this.builder.settings.uploadMediaUrl_Fal:c=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const u=await(await fetch(c,{method:"POST",body:l})).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 l;t==="replicate"?l=this.builder.settings.uploadMediaUrl:t==="fal"?l=this.builder.settings.uploadMediaUrl_Fal:l=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const h=await(await fetch(l,{method:"POST",body:r})).json();return h.ok?(s=h.url,n=h.filename,{filename:n,url:s}):{error:this.out("Upload file failed.")}}if(i){const r=i.files[0];if(r){n=r.name;const l=new FormData;l.append("file",r),l.append("customData",this.builder.settings.customData);let c;t==="replicate"?c=this.builder.settings.uploadMediaUrl:t==="fal"?c=this.builder.settings.uploadMediaUrl_Fal:c=this.builder.settings.uploadMediaUrl_Fal||this.builder.settings.uploadMediaUrl;const u=await(await fetch(c,{method:"POST",body:l})).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 Fs{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
|
+
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"
|
|
272
|
+
stroke-linejoin="round" class="icon-close">
|
|
273
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
274
|
+
<path d="M18 6l-12 12" /><path d="M6 6l12 12" />
|
|
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 l=document.createElement("label");r.appendChild(l),l.innerHTML=`${this.out("Brush Size")}:
|
|
276
|
+
<input type="range" class="brush-size" min="5" max="100" value="30">`;const c=l.querySelector(".brush-size"),h=document.createElement("button");h.className="btn-undobrush",h.title=this.out("Undo"),h.innerHTML=`
|
|
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
|
+
class="icon-undo">
|
|
279
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
280
|
+
<path d="M9 14l-4 -4l4 -4"></path>
|
|
281
|
+
<path d="M5 10h11a4 4 0 1 1 0 8h-1"></path>
|
|
282
|
+
</svg>`,r.appendChild(h);const u=document.createElement("button");u.className="btn-redobrush",u.title=this.out("Redo"),u.innerHTML=`
|
|
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
|
+
class="icon-redo">
|
|
285
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
|
286
|
+
<path d="M15 14l4 -4l-4 -4"></path>
|
|
287
|
+
<path d="M19 10h-11a4 4 0 1 0 0 8h1"></path>
|
|
288
|
+
</svg>`,r.appendChild(u);const a=document.createElement("button");a.className="btn-clearbrush",a.title=this.out("Clear"),a.innerHTML=`
|
|
289
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
|
290
|
+
stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"
|
|
291
|
+
class="icon-eraser">
|
|
292
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
293
|
+
<path d="M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3" />
|
|
294
|
+
<path d="M18 13.3l-6.3 -6.3" /><
|
|
295
|
+
/svg>`,r.appendChild(a);const p=document.createElement("button");p.className="btn-enlargemask",a.title=this.out("Enlarge"),p.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
|
|
296
|
+
fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"
|
|
297
|
+
class="icon-maximize">
|
|
298
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
299
|
+
<path d="M16 4l4 0l0 4" /><path d="M14 10l6 -6" />
|
|
300
|
+
<path d="M8 20l-4 0l0 -4" /><path d="M4 20l6 -6" />
|
|
301
|
+
<path d="M16 20l4 0l0 -4" /><path d="M14 14l6 6" />
|
|
302
|
+
<path d="M8 4l-4 0l0 4" /><path d="M4 4l6 6" />
|
|
303
|
+
</svg>`,r.appendChild(p);const m=document.createElement("input");m.type="hidden",m.name=this.settings.name,m.className="inp-imagemask",m.value="",n.appendChild(m);const w=document.createElement("canvas");w.className="imagemask";const S=w.getContext("2d",{willReadFrequently:!0}),L=document.createElement("canvas"),y=L.getContext("2d",{willReadFrequently:!0}),x=this.element.querySelector(".inp-imagemask"),g=O=>{const V=document.createElement("canvas"),W=V.getContext("2d",{willReadFrequently:!0});V.width=O.width,V.height=O.height,W.clearRect(0,0,O.width,O.height),W.fillStyle="black",W.fillRect(0,0,O.width,O.height),W.drawImage(O,0,0);const se=V.toDataURL("image/png");let re=document.querySelector(".imagemask-output");re||(re=document.createElement("img"),re.className="imagemask-output",document.body.appendChild(re)),re.src=se,this.empty||(x.value=se)};let v=[],_=[];const C=()=>{v.push(L.toDataURL()),v.length>10&&v.shift(),_=[]},E=O=>{const V=new Image;V.src=O,V.onload=()=>{S.clearRect(0,0,w.width,w.height),S.drawImage(V,0,0,w.width,w.height),y.clearRect(0,0,L.width,L.height),y.drawImage(V,0,0,L.width,L.height),g(L)}};w.addEventListener("mousedown",()=>{C()}),h.addEventListener("click",O=>{O.preventDefault(),v.length>0&&(_.push(w.toDataURL()),E(v.pop()))}),u.addEventListener("click",O=>{O.preventDefault(),_.length>0&&(v.push(w.toDataURL()),E(_.pop()))});const q=document.createElement("img");s.appendChild(q),s.appendChild(w),this.loaded=()=>{s.style.display="flex";const O=document.querySelector(".imagemask-controls");O.style.display="flex",e.style.display="flex",$(),v=[],_=[],S.clearRect(0,0,w.width,w.height),y.clearRect(0,0,L.width,L.height),this.empty=!0,x.value="";try{g(L)}catch{}},q.onload=()=>{this.loaded()};let N=null,I=null;const $=()=>{w.width>0&&w.height>0&&(N=S.getImageData(0,0,w.width,w.height),I=y.getImageData(0,0,L.width,L.height));const O=q.offsetWidth,V=q.offsetHeight,W=window.devicePixelRatio||1;w.width=O*W,w.height=V*W,S.scale(W,W),w.style.width=`${O}px`,w.style.height=`${V}px`;const se=q.naturalWidth,re=q.naturalHeight;if(L.width=se*W,L.height=re*W,y.scale(W,W),L.style.width=`${se}px`,L.style.height=`${re}px`,N){const le=document.createElement("canvas");le.width=N.width,le.height=N.height,le.getContext("2d").putImageData(N,0,0);const he=document.createElement("canvas");he.width=I.width,he.height=I.height,he.getContext("2d").putImageData(I,0,0),S.drawImage(le,0,0,N.width,N.height,0,0,w.width,w.height),y.drawImage(he,0,0,I.width,I.height,0,0,L.width,L.height)}};let P=!1,J=parseInt(c.value,10);c.addEventListener("input",O=>{J=parseInt(O.target.value,10)});const j=O=>{const V=w.getBoundingClientRect();if(O.touches){const W=O.touches[0];return{x:W.clientX-V.left,y:W.clientY-V.top}}return{x:O.clientX-V.left,y:O.clientY-V.top}},B=O=>{P=!0,D(O)},G=()=>{P=!1,S.beginPath(),this.empty=!1,g(L)},D=O=>{if(!P)return;const{x:V,y:W}=j(O),se=L.width/w.width,re=L.height/w.height,le=V*se,xe=W*re;S.fillStyle="rgb(255, 255, 255)",S.beginPath(),S.arc(V,W,J/2,0,Math.PI*2),S.fill(),y.fillStyle="rgb(255, 255, 255)",y.beginPath(),y.arc(le,xe,J/2*se,0,Math.PI*2),y.fill()};w.addEventListener("mousedown",B),w.addEventListener("mouseup",G),w.addEventListener("mousemove",D),w.addEventListener("touchstart",O=>{B(O),O.preventDefault()},{passive:!1}),w.addEventListener("touchend",O=>{G(),O.preventDefault()}),w.addEventListener("touchmove",O=>{D(O),O.preventDefault()},{passive:!1}),a.addEventListener("click",O=>{O.preventDefault(),C(),S.clearRect(0,0,w.width,w.height),y.clearRect(0,0,L.width,L.height),this.empty=!0,x.value="",g(L)}),window.addEventListener("resize",$);const z=O=>{O?(e.setAttribute("aria-modal","true"),e.setAttribute("role","dialog"),e.classList.add("fullscreen"),t.style.display="block",i.style.display="flex",p.style.display="none"):(e.removeAttribute("aria-modal"),e.removeAttribute("role"),e.classList.remove("fullscreen"),t.style.display="none",i.style.display="none",p.style.display=""),$()};p.addEventListener("click",O=>{O.preventDefault(),z(!0)}),i.addEventListener("click",O=>{O.preventDefault(),z(!1)}),document.addEventListener("keydown",O=>{O.key==="Escape"&&z(!1)})}}class Gs{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 js({lang:this.settings.lang},this),this.upload=new Bs({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(a=>{const p=a.supports||[];if(p.length===0)return!0;const{fal:m,replicate:w,web:S,openai:L,google:y}=this.settings.templatesConfig;return!S&&p.includes("web")||!y&&p.includes("google")||!L&&p.includes("openai")?!1:!m&&!w?!(p.includes("fal")||p.includes("replicate")):!m&&p.includes("fal")?p.includes("replicate"):!w&&p.includes("replicate")?p.includes("fal"):!0});const r=this.settings.templateFilters,l={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")}},c=document.createElement("div");c.className="app-filters",e.appendChild(c);const h=document.createElement("ul");h.className="app-list",e.appendChild(h);const u=a=>{let p=n.filter(w=>a==="all"||w.categories.includes(a));const m=this.settings.templateOutput||["image","video","audio","text"];p=p.filter(w=>w.categories.every(S=>m.includes(S))),this.renderList(p,h)};r.forEach(a=>{const p=document.createElement("button");p.textContent=l[a].desc,p.setAttribute("data-value",a),a==="all"&&p.classList.add("active"),p.addEventListener("click",()=>{c.querySelectorAll("button").forEach(w=>w.classList.remove("active")),p.classList.add("active"),u(a)}),c.appendChild(p)}),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(),l=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===l.name)||this.selectedFiles.push(l):this.selectedFiles=[l],this.setSelectedFiles(this.selectedFiles),this.renderSelectedFiles(),t.closest(".image-mask")&&this.objImageMask&&this.objImageMask.loadImage(l)}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 l=document.createElement("button");l.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
|
+
<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>`,l.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(l),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 c=new DataTransfer;t.files=c.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 l=this.element.querySelector('input[type="file"]');l&&l.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,l=i.form.thumbnail,c="";if(r&&l){let p=r+l;c=`<img class="thumbnail" src="${p}" alt="${i.name}" />`,i.form.thumbnailFit&&(c=`<img class="thumbnail" style="object-fit:${i.form.thumbnailFit}" src="${p}" alt="${i.name}" />`)}const h=document.createElement("div");h.className="div-template-buttons";let u=!1,a=!1;if(this.settings.templateButtons&&this.settings.templateButtons.viewButton&&this.settings.templateButtons.viewButton.text){const p=document.createElement("button");p.className="btn-template-view",p.innerText=this.out(this.settings.templateButtons.viewButton.text),h.appendChild(p),p.addEventListener("click",m=>{if(m.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 p=document.createElement("button");p.className="btn-template-use",p.innerText=this.out(this.settings.templateButtons.useButton.text),h.appendChild(p),p.addEventListener("click",m=>{m.preventDefault(),this.settings.onSelectTemplate&&this.settings.onSelectTemplate(i),this.trigger("templateUse",i)}),a=!0}s.innerHTML=`
|
|
306
|
+
${c}
|
|
307
|
+
<div class="card-text">
|
|
308
|
+
<div class="title">${i.name}</div>
|
|
309
|
+
<div class="description">${i.form.description}</div>
|
|
310
|
+
${i.info?` <div class="info mt-1">${i.info}</div>`:""}
|
|
311
|
+
</div>
|
|
312
|
+
`,u||a?(s.querySelector(".card-text").appendChild(h),s.classList.remove("cursor-pointer"),s.classList.add("cursor-default")):(s.classList.add("cursor-pointer"),s.classList.remove("cursor-default")),n.appendChild(s),u||a||s.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("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(p=>{p.remove()});let l=!1;n.body.innerText.trim()===""&&(l=!0);const h=document.createElement("div");h.className="result-tool",e.appendChild(h);const u=document.createElement("button");u.className="btn-result-tool",u.innerHTML=`
|
|
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
|
+
<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
|
+
</svg>
|
|
316
|
+
<span>${this.out("Copy")}</span>
|
|
317
|
+
`,l||h.appendChild(u);const a=document.createElement("button");a.className="btn-result-tool",a.innerHTML=`
|
|
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
|
+
<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
|
+
</svg>
|
|
321
|
+
<span>${this.out("Clear")}</span>
|
|
322
|
+
`,h.appendChild(a),u&&u.addEventListener("click",p=>{p.preventDefault();const m=e.cloneNode(!0),w=m.querySelector(".result-tool");w&&w.remove(),m.querySelectorAll(".link-view, .link-download").forEach(y=>{y.remove()}),m.style.position="fixed",m.style.left="-9999px",document.body.appendChild(m);const L=m.innerText.trim();document.body.removeChild(m),navigator.clipboard.writeText(L),u.innerHTML=`
|
|
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
|
+
<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
|
+
</svg>
|
|
326
|
+
<span>${this.out("Copied")}</span>
|
|
327
|
+
`,setTimeout(()=>{u.innerHTML=`
|
|
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
|
+
<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
|
+
</svg>
|
|
331
|
+
<span>${this.out("Copy")}</span>
|
|
332
|
+
`},600)}),a.addEventListener("click",p=>{p.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 c=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${c}px`}else if(window.innerHeight+window.scrollY>i)e.style.position="",e.style.top="";else{const c=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${c}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 l=null;const c=()=>{const h=e.offsetTop;h===l?(n(),s()):(l=h,requestAnimationFrame(c))};c()},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 a=document.createElement("div");a.className="form-header",i.appendChild(a);const p=document.createElement("h1");p.className="form-title",p.innerText=t.title||this.out("Your Form Title Here"),a.appendChild(p);const m=document.createElement("p");m.className="form-desc",m.innerText=t.description||this.out("Your Description Here"),a.appendChild(m)}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 l=1;t.elements&&t.elements.forEach(a=>{if(a.type==="spacer"){const y=document.createElement("div");y.className="form-spacer",a.spacerHeight&&!isNaN(parseFloat(a.spacerHeight))&&(y.style.height=a.spacerHeight+"px"),a.displayInOutput||r.appendChild(y);return}if(a.type==="separator"){const y=document.createElement("hr");y.style.borderTopColor=a.color,a.displayInOutput||r.appendChild(y);return}if(a.type==="html"){if(a.html){const y=document.createElement("div");y.innerHTML=a.html,a.displayInOutput||r.appendChild(y)}return}if(a.type==="heading"){const y=document.createElement(a.heading||"h2");y.innerHTML=a.headingText||this.out("Your Heading Here!"),a.displayInOutput||r.appendChild(y);return}if(a.type==="paragraph"){const y=document.createElement("p");y.innerHTML=a.paragraphText||this.out("Your paragraph content here!"),a.displayInOutput||r.appendChild(y);return}if(a.type==="media"){if(a.tag==="video"){const y=document.createElement("video");y.style.width="100%",y.style.height="auto",y.controls=!0;var p=document.createElement("source");p.src=a.url,p.type="video/mp4",y.appendChild(p),a.displayInOutput||r.appendChild(y)}else if(a.tag==="audio"){const y=document.createElement("audio");y.controls=!0;let x=document.createElement("source");x.src=a.url,x.type="audio/mp3",y.appendChild(x),a.displayInOutput||r.appendChild(y)}else if(a.tag==="img"){const y=document.createElement("img");y.src=a.url,y.setAttribute("alt",this.out("Output Image")),a.displayInOutput||r.appendChild(y)}return}if(a.type==="image"){const y=document.createElement("img");y.src=a.url,y.setAttribute("alt",this.out("Output Image")),a.displayInOutput||r.appendChild(y);return}if(a.type==="video"){const y=document.createElement("video");y.style.width="100%",y.style.height="auto",y.controls=!0;let x=document.createElement("source");x.src=a.url,x.type="video/mp4",y.appendChild(x),a.displayInOutput||r.appendChild(y);return}if(a.type==="audio"){const y=document.createElement("audio");y.controls=!0;let x=document.createElement("source");x.src=a.url,x.type="audio/mp3",y.appendChild(x),a.displayInOutput||r.appendChild(y);return}const m=document.createElement("div");m.className="form-field",a.type==="hidden"&&(m.className="hidden"),a.displayInOutput||r.appendChild(m),a.type==="color"&&m.classList.add("field-color");const w=a.type;let S=a.name;if(r.querySelector(`[name="${S}"]`)&&(l++,S=S+"_"+l),w==="short-text"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`short_text_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`short_text_label_${y}`,g.type="text",g.name=S,g.value=a.value||"",g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="long-text"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`long_text_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("textarea");g.id=`long_text_label_${y}`,g.name=S,g.value=a.value||"",g.className="inp-base",g.style.height=a.height+"px",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="number"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`number_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`number_label_${y}`,g.type="number",g.name=S,g.value=a.value||"",g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="slider"){m.classList.add("input-slider");let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`number_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const N=document.createElement("div");N.className="field-note",N.innerHTML=a.fieldNote,m.appendChild(N)}const g=document.createElement("div");g.className="slider-container",m.appendChild(g);const v=document.createElement("div");v.className="slider-values",g.appendChild(v);const _=document.createElement("span");v.appendChild(_),_.innerText=a.minValue;const C=document.createElement("span");v.appendChild(C),C.innerText=a.maxValue;const E=document.createElement("input");E.id=`number_label_${y}`,E.type="range",E.name=S,E.setAttribute("min",a.minValue),E.setAttribute("max",a.maxValue),E.setAttribute("step",a.step),E.setAttribute("value",a.value||0),g.appendChild(E);const q=document.createElement("div");q.className="current-value",g.appendChild(q),g.querySelector(".current-value").textContent=a.value||0,E.addEventListener("input",()=>{g.querySelector(".current-value").textContent=E.value})}if(w==="select"){let y=this.getId();const x=document.createElement("div");if(x.id=`radio_group_label_${y}`,x.className="field-label-normal",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("div");if(g.setAttribute("aria-labelledby",`radio_group_label_${y}`),g.setAttribute("role","group"),g.className="div-options",m.appendChild(g),a.choices&&a.choices.forEach((v,_)=>{let C=v;a.choicesText&&(C=a.choicesText[_]||v);const E=document.createElement("label");E.setAttribute("for",`${y}_${_}`),E.className="option-label",g.appendChild(E);const q=document.createElement("input");q.type="radio",q.className="peer",q.id=`${y}_${_}`,q.name=S,q.value=v,E.appendChild(q),_===a.selected&&(q.checked=!0);const N=document.createElement("span");N.className="peer-span-rounded",E.appendChild(N);const I='<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>';N.innerHTML=I,_===0&&a.isRequired&&q.setAttribute("required","required");const $=document.createElement("span");$.innerText=C,E.appendChild($),q.addEventListener("change",this.changeListener)}),a.showOtherItem){const v=document.createElement("label");v.setAttribute("for",y+"_other"),v.className="option-label",g.appendChild(v);const _=document.createElement("input");_.type="radio",_.className="peer",_.id=y+"_other",_.name=S,_.value="other",v.appendChild(_);const C=document.createElement("span");C.className="peer-span-rounded",v.appendChild(C);const E='<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>';C.innerHTML=E;const q=document.createElement("span");q.innerText=a.otherText,v.appendChild(q);const N=document.createElement("div");m.appendChild(N);const I=document.createElement("input");I.type="text",I.name=S+"_other",I.className="inp-base",N.appendChild(I),_.addEventListener("change",this.changeListener),I.addEventListener("input",this.inputListener)}}if(w==="multi-select"){let y=this.getId();const x=document.createElement("div");if(x.id=`checkbox_group_label_${y}`,x.className="field-label-normal",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("div");if(g.setAttribute("aria-labelledby",`checkbox_group_label_${y}`),g.setAttribute("role","group"),g.className="div-options",m.appendChild(g),a.choices&&a.choices.forEach((v,_)=>{let C=v;a.choicesText&&(C=a.choicesText[_]||v);const E=document.createElement("label");E.setAttribute("for",`${y}_${_}`),E.className="option-label",g.appendChild(E);const q=document.createElement("input");q.type="checkbox",q.className="peer",q.id=`${y}_${_}`,q.name=S+"[]",q.value=v,E.appendChild(q);const N=document.createElement("span");N.className="peer-span-square",E.appendChild(N);const I=`<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
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
|
|
334
|
+
</svg>`;N.innerHTML=I;const $=document.createElement("span");$.innerText=C,E.appendChild($),q.addEventListener("change",this.changeListener)}),a.showOtherItem){const v=document.createElement("label");v.setAttribute("for",y+"_other"),v.className="option-label",g.appendChild(v);const _=document.createElement("input");_.type="checkbox",_.className="peer",_.id=y+"_other",_.name=S,_.value="other",v.appendChild(_);const C=document.createElement("span");C.className="peer-span-square",v.appendChild(C);const E=`<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
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
|
|
336
|
+
</svg>`;C.innerHTML=E;const q=document.createElement("span");q.innerText=a.otherText,v.appendChild(q);const N=document.createElement("div");m.appendChild(N);const I=document.createElement("input");I.type="text",I.name=S+"_other",I.className="inp-base",N.appendChild(I),_.addEventListener("change",this.changeListener),I.addEventListener("input",this.inputListener)}}if(w==="switch"){let y=this.getId();const x=document.createElement("label");if(x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),x.id=`switch_${y}`,m.appendChild(x),a.fieldNote){const E=document.createElement("div");E.className="field-note",E.innerHTML=a.fieldNote,m.appendChild(E)}const g=document.createElement("div");g.className="switch",g.tabIndex=0,g.role="switch",g.setAttribute("aria-labelledby",`switch_${y}`),g.setAttribute("aria-checked","false"),g.setAttribute("data-checked","false"),m.appendChild(g);const v=document.createElement("div");v.className="switch-thumb",g.appendChild(v);const _=document.createElement("input");_.id=`switch_${y}`,_.type="text",_.name=S,_.style.cssText="opacity:0.01;width:1px;height:1px;position:absolute;bottom:0px;left:25px;",_.setAttribute("tabindex","-1"),a.isRequired&&(_.setAttribute("required","required"),_.setCustomValidity(this.out("Please toggle this switch to proceed."))),g.appendChild(_),a.value==="true"?(g.setAttribute("aria-checked","true"),g.setAttribute("data-checked","true"),_.value="true",a.isRequired&&_.setCustomValidity("")):(g.setAttribute("aria-checked","false"),g.setAttribute("data-checked","false"),_.value="false",a.isRequired&&_.setCustomValidity(this.out("Please toggle this switch to proceed."))),x.addEventListener("click",()=>{g.focus()});const C=()=>{const E=g.getAttribute("aria-checked")==="true";g.setAttribute("aria-checked",!E),g.setAttribute("data-checked",!E),E?(_.value="false",a.isRequired&&_.setCustomValidity(this.out("Please toggle this switch to proceed."))):(_.value="true",a.isRequired&&_.setCustomValidity(""));const q=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(q)};g.addEventListener("keydown",E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),C())}),g.addEventListener("click",()=>{C()})}if(w==="dropdown"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`dropdown_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const $=document.createElement("div");$.className="field-note",$.innerHTML=a.fieldNote,m.appendChild($)}const g=document.createElement("div");g.className="relative",m.appendChild(g);const v=document.createElement("div");v.className="relative inline-block",g.appendChild(v);const _=document.createElement("select");_.id=`dropdown_${y}`,_.name=S,a.isRequired&&_.setAttribute("required","required"),v.appendChild(_);const C=document.createElement("option");if(C.setAttribute("selected","selected"),C.setAttribute("disabled","disabled"),C.value="",C.innerText=a.placeholder,_.appendChild(C),a.choices&&a.choices.forEach(($,P)=>{let J=$;a.choicesText&&(J=a.choicesText[P]||$);const j=document.createElement("option");j.value=$,j.innerText=J,_.appendChild(j),P===a.selected&&(C.remove(),j.setAttribute("selected","selected"))}),a.showOtherItem){const $=document.createElement("option");$.value="other",$.innerText=a.otherText,_.appendChild($)}const E=document.createElement("div");E.className="select-arrow",v.appendChild(E),this.appendHtml(E,`
|
|
337
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
338
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
339
|
+
</svg>
|
|
340
|
+
`);const q=document.createElement("input");q.type="text",q.id=`input_other_${y}`,q.name=S+"_other",q.className="input-other hidden inp-base",m.appendChild(q);const N=m.querySelector(`#dropdown_${y}`),I=m.querySelector(`#input_other_${y}`);N.addEventListener("change",()=>{N.value==="other"?(I.classList.remove("hidden"),I.focus()):I.classList.add("hidden");const $=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange($)}),q.addEventListener("input",this.inputListener)}if(w==="date"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`date_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`date_${y}`,g.type="date",g.name=S,g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("change",this.changeListener)}if(w==="time"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`time_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`time_${y}`,g.type="time",g.name=S,g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("change",this.changeListener)}if(w==="datetime"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`datetime_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`datetime_${y}`,g.type="datetime-local",g.name=S,g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("change",this.changeListener)}if(w==="color"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`color_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`color_${y}`,g.type="color",g.name=S,g.value=a.value||"",g.className="input-color",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="file"||w==="multifile"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`file_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const H=document.createElement("div");H.className="field-note",H.innerHTML=a.fieldNote,m.appendChild(H)}const g=document.createElement("div");g.className="file-input-wrapper",w==="file"&&g.setAttribute("aria-label",this.out(this.settings.fileUploadText)),w==="multifile"&&g.setAttribute("aria-label",this.out(this.settings.multiFileUploadText)),m.appendChild(g);const v=document.createElement("input");v.id=`input_url_label_${y}`,v.type="text",v.name=S+"__url",v.value=a.value||"",v.className="inp-base input-file-url",v.placeholder=a.placeholder||this.out("Enter URL."),m.appendChild(v),v.addEventListener("input",()=>{const H=m.querySelector(".btn-clearfile");H&&H.click(),this.inputListener(),v.value!==""?a.isRequired&&_.removeAttribute("required"):a.isRequired&&_.setAttribute("required","required"),De(v.value),this.clearSelectedFiles()}),a.useURL?v.style.display="":v.style.display="none";const _=document.createElement("input");_.id=`file_${y}`,_.type="file",w==="multifile"&&(_.multiple=!0),_.name=S,a.isRequired&&_.setAttribute("required","required"),_.className="peer",g.appendChild(_);const C=document.createElement("div");C.className="file-drop-area",g.appendChild(C);const E=document.createElement("div");E.className="file-controls",E.id=`drag_message_${y}`,g.appendChild(E);let q;(!a.source||a.source&&a.source==="local"||a.source&&a.source==="local_and_camera")&&(q=document.createElement("div"),q.className="file-drop-info",w==="file"&&(q.innerHTML=this.out(this.settings.fileUploadText)),w==="multifile"&&(q.innerHTML=this.out(this.settings.multiFileUploadText)),E.appendChild(q));let N;(!a.source||a.source&&a.source==="local"||a.source&&a.source==="local_and_camera")&&(N=document.createElement("button"),N.className="btn-selectfile",N.innerHTML=`
|
|
341
|
+
<svg style="fill:none"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" class="icon-folder-open"><path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
342
|
+
<path d="M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2" />
|
|
343
|
+
</svg>
|
|
344
|
+
${this.out("Select File")}
|
|
345
|
+
`,E.appendChild(N));let I;(a.source&&a.source==="camera"||a.source&&a.source==="local_and_camera")&&(I=document.createElement("button"),I.className="btn-takephoto",I.innerHTML=`
|
|
346
|
+
<svg style="fill:none"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" class="icon-camera">
|
|
347
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 7h1a2 2 0 0 0 2 -2a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1a2 2 0 0 0 2 2h1a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2" /><path d="M9 13a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
|
|
348
|
+
</svg>
|
|
349
|
+
${this.out("Take Photo")}
|
|
350
|
+
`,E.appendChild(I));const $=document.createElement("div");$.className="file-preview-container",g.appendChild($);const P=document.createElement("div");P.className="file-drop-info-highlight",P.id=`file_name_${y}`,g.appendChild(P),N&&N.addEventListener("click",H=>{H.preventDefault(),_.click()}),g.classList.add("disabledrop"),(!a.source||a.source&&a.source==="local"||a.source&&a.source==="local_and_camera")&&(g.classList.remove("disabledrop"),g.addEventListener("dragover",H=>{H.preventDefault(),Array.from(H.dataTransfer.items).some(pe=>pe.kind==="file")&&g.classList.add("drag-over")}),g.addEventListener("dragleave",()=>{g.classList.remove("drag-over")}),w==="file"?g.addEventListener("drop",H=>{if(H.preventDefault(),H.dataTransfer.files&&H.dataTransfer.files.length>0){g.classList.remove("drag-over");const Q=H.dataTransfer.files[0];Q&&(_.files=H.dataTransfer.files,Ce(Q),this.clearSelectedFiles())}}):w==="multifile"&&g.addEventListener("drop",H=>{if(H.preventDefault(),H.dataTransfer.files&&H.dataTransfer.files.length>0){g.classList.remove("drag-over"),$.innerHTML="";const Q=H.dataTransfer.files;Q.length>0&&(_.files=Q,Array.from(Q).forEach(pe=>{Be(pe)}),this.clearSelectedFiles())}})),w==="file"?_.addEventListener("change",()=>{const H=_.files[0];H&&(Ce(H),this.clearSelectedFiles())}):w==="multifile"&&_.addEventListener("change",()=>{$.innerHTML="";const H=_.files;Array.from(H).forEach(Q=>{Q&&(Be(Q),this.clearSelectedFiles())})});const J={images:[{type:"image/jpeg",extensions:".jpg, .jpeg"},{type:"image/png",extensions:".png"},{type:"image/gif",extensions:".gif"},{type:"image/webp",extensions:".webp"}],videos:[{type:"video/mp4",extensions:".mp4"},{type:"video/webm",extensions:".webm"},{type:"video/ogg",extensions:".ogg"},{type:"video/quicktime",extensions:".mov"}],audio:[{type:"audio/mpeg",extensions:".mp3"},{type:"audio/wav",extensions:".wav"}],documents:[{type:"application/pdf",extensions:".pdf"},{type:"application/json",extensions:".json"},{type:"text/plain",extensions:".txt"},{type:"text/csv",extensions:".csv"},{type:"application/msword",extensions:".doc"},{type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",extensions:".docx"},{type:"application/vnd.ms-excel",extensions:".xls"},{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",extensions:".xlsx"}],others:[{type:"application/zip",extensions:".zip"},{type:"application/x-rar-compressed",extensions:".rar"}]};let j=[];(a.allowedFileTypes||["images","videos","audio","documents","others"]).forEach(H=>{switch(H){case"images":j=j.concat(J.images);break;case"videos":j=j.concat(J.videos);break;case"audio":j=j.concat(J.audio);break;case"documents":j=j.concat(J.documents);break;case"others":j=j.concat(J.others);break}});const G=j.map(H=>H.type).join(",");_.setAttribute("accept",G);let D;if(a.useImageMask){m.classList.add("image-mask");const H=document.createElement("div");m.appendChild(H),D=new Fs(H,{lang:this.settings.lang,name:S+"_mask"}),this.objImageMask=D}a.largePreview&&m.classList.add("large-preview");const z=()=>{const H=g.querySelector(".img-preview");H&&(H.remove(),a.useImageMask&&D.clearImage())};let O=`
|
|
351
|
+
<div class="div-livevideo">
|
|
352
|
+
<video class="livevideo" autoplay playsinline style="display:none"></video>
|
|
353
|
+
<canvas class="photo-captured" style="display:none"></canvas>
|
|
354
|
+
${!a.source||a.source&&a.source==="local"||a.source&&a.source==="local_and_camera"?`<button class="btn-selectfile2" title="${this.out("Select File")}" style="display:none">
|
|
355
|
+
<svg style="fill:none" 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" class="icon-folder-open"><path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
356
|
+
<path d="M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2" />
|
|
357
|
+
</svg>
|
|
358
|
+
</button>
|
|
359
|
+
`:""}
|
|
360
|
+
<button class="btn-takephoto2" title="${this.out("Take Photo")}" style="display:none">
|
|
361
|
+
<svg style="fill:none" 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" class="icon-camera">
|
|
362
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 7h1a2 2 0 0 0 2 -2a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1a2 2 0 0 0 2 2h1a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2" /><path d="M9 13a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
|
|
363
|
+
</svg>
|
|
364
|
+
</button>
|
|
365
|
+
|
|
366
|
+
<button class="btn-capturephoto" title="${this.out("Capture")}" style="display:none">
|
|
367
|
+
<svg style="fill:none" 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" class="icon-camera">
|
|
368
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 7h1a2 2 0 0 0 2 -2a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1a2 2 0 0 0 2 2h1a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2" /><path d="M9 13a3 3 0 1 0 6 0a3 3 0 0 0 -6 0" />
|
|
369
|
+
</svg>
|
|
370
|
+
</button>
|
|
371
|
+
<button type="button" class="btn-clearphoto" title="${this.out("Clear")}" style="display: none;">
|
|
372
|
+
<svg style="fill:none" 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" class="icon-eraser">
|
|
373
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3" /><path d="M18 13.3l-6.3 -6.3" />
|
|
374
|
+
</svg>
|
|
375
|
+
</button>
|
|
376
|
+
<button type="button" class="btn-stopcamera" title="${this.out("Close")}" style="display: none;">
|
|
377
|
+
<svg style="fill:none" 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" class="icon-close">
|
|
378
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M18 6l-12 12" /><path d="M6 6l12 12" />
|
|
379
|
+
</svg>
|
|
380
|
+
</button>
|
|
381
|
+
</div>
|
|
382
|
+
`;this.appendHtml(g,O);const V=m.querySelector(".livevideo"),W=m.querySelector(".photo-captured"),se=m.querySelector(".btn-selectfile2"),re=m.querySelector(".btn-takephoto2"),le=m.querySelector(".btn-capturephoto"),xe=m.querySelector(".btn-clearphoto"),he=m.querySelector(".btn-stopcamera");this.photoBlob={};let Ee;se&&se.addEventListener("click",H=>{H.preventDefault(),N.click()});const $e=async()=>{const H=m.querySelector(".btn-clearfile");H&&H.click();try{Ee=await navigator.mediaDevices.getUserMedia({video:!0}),V.srcObject=Ee}catch{alert("Unable to access the camera."),V.style.display="none",le.style.display="none",he.style.display="none",E.style.display="none",P.style.display="none"}setTimeout(()=>{re.style.display="none",W.style.display="none",V.style.display="",le.style.display="",xe.style.display="none",se&&(se.style.display="none"),re.style.display="none",he.style.display="",E.style.display="none",P.style.display="none"},100)};I&&I.addEventListener("click",async H=>{H.preventDefault(),$e()}),re.addEventListener("click",async H=>{H.preventDefault(),$e()}),he.addEventListener("click",()=>{Ee&&Ee.getTracks().forEach(H=>H.stop()),V.style.display="none",le.style.display="none",he.style.display="none",re.style.display="none",E.style.display="",P.style.display=""}),le.addEventListener("click",H=>{if(H.preventDefault(),W.style.display="",W.width=V.videoWidth,W.height=V.videoHeight,W.getContext("2d").drawImage(V,0,0,W.width,W.height),Ee.getTracks().forEach(Q=>Q.stop()),V.style.display="none",le.style.display="none",xe.style.display="",se&&(se.style.display=""),re.style.display="",he.style.display="none",W.toBlob(Q=>{this.photoBlob[S]=Q,_.removeAttribute("required")},"image/jpeg"),re.style.display="",a.useImageMask){const Q=W.toDataURL("image/jpeg");D.setImage(Q)}this.clearSelectedFiles()});const je=()=>{this.photoBlob[S]=null,W.style.display="none",W.getContext("2d").clearRect(0,0,W.width,W.height),v.value!==""?a.isRequired&&_.removeAttribute("required"):a.isRequired&&_.setAttribute("required","required"),xe.style.display="none",se&&(se.style.display="none"),re.style.display="none",E.style.display="",P.style.display=""};xe.addEventListener("click",()=>{je()});const De=(H,Q)=>{const pe=`.${H.split(".").pop().toLowerCase()}`;if(!j.some(ie=>ie.extensions.split(", ").includes(pe)))return;let Ae=J.images.some(ie=>ie.extensions.split(", ").includes(pe));if(a.useImageMask){if(!Ae)return;D.loadUrl(H)}je(),P.innerHTML="";const be=document.createElement("div");P.appendChild(be);const ue=document.createElement("button");if(ue.className="btn-clearfile",ue.innerHTML=`
|
|
383
|
+
<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">
|
|
384
|
+
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3" /><path d="M18 13.3l-6.3 -6.3" />
|
|
385
|
+
</svg>
|
|
386
|
+
`,P.appendChild(ue),ue.addEventListener("click",ie=>{let o=ue.closest(".form-field").querySelector(".img-preview");o&&o.remove(),v.value="",_.value="",P.innerHTML="",q.innerText=this.out(this.settings.fileUploadText),a.useImageMask&&D.clearImage();const d=document.querySelector(".formview-container .submit-container");d&&setTimeout(()=>{this.stickyElement(d)},1e3),ie.preventDefault(),ie.stopImmediatePropagation()}),Ae){let ie=g.querySelector(".formview-container .img-preview");ie||(ie=document.createElement("img"),ie.className="img-preview",g.appendChild(ie)),ie.src=H}else z();if(!Q){const ie=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(ie)}const Se=document.querySelector(".formview-container .submit-container");Se&&setTimeout(()=>{this.stickyElement(Se)},1e3)};a.value&&De(a.value,!0);const Ce=H=>{if(H){if(!j.some(ue=>ue.type===H.type)){alert(this.out("Invalid file type."));return}if(a.useImageMask){if(!["image/jpeg","image/png","image/webp"].includes(H.type)){alert(this.out("Invalid file type."));return}D.loadImage(H)}je(),v.value="",P.innerHTML="";const pe=document.createElement("div");pe.innerText=H.name,P.appendChild(pe);const ge=document.createElement("button");if(ge.className="btn-clearfile",ge.innerHTML=`
|
|
387
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
388
|
+
<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" />
|
|
389
|
+
</svg>
|
|
390
|
+
`,P.appendChild(ge),ge.addEventListener("click",ue=>{let ie=ge.closest(".form-field").querySelector(".img-preview");ie&&ie.remove(),_.value="",P.innerHTML="",q.innerText=this.out(this.settings.fileUploadText),a.useImageMask&&D.clearImage();const Le=document.querySelector(".formview-container .submit-container");Le&&setTimeout(()=>{this.stickyElement(Le)},1e3),ue.preventDefault(),ue.stopImmediatePropagation()}),H.type.startsWith("image/")){const ue=new FileReader;ue.onload=function(Se){let ie=g.querySelector(".formview-container .img-preview");ie||(ie=document.createElement("img"),ie.className="img-preview",g.appendChild(ie)),ie.src=Se.target.result},ue.readAsDataURL(H)}else z();const Ae=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(Ae);const be=document.querySelector(".formview-container .submit-container");be&&setTimeout(()=>{this.stickyElement(be)},1e3)}},Be=H=>{if(H){if(j=j.concat(J.images),!j.some(ie=>ie.type===H.type)){alert(this.out("Invalid file type."));return}const pe=document.createElement("div");pe.className="image-item",$.appendChild(pe);const ge=document.createElement("div");ge.className="file-drop-info-highlight",pe.appendChild(ge);const Ae=document.createElement("div");Ae.innerText=H.name,ge.appendChild(Ae);const be=document.createElement("button");if(be.className="btn-clearfile",be.innerHTML=`
|
|
391
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
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
|
+
</svg>
|
|
394
|
+
`,ge.appendChild(be),be.addEventListener("click",ie=>{const Le=be.closest(".image-item");Le&&Le.remove(),(b=>{const k=new DataTransfer,T=_.files;Array.from(T).forEach(R=>{R!==b&&k.items.add(R)}),_.files=k.files})(H);const d=document.querySelector(".formview-container .submit-container");d&&setTimeout(()=>{this.stickyElement(d)},1e3),ie.preventDefault(),ie.stopImmediatePropagation()}),H.type.startsWith("image/")){const ie=new FileReader;ie.onload=function(Le){let o=document.createElement("img");o.className="img-preview",pe.appendChild(o),o.src=Le.target.result},ie.readAsDataURL(H)}const ue=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(ue);const Se=document.querySelector(".formview-container .submit-container");Se&&setTimeout(()=>{this.stickyElement(Se)},1e3)}}}if(w==="email"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`email_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`email_label_${y}`,g.type="email",g.name=S,g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="phone"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`phone_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`phone_label_${y}`,g.type="tel",g.name=S,g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="url"){let y=this.getId();const x=document.createElement("label");if(x.setAttribute("for",`url_label_${y}`),x.className="field-label",x.innerHTML=a.title+(a.isRequired?' <span class="text-red-500">*</span>':""),m.appendChild(x),a.fieldNote){const v=document.createElement("div");v.className="field-note",v.innerHTML=a.fieldNote,m.appendChild(v)}const g=document.createElement("input");g.id=`url_label_${y}`,g.type="url",g.name=S,g.value=a.value||"",g.className="inp-base",g.placeholder=a.placeholder,a.isRequired&&g.setAttribute("required","required"),m.appendChild(g),g.addEventListener("input",this.inputListener)}if(w==="hidden"){let y=this.getId();const x=document.createElement("label");x.setAttribute("for",`hidden_label_${y}`),x.className="field-label hidden",x.innerText=a.title,m.appendChild(x);const g=document.createElement("input");g.id=`hidden_label_${y}`,g.type="hidden",g.name=S,g.value=a.value,m.appendChild(g)}});const c=r.closest("[data-site-token]");if(c){const a=c.getAttribute("data-site-token"),p=document.createElement("input");p.type="hidden",p.name="form_token",p.value=a,r.appendChild(p)}if(this.settings.isBuilder){const a=document.createElement("div");a.className="submit-container",r.appendChild(a);let p=!0;if("hideReset"in t&&(p=t.hideReset),!p){const L=document.createElement("button");L.className="btn-resetform";const y=t.resetText||this.settings.resetText;L.innerText=y,a.appendChild(L),L.addEventListener("click",g=>{g.preventDefault();const v=L.closest("form");v&&(v.reset(),v.querySelectorAll(".btn-clearfile").forEach(E=>{E.click()}),v.querySelectorAll(".slider-container").forEach(E=>{const q=E.querySelector("input");E.querySelector(".current-value").textContent=q.value}))}),(t.fullWidthButton||!1)&&L.classList.add("w-full")}const m=document.createElement("button");m.className="btn-submitform";const w=t.submitText||this.settings.submitText;m.innerText=w,a.appendChild(m),(t.fullWidthButton||!1)&&m.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&a.classList.add("always-visible"),this.stickyElement(a),r.addEventListener("submit",async L=>{L.preventDefault(),this.steps&&this.steps.length>0&&this.process()})}else{let a="Reference Code:",p="reference_code",m="reference_code";const w=document.createElement("div");w.className="form-field ",w.classList.add(m),r.appendChild(w);let S=this.getId();const L=document.createElement("label");L.setAttribute("for",`short_text_label_${S}`),L.className="field-label",L.innerHTML=a,w.appendChild(L);const y=document.createElement("input");if(y.id=`short_text_label_${S}`,y.type="text",y.name=p,y.autocomplete="off",y.setAttribute("aria-hidden","true"),y.setAttribute("tabindex","-1"),y.className="inp-base",w.appendChild(y),this.settings.captchaContainer){const x=this.settings.captchaContainerClassName,g=document.createElement("div");g.className="captcha-container",x&&g.classList.add(x),r.appendChild(g)}if(t.useSubmitButton){const x=document.createElement("div");x.className="submit-container",r.appendChild(x);let g=!0;if("hideReset"in t&&(g=t.hideReset),!g){const q=document.createElement("button");q.className="btn-resetform";const N=t.resetText||this.settings.resetText;q.innerText=N,x.appendChild(q),q.addEventListener("click",$=>{$.preventDefault();const P=q.closest("form");P&&(P.reset(),P.querySelectorAll(".btn-clearfile").forEach(B=>{B.click()}),P.querySelectorAll(".slider-container").forEach(B=>{const G=B.querySelector("input");B.querySelector(".current-value").textContent=G.value}))}),(t.fullWidthButton||!1)&&q.classList.add("w-full")}const v=document.createElement("button");v.className="btn-submitform";const _=t.submitText;v.innerText=_,x.appendChild(v),(t.fullWidthButton||!1)&&v.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&x.classList.add("always-visible"),this.stickyElement(x),v.addEventListener("click",async q=>{this.trigger("submit",q)});const E=r.closest("form");E?E.addEventListener("submit",async q=>{this.steps&&this.steps.length>0&&(q.preventDefault(),q.stopImmediatePropagation(),this.process())}):v.addEventListener("click",async q=>{this.steps&&this.steps.length>0&&(q.preventDefault(),this.process())})}}let h,u;this.settings.resultSelector&&(h=document.querySelector(this.settings.resultSelector),h.classList.add("result-wrapper"),h.innerHTML="",u=document.createElement("div"),u.classList.add("result-container"),h.appendChild(u)),t.elements&&h&&t.elements.forEach(a=>{if(a.displayInOutput){if(a.type==="spacer"){const m=document.createElement("div");m.className="form-spacer",a.spacerHeight&&!isNaN(parseFloat(a.spacerHeight))&&(m.style.height=a.spacerHeight+"px"),u.appendChild(m);return}if(a.type==="separator"){const m=document.createElement("hr");m.style.borderTopColor=a.color,u.appendChild(m);return}if(a.type==="html"){if(a.html){const m=document.createElement("div");m.innerHTML=a.html,u.appendChild(m)}return}if(a.type==="heading"){const m=document.createElement(a.heading||"h2");m.innerHTML=a.headingText||this.out("Your Heading Here!"),u.appendChild(m);return}if(a.type==="paragraph"){const m=document.createElement("p");m.innerHTML=a.paragraphText||this.out("Your paragraph content here!"),u.appendChild(m);return}if(a.type==="media"){if(a.tag==="video"){const m=document.createElement("video");m.style.width="100%",m.style.height="auto",m.controls=!0;var p=document.createElement("source");p.src=a.url,p.type="video/mp4",m.appendChild(p),u.appendChild(m)}else if(a.tag==="audio"){const m=document.createElement("audio");m.controls=!0;let w=document.createElement("source");w.src=a.url,w.type="audio/mp3",m.appendChild(w),u.appendChild(m)}else if(a.tag==="img"){const m=document.createElement("img");m.src=a.url,m.setAttribute("alt",this.out("Output Image")),u.appendChild(m)}return}if(a.type==="image"){const m=document.createElement("img");m.src=a.url,m.setAttribute("alt",this.out("Output Image")),u.appendChild(m);return}if(a.type==="video"){const m=document.createElement("video");m.style.width="100%",m.style.height="auto",m.controls=!0;let w=document.createElement("source");w.src=a.url,w.type="video/mp4",m.appendChild(w),u.appendChild(m);return}if(a.type==="audio"){const m=document.createElement("audio");m.controls=!0;let w=document.createElement("source");w.src=a.url,w.type="audio/mp3",m.appendChild(w),u.appendChild(m);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(c=>{c.addEventListener("click",async h=>{h.preventDefault();const u=h.target.href;try{const a=await fetch(u,{mode:"cors"});if(!a.ok)throw new Error("Failed to fetch the image.");const p=await a.blob(),m=u.substring(u.lastIndexOf("/")+1),w=document.createElement("a");w.href=URL.createObjectURL(p),w.download=m,w.click(),URL.revokeObjectURL(w.href)}catch(a){console.error("Error downloading the image:",a)}})})}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=[],l=[];if(this.settings.scrapeProvider==="firecrawl"&&s.forEach(c=>{if(c.success){const h=c.metadata.title,u=c.markdown,a=c.metadata.url;r.push(a),n+=`
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
## ${h}
|
|
398
|
+
|
|
399
|
+
Source: ${a}
|
|
400
|
+
|
|
401
|
+
${u}
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
----------------
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
`}else{let h=c.url;if(h){const u=c.url;l.push(u)}else h=c.url.link,l.push(h)}}),this.settings.scrapeProvider==="scrapingbee")for(let c=0;c<s.length;c++){let h=e[c];r.push(h);let u=s[c];n+=`
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
## ${h}
|
|
411
|
+
|
|
412
|
+
${u}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
----------------
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
`}return n=`These are the information from the URLs:
|
|
419
|
+
|
|
420
|
+
${n}
|
|
421
|
+
`,{data:n,urls:r,failed:l}}async checkPrompt(e){let t="You are an assistant",i=`This is user's request:
|
|
422
|
+
|
|
423
|
+
${e}
|
|
424
|
+
`,n=`
|
|
425
|
+
Check if the request requires checking certain URLs. If so, returns the URLs.
|
|
426
|
+
Also check if the request requires search to find answers by searching on the web to get the current relevant information.
|
|
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
|
+
|
|
429
|
+
${e}`);this.settings.consoleLog&&console.log(r);let l=[],c=[];if(r.url&&r.needscrape&&this.settings.scrapeUrl){let h=document.createElement("p");h.innerHTML=this.out("Fetching data from the web..."),n.appendChild(h);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 a=await this.scrapeUrls(u);s+=a.data,l=a.urls,c=a.failed}else if(this.settings.searchUrl&&this.settings.scrapeUrl){let h=document.createElement("p");h.innerHTML=this.out("Searching the web.."),n.appendChild(h);let u=await this.search(e);const a=this.settings.scrapeExclude;let p=u.filter(y=>{let x=new URL(y.link).hostname;return!a.some(g=>x.includes(g))});const m=this.settings.scrapeLimit,w=p.slice(0,m);n.innerHTML="",h=document.createElement("p"),h.innerHTML=this.out("Getting more information..."),n.appendChild(h);let S=[];for(let y=0;y<w.length;y++)S.push(u[y].link);let L=await this.scrapeUrls(S);s+=L.data,l=L.urls,c=L.failed}return{data:s,urls:l,failed:c}}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
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 20" width="27" height="20" fill="currentColor">
|
|
431
|
+
<circle cx="15" cy="15" r="10">
|
|
432
|
+
<animate attributeName="cy" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
433
|
+
</circle>
|
|
434
|
+
<circle cx="60" cy="15" r="10">
|
|
435
|
+
<animate attributeName="cy" begin="0.2s" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
436
|
+
</circle>
|
|
437
|
+
<circle cx="105" cy="15" r="10">
|
|
438
|
+
<animate attributeName="cy" begin="0.4s" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
439
|
+
</circle>
|
|
440
|
+
</svg>
|
|
441
|
+
`;let n;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}n=document.querySelector(this.settings.previewSelector)}else n=this.element;let s=n.querySelector(".btn-submitform"),r=s.innerHTML;s.innerHTML=`
|
|
442
|
+
<span class="loading-icon" style="width:60px;display:flex;align-items:center;justify-content:center">
|
|
443
|
+
<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">
|
|
444
|
+
<circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
445
|
+
<path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
446
|
+
</svg>
|
|
447
|
+
</span>
|
|
448
|
+
|
|
449
|
+
`,setTimeout(()=>{i.innerHTML=e,s.innerHTML=r},400)}async process(e){if(this.trigger("generate"),this.payloads=[],this.output=[],this.mediaGenerated=[],this.needCleanup=!1,this.outputHtml="",!this.settings.resultSelector){this.settings.consoleLog&&console.log("resultSelector not set.");return}const t=document.querySelector(this.settings.resultSelector);if(!t){console.log("resultElement not found.");return}let i=!1,n=!1;this.steps.forEach(v=>{v.prompt.trim().startsWith("{")&&(i=!0),v.tools&&(v.tools.image||v.tools.video||v.tools.audio)&&(i=!0),v.tools&&v.tools.search&&(n=!0)});let s;if(i&&this.settings.disableMediaGeneration){s=`
|
|
450
|
+
<div class="form-info">
|
|
451
|
+
<h3>${this.out(this.settings.disableMediaGenerationTitle)}</h3>
|
|
452
|
+
<p>
|
|
453
|
+
<b>${this.out(this.settings.disableMediaGenerationMessage)}</b>
|
|
454
|
+
</p>
|
|
455
|
+
</div>`,this.showDemoInfo(s);return}if(!this.settings.scrapeUrl&&n){this.settings.demo?s=`
|
|
456
|
+
<div class="form-info">
|
|
457
|
+
<h3>Demo Info</h3>
|
|
458
|
+
<p>
|
|
459
|
+
<b>This is an online demo, so web searching and scraping features are currently disabled. In the full version, you’ll have access to all these features!</b>
|
|
460
|
+
</p>
|
|
461
|
+
</div>`:s=`
|
|
462
|
+
<div class="form-info">
|
|
463
|
+
<p>
|
|
464
|
+
<b>Web searching and scraping are currently disabled, so your request cannot be processed.</b>
|
|
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 l=r.querySelector(".btn-submitform"),c=l.innerHTML;this.tokenInput=0,this.tokenOutput=0;let h=!1;if(e!=null&&(h=!0),this.singleStep=h,h||(this.filesUploaded={}),this.isNormal&&!h){if(this.isMediaGenerating){alert(this.out("The media generation process cannot be aborted."));return}this.abort(),l.innerHTML=c,l.removeAttribute("disabled"),this.isGenerating=!1;return}if(this.isNormal&&h||this.isSingle&&!h||this.isSingle&&h)return;this.isNormal=!1,this.isSingle=!1,h?(l.innerHTML=`
|
|
467
|
+
<span class="loading-icon">
|
|
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
|
+
<circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
470
|
+
<path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
471
|
+
</svg>
|
|
472
|
+
</span>
|
|
473
|
+
`,this.isSingle=!0):(l.innerHTML=`
|
|
474
|
+
<span class="loading-icon">
|
|
475
|
+
<svg class="animate-spin" style="margin: 0;margin-right: 0.6rem;width: 1.25rem;height: 1.25rem;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
476
|
+
<circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
477
|
+
<path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
478
|
+
</svg>
|
|
479
|
+
</span>
|
|
480
|
+
${this.out("Abort")}
|
|
481
|
+
`,this.isNormal=!0),this.isGenerating=!0;let u=(v,_)=>{if(v===void 0)return"";if(!isNaN(v))return v;let C=v;return _&&_.trim().startsWith("{")&&(C=JSON.stringify(v).slice(1,-1)),C};t.innerHTML="";let a=JSON.parse(JSON.stringify(this.steps)),p=this.getFormValues();if(!p)return;if(!(p&&Object.keys(p).length===0)){for(const v of a){let _=v.prompt;if(v.provider==="google"){for(const E of p)if(E.value instanceof FileList&&E.value.length>0){const N=E.value[0];if(!N)continue;const I=await new Promise(($,P)=>{const J=new FileReader;J.onload=j=>{const B=j.target.result.split(",")[1];$(B)},J.onerror=P,J.readAsDataURL(N)});_=_.replaceAll(`{{${E.name}}}`,I),_=_.replaceAll(`{{${E.name.toUpperCase()}}}`,I)}}v.prompt=_}a.forEach(v=>{let _=v.prompt;p.forEach(C=>{if(C.value===void 0&&(C.value=""),typeof C.value=="object"&&Array.isArray(C.value)){const E=C.value.join(", ");_=_.replaceAll(`{{${C.name}}}`,E),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,E)}else C.value instanceof FileList||typeof C.value=="string"&&C.value.indexOf("base64")!==-1?(_=_.replaceAll(`{{${C.name}}}`,C.name),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,C.name)):(_=_.replaceAll(`{{${C.name}}}`,u(C.value,v.prompt)),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,u(C.value,v.prompt)))}),v.prompt=_}),a.forEach(v=>{let _=v.context;p.forEach(C=>{if(C.value||(C.value=""),typeof C.value=="object"&&Array.isArray(C.value)){const E=C.value.join(", ");_=_.replaceAll(`{{${C.name}}}`,E),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,E)}else C.value instanceof FileList||typeof C.value=="string"&&C.value.indexOf("base64")!==-1?(_=_.replaceAll(`{{${C.name}}}`,C.name),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,C.name)):(_=_.replaceAll(`{{${C.name}}}`,u(C.value,v.prompt)),_=_.replaceAll(`{{${C.name.toUpperCase()}}}`,u(C.value,v.prompt)))}),v.context=_})}const m=async(v,_,C,E,q,N,I,$)=>{const P=document.createElement("div");P.classList.add("result-container"),t.appendChild(P),P.innerHTML=`
|
|
482
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 20" width="27" height="20" fill="currentColor">
|
|
483
|
+
<circle cx="15" cy="15" r="10">
|
|
484
|
+
<animate attributeName="cy" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
485
|
+
</circle>
|
|
486
|
+
<circle cx="60" cy="15" r="10">
|
|
487
|
+
<animate attributeName="cy" begin="0.2s" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
488
|
+
</circle>
|
|
489
|
+
<circle cx="105" cy="15" r="10">
|
|
490
|
+
<animate attributeName="cy" begin="0.4s" dur="0.6s" values="15;5;15" repeatCount="indefinite"></animate>
|
|
491
|
+
</circle>
|
|
492
|
+
</svg>
|
|
493
|
+
`;let J=!1,j;if(v.trim().startsWith("{"))try{j=JSON.parse(v),j&&typeof j=="object"&&(J=!0)}catch{return P.innerHTML=`<p>${this.out("Incorrect JSON format.")}</p>`,!1}(I&&(I.image||I.video||I.audio)||J)&&(h||(l.innerHTML=`
|
|
494
|
+
<span class="loading-icon" style="width:60px;display:flex;align-items:center;justify-content:center">
|
|
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
|
+
<circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
497
|
+
<path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
498
|
+
</svg>
|
|
499
|
+
</span>
|
|
500
|
+
|
|
501
|
+
`,l.setAttribute("disabled","")));let B="",G="",D;if(I&&I.search&&(D=await this.getRelevantInfo(v,_,P),D.data!==""&&(_+=`
|
|
502
|
+
Use the following information to answer the request:
|
|
503
|
+
|
|
504
|
+
${D.data}
|
|
505
|
+
`)),I&&(I.image||I.video||I.audio)||J){const z=await this.media.generate(v,_,C,E,I,P,$);return this.needCleanup=!0,this.settings.consoleLog&&console.log(z),z.mediaGenerated?{media:z.output,media2:z.output2,markdown:z.markdown}:(P.innerHTML=`<p>${z.message}</p>`,!1)}if(this.settings.assistantId){if(this.settings.assistantStreamUrl)await this.assistantStream(v,_,q,N,async z=>{if(!(z&&typeof z=="object")){if(B+=z,!$){const O=te.parse(B);P.innerHTML=O,G+=O}await new Promise(O=>setTimeout(O,50))}}),await new Promise(z=>{const O=setInterval(()=>{P.innerHTML===te.parse(B)&&(clearInterval(O),z())},10)}),$&&(P.innerHTML="",P.remove()),this.outputHtml+=`<div class="result-container">${G}</div>`;else if(this.settings.assistantUrl){let z=await this.assistant(v,_,q,N);if(!z)return!1;if(B=z,$)P.innerHTML="",P.remove();else{const O=te.parse(z);P.innerHTML=O,this.outputHtml+=`<div class="result-container">${O}</div>`}}}else if(this.settings.sendCommandStreamUrl){let z="",O="",V="";const W=async se=>{let re=0;for(;re<se.length;){if(V=z.slice(0,V.length+1),re++,!$){const le=te.parse(V);P.innerHTML=le,O=le}await new Promise(le=>setTimeout(le,50))}};await this.sendStream(v,_,q,E,N,async se=>{B+=se,z+=se,await W(se)}),await new Promise(se=>{const re=setInterval(()=>{V.length===z.length&&(clearInterval(re),se())},10)}),$&&(P.innerHTML="",P.remove()),this.outputHtml+=`<div class="result-container">${O}</div>`}else{let z=await this.send(v,_,q,E,N);if(!z)return!1;if(B=z,$)P.innerHTML="",P.remove();else{const O=te.parse(z);P.innerHTML=O,this.outputHtml+=`<div class="result-container">${O}</div>`}}if(!$){let z="";if(D&&D.urls.forEach(V=>{let W=V;W.length>75&&(W=W.slice(0,75)+"..."),z+=`<div><a class="source_url" href="${V}">${W}</url></div>`}),D&&D.failed.forEach(V=>{let W=V;W.length>75&&(W=W.slice(0,75)+"..."),z+=`<div><a class="source_url" style="opacity:0.5" href="${V}">${W}</url></div>`}),z!==""){const V=document.createElement("div");V.classList.add("result-container"),t.appendChild(V),V.innerHTML=z}}return this.payloads.push({prompt:v,context:_}),this.output.push(B),{media:[],markdown:B}};h||await(async v=>{this.previousResults=[],this.outputHtml="";for(let _=0;_<v.length;_++){if(!this.isGenerating)return;let{prompt:C,context:E,provider:q,model:N,system:I,functs:$,tools:P,hideOutput:J}=v[_];q=q||"",E=E||"",I=I||"You are an assistant",$=$||[];let j=C;this.previousResults.forEach((G,D)=>{const z=`{{output_step_${D+1}}}`;j=j.replace(new RegExp(z,"g"),u(G,C)),j=j.replace(new RegExp(z.toUpperCase(),"g"),u(G,C))}),C=j,C=C.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(C),j=E,this.previousResults.forEach((G,D)=>{const z=`{{output_step_${D+1}}}`;j=j.replace(new RegExp(z,"g"),u(G,C)),j=j.replace(new RegExp(z.toUpperCase(),"g"),u(G,C))}),E=j,E=E.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim();let B=await m(C,E,q,N,I,$,P,J);if(!B)break;if(this.mediaGenerated.push(...B.media),B.media&&B.media.length===1){let G=B.media[0],D=B.media2&&B.media2.length===1&&B.media2[0];this.previousResults.push(D||G),J&&(this.filesUploaded[`output_step_${_}`]=G)}else this.previousResults.push(B.markdown)}})(a),h&&(e===0&&(this.previousResults=[]),await(async(_,C)=>{if(!this.isGenerating)return;let{prompt:E,context:q,provider:N,model:I,system:$,functs:P,tools:J,hideOutput:j}=_[C];q=q||"",$=$||"You are an assistant",P=P||[];let B=E;this.previousResults&&this.previousResults.forEach((D,z)=>{const O=`{{output_step_${z+1}}}`;B=B.replace(new RegExp(O,"g"),D),B=B.replace(new RegExp(O.toUpperCase(),"g"),D)}),E=B,E=E.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(E),B=q,this.previousResults&&this.previousResults.forEach((D,z)=>{const O=`{{output_step_${z+1}}}`;B=B.replace(new RegExp(O,"g"),D),B=B.replace(new RegExp(O.toUpperCase(),"g"),D)}),q=B,q=q.replace(/[\u00A0\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g," ").trim(),this.settings.consoleLog&&console.log(q);let G=await m(E,q,N,I,$,P,J,j);if(G&&(this.mediaGenerated.push(...G.media),!!this.previousResults))if(G.media&&G.media.length===1){let D=G.media[0],z=G.media2&&G.media2.length===1&&G.media2[0];this.previousResults[C]=z||D,j&&(this.filesUploaded[`output_step_${C}`]=D)}else this.previousResults[C]=G.markdown})(a,e)),l.innerHTML=c,l.removeAttribute("disabled"),this.isGenerating=!1;const S=this.calculateCost();this.settings.onUsage&&this.settings.onUsage(S),this.trigger("usage",S),this.isNormal=!1,this.isSingle=!1;const L=(v,_=100)=>{const C=document.createElement("div");if(C.innerHTML=v,C.querySelector("video"))return"Video";if(C.querySelector("img"))return"Image";if(C.querySelector("audio"))return"Audio";const E=C.textContent.trim();return E.length>_?E.substring(0,_)+"...":E},y=Object.keys(this.filesUploaded).length===0&&this.filesUploaded.constructor===Object;if(this.needCleanup&&!y){this.settings.consoleLog&&(console.log("Cleanup"),console.log(this.filesUploaded));let v={"Content-Type":"application/json",...this.settings.headers};await fetch(this.settings.cleanup,{method:"POST",headers:v,body:JSON.stringify(this.filesUploaded)})}let x=this.outputHtml;this.mediaGenerated=this.mediaGenerated.filter(v=>x.indexOf(v)!==-1),this.trigger("resultReady",{previewText:L(x),markdown:this.previousResults,html:x,media:this.mediaGenerated,input:this.payloads,output:this.output}),this.settings.saveResults&&(localStorage.setItem("_results",JSON.stringify(this.previousResults)),localStorage.setItem("_results_html",x)),this.addResultTool(),t.querySelectorAll(".link-download").forEach(v=>{v.addEventListener("click",async _=>{_.preventDefault();const C=_.target.href;try{const E=await fetch(C,{mode:"cors"});if(!E.ok)throw new Error("Failed to fetch the image.");const q=await E.blob(),N=C.substring(C.lastIndexOf("/")+1),I=document.createElement("a");I.href=URL.createObjectURL(q),I.download=N,I.click(),URL.revokeObjectURL(I.href)}catch(E){console.error("Error downloading the image:",E)}})})}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:l,type:c,value:h,checked:u,files:a}=r;if(c==="checkbox")l=l.replace("[]",""),u&&(i[l]=i[l]||[],h==="other"&&(h=e.querySelector(`[name="${l+"_other"}"]`).value),i[l].push(h));else if(c==="radio")u&&(h==="other"&&(h=e.querySelector(`[name="${l+"_other"}"]`).value),i[l]=h);else if(c==="select-one")h==="other"&&(h=e.querySelector(`[name="${l+"_other"}"]`).value),i[l]=h;else if(c==="file")i[l]=a;else if(c==="select-multiple"){const p=Array.from(r.selectedOptions);i[l]=p.map(m=>m.value)}else if(c==="color"){i[l]=h;const p=this.hexToRgb(h);i[l+"_red"]=p.red,i[l+"_green"]=p.green,i[l+"_blue"]=p.blue}else i[l]=h});let n=[];return this.json.elements.forEach(r=>{let l=r.title,c=r.name,h=r.type;if(c==="")return;let u=i[c],a={questions:l,name:c,value:u,type:h};n.push(a);let p=c+"__url";u=i[p],u&&(a={questions:l,name:p,value:u},n.push(a)),r.useImageMask&&(c=c+"_mask",u=i[c],a={questions:l,name:c,value:u},n.push(a));let m=c+"_red";u=i[m],u!==void 0&&(a={questions:l,name:m,value:u},n.push(a));let w=c+"_green";u=i[w],u!==void 0&&(a={questions:l,name:w,value:u},n.push(a));let S=c+"_blue";u=i[S],u!==void 0&&(a={questions:l,name:S,value:u},n.push(a))}),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,l=.9,c=1;s||(s=[]),n=n||this.settings.model,s.length>0&&(n=this.settings.model2);const h={question:e,context:t,system:i,functs:s,temperature:r,topP:l,num:c,model:n,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers},p=await(await fetch(this.settings.sendCommandUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(h)})).json();if(p.error)return console.log(`Error:
|
|
506
|
+
`+p.error),!1;if(p.answer.usage&&(this.tokenInput+=p.answer.usage.prompt_tokens,this.tokenOutput+=p.answer.usage.completion_tokens),s.length===0){let m;return p.answer.choices.forEach(w=>{m=w.message.content}),m}else return p.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 l=.6,c=.9,h=1;s||(s=[]),n=n||this.settings.model;const u={question:e,context:t,system:i,functs:s,temperature:l,topP:c,num:h,model:n,customData:this.settings.customData};try{let a={"Content-Type":"application/json",...this.settings.headers};const p=await fetch(this.settings.sendCommandStreamUrl,{signal:this.signal,method:"POST",headers:a,body:JSON.stringify(u)});if(!p.ok)return console.error("Error:",p.statusText),!1;const m=p.body.getReader(),w=new TextDecoder;let S="",L=!1;for(;!L;){const{done:y,value:x}=await m.read();if(L=y,L)break;const g=w.decode(x,{stream:!0});S+=g;const v=S.split(`
|
|
507
|
+
`);S="";let _=0,C=0;for(const E of v)if(E.trim()!==""&&E.startsWith("data:")){const q=E.slice(5).trim();if(q==="[DONE]"){this.settings.consoleLog&&console.log("Stream completed.");break}try{const N=JSON.parse(q);if(N.usage&&(_=N.usage.prompt_tokens,C=N.usage.completion_tokens),N.choices&&N.choices[0].delta&&N.choices[0].delta.content){const I=N.choices[0].delta.content;r&&r(I)}}catch{S+=E+`
|
|
508
|
+
`}}this.tokenInput+=_,this.tokenOutput+=C}return!0}catch(a){return a.name==="AbortError"?this.settings.consoleLog&&console.log("Request aborted by user."):console.error("Error:",a),!1}}async assistant(e,t,i,n){this.controller=new AbortController,this.signal=this.controller.signal;let s=.6,r=.9,l=1;n||(n=[]);let c=this.settings.model;n.length>0&&(c=this.settings.model2);const h={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:s,topP:r,num:l,model:c,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers},p=await(await fetch(this.settings.assistantUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(h)})).json();return p.error?(console.log(`Error:
|
|
509
|
+
`+p.error),!1):(p.usage&&(this.tokenInput+=p.usage.prompt_tokens,this.tokenOutput+=p.usage.completion_tokens),p.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,l=.9,c=1;n||(n=[]);const h={assistantId:this.settings.assistantId,question:e,context:t,system:i,functs:n,temperature:r,topP:l,num:c,model:this.settings.model,customData:this.settings.customData};try{let u={"Content-Type":"application/json",...this.settings.headers};const a=await fetch(this.settings.assistantStreamUrl,{signal:this.signal,method:"POST",headers:u,body:JSON.stringify(h)});if(!a.ok)return console.error("Error:",a.statusText),!1;const p=a.body.getReader(),m=new TextDecoder;let w="",S=!1;for(;!S;){const{done:L,value:y}=await p.read();if(S=L,S)break;const x=m.decode(y,{stream:!0});w+=x;const g=w.split(`
|
|
510
|
+
`);w="";for(const v of g)if(v.trim()!=="")if(v.startsWith("data:")){const _=v.slice(5).trim();_==="[DONE]"&&this.settings.consoleLog&&console.log("Stream completed.");try{const C=JSON.parse(_);if(C.choices&&C.choices[0].delta&&C.choices[0].delta.content){const E=C.choices[0].delta.content;s&&s(E)}}catch{w+=v+`
|
|
511
|
+
`}}else{const _=JSON.parse(v);this.tokenInput+=_.prompt_tokens,this.tokenOutput+=_.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 Vs{constructor(e={}){const t={skin:"light"};this.settings={...t,...e},window.Glide=os,window.FormViewer=Gs}init(){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=Ot(e),window.GLightbox=Ot}openLightbox(e,t,i){let n=[],s=0;if(t){const r=t.closest("[data-gallery]");let l=[];r?l=r.querySelectorAll(".is-lightbox"):document.querySelectorAll(".is-lightbox,.block-click").forEach(h=>{h.closest("[data-gallery]")||l.push(h)}),l.forEach((c,h)=>{let u=c.getAttribute("href");u||(u=c.getAttribute("data-modal-url")),n.push({href:u}),e===u&&(s=h)})}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)})}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)})}}return Vs})();
|