BossBey File Manager
PHP:
8.2.30
OS:
Linux
User:
imagivibe
Root
/
home
/
imagivibe
/
www
/
app.imagivibe.com
/
public
/
build
/
assets
📤 Upload
📝 New File
📁 New Folder
Close
Editing: app-923caa6f.js
import{e as S,f as Ht,m as Ut,L as jt}from"./fetch-727eea72.js";import{c as Xt}from"./clipboard-f64d1f4d.js";const Yt="modulepreload",Gt=function(r){return"/build/"+r},gt={},vt=function(e,t,i){if(!t||t.length===0)return e();const n=document.getElementsByTagName("link");return Promise.all(t.map(o=>{if(o=Gt(o),o in gt)return;gt[o]=!0;const a=o.endsWith(".css"),l=a?'[rel="stylesheet"]':"";if(!!i)for(let d=n.length-1;d>=0;d--){const u=n[d];if(u.href===o&&(!a||u.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${l}`))return;const s=document.createElement("link");if(s.rel=a?"stylesheet":Yt,a||(s.as="script",s.crossOrigin=""),s.href=o,document.head.appendChild(s),a)return new Promise((d,u)=>{s.addEventListener("load",d),s.addEventListener("error",()=>u(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e()).catch(o=>{const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o})};typeof window.pusherConfig<"u"?vt(()=>import("./echo-4c3fda6b.js"),[]).then(({default:r})=>{vt(()=>import("./pusher-32a7bc32.js").then(e=>e.p),[]).then(({default:e})=>{window.Pusher=e;let t=window.pusherConfig;window.Echo=new r({broadcaster:"pusher",key:t.key,cluster:t.cluster,wsHost:t.wsHost??`ws-${t.cluster}.pusher.com`,wsPort:t.port??80,wssPort:t.port??443,forceTLS:(t.scheme??"https")==="https",enabledTransports:["ws","wss"]})}).catch(e=>console.log("Failed to load Pusher:",e))}).catch(r=>console.log("Failed to load Echo:",r)):console.log("window.pusherConfig is not defined.");function bt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function X(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?bt(Object(t),!0).forEach(function(i){Zt(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):bt(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function Be(r){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Be=function(e){return typeof e}:Be=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Be(r)}function Zt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Z(){return Z=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},Z.apply(this,arguments)}function Qt(r,e){if(r==null)return{};var t={},i=Object.keys(r),n,o;for(o=0;o<i.length;o++)n=i[o],!(e.indexOf(n)>=0)&&(t[n]=r[n]);return t}function Kt(r,e){if(r==null)return{};var t=Qt(r,e),i,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(n=0;n<o.length;n++)i=o[n],!(e.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(r,i)&&(t[i]=r[i])}return t}var Jt="1.15.2";function G(r){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(r)}var Q=G(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),ke=G(/Edge/i),yt=G(/firefox/i),De=G(/safari/i)&&!G(/chrome/i)&&!G(/android/i),It=G(/iP(ad|od|hone)/i),xt=G(/chrome/i)&&G(/android/i),Pt={capture:!1,passive:!1};function _(r,e,t){r.addEventListener(e,t,!Q&&Pt)}function w(r,e,t){r.removeEventListener(e,t,!Q&&Pt)}function We(r,e){if(e){if(e[0]===">"&&(e=e.substring(1)),r)try{if(r.matches)return r.matches(e);if(r.msMatchesSelector)return r.msMatchesSelector(e);if(r.webkitMatchesSelector)return r.webkitMatchesSelector(e)}catch{return!1}return!1}}function ei(r){return r.host&&r!==document&&r.host.nodeType?r.host:r.parentNode}function H(r,e,t,i){if(r){t=t||document;do{if(e!=null&&(e[0]===">"?r.parentNode===t&&We(r,e):We(r,e))||i&&r===t)return r;if(r===t)break}while(r=ei(r))}return null}var wt=/\s+/g;function L(r,e,t){if(r&&e)if(r.classList)r.classList[t?"add":"remove"](e);else{var i=(" "+r.className+" ").replace(wt," ").replace(" "+e+" "," ");r.className=(i+(t?" "+e:"")).replace(wt," ")}}function m(r,e,t){var i=r&&r.style;if(i){if(t===void 0)return document.defaultView&&document.defaultView.getComputedStyle?t=document.defaultView.getComputedStyle(r,""):r.currentStyle&&(t=r.currentStyle),e===void 0?t:t[e];!(e in i)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),i[e]=t+(typeof t=="string"?"":"px")}}function pe(r,e){var t="";if(typeof r=="string")t=r;else do{var i=m(r,"transform");i&&i!=="none"&&(t=i+" "+t)}while(!e&&(r=r.parentNode));var n=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return n&&new n(t)}function kt(r,e,t){if(r){var i=r.getElementsByTagName(e),n=0,o=i.length;if(t)for(;n<o;n++)t(i[n],n);return i}return[]}function j(){var r=document.scrollingElement;return r||document.documentElement}function I(r,e,t,i,n){if(!(!r.getBoundingClientRect&&r!==window)){var o,a,l,c,s,d,u;if(r!==window&&r.parentNode&&r!==j()?(o=r.getBoundingClientRect(),a=o.top,l=o.left,c=o.bottom,s=o.right,d=o.height,u=o.width):(a=0,l=0,c=window.innerHeight,s=window.innerWidth,d=window.innerHeight,u=window.innerWidth),(e||t)&&r!==window&&(n=n||r.parentNode,!Q))do if(n&&n.getBoundingClientRect&&(m(n,"transform")!=="none"||t&&m(n,"position")!=="static")){var p=n.getBoundingClientRect();a-=p.top+parseInt(m(n,"border-top-width")),l-=p.left+parseInt(m(n,"border-left-width")),c=a+o.height,s=l+o.width;break}while(n=n.parentNode);if(i&&r!==window){var f=pe(n||r),v=f&&f.a,y=f&&f.d;f&&(a/=y,l/=v,u/=v,d/=y,c=a+d,s=l+u)}return{top:a,left:l,bottom:c,right:s,width:u,height:d}}}function St(r,e,t){for(var i=ie(r,!0),n=I(r)[e];i;){var o=I(i)[t],a=void 0;if(t==="top"||t==="left"?a=n>=o:a=n<=o,!a)return i;if(i===j())break;i=ie(i,!1)}return!1}function ve(r,e,t,i){for(var n=0,o=0,a=r.children;o<a.length;){if(a[o].style.display!=="none"&&a[o]!==g.ghost&&(i||a[o]!==g.dragged)&&H(a[o],t.draggable,r,!1)){if(n===e)return a[o];n++}o++}return null}function ht(r,e){for(var t=r.lastElementChild;t&&(t===g.ghost||m(t,"display")==="none"||e&&!We(t,e));)t=t.previousElementSibling;return t||null}function q(r,e){var t=0;if(!r||!r.parentNode)return-1;for(;r=r.previousElementSibling;)r.nodeName.toUpperCase()!=="TEMPLATE"&&r!==g.clone&&(!e||We(r,e))&&t++;return t}function _t(r){var e=0,t=0,i=j();if(r)do{var n=pe(r),o=n.a,a=n.d;e+=r.scrollLeft*o,t+=r.scrollTop*a}while(r!==i&&(r=r.parentNode));return[e,t]}function ti(r,e){for(var t in r)if(r.hasOwnProperty(t)){for(var i in e)if(e.hasOwnProperty(i)&&e[i]===r[t][i])return Number(t)}return-1}function ie(r,e){if(!r||!r.getBoundingClientRect)return j();var t=r,i=!1;do if(t.clientWidth<t.scrollWidth||t.clientHeight<t.scrollHeight){var n=m(t);if(t.clientWidth<t.scrollWidth&&(n.overflowX=="auto"||n.overflowX=="scroll")||t.clientHeight<t.scrollHeight&&(n.overflowY=="auto"||n.overflowY=="scroll")){if(!t.getBoundingClientRect||t===document.body)return j();if(i||e)return t;i=!0}}while(t=t.parentNode);return j()}function ii(r,e){if(r&&e)for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);return r}function Ge(r,e){return Math.round(r.top)===Math.round(e.top)&&Math.round(r.left)===Math.round(e.left)&&Math.round(r.height)===Math.round(e.height)&&Math.round(r.width)===Math.round(e.width)}var Ae;function Mt(r,e){return function(){if(!Ae){var t=arguments,i=this;t.length===1?r.call(i,t[0]):r.apply(i,t),Ae=setTimeout(function(){Ae=void 0},e)}}}function ri(){clearTimeout(Ae),Ae=void 0}function Ot(r,e,t){r.scrollLeft+=e,r.scrollTop+=t}function Nt(r){var e=window.Polymer,t=window.jQuery||window.Zepto;return e&&e.dom?e.dom(r).cloneNode(!0):t?t(r).clone(!0)[0]:r.cloneNode(!0)}function Rt(r,e,t){var i={};return Array.from(r.children).forEach(function(n){var o,a,l,c;if(!(!H(n,e.draggable,r,!1)||n.animated||n===t)){var s=I(n);i.left=Math.min((o=i.left)!==null&&o!==void 0?o:1/0,s.left),i.top=Math.min((a=i.top)!==null&&a!==void 0?a:1/0,s.top),i.right=Math.max((l=i.right)!==null&&l!==void 0?l:-1/0,s.right),i.bottom=Math.max((c=i.bottom)!==null&&c!==void 0?c:-1/0,s.bottom)}}),i.width=i.right-i.left,i.height=i.bottom-i.top,i.x=i.left,i.y=i.top,i}var V="Sortable"+new Date().getTime();function ni(){var r=[],e;return{captureAnimationState:function(){if(r=[],!!this.options.animation){var i=[].slice.call(this.el.children);i.forEach(function(n){if(!(m(n,"display")==="none"||n===g.ghost)){r.push({target:n,rect:I(n)});var o=X({},r[r.length-1].rect);if(n.thisAnimationDuration){var a=pe(n,!0);a&&(o.top-=a.f,o.left-=a.e)}n.fromRect=o}})}},addAnimationState:function(i){r.push(i)},removeAnimationState:function(i){r.splice(ti(r,{target:i}),1)},animateAll:function(i){var n=this;if(!this.options.animation){clearTimeout(e),typeof i=="function"&&i();return}var o=!1,a=0;r.forEach(function(l){var c=0,s=l.target,d=s.fromRect,u=I(s),p=s.prevFromRect,f=s.prevToRect,v=l.rect,y=pe(s,!0);y&&(u.top-=y.f,u.left-=y.e),s.toRect=u,s.thisAnimationDuration&&Ge(p,u)&&!Ge(d,u)&&(v.top-u.top)/(v.left-u.left)===(d.top-u.top)/(d.left-u.left)&&(c=ai(v,p,f,n.options)),Ge(u,d)||(s.prevFromRect=d,s.prevToRect=u,c||(c=n.options.animation),n.animate(s,v,u,c)),c&&(o=!0,a=Math.max(a,c),clearTimeout(s.animationResetTimer),s.animationResetTimer=setTimeout(function(){s.animationTime=0,s.prevFromRect=null,s.fromRect=null,s.prevToRect=null,s.thisAnimationDuration=null},c),s.thisAnimationDuration=c)}),clearTimeout(e),o?e=setTimeout(function(){typeof i=="function"&&i()},a):typeof i=="function"&&i(),r=[]},animate:function(i,n,o,a){if(a){m(i,"transition",""),m(i,"transform","");var l=pe(this.el),c=l&&l.a,s=l&&l.d,d=(n.left-o.left)/(c||1),u=(n.top-o.top)/(s||1);i.animatingX=!!d,i.animatingY=!!u,m(i,"transform","translate3d("+d+"px,"+u+"px,0)"),this.forRepaintDummy=oi(i),m(i,"transition","transform "+a+"ms"+(this.options.easing?" "+this.options.easing:"")),m(i,"transform","translate3d(0,0,0)"),typeof i.animated=="number"&&clearTimeout(i.animated),i.animated=setTimeout(function(){m(i,"transition",""),m(i,"transform",""),i.animated=!1,i.animatingX=!1,i.animatingY=!1},a)}}}}function oi(r){return r.offsetWidth}function ai(r,e,t,i){return Math.sqrt(Math.pow(e.top-r.top,2)+Math.pow(e.left-r.left,2))/Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))*i.animation}var ue=[],Ze={initializeByDefault:!0},Me={mount:function(e){for(var t in Ze)Ze.hasOwnProperty(t)&&!(t in e)&&(e[t]=Ze[t]);ue.forEach(function(i){if(i.pluginName===e.pluginName)throw"Sortable: Cannot mount plugin ".concat(e.pluginName," more than once")}),ue.push(e)},pluginEvent:function(e,t,i){var n=this;this.eventCanceled=!1,i.cancel=function(){n.eventCanceled=!0};var o=e+"Global";ue.forEach(function(a){t[a.pluginName]&&(t[a.pluginName][o]&&t[a.pluginName][o](X({sortable:t},i)),t.options[a.pluginName]&&t[a.pluginName][e]&&t[a.pluginName][e](X({sortable:t},i)))})},initializePlugins:function(e,t,i,n){ue.forEach(function(l){var c=l.pluginName;if(!(!e.options[c]&&!l.initializeByDefault)){var s=new l(e,t,e.options);s.sortable=e,s.options=e.options,e[c]=s,Z(i,s.defaults)}});for(var o in e.options)if(e.options.hasOwnProperty(o)){var a=this.modifyOption(e,o,e.options[o]);typeof a<"u"&&(e.options[o]=a)}},getEventProperties:function(e,t){var i={};return ue.forEach(function(n){typeof n.eventProperties=="function"&&Z(i,n.eventProperties.call(t[n.pluginName],e))}),i},modifyOption:function(e,t,i){var n;return ue.forEach(function(o){e[o.pluginName]&&o.optionListeners&&typeof o.optionListeners[t]=="function"&&(n=o.optionListeners[t].call(e[o.pluginName],i))}),n}};function si(r){var e=r.sortable,t=r.rootEl,i=r.name,n=r.targetEl,o=r.cloneEl,a=r.toEl,l=r.fromEl,c=r.oldIndex,s=r.newIndex,d=r.oldDraggableIndex,u=r.newDraggableIndex,p=r.originalEvent,f=r.putSortable,v=r.extraEventProperties;if(e=e||t&&t[V],!!e){var y,x=e.options,N="on"+i.charAt(0).toUpperCase()+i.substr(1);window.CustomEvent&&!Q&&!ke?y=new CustomEvent(i,{bubbles:!0,cancelable:!0}):(y=document.createEvent("Event"),y.initEvent(i,!0,!0)),y.to=a||t,y.from=l||t,y.item=n||t,y.clone=o,y.oldIndex=c,y.newIndex=s,y.oldDraggableIndex=d,y.newDraggableIndex=u,y.originalEvent=p,y.pullMode=f?f.lastPutMode:void 0;var D=X(X({},v),Me.getEventProperties(i,e));for(var z in D)y[z]=D[z];t&&t.dispatchEvent(y),x[N]&&x[N].call(e,y)}}var li=["evt"],O=function(e,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=i.evt,o=Kt(i,li);Me.pluginEvent.bind(g)(e,t,X({dragEl:h,parentEl:T,ghostEl:b,rootEl:E,nextEl:le,lastDownEl:Ve,cloneEl:C,cloneHidden:te,dragStarted:Ee,putSortable:P,activeSortable:g.active,originalEvent:n,oldIndex:fe,oldDraggableIndex:Ie,newIndex:B,newDraggableIndex:ee,hideGhostForTarget:Vt,unhideGhostForTarget:$t,cloneNowHidden:function(){te=!0},cloneNowShown:function(){te=!1},dispatchSortableEvent:function(l){M({sortable:t,name:l,originalEvent:n})}},o))};function M(r){si(X({putSortable:P,cloneEl:C,targetEl:h,rootEl:E,oldIndex:fe,oldDraggableIndex:Ie,newIndex:B,newDraggableIndex:ee},r))}var h,T,b,E,le,Ve,C,te,fe,B,Ie,ee,Ne,P,he=!1,He=!1,Ue=[],ae,W,Qe,Ke,Et,Ct,Ee,de,xe,Pe=!1,Re=!1,$e,k,Je=[],at=!1,je=[],Ye=typeof document<"u",Fe=It,Tt=ke||Q?"cssFloat":"float",ci=Ye&&!xt&&!It&&"draggable"in document.createElement("div"),Ft=function(){if(Ye){if(Q)return!1;var r=document.createElement("x");return r.style.cssText="pointer-events:auto",r.style.pointerEvents==="auto"}}(),Lt=function(e,t){var i=m(e),n=parseInt(i.width)-parseInt(i.paddingLeft)-parseInt(i.paddingRight)-parseInt(i.borderLeftWidth)-parseInt(i.borderRightWidth),o=ve(e,0,t),a=ve(e,1,t),l=o&&m(o),c=a&&m(a),s=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+I(o).width,d=c&&parseInt(c.marginLeft)+parseInt(c.marginRight)+I(a).width;if(i.display==="flex")return i.flexDirection==="column"||i.flexDirection==="column-reverse"?"vertical":"horizontal";if(i.display==="grid")return i.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(o&&l.float&&l.float!=="none"){var u=l.float==="left"?"left":"right";return a&&(c.clear==="both"||c.clear===u)?"vertical":"horizontal"}return o&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||s>=n&&i[Tt]==="none"||a&&i[Tt]==="none"&&s+d>n)?"vertical":"horizontal"},ui=function(e,t,i){var n=i?e.left:e.top,o=i?e.right:e.bottom,a=i?e.width:e.height,l=i?t.left:t.top,c=i?t.right:t.bottom,s=i?t.width:t.height;return n===l||o===c||n+a/2===l+s/2},di=function(e,t){var i;return Ue.some(function(n){var o=n[V].options.emptyInsertThreshold;if(!(!o||ht(n))){var a=I(n),l=e>=a.left-o&&e<=a.right+o,c=t>=a.top-o&&t<=a.bottom+o;if(l&&c)return i=n}}),i},Bt=function(e){function t(o,a){return function(l,c,s,d){var u=l.options.group.name&&c.options.group.name&&l.options.group.name===c.options.group.name;if(o==null&&(a||u))return!0;if(o==null||o===!1)return!1;if(a&&o==="clone")return o;if(typeof o=="function")return t(o(l,c,s,d),a)(l,c,s,d);var p=(a?l:c).options.group.name;return o===!0||typeof o=="string"&&o===p||o.join&&o.indexOf(p)>-1}}var i={},n=e.group;(!n||Be(n)!="object")&&(n={name:n}),i.name=n.name,i.checkPull=t(n.pull,!0),i.checkPut=t(n.put),i.revertClone=n.revertClone,e.group=i},Vt=function(){!Ft&&b&&m(b,"display","none")},$t=function(){!Ft&&b&&m(b,"display","")};Ye&&!xt&&document.addEventListener("click",function(r){if(He)return r.preventDefault(),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),He=!1,!1},!0);var se=function(e){if(h){e=e.touches?e.touches[0]:e;var t=di(e.clientX,e.clientY);if(t){var i={};for(var n in e)e.hasOwnProperty(n)&&(i[n]=e[n]);i.target=i.rootEl=t,i.preventDefault=void 0,i.stopPropagation=void 0,t[V]._onDragOver(i)}}},hi=function(e){h&&h.parentNode[V]._isOutsideThisEl(e.target)};function g(r,e){if(!(r&&r.nodeType&&r.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));this.el=r,this.options=e=Z({},e),r[V]=this;var t={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(r.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Lt(r,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(a,l){a.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:g.supportPointer!==!1&&"PointerEvent"in window&&!De,emptyInsertThreshold:5};Me.initializePlugins(this,r,t);for(var i in t)!(i in e)&&(e[i]=t[i]);Bt(e);for(var n in this)n.charAt(0)==="_"&&typeof this[n]=="function"&&(this[n]=this[n].bind(this));this.nativeDraggable=e.forceFallback?!1:ci,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?_(r,"pointerdown",this._onTapStart):(_(r,"mousedown",this._onTapStart),_(r,"touchstart",this._onTapStart)),this.nativeDraggable&&(_(r,"dragover",this),_(r,"dragenter",this)),Ue.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Z(this,ni())}g.prototype={constructor:g,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(de=null)},_getDirection:function(e,t){return typeof this.options.direction=="function"?this.options.direction.call(this,e,t,h):this.options.direction},_onTapStart:function(e){if(e.cancelable){var t=this,i=this.el,n=this.options,o=n.preventOnFilter,a=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,c=(l||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||c,d=n.filter;if(wi(i),!h&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||n.disabled)&&!s.isContentEditable&&!(!this.nativeDraggable&&De&&c&&c.tagName.toUpperCase()==="SELECT")&&(c=H(c,n.draggable,i,!1),!(c&&c.animated)&&Ve!==c)){if(fe=q(c),Ie=q(c,n.draggable),typeof d=="function"){if(d.call(this,e,c,this)){M({sortable:t,rootEl:s,name:"filter",targetEl:c,toEl:i,fromEl:i}),O("filter",t,{evt:e}),o&&e.cancelable&&e.preventDefault();return}}else if(d&&(d=d.split(",").some(function(u){if(u=H(s,u.trim(),i,!1),u)return M({sortable:t,rootEl:u,name:"filter",targetEl:c,fromEl:i,toEl:i}),O("filter",t,{evt:e}),!0}),d)){o&&e.cancelable&&e.preventDefault();return}n.handle&&!H(s,n.handle,i,!1)||this._prepareDragStart(e,l,c)}}},_prepareDragStart:function(e,t,i){var n=this,o=n.el,a=n.options,l=o.ownerDocument,c;if(i&&!h&&i.parentNode===o){var s=I(i);if(E=o,h=i,T=h.parentNode,le=h.nextSibling,Ve=i,Ne=a.group,g.dragged=h,ae={target:h,clientX:(t||e).clientX,clientY:(t||e).clientY},Et=ae.clientX-s.left,Ct=ae.clientY-s.top,this._lastX=(t||e).clientX,this._lastY=(t||e).clientY,h.style["will-change"]="all",c=function(){if(O("delayEnded",n,{evt:e}),g.eventCanceled){n._onDrop();return}n._disableDelayedDragEvents(),!yt&&n.nativeDraggable&&(h.draggable=!0),n._triggerDragStart(e,t),M({sortable:n,name:"choose",originalEvent:e}),L(h,a.chosenClass,!0)},a.ignore.split(",").forEach(function(d){kt(h,d.trim(),et)}),_(l,"dragover",se),_(l,"mousemove",se),_(l,"touchmove",se),_(l,"mouseup",n._onDrop),_(l,"touchend",n._onDrop),_(l,"touchcancel",n._onDrop),yt&&this.nativeDraggable&&(this.options.touchStartThreshold=4,h.draggable=!0),O("delayStart",this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||t)&&(!this.nativeDraggable||!(ke||Q))){if(g.eventCanceled){this._onDrop();return}_(l,"mouseup",n._disableDelayedDrag),_(l,"touchend",n._disableDelayedDrag),_(l,"touchcancel",n._disableDelayedDrag),_(l,"mousemove",n._delayedDragTouchMoveHandler),_(l,"touchmove",n._delayedDragTouchMoveHandler),a.supportPointer&&_(l,"pointermove",n._delayedDragTouchMoveHandler),n._dragStartTimer=setTimeout(c,a.delay)}else c()}},_delayedDragTouchMoveHandler:function(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){h&&et(h),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;w(e,"mouseup",this._disableDelayedDrag),w(e,"touchend",this._disableDelayedDrag),w(e,"touchcancel",this._disableDelayedDrag),w(e,"mousemove",this._delayedDragTouchMoveHandler),w(e,"touchmove",this._delayedDragTouchMoveHandler),w(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,t){t=t||e.pointerType=="touch"&&e,!this.nativeDraggable||t?this.options.supportPointer?_(document,"pointermove",this._onTouchMove):t?_(document,"touchmove",this._onTouchMove):_(document,"mousemove",this._onTouchMove):(_(h,"dragend",this),_(E,"dragstart",this._onDragStart));try{document.selection?qe(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(e,t){if(he=!1,E&&h){O("dragStarted",this,{evt:t}),this.nativeDraggable&&_(document,"dragover",hi);var i=this.options;!e&&L(h,i.dragClass,!1),L(h,i.ghostClass,!0),g.active=this,e&&this._appendGhost(),M({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function(){if(W){this._lastX=W.clientX,this._lastY=W.clientY,Vt();for(var e=document.elementFromPoint(W.clientX,W.clientY),t=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(W.clientX,W.clientY),e!==t);)t=e;if(h.parentNode[V]._isOutsideThisEl(e),t)do{if(t[V]){var i=void 0;if(i=t[V]._onDragOver({clientX:W.clientX,clientY:W.clientY,target:e,rootEl:t}),i&&!this.options.dragoverBubble)break}e=t}while(t=t.parentNode);$t()}},_onTouchMove:function(e){if(ae){var t=this.options,i=t.fallbackTolerance,n=t.fallbackOffset,o=e.touches?e.touches[0]:e,a=b&&pe(b,!0),l=b&&a&&a.a,c=b&&a&&a.d,s=Fe&&k&&_t(k),d=(o.clientX-ae.clientX+n.x)/(l||1)+(s?s[0]-Je[0]:0)/(l||1),u=(o.clientY-ae.clientY+n.y)/(c||1)+(s?s[1]-Je[1]:0)/(c||1);if(!g.active&&!he){if(i&&Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))<i)return;this._onDragStart(e,!0)}if(b){a?(a.e+=d-(Qe||0),a.f+=u-(Ke||0)):a={a:1,b:0,c:0,d:1,e:d,f:u};var p="matrix(".concat(a.a,",").concat(a.b,",").concat(a.c,",").concat(a.d,",").concat(a.e,",").concat(a.f,")");m(b,"webkitTransform",p),m(b,"mozTransform",p),m(b,"msTransform",p),m(b,"transform",p),Qe=d,Ke=u,W=o}e.cancelable&&e.preventDefault()}},_appendGhost:function(){if(!b){var e=this.options.fallbackOnBody?document.body:E,t=I(h,!0,Fe,!0,e),i=this.options;if(Fe){for(k=e;m(k,"position")==="static"&&m(k,"transform")==="none"&&k!==document;)k=k.parentNode;k!==document.body&&k!==document.documentElement?(k===document&&(k=j()),t.top+=k.scrollTop,t.left+=k.scrollLeft):k=j(),Je=_t(k)}b=h.cloneNode(!0),L(b,i.ghostClass,!1),L(b,i.fallbackClass,!0),L(b,i.dragClass,!0),m(b,"transition",""),m(b,"transform",""),m(b,"box-sizing","border-box"),m(b,"margin",0),m(b,"top",t.top),m(b,"left",t.left),m(b,"width",t.width),m(b,"height",t.height),m(b,"opacity","0.8"),m(b,"position",Fe?"absolute":"fixed"),m(b,"zIndex","100000"),m(b,"pointerEvents","none"),g.ghost=b,e.appendChild(b),m(b,"transform-origin",Et/parseInt(b.style.width)*100+"% "+Ct/parseInt(b.style.height)*100+"%")}},_onDragStart:function(e,t){var i=this,n=e.dataTransfer,o=i.options;if(O("dragStart",this,{evt:e}),g.eventCanceled){this._onDrop();return}O("setupClone",this),g.eventCanceled||(C=Nt(h),C.removeAttribute("id"),C.draggable=!1,C.style["will-change"]="",this._hideClone(),L(C,this.options.chosenClass,!1),g.clone=C),i.cloneId=qe(function(){O("clone",i),!g.eventCanceled&&(i.options.removeCloneOnHide||E.insertBefore(C,h),i._hideClone(),M({sortable:i,name:"clone"}))}),!t&&L(h,o.dragClass,!0),t?(He=!0,i._loopId=setInterval(i._emulateDragOver,50)):(w(document,"mouseup",i._onDrop),w(document,"touchend",i._onDrop),w(document,"touchcancel",i._onDrop),n&&(n.effectAllowed="move",o.setData&&o.setData.call(i,n,h)),_(document,"drop",i),m(h,"transform","translateZ(0)")),he=!0,i._dragStartId=qe(i._dragStarted.bind(i,t,e)),_(document,"selectstart",i),Ee=!0,De&&m(document.body,"user-select","none")},_onDragOver:function(e){var t=this.el,i=e.target,n,o,a,l=this.options,c=l.group,s=g.active,d=Ne===c,u=l.sort,p=P||s,f,v=this,y=!1;if(at)return;function x(_e,zt){O(_e,v,X({evt:e,isOwner:d,axis:f?"vertical":"horizontal",revert:a,dragRect:n,targetRect:o,canSort:u,fromSortable:p,target:i,completed:D,onMove:function(mt,Wt){return Le(E,t,h,n,mt,I(mt),e,Wt)},changed:z},zt))}function N(){x("dragOverAnimationCapture"),v.captureAnimationState(),v!==p&&p.captureAnimationState()}function D(_e){return x("dragOverCompleted",{insertion:_e}),_e&&(d?s._hideClone():s._showClone(v),v!==p&&(L(h,P?P.options.ghostClass:s.options.ghostClass,!1),L(h,l.ghostClass,!0)),P!==v&&v!==g.active?P=v:v===g.active&&P&&(P=null),p===v&&(v._ignoreWhileAnimating=i),v.animateAll(function(){x("dragOverAnimationComplete"),v._ignoreWhileAnimating=null}),v!==p&&(p.animateAll(),p._ignoreWhileAnimating=null)),(i===h&&!h.animated||i===t&&!i.animated)&&(de=null),!l.dragoverBubble&&!e.rootEl&&i!==document&&(h.parentNode[V]._isOutsideThisEl(e.target),!_e&&se(e)),!l.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),y=!0}function z(){B=q(h),ee=q(h,l.draggable),M({sortable:v,name:"change",toEl:t,newIndex:B,newDraggableIndex:ee,originalEvent:e})}if(e.preventDefault!==void 0&&e.cancelable&&e.preventDefault(),i=H(i,l.draggable,t,!0),x("dragOver"),g.eventCanceled)return y;if(h.contains(e.target)||i.animated&&i.animatingX&&i.animatingY||v._ignoreWhileAnimating===i)return D(!1);if(He=!1,s&&!l.disabled&&(d?u||(a=T!==E):P===this||(this.lastPutMode=Ne.checkPull(this,s,h,e))&&c.checkPut(this,s,h,e))){if(f=this._getDirection(e,i)==="vertical",n=I(h),x("dragOverValid"),g.eventCanceled)return y;if(a)return T=E,N(),this._hideClone(),x("revert"),g.eventCanceled||(le?E.insertBefore(h,le):E.appendChild(h)),D(!0);var R=ht(t,l.draggable);if(!R||gi(e,f,this)&&!R.animated){if(R===h)return D(!1);if(R&&t===e.target&&(i=R),i&&(o=I(i)),Le(E,t,h,n,i,o,e,!!i)!==!1)return N(),R&&R.nextSibling?t.insertBefore(h,R.nextSibling):t.appendChild(h),T=t,z(),D(!0)}else if(R&&mi(e,f,this)){var re=ve(t,0,l,!0);if(re===h)return D(!1);if(i=re,o=I(i),Le(E,t,h,n,i,o,e,!1)!==!1)return N(),t.insertBefore(h,re),T=t,z(),D(!0)}else if(i.parentNode===t){o=I(i);var U=0,ne,be=h.parentNode!==t,F=!ui(h.animated&&h.toRect||n,i.animated&&i.toRect||o,f),ye=f?"top":"left",K=St(i,"top","top")||St(h,"top","top"),we=K?K.scrollTop:void 0;de!==i&&(ne=o[ye],Pe=!1,Re=!F&&l.invertSwap||be),U=vi(e,i,o,f,F?1:l.swapThreshold,l.invertedSwapThreshold==null?l.swapThreshold:l.invertedSwapThreshold,Re,de===i);var Y;if(U!==0){var oe=q(h);do oe-=U,Y=T.children[oe];while(Y&&(m(Y,"display")==="none"||Y===b))}if(U===0||Y===i)return D(!1);de=i,xe=U;var Se=i.nextElementSibling,J=!1;J=U===1;var Oe=Le(E,t,h,n,i,o,e,J);if(Oe!==!1)return(Oe===1||Oe===-1)&&(J=Oe===1),at=!0,setTimeout(pi,30),N(),J&&!Se?t.appendChild(h):i.parentNode.insertBefore(h,J?Se:i),K&&Ot(K,0,we-K.scrollTop),T=h.parentNode,ne!==void 0&&!Re&&($e=Math.abs(ne-I(i)[ye])),z(),D(!0)}if(t.contains(h))return D(!1)}return!1},_ignoreWhileAnimating:null,_offMoveEvents:function(){w(document,"mousemove",this._onTouchMove),w(document,"touchmove",this._onTouchMove),w(document,"pointermove",this._onTouchMove),w(document,"dragover",se),w(document,"mousemove",se),w(document,"touchmove",se)},_offUpEvents:function(){var e=this.el.ownerDocument;w(e,"mouseup",this._onDrop),w(e,"touchend",this._onDrop),w(e,"pointerup",this._onDrop),w(e,"touchcancel",this._onDrop),w(document,"selectstart",this)},_onDrop:function(e){var t=this.el,i=this.options;if(B=q(h),ee=q(h,i.draggable),O("drop",this,{evt:e}),T=h&&h.parentNode,B=q(h),ee=q(h,i.draggable),g.eventCanceled){this._nulling();return}he=!1,Re=!1,Pe=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),st(this.cloneId),st(this._dragStartId),this.nativeDraggable&&(w(document,"drop",this),w(t,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),De&&m(document.body,"user-select",""),m(h,"transform",""),e&&(Ee&&(e.cancelable&&e.preventDefault(),!i.dropBubble&&e.stopPropagation()),b&&b.parentNode&&b.parentNode.removeChild(b),(E===T||P&&P.lastPutMode!=="clone")&&C&&C.parentNode&&C.parentNode.removeChild(C),h&&(this.nativeDraggable&&w(h,"dragend",this),et(h),h.style["will-change"]="",Ee&&!he&&L(h,P?P.options.ghostClass:this.options.ghostClass,!1),L(h,this.options.chosenClass,!1),M({sortable:this,name:"unchoose",toEl:T,newIndex:null,newDraggableIndex:null,originalEvent:e}),E!==T?(B>=0&&(M({rootEl:T,name:"add",toEl:T,fromEl:E,originalEvent:e}),M({sortable:this,name:"remove",toEl:T,originalEvent:e}),M({rootEl:T,name:"sort",toEl:T,fromEl:E,originalEvent:e}),M({sortable:this,name:"sort",toEl:T,originalEvent:e})),P&&P.save()):B!==fe&&B>=0&&(M({sortable:this,name:"update",toEl:T,originalEvent:e}),M({sortable:this,name:"sort",toEl:T,originalEvent:e})),g.active&&((B==null||B===-1)&&(B=fe,ee=Ie),M({sortable:this,name:"end",toEl:T,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){O("nulling",this),E=h=T=b=le=C=Ve=te=ae=W=Ee=B=ee=fe=Ie=de=xe=P=Ne=g.dragged=g.ghost=g.clone=g.active=null,je.forEach(function(e){e.checked=!0}),je.length=Qe=Ke=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":h&&(this._onDragOver(e),fi(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],t,i=this.el.children,n=0,o=i.length,a=this.options;n<o;n++)t=i[n],H(t,a.draggable,this.el,!1)&&e.push(t.getAttribute(a.dataIdAttr)||yi(t));return e},sort:function(e,t){var i={},n=this.el;this.toArray().forEach(function(o,a){var l=n.children[a];H(l,this.options.draggable,n,!1)&&(i[o]=l)},this),t&&this.captureAnimationState(),e.forEach(function(o){i[o]&&(n.removeChild(i[o]),n.appendChild(i[o]))}),t&&this.animateAll()},save:function(){var e=this.options.store;e&&e.set&&e.set(this)},closest:function(e,t){return H(e,t||this.options.draggable,this.el,!1)},option:function(e,t){var i=this.options;if(t===void 0)return i[e];var n=Me.modifyOption(this,e,t);typeof n<"u"?i[e]=n:i[e]=t,e==="group"&&Bt(i)},destroy:function(){O("destroy",this);var e=this.el;e[V]=null,w(e,"mousedown",this._onTapStart),w(e,"touchstart",this._onTapStart),w(e,"pointerdown",this._onTapStart),this.nativeDraggable&&(w(e,"dragover",this),w(e,"dragenter",this)),Array.prototype.forEach.call(e.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),this._disableDelayedDragEvents(),Ue.splice(Ue.indexOf(this.el),1),this.el=e=null},_hideClone:function(){if(!te){if(O("hideClone",this),g.eventCanceled)return;m(C,"display","none"),this.options.removeCloneOnHide&&C.parentNode&&C.parentNode.removeChild(C),te=!0}},_showClone:function(e){if(e.lastPutMode!=="clone"){this._hideClone();return}if(te){if(O("showClone",this),g.eventCanceled)return;h.parentNode==E&&!this.options.group.revertClone?E.insertBefore(C,h):le?E.insertBefore(C,le):E.appendChild(C),this.options.group.revertClone&&this.animate(h,C),m(C,"display",""),te=!1}}};function fi(r){r.dataTransfer&&(r.dataTransfer.dropEffect="move"),r.cancelable&&r.preventDefault()}function Le(r,e,t,i,n,o,a,l){var c,s=r[V],d=s.options.onMove,u;return window.CustomEvent&&!Q&&!ke?c=new CustomEvent("move",{bubbles:!0,cancelable:!0}):(c=document.createEvent("Event"),c.initEvent("move",!0,!0)),c.to=e,c.from=r,c.dragged=t,c.draggedRect=i,c.related=n||e,c.relatedRect=o||I(e),c.willInsertAfter=l,c.originalEvent=a,r.dispatchEvent(c),d&&(u=d.call(s,c,a)),u}function et(r){r.draggable=!1}function pi(){at=!1}function mi(r,e,t){var i=I(ve(t.el,0,t.options,!0)),n=Rt(t.el,t.options,b),o=10;return e?r.clientX<n.left-o||r.clientY<i.top&&r.clientX<i.right:r.clientY<n.top-o||r.clientY<i.bottom&&r.clientX<i.left}function gi(r,e,t){var i=I(ht(t.el,t.options.draggable)),n=Rt(t.el,t.options,b),o=10;return e?r.clientX>n.right+o||r.clientY>i.bottom&&r.clientX>i.left:r.clientY>n.bottom+o||r.clientX>i.right&&r.clientY>i.top}function vi(r,e,t,i,n,o,a,l){var c=i?r.clientY:r.clientX,s=i?t.height:t.width,d=i?t.top:t.left,u=i?t.bottom:t.right,p=!1;if(!a){if(l&&$e<s*n){if(!Pe&&(xe===1?c>d+s*o/2:c<u-s*o/2)&&(Pe=!0),Pe)p=!0;else if(xe===1?c<d+$e:c>u-$e)return-xe}else if(c>d+s*(1-n)/2&&c<u-s*(1-n)/2)return bi(e)}return p=p||a,p&&(c<d+s*o/2||c>u-s*o/2)?c>d+s/2?1:-1:0}function bi(r){return q(h)<q(r)?1:-1}function yi(r){for(var e=r.tagName+r.className+r.src+r.href+r.textContent,t=e.length,i=0;t--;)i+=e.charCodeAt(t);return i.toString(36)}function wi(r){je.length=0;for(var e=r.getElementsByTagName("input"),t=e.length;t--;){var i=e[t];i.checked&&je.push(i)}}function qe(r){return setTimeout(r,0)}function st(r){return clearTimeout(r)}Ye&&_(document,"touchmove",function(r){(g.active||he)&&r.cancelable&&r.preventDefault()});g.utils={on:_,off:w,css:m,find:kt,is:function(e,t){return!!H(e,t,e,!1)},extend:ii,throttle:Mt,closest:H,toggleClass:L,clone:Nt,index:q,nextTick:qe,cancelNextTick:st,detectDirection:Lt,getChild:ve};g.get=function(r){return r[V]};g.mount=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];e[0].constructor===Array&&(e=e[0]),e.forEach(function(i){if(!i.prototype||!i.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(i));i.utils&&(g.utils=X(X({},g.utils),i.utils)),Me.mount(i)})};g.create=function(r,e){return new g(r,e)};g.version=Jt;var A=[],Ce,lt,ct=!1,tt,it,Xe,Te;function Si(){function r(){this.defaults={scroll:!0,forceAutoScrollFallback:!1,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0};for(var e in this)e.charAt(0)==="_"&&typeof this[e]=="function"&&(this[e]=this[e].bind(this))}return r.prototype={dragStarted:function(t){var i=t.originalEvent;this.sortable.nativeDraggable?_(document,"dragover",this._handleAutoScroll):this.options.supportPointer?_(document,"pointermove",this._handleFallbackAutoScroll):i.touches?_(document,"touchmove",this._handleFallbackAutoScroll):_(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var i=t.originalEvent;!this.options.dragOverBubble&&!i.rootEl&&this._handleAutoScroll(i)},drop:function(){this.sortable.nativeDraggable?w(document,"dragover",this._handleAutoScroll):(w(document,"pointermove",this._handleFallbackAutoScroll),w(document,"touchmove",this._handleFallbackAutoScroll),w(document,"mousemove",this._handleFallbackAutoScroll)),Dt(),ze(),ri()},nulling:function(){Xe=lt=Ce=ct=Te=tt=it=null,A.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(t,i){var n=this,o=(t.touches?t.touches[0]:t).clientX,a=(t.touches?t.touches[0]:t).clientY,l=document.elementFromPoint(o,a);if(Xe=t,i||this.options.forceAutoScrollFallback||ke||Q||De){rt(t,this.options,l,i);var c=ie(l,!0);ct&&(!Te||o!==tt||a!==it)&&(Te&&Dt(),Te=setInterval(function(){var s=ie(document.elementFromPoint(o,a),!0);s!==c&&(c=s,ze()),rt(t,n.options,s,i)},10),tt=o,it=a)}else{if(!this.options.bubbleScroll||ie(l,!0)===j()){ze();return}rt(t,this.options,ie(l,!1),!1)}}},Z(r,{pluginName:"scroll",initializeByDefault:!0})}function ze(){A.forEach(function(r){clearInterval(r.pid)}),A=[]}function Dt(){clearInterval(Te)}var rt=Mt(function(r,e,t,i){if(e.scroll){var n=(r.touches?r.touches[0]:r).clientX,o=(r.touches?r.touches[0]:r).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,c=j(),s=!1,d;lt!==t&&(lt=t,ze(),Ce=e.scroll,d=e.scrollFn,Ce===!0&&(Ce=ie(t,!0)));var u=0,p=Ce;do{var f=p,v=I(f),y=v.top,x=v.bottom,N=v.left,D=v.right,z=v.width,R=v.height,re=void 0,U=void 0,ne=f.scrollWidth,be=f.scrollHeight,F=m(f),ye=f.scrollLeft,K=f.scrollTop;f===c?(re=z<ne&&(F.overflowX==="auto"||F.overflowX==="scroll"||F.overflowX==="visible"),U=R<be&&(F.overflowY==="auto"||F.overflowY==="scroll"||F.overflowY==="visible")):(re=z<ne&&(F.overflowX==="auto"||F.overflowX==="scroll"),U=R<be&&(F.overflowY==="auto"||F.overflowY==="scroll"));var we=re&&(Math.abs(D-n)<=a&&ye+z<ne)-(Math.abs(N-n)<=a&&!!ye),Y=U&&(Math.abs(x-o)<=a&&K+R<be)-(Math.abs(y-o)<=a&&!!K);if(!A[u])for(var oe=0;oe<=u;oe++)A[oe]||(A[oe]={});(A[u].vx!=we||A[u].vy!=Y||A[u].el!==f)&&(A[u].el=f,A[u].vx=we,A[u].vy=Y,clearInterval(A[u].pid),(we!=0||Y!=0)&&(s=!0,A[u].pid=setInterval((function(){i&&this.layer===0&&g.active._onTouchMove(Xe);var Se=A[this.layer].vy?A[this.layer].vy*l:0,J=A[this.layer].vx?A[this.layer].vx*l:0;typeof d=="function"&&d.call(g.dragged.parentNode[V],J,Se,r,Xe,A[this.layer].el)!=="continue"||Ot(A[this.layer].el,J,Se)}).bind({layer:u}),24))),u++}while(e.bubbleScroll&&p!==c&&(p=ie(p,!1)));ct=s}},30),qt=function(e){var t=e.originalEvent,i=e.putSortable,n=e.dragEl,o=e.activeSortable,a=e.dispatchSortableEvent,l=e.hideGhostForTarget,c=e.unhideGhostForTarget;if(t){var s=i||o;l();var d=t.changedTouches&&t.changedTouches.length?t.changedTouches[0]:t,u=document.elementFromPoint(d.clientX,d.clientY);c(),s&&!s.el.contains(u)&&(a("spill"),this.onSpill({dragEl:n,putSortable:i}))}};function ft(){}ft.prototype={startIndex:null,dragStart:function(e){var t=e.oldDraggableIndex;this.startIndex=t},onSpill:function(e){var t=e.dragEl,i=e.putSortable;this.sortable.captureAnimationState(),i&&i.captureAnimationState();var n=ve(this.sortable.el,this.startIndex,this.options);n?this.sortable.el.insertBefore(t,n):this.sortable.el.appendChild(t),this.sortable.animateAll(),i&&i.animateAll()},drop:qt};Z(ft,{pluginName:"revertOnSpill"});function pt(){}pt.prototype={onSpill:function(e){var t=e.dragEl,i=e.putSortable,n=i||this.sortable;n.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),n.animateAll()},drop:qt};Z(pt,{pluginName:"removeOnSpill"});g.mount(new Si);g.mount(pt,ft);var _i=g;function Ei(r){r.directive("sort",(e,{value:t,modifiers:i,expression:n},{effect:o,evaluate:a,evaluateLater:l,cleanup:c})=>{if(t==="config"||t==="handle"||t==="group")return;if(t==="key"||t==="item"){if([void 0,null,""].includes(n))return;e._x_sort_key=a(n);return}let s={hideGhost:!i.includes("ghost"),useHandles:!!e.querySelector("[x-sort\\:handle]"),group:Ii(e,i)},d=Ci(n,l),u=Ti(e,i,a),p=Di(e,u,s,(f,v)=>{d(f,v)});c(()=>p.destroy())})}function Ci(r,e){if([void 0,null,""].includes(r))return()=>{};let t=e(r);return(i,n)=>{Alpine.dontAutoEvaluateFunctions(()=>{t(o=>{typeof o=="function"&&o(i,n)},{scope:{$key:i,$item:i,$position:n}})})}}function Ti(r,e,t){return r.hasAttribute("x-sort:config")?t(r.getAttribute("x-sort:config")):{}}function Di(r,e,t,i){let n,o={animation:150,handle:t.useHandles?"[x-sort\\:handle]":null,group:t.group,filter(a){return r.querySelector("[x-sort\\:item]")?!a.target.closest("[x-sort\\:item]"):!1},onSort(a){if(a.from!==a.to&&a.to!==a.target)return;let l=a.item._x_sort_key,c=a.newIndex;(l!==void 0||l!==null)&&i(l,c)},onStart(){document.body.classList.add("sorting"),n=document.querySelector(".sortable-ghost"),t.hideGhost&&n&&(n.style.opacity="0")},onEnd(){document.body.classList.remove("sorting"),t.hideGhost&&n&&(n.style.opacity="1"),n=void 0,Ai(r)}};return new _i(r,{...o,...e})}function Ai(r){let e=r.firstChild;for(;e.nextSibling;){if(e.textContent.trim()==="[if ENDBLOCK]><![endif]"){r.append(e);break}e=e.nextSibling}}function Ii(r,e){return r.hasAttribute("x-sort:group")?r.getAttribute("x-sort:group"):e.indexOf("group")!==-1?e[e.indexOf("group")+1]:null}var xi=Ei;/*! Bundled license information: sortablejs/modular/sortable.esm.js: (**! * Sortable 1.15.2 * @author RubaXa <trash@rubaxa.org> * @author owenm <owen23355@gmail.com> * @license MIT *) */function Pi(r={show:!1,focusable:!1}){return{show:r.show,focusable:r.focusable,closeModal(){this.show=!1},openModal(){this.show=!0},focusables(){let e="a, button, input:not([type='hidden']), textarea, select, details, [tabindex]:not([tabindex='-1'])";return[...this.$el.querySelectorAll(e)].filter(t=>!t.hasAttribute("disabled"))},firstFocusable(){return this.focusables()[0]},lastFocusable(){return this.focusables().slice(-1)[0]},nextFocusable(){return this.focusables()[this.nextFocusableIndex()]||this.firstFocusable()},prevFocusable(){return this.focusables()[this.prevFocusableIndex()]||this.lastFocusable()},nextFocusableIndex(){return(this.focusables().indexOf(document.activeElement)+1)%(this.focusables().length+1)},prevFocusableIndex(){return Math.max(0,this.focusables().indexOf(document.activeElement))-1},init(){this.$watch("show",e=>{e?(document.body.classList.add("overflow-y-hidden"),this.focusable!==!1&&setTimeout(()=>this.firstFocusable().focus(),100)):document.body.classList.remove("overflow-y-hidden")})}}}function ki(r={}){return{isShared:r.isShared??!1,limits:r.limits??{},init(){},pushToAiEngines(e){this.aiEngines.push(e)}}}class Mi{constructor(){this.playbackNode=null}async init(e){this.audioContext=new AudioContext({sampleRate:e}),await this.audioContext.audioWorklet.addModule("/themes/default/assets/js/audio/playback-worklet.js"),this.playbackNode=new AudioWorkletNode(this.audioContext,"playback-worklet"),this.playbackNode.connect(this.audioContext.destination)}play(e){this.playbackNode&&this.playbackNode.port.postMessage(e)}clear(){this.playbackNode&&this.playbackNode.port.postMessage(null)}}class Oi{constructor(e){this.onDataAvailable=e,this.audioContext=null,this.mediaStream=null,this.mediaStreamSource=null,this.workletNode=null}async start(e){try{this.audioContext=new AudioContext({sampleRate:24e3}),await this.audioContext.audioWorklet.addModule("/themes/default/assets/js/audio/audio-worklet-processor.js"),this.mediaStream=e,this.mediaStreamSource=this.audioContext.createMediaStreamSource(this.mediaStream),this.workletNode=new AudioWorkletNode(this.audioContext,"audio-worklet-processor"),this.workletNode.port.onmessage=t=>this.onDataAvailable(t.data.buffer),this.mediaStreamSource.connect(this.workletNode)}catch(t){console.error("Error in recorder start:",t),this.stop()}}stop(){this.mediaStream&&this.mediaStream.getTracks().forEach(e=>e.stop()),this.audioContext&&this.audioContext.state!=="closed"&&this.audioContext.close()}getMediaStreamSource(){return this.mediaStreamSource}}function me(r,e,t,i){function n(o){return o instanceof t?o:new t(function(a){a(o)})}return new(t||(t=Promise))(function(o,a){function l(d){try{s(i.next(d))}catch(u){a(u)}}function c(d){try{s(i.throw(d))}catch(u){a(u)}}function s(d){d.done?o(d.value):n(d.value).then(l,c)}s((i=i.apply(r,e||[])).next())})}function ce(r,e){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(s){return function(d){return c([s,d])}}function c(s){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(t=0)),t;)try{if(i=1,n&&(o=s[0]&2?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,n=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1],o=s;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(s);break}o[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(r,t)}catch(d){s=[6,d],n=0}finally{i=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function At(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function nt(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,o=[],a;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return o}function ge(r){return this instanceof ge?(this.v=r,this):new ge(r)}function Ni(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=t.apply(r,e||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(v){return Promise.resolve(v).then(f,u)}}function l(f,v){i[f]&&(n[f]=function(y){return new Promise(function(x,N){o.push([f,y,x,N])>1||c(f,y)})},v&&(n[f]=v(n[f])))}function c(f,v){try{s(i[f](v))}catch(y){p(o[0][3],y)}}function s(f){f.value instanceof ge?Promise.resolve(f.value.v).then(d,u):p(o[0][2],f)}function d(f){c("next",f)}function u(f){c("throw",f)}function p(f,v){f(v),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Ri(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof At=="function"?At(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(o){t[o]=r[o]&&function(a){return new Promise(function(l,c){a=r[o](a),n(l,c,a.done,a.value)})}}function n(o,a,l,c){Promise.resolve(c).then(function(s){o({value:s,done:l})},a)}}var Fi=function(r){return typeof r=="object"&&r!==null&&"type"in r},Li=function(r){return Fi(r)&&["error","session.created","session.updated","input_audio_buffer.committed","input_audio_buffer.cleared","input_audio_buffer.speech_started","input_audio_buffer.speech_stopped","conversation.item.created","conversation.item.truncated","conversation.item.deleted","conversation.item.input_audio_transcription.completed","conversation.item.input_audio_transcription.failed","response.created","response.done","response.output_item.added","response.output_item.done","response.content_part.added","response.content_part.done","response.text.delta","response.text.done","response.audio_transcript.delta","response.audio_transcript.done","response.audio.delta","response.audio.done","response.function_call_arguments.delta","response.function_call_arguments.done","rate_limits.updated"].includes(r.type)},Bi=WebSocket,Vi=function(r,e){return r.readyState!==WebSocket.OPEN?Promise.reject(new Error("Socket is not open")):(r.send(e),Promise.resolve())},$i=function(r){return{success:!0,message:r}},ot=function(r){return{success:!1,error:r}},qi=function(r){return r.success},zi=function(){function r(e,t){var i=this;this.closedPromise=void 0,this.messageQueue=[],this.receiverQueue=[],this.done=!1,this.validate=t.validate,this.serialize=t.serialize,this.connectedPromise=new Promise(function(n,o){return me(i,void 0,void 0,function(){var a,l,c,s,d=this;return ce(this,function(u){switch(u.label){case 0:return e.policy!==void 0?[3,1]:(s=e,[3,3]);case 1:return[4,e.policy(e)];case 2:s=u.sent(),u.label=3;case 3:return a=s,l=a.uri,c=a.protocols,this.socket=new Bi(l.toString(),c),this.socket.onopen=function(){d.socket.onmessage=d.getMessageHandler(),d.closedPromise=new Promise(function(p){d.socket.onclose=d.getClosedHandler(p)}),d.socket.onerror=d.handleError,n()},this.socket.onerror=function(p){d.error=p.error,o(p)},[2]}})})})}return r.prototype.handleError=function(e){for(this.error=e.error;this.receiverQueue.length>0;){var t=nt(this.receiverQueue.shift(),2);t[0];var i=t[1];i(e.error)}},r.prototype.getClosedHandler=function(e){var t=this;return function(i){for(t.done=!0;t.receiverQueue.length>0;){var n=nt(t.receiverQueue.shift(),2),o=n[0],a=n[1];t.error?a(t.error):o({value:void 0,done:!0})}e()}},r.prototype.getMessageHandler=function(){var e=this;return function(t){var i=e.validate(t);if(qi(i)){var n=i.message;if(e.receiverQueue.length>0){var o=nt(e.receiverQueue.shift(),2),a=o[0];o[1],a({value:n,done:!1})}else e.messageQueue.push(n)}else e.error=i.error,e.socket.close(1e3,"Unexpected message received")}},r.prototype[Symbol.asyncIterator]=function(){var e=this;return{next:function(){if(e.error)return Promise.reject(e.error);if(e.done)return Promise.resolve({value:void 0,done:!0});if(e.messageQueue.length>0){var t=e.messageQueue.shift();return Promise.resolve({value:t,done:!1})}else return new Promise(function(i,n){e.receiverQueue.push([i,n])})}}},r.prototype.send=function(e){return me(this,void 0,void 0,function(){var t;return ce(this,function(i){switch(i.label){case 0:return[4,this.connectedPromise];case 1:if(i.sent(),this.error)throw this.error;return t=this.serialize(e),[2,Vi(this.socket,t)]}})})},r.prototype.close=function(){return me(this,void 0,void 0,function(){return ce(this,function(e){switch(e.label){case 0:return[4,this.connectedPromise];case 1:return e.sent(),this.done?[2]:(this.socket.close(),[4,this.closedPromise]);case 2:return e.sent(),[2]}})})},r}();function ut(r){return typeof r=="object"&&r!==null&&"key"in r&&typeof r.key=="string"}function Wi(r){return typeof r=="object"&&r!==null&&"getToken"in r&&typeof r.getToken=="function"}var Hi=function(r){return ut(r)||Wi(r)},Ui=function(r){return typeof r=="object"&&r!==null&&"model"in r&&typeof r.model=="string"},ji=function(r){return typeof r=="object"&&r!==null&&"deployment"in r&&typeof r.deployment=="string"},Xi=function(){function r(e,t,i){var n=this,o=function(){if(ut(e)&&Ui(t))return n.openAISettings(e,t);if(Hi(t)&&ji(i))return n.azureOpenAISettings(e,t,i);throw new Error("Invalid combination of arguments to initialize the Realtime client")}();this.client=this.getWebsocket(o)}return r.prototype.azureOpenAISettings=function(e,t,i){var n=this,o=["https://cognitiveservices.azure.com/.default"];return this.requestId=crypto.randomUUID(),e.searchParams.set("api-version","2024-10-01-preview"),e.searchParams.set("x-ms-client-request-id",this.requestId),e.searchParams.set("deployment",i.deployment),e.pathname="openai/realtime",{uri:e,policy:function(a){return me(n,void 0,void 0,function(){var l;return ce(this,function(c){switch(c.label){case 0:return ut(t)?(a.uri.searchParams.set("api-key",t.key),[3,3]):[3,1];case 1:return[4,t.getToken(o)];case 2:l=c.sent(),a.uri.searchParams.set("Authorization","Bearer ".concat(l.token)),c.label=3;case 3:return[2,a]}})})}}},r.prototype.openAISettings=function(e,t){var i=new URL("wss://api.openai.com/v1/realtime");return i.searchParams.set("model",t.model),{uri:i,protocols:["realtime","openai-insecure-api-key.".concat(e.key),"openai-beta.realtime-v1"]}},r.prototype.getWebsocket=function(e){var t={validate:function(i){if(typeof i.data!="string")return ot(new Error("Invalid message type"));try{var n=JSON.parse(i.data);return Li(n)?$i(n):ot(new Error("Invalid message type"))}catch{return ot(new Error("Invalid JSON message"))}},serialize:function(i){return JSON.stringify(i)}};return new zi(e,t)},r.prototype.messages=function(){return Ni(this,arguments,function(){var t,i,n,o,a,l,c,s,d;return ce(this,function(u){switch(u.label){case 0:u.trys.push([0,7,8,13]),t=!0,i=Ri(this.client),u.label=1;case 1:return[4,ge(i.next())];case 2:return n=u.sent(),l=n.done,!l?(d=n.value,t=!1,o=d,[4,ge(o)]):[3,6];case 3:return[4,u.sent()];case 4:u.sent(),u.label=5;case 5:return t=!0,[3,1];case 6:return[3,13];case 7:return a=u.sent(),c={error:a},[3,13];case 8:return u.trys.push([8,,11,12]),!t&&!l&&(s=i.return)?[4,ge(s.call(i))]:[3,10];case 9:u.sent(),u.label=10;case 10:return[3,12];case 11:if(c)throw c.error;return[7];case 12:return[7];case 13:return[2]}})})},r.prototype.send=function(e){return me(this,void 0,void 0,function(){return ce(this,function(t){switch(t.label){case 0:return[4,this.client.send(e)];case 1:return t.sent(),[2]}})})},r.prototype.close=function(){return me(this,void 0,void 0,function(){return ce(this,function(e){switch(e.label){case 0:return[4,this.client.close()];case 1:return e.sent(),[2]}})})},r}();S.store("realtimeChatStatus",{active:!1,conversationStarted:!1,setActive(r){this.active=r,this.onActiveChange()},setConversationStarted(r){this.conversationStarted=r,this.onConversationStartedChange()},onActiveChange(){var r,e;document.querySelectorAll(".lqd-realtime-chat-button").forEach(t=>t.classList.toggle("active",this.active)),(e=(r=document.querySelector(".lqd-audio-vis-wrap"))==null?void 0:r.classList)==null||e.toggle("active",this.active)},onConversationStartedChange(){document.querySelectorAll(".lqd-realtime-chat-button").forEach(r=>{r.classList.toggle("conversation-started",this.conversationStarted),r.classList.toggle("conversation-not-started",!this.conversationStarted)})}});const Yi=(r,e,t)=>({apiKey:"",recordingActive:!1,buffer:new Uint8Array,wsConnection:null,audioRecorder:null,audioPlayer:null,activeVisulaizer:"idle",audioVisWrap:null,audioVisBars:null,audioVisDotWrap:null,audioVisLoader:null,conversationArea:document.querySelector(".conversation-area"),chatsContainer:document.querySelector(".chats-container"),userBubbleTemplate:document.querySelector("#chat_user_bubble"),aiBubbleTemplate:document.querySelector("#chat_ai_bubble"),lastAiBubble:null,lastUserBubble:null,lastUserQuestion:"",lastAiResponse:"",lastResponseSaved:!1,init(){var i,n,o;this.audioVisWrap=document.querySelector(".lqd-audio-vis-wrap"),this.audioVisBars=(i=this.audioVisWrap)==null?void 0:i.querySelectorAll(".lqd-audio-vis-bar"),this.audioVisDotWrap=(n=this.audioVisWrap)==null?void 0:n.querySelector(".lqd-audio-vis-dot-wrap"),this.audioVisLoader=(o=this.audioVisWrap)==null?void 0:o.querySelector(".lqd-audio-vis-loader"),this.processAudioRecordingBuffer=this.processAudioRecordingBuffer.bind(this)},async start(){if(!S.store("realtimeChatStatus").isActive){S.store("realtimeChatStatus").setActive(!0),this.switchVisualizers("waiting"),this.wsConnection=new Xi({key:atob(r)+atob(e)+atob(t)},{model:"gpt-4o-realtime-preview-2024-12-17"});try{await this.wsConnection.send(this.createConfigMessage())}catch(i){this.stop(),console.error("Error sending initial config message:",i),this.appendToChatBubble("ai","[Connection error]: Unable to send initial config message. Please check your endpoint and authentication details.");return}await Promise.all([this.startRecorder(),this.startPlayer()]).then(()=>{this.handleRealtimeMessages(),this.startBarsVisualizer(),this.startDotVisualizer(),this.switchVisualizers("idle")}).catch(i=>{this.stop(),console.error("Error starting recorder and player:",i),this.appendToChatBubble("ai","[Error]: Unable to start audio recorder and player. Please check your microphone permissions and refresh the page.")})}},stop(){!this.lastResponseSaved&&"saveResponseAsync"in window&&this.lastUserQuestion.trim()!==""&&this.lastAiResponse.trim()!==""&&saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","",""),this.resetPlayers(),this.wsConnection&&this.wsConnection.close(),this.switchVisualizers(""),S.store("realtimeChatStatus").setActive(!1)},async startPlayer(){try{this.audioPlayer=new Mi,await this.audioPlayer.init(24e3)}catch(i){console.error("Error starting audio player:",i)}},async startRecorder(){try{this.audioRecorder=new Oi(this.processAudioRecordingBuffer);const i=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1});await this.audioRecorder.start(i),this.recordingActive=!0}catch(i){console.error("Error starting audio recorder:",i)}},createConfigMessage(){let i={type:"session.update",session:{turn_detection:{type:"server_vad",silence_duration_ms:500},input_audio_transcription:{model:"whisper-1"}}};const n=this.getSystemMessage(),o=this.getTemperature(),a=this.getVoice();return n&&(i.session.instructions=n),isNaN(o)||(i.session.temperature=o),a&&(i.session.voice=a),i},async handleRealtimeMessages(){for await(const i of this.wsConnection.messages())switch(""+i.type,i.type){case"session.created":this.switchVisualizers("idle");break;case"response.content_part.added":this.lastAiResponse="",S.store("realtimeChatStatus").setConversationStarted(!0),this.createChatBubble("ai");break;case"response.audio_transcript.delta":this.lastAiResponse+=i.delta,this.appendToChatBubble("ai",i.delta);break;case"response.audio.delta":{this.switchVisualizers("playing");const n=atob(i.delta),o=Uint8Array.from(n,l=>l.charCodeAt(0)),a=new Int16Array(o.buffer);this.audioPlayer.play(a);break}case"input_audio_buffer.speech_started":{this.createChatBubble("user"),this.switchVisualizers("recording"),this.audioPlayer.clear(),this.lastResponseSaved=!1,setTimeout(()=>{this.lastUserQuestion=""},0);break}case"conversation.item.input_audio_transcription.completed":this.lastUserQuestion+=i.transcript,this.appendToChatBubble("user",i.transcript);break;case"response.output_item.done":break;case"conversation.item.truncated":this.appendToChatBubble("ai","...");break;case"conversation.item.deleted":break;case"response.done":"saveResponseAsync"in window&&(saveResponseAsync(this.lastUserQuestion.trim(),this.lastAiResponse.trim(),document.querySelector("#chat_id").value,"","","",""),this.lastResponseSaved=!0),"formatString"in window&&this.lastAiBubble&&(this.lastAiBubble.innerHTML=formatString(this.lastAiResponse));break;default:JSON.stringify(i,null,2);break}this.resetPlayers()},combineArray(i){const n=new Uint8Array(this.buffer.length+i.length);n.set(this.buffer),n.set(i,this.buffer.length),this.buffer=n},processAudioRecordingBuffer(i){const n=new Uint8Array(i);if(this.combineArray(n),this.buffer.length>=4800){const o=new Uint8Array(this.buffer.slice(0,4800));this.buffer=new Uint8Array(this.buffer.slice(4800));const a=String.fromCharCode(...o),l=btoa(a);this.recordingActive&&this.wsConnection.send({type:"input_audio_buffer.append",audio:l})}},async resetPlayers(){var i,n;this.recordingActive=!1,(i=this.audioRecorder)==null||i.stop(),(n=this.audioPlayer)==null||n.clear()},getSystemMessage(){return""},getTemperature(){return parseFloat(.8)},getVoice(){return"alloy"},switchVisualizers(i){var n;this.activeVisulaizer=i,(n=this.audioVisWrap)==null||n.setAttribute("data-state",this.activeVisulaizer)},createChatBubble(i){const o=(i==="user"?this.userBubbleTemplate:this.aiBubbleTemplate).content.cloneNode(!0),a=o.querySelector(".chat-content");this.chatsContainer.appendChild(o),i==="user"?this.lastUserBubble=a:this.lastAiBubble=a,this.scrollConversationAreaToBottom()},appendToChatBubble(i,n){const o=i==="user"?this.lastUserBubble:this.lastAiBubble;o?(o.textContent+=n,this.scrollConversationAreaToBottom()):(this.createChatBubble(i),this.appendToChatBubble(i,n))},scrollConversationAreaToBottom(){this.conversationArea.scrollTo({top:this.conversationArea.scrollHeight+200,left:0})},startBarsVisualizer(){var s;if(!((s=this.audioVisBars)!=null&&s.length))return;const i=this.audioPlayer.audioContext.createAnalyser();i.fftSize=4096;const n=i.frequencyBinCount,o=new Uint8Array(n),a=this.audioVisBars.length;this.audioPlayer.playbackNode.connect(i);const l=[[85,150],[150,250],[250,400],[400,600],[600,1e3]];this.barHeights=this.barHeights||new Array(a).fill(0);const c=()=>{i.getByteFrequencyData(o),this.audioVisBars.forEach((d,u)=>{const[p,f]=l[u],v=Math.floor(p/(this.audioPlayer.audioContext.sampleRate/i.fftSize)),y=Math.ceil(f/(this.audioPlayer.audioContext.sampleRate/i.fftSize));let x=0;for(let D=v;D<=y&&D<o.length;D++)o[D]>x&&(x=o[D]);let N=x/255*80;this.barHeights[u]+=(N-this.barHeights[u])*.4,this.barHeights[u]+=(Math.random()-.5)*2,this.barHeights[u]=Math.max(5,Math.min(100,this.barHeights[u])),d.animate([{height:d.style.height},{height:`${this.barHeights[u]}%`}],{duration:30,fill:"forwards",easing:"linear"})}),requestAnimationFrame(c)};c()},startDotVisualizer(){if(!this.audioRecorder||!this.audioVisDotWrap)return;const i=this.audioRecorder.audioContext.createAnalyser();i.fftSize=256;const n=i.frequencyBinCount,o=new Uint8Array(n);this.audioRecorder.getMediaStreamSource().connect(i);const a=this.audioVisDotWrap.querySelector(".lqd-audio-vis-dot");if(!a)return;const l=()=>{i.getByteFrequencyData(o);let c=0;for(let p=0;p<n;p++)c+=o[p];const d=1+c/n/256*1.5,u=Math.max(.2,1-(d-1)/1.5);a.style.transform=`scale(${d})`,a.style.opacity=u.toFixed(2),requestAnimationFrame(l)};l()}}),Gi=(r={})=>({prevViews:[],currentView:"home",sidebarCollapsed:!1,modalShow:!1,activeModal:null,activeModalId:null,activeModalIdPrefix:null,currentToolsCat:"primary",predefinedPrompts:r.predefinedPrompts||[],tools:r.tools||[],primaryToolKeys:r.primaryToolKeys||[],uploadingFile:{},showImageDetails:!1,zoomLevel:1,reachedMinZoom:!1,reachedMaxZoom:!1,newItems:[],showNotif:!1,editingImageDimensions:{width:0,height:0},painting:!1,brushSize:40,canvasCtx:null,_busy:!1,_template:"",_prompt:"",_selectedTemplateDescription:"",_selectedPromptDescription:"",_selectedTool:"",_prevEditingImage:{},_editingImage:{},get busy(){return this._busy},set busy(e){this._busy=e},get selectedTemplate(){return this._template.trim()},set selectedTemplate(e){var t;this._template=e,(t=this.$refs.promptInput)==null||t.focus()},get prompt(){return this._prompt},set prompt(e){var t;this._prompt=e.trim(),(t=this.$refs.promptInput)==null||t.focus()},get selectedTemplateDescription(){return this._selectedTemplateDescription},set selectedTemplateDescription(e){this._selectedTemplateDescription!==e&&(this._selectedTemplateDescription=e)},get selectedPromptDescription(){return this._selectedPromptDescription},set selectedPromptDescription(e){this._selectedPromptDescription!==e&&(this._selectedPromptDescription=e)},get selectedTool(){return this._selectedTool},set selectedTool(e){this._selectedTool!==e&&(this._selectedTool=e,this.makeCanvasEditable(this._selectedTool==="sketch_to_image"?{width:1024,height:1024}:{}))},get prevEditingImage(){return this._prevEditingImage},get editingImage(){return this._editingImage},set editingImage(e){this._prevEditingImage=this._editingImage,this._editingImage=e,this.showImageDetails=!1,this.zoomLevel=1,fetch(e.output).then(t=>t.blob()).then(t=>{var o,a;const i=new File([t],((a=(o=e.title)==null?void 0:o.split("."))==null?void 0:a.at(0))||"image",{type:t.type}),n=new DataTransfer;n.items.add(i),this.$refs.uploadedImageInput.files=n.files}).catch(t=>{toastr.error("Failed to load image"),console.error("Error creating file from URL:",t)})},init(){this.onViewChange=this.onViewChange.bind(this),this.onZoomLevelChange=this.onZoomLevelChange.bind(this),this.makeCanvasEditable=this.makeCanvasEditable.bind(this),this.startPainting=this.startPainting.bind(this),this.stopPainting=this.stopPainting.bind(this),this.paint=this.paint.bind(this),document.documentElement.style.scrollbarGutter="stable",this.$watch("currentView",this.onViewChange),this.$watch("zoomLevel",this.onZoomLevelChange)},switchView(e){if(e==="<"){this.currentView=this.prevViews.pop()||"home";return}this.prevViews.push(this.currentView),this.currentView=e||"home"},switchSidebarCollapsed(e){if(e!=null){this.sidebarCollapsed=e;return}this.sidebarCollapsed=!this.sidebarCollapsed,this.$nextTick(()=>{this.zoomLevel>1&&this.fitToScreen()}),this.$refs.imageEditorSidebar.addEventListener("transitionend",t=>{t.target!==this.$refs.imageEditorSidebar&&t.propertyName!=="transform"||this.reachedMaxZoom&&this.fitToScreen()})},onViewChange(e){const t=e==="editor";document.documentElement.style.overflow=t?"hidden":""},setRandomPrompt(){this.prompt=this.predefinedPrompts[Math.floor(Math.random()*this.predefinedPrompts.length)]},setActiveModal(e,t="modal"){this.activeModal=e,this.activeModalId=e.id,this.activeModalIdPrefix=t},prevImageModal(){const e=document.querySelector(`.image-result[data-id='${this.activeModalId}'][data-id-prefix=${this.activeModalIdPrefix}]`),t=e==null?void 0:e.previousElementSibling;if(!t)return;const i=JSON.parse(t.getAttribute("data-payload")||{});this.setActiveModal(i,e.getAttribute("data-id-prefix"))},nextImageModal(){const e=document.querySelector(`.image-result[data-id='${this.activeModalId}'][data-id-prefix=${this.activeModalIdPrefix}]`),t=e==null?void 0:e.nextElementSibling;if(!t)return;const i=JSON.parse(t.getAttribute("data-payload")||{});this.setActiveModal(i,e.getAttribute("data-id-prefix"))},getSelectedToolCat(){return this.getToolCat(this.selectedTool)},switchToolsCat(e={}){if(e.cat)return this.currentToolsCat=e.cat;if(e.toolKey)return this.currentToolsCat=this.getToolCat(e.toolKey);if(!e.cat&&!e.toolKey)return this.currentToolsCat=this.currentToolsCat==="primary"?"secondary":"primary"},getToolCat(e){return this.primaryToolKeys.findIndex(t=>t===e)>=0?"primary":"secondary"},handleDragOver(){this.$refs.dropArea.classList.add("drag-over")},handleDragLeave(){this.$refs.dropArea.classList.remove("drag-over")},handleDrop(e){const{dataTransfer:t}=e,{files:i}=t;i&&(this.handleFiles(i),this.$refs.dropArea.classList.remove("drag-over"))},handleFileChange(e){const{files:t}=e.target;t&&this.handleFiles(t)},handleFiles(e){const t=e[0];this.editingImage={output:URL.createObjectURL(t),name:t.name},this.$refs.uploadedImageInput.files=e},resetUploadedImageInput(){this.zoomLevel=1,this.editingImage={},this.$refs.editorFileInput.value="",this.$refs.uploadedImageInput.value="",this.selectedTool==="sketch_to_image"&&this.makeCanvasEditable({width:1024,height:1024})},downloadImage(e,t){const i=document.createElement("a");i.href=e,i.download=t?t.replaceAll(" ","-"):"image",i.click(),i.remove()},getMaxZoom(){const e=this.$refs.editorCanvas,t=e.offsetWidth,i=window.getComputedStyle(e);return 1+(parseFloat(i.marginLeft)+parseFloat(i.marginRight)-20)/t},setZoomLevel(e){const t=this.getMaxZoom();this.zoomLevel=Math.max(.1,Math.min(t,e)),this.reachedMinZoom=this.zoomLevel===.1,this.reachedMaxZoom=this.zoomLevel>=t},zoomIn(){this.setZoomLevel(this.zoomLevel+.1)},zoomOut(){this.setZoomLevel(this.zoomLevel-.1)},fitToScreen(){const e=this.getMaxZoom();this.setZoomLevel(e)},onZoomLevelChange(){const e=this.$refs.editorCanvas;e.style.setProperty("--zoom-level",this.zoomLevel.toFixed(3)),e.style.setProperty("--zoom-offset","0px");const t=window.getComputedStyle(e),i=parseFloat(t.getPropertyValue("--header-h")),o=e.getBoundingClientRect().top+this.$refs.editorCanvasWrap.scrollTop;o<i&&e.style.setProperty("--zoom-offset",`${(o>=0?i-o:i+Math.abs(o)).toFixed(0)}px`)},submitEditorForm(e){this.busy=!0;const t=new FormData(e.target);fetch(e.target.action,{method:"POST",body:t,headers:{Accept:"application/json"}}).then(i=>{if(!i.ok)throw new Error("Network response was not ok");return i.json()}).then(i=>{if(i.status==="error")throw new Error(i.message);this.editingImage=i.data,this.newItems.push(i.data),this.showNotif=!0,this.selectedTool==="sketch_to_image"&&(this.switchToolsCat({toolKey:this.primaryToolKeys[0]}),this.selectedTool=this.primaryToolKeys[0]);const n=setTimeout(()=>{this.showNotif=!1,clearTimeout(n)},3e3)}).catch(i=>{console.error(i),toastr.error(i)}).finally(()=>{this.busy=!1})},async makeCanvasEditable(e={}){var i;this.editingImageDimensions={width:e.width||this.$refs.editorImagePreview.naturalWidth,height:e.height||this.$refs.editorImagePreview.naturalHeight},await this.$nextTick();const t=this.$refs.editorMaskCanvas;(i=this.canvasCtx)==null||i.reset(),this.canvasCtx=t.getContext("2d"),this.canvasCtx.fillStyle="black",this.canvasCtx.fillRect(0,0,t.width,t.height)},startPainting(e){this.painting=!0,this.painted=!1,this.paint(e)},stopPainting(){if(!this.painted)return;this.painting=!1,this.canvasCtx.beginPath();const e=this.$refs.editorMaskCanvas,t=document.createElement("canvas");t.width=this.editingImageDimensions.width,t.height=this.editingImageDimensions.height,t.getContext("2d").drawImage(e,0,0,t.width,t.height),t.toBlob(n=>{const o=new File([n],"mask.png",{type:"image/png"}),a=new DataTransfer;a.items.add(o),this.$refs[this.selectedTool==="sketch_to_image"?"sketchFileInput":"maskFileInput"].files=a.files,t.remove()},"image/png"),this.painted=!1},paint(e){if(!this.painting)return;const t=this.$refs.editorMaskCanvas,i=t.getBoundingClientRect(),n=(e.clientX-i.left)*(t.width/i.width),o=(e.clientY-i.top)*(t.height/i.height);this.canvasCtx.lineWidth=this.brushSize,this.canvasCtx.lineCap="round",this.canvasCtx.strokeStyle="white",this.canvasCtx.lineTo(n,o),this.canvasCtx.stroke(),this.canvasCtx.beginPath(),this.canvasCtx.moveTo(n,o),this.painted=!0},setBrushSize(e){e==="-"?e=Math.max(this.brushSize-10,10):e==="+"&&(e=Math.min(this.brushSize+10,100)),this.brushSize=parseInt(e,10)}});window.fetchEventSource=Ht;const Zi=localStorage.getItem("lqdDarkMode"),Qi=localStorage.getItem("docsViewMode"),Ki=localStorage.getItem("lqdNavbarShrinked"),dt=document.querySelector("body").getAttribute("data-theme"),Ji=localStorage.getItem(dt+":lqdFocusModeEnabled");window.collectCreditsToFormData=function(r){document.querySelectorAll('input[name^="entities"]').forEach(t=>{const i=t.name,n=t.type==="checkbox"||t.type==="radio"?t.checked:t.value;r.append(i,n)})};window.Alpine=S;S.plugin(Ut);S.plugin(xi);document.addEventListener("alpine:init",()=>{const r=S.$persist;S.data("modal",e=>Pi(e)),S.data("clipboard",e=>Xt(e)),S.data("assignViewCredits",e=>ki(e)),S.store("navbarShrink",{active:r(!!Ki).as("lqdNavbarShrinked"),toggle(e){this.active=e?e==="shrink":!this.active,document.body.classList.toggle("navbar-shrinked",this.active)}}),S.data("navbarItem",()=>({dropdownOpen:!1,toggleDropdownOpen(e){this.dropdownOpen=e?e==="collapse":!this.dropdownOpen},item:{"x-ref":"item","@mouseenter"(){if(!S.store("navbarShrink").active)return;const e=this.$el.getBoundingClientRect(),t=this.$refs.item.querySelector(".lqd-navbar-dropdown");if(["y","height","bottom"].forEach(i=>this.$refs.item.style.setProperty(`--item-${i}`,`${e[i]}px`)),t){const i=t.getBoundingClientRect();["height"].forEach(n=>this.$refs.item.style.setProperty(`--dropdown-${n}`,`${i[n]}px`))}}}})),S.store("mobileNav",{navCollapse:!0,toggleNav(e){this.navCollapse=e?e==="collapse":!this.navCollapse},templatesCollapse:!0,toggleTemplates(e){this.templatesCollapse=e?e==="collapse":!this.templatesCollapse},searchCollapse:!0,toggleSearch(e){this.searchCollapse=e?e==="collapse":!this.searchCollapse}}),S.store("darkMode",{on:r(!!Zi).as("lqdDarkMode"),toggle(){this.on=!this.on,document.body.classList.toggle("theme-dark",this.on),document.body.classList.toggle("theme-light",!this.on)}}),S.store("appLoadingIndicator",{showing:!1,show(){this.showing=!0},hide(){this.showing=!1},toggle(){this.showing=!this.showing}}),S.store("docsViewMode",{docsViewMode:r(Qi||"list").as("docsViewMode"),change(e){this.docsViewMode=e}}),S.store("generatorsFilter",{init(){const e=new URLSearchParams(window.location.search);this.filter=e.get("filter")||"all"},filter:"all",changeFilter(e){if(this.filter!==e){if(!document.startViewTransition)return this.filter=e;document.startViewTransition(()=>this.filter=e)}}}),S.store("documentsFilter",{init(){const e=new URLSearchParams(window.location.search);this.sort=e.get("sort")||"created_at",this.sortAscDesc=e.get("sortAscDesc")||"desc",this.filter=e.get("filter")||"all",this.page=e.get("page")||"1"},sort:"created_at",sortAscDesc:"desc",filter:"all",page:"1",changeSort(e){e===this.sort?this.sortAscDesc=this.sortAscDesc==="desc"?"asc":"desc":this.sortAscDesc="desc",this.sort=e},changeAscDesc(e){this.ascDesc!==e&&(this.ascDesc=e)},changeFilter(e){this.filter!==e&&(this.filter=e)},changePage(e){(e===">"||e==="<")&&(e=e===">"?Number(this.page)+1:Number(this.page)-1),this.page!==e&&(this.page=e)}}),S.store("chatsFilter",{init(){const e=new URLSearchParams(window.location.search);this.filter=e.get("filter")||"all",this.setSearchStr(e.get("search")||"")},searchStr:"",setSearchStr(e){this.searchStr=e.trim().toLowerCase()},filter:"all",changeFilter(e){if(this.filter!==e){if(!document.startViewTransition)return this.filter=e;document.startViewTransition(()=>this.filter=e)}}}),S.data("generatorV2",()=>({itemsSearchStr:"",setItemsSearchStr(e){this.itemsSearchStr=e.trim().toLowerCase(),this.itemsSearchStr!==""?this.$el.closest(".lqd-generator-sidebar").classList.add("lqd-showing-search-results"):this.$el.closest(".lqd-generator-sidebar").classList.remove("lqd-showing-search-results")},sideNavCollapsed:!1,toggleSideNavCollapse(e){var t;this.sideNavCollapsed=e?e==="collapse":!this.sideNavCollapsed,this.sideNavCollapsed&&((t=tinymce==null?void 0:tinymce.activeEditor)==null||t.focus())},generatorStep:0,setGeneratorStep(e){if(e!==this.generatorStep){if(!document.startViewTransition)return this.generatorStep=Number(e);document.startViewTransition(()=>this.generatorStep=Number(e))}},selectedGenerator:null})),S.store("mobileChat",{sidebarOpen:!1,toggleSidebar(e){this.sidebarOpen=e?!1:!this.sidebarOpen}}),S.data("dropdown",({triggerType:e="hover"})=>({open:!1,toggle(t){this.open=t?t!=="collapse":!this.open,this.$refs.parent.classList.toggle("lqd-is-active",this.open)},parent:{"@mouseenter"(){e==="hover"&&this.toggle("expand")},"@mouseleave"(){e==="hover"&&this.toggle("collapse")},"@click.outside"(){this.toggle("collapse")}},trigger:{"@click.prevent"(){e==="click"&&this.toggle()}},dropdown:{}})),S.store("notifications",{notifications:[],loading:!1,add(e){this.notifications.unshift(e)},remove(e){this.notifications.splice(e,1)},markThenHref(e){const t=this.notifications.indexOf(e);if(t!==-1){var i=new FormData;i.append("id",e.id),this.loading=!0,$.ajax({url:"/dashboard/notifications/mark-as-read",type:"POST",data:i,cache:!1,contentType:!1,processData:!1,success:n=>{},error:n=>{console.error(n)},complete:()=>{this.markAsRead(t),window.location=e.link,this.loading=!1}})}},markAsRead(e){this.notifications=this.notifications.map((t,i)=>(i===e&&(t.unread=!1),t))},markAllAsRead(){this.loading=!0,$.ajax({url:"/dashboard/notifications/mark-as-read",type:"POST",success:e=>{e.success&&this.notifications.forEach((t,i)=>{this.markAsRead(i)})},error:e=>{console.error(e)},complete:()=>{this.loading=!1}})},setNotifications(e){this.notifications=e},hasUnread:function(){return this.notifications.some(e=>e.unread)}}),S.data("notifications",e=>({notifications:e||[]})),S.store("focusMode",{active:S.$persist(!!Ji).as(dt+":lqdFocusModeEnabled"),toggle(e){console.log(dt),this.active=e?e==="activate":!this.active,document.body.classList.toggle("focus-mode",this.active)}}),S.data("openaiRealtime",Yi),S.data("advancedImageEditor",Gi)});jt.start();
Save
Cancel