@codingfactory/mediables-vue 2.0.1 → 2.0.5
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.
- package/LICENSE.md +22 -0
- package/README.md +923 -0
- package/dist/{PixiFrameExporter-Bb3QNWP-.js → PixiFrameExporter-B5tJ62bD.js} +2 -2
- package/dist/{PixiFrameExporter-Bb3QNWP-.js.map → PixiFrameExporter-B5tJ62bD.js.map} +1 -1
- package/dist/{PixiFrameExporter-BTU38EVl.cjs → PixiFrameExporter-BTXhmL54.cjs} +2 -2
- package/dist/{PixiFrameExporter-BTU38EVl.cjs.map → PixiFrameExporter-BTXhmL54.cjs.map} +1 -1
- package/dist/components/ImageEditorModal.vue.d.ts +2 -0
- package/dist/composables/useVideoFilters.d.ts +20 -0
- package/dist/{index-CcGWfCCV.js → index-BsOWbGbb.js} +879 -653
- package/dist/index-BsOWbGbb.js.map +1 -0
- package/dist/{index-VrUG0lmk.js → index-CWcyKIOz.js} +6851 -6650
- package/dist/index-CWcyKIOz.js.map +1 -0
- package/dist/index-C_X9_ptj.cjs +42 -0
- package/dist/{index-CcGWfCCV.js.map → index-C_X9_ptj.cjs.map} +1 -1
- package/dist/index-DVJg3EKN.cjs +76 -0
- package/dist/index-DVJg3EKN.cjs.map +1 -0
- package/dist/mediables-vanilla.cjs +1 -1
- package/dist/mediables-vanilla.mjs +1 -1
- package/dist/mediables-vue.cjs +1 -1
- package/dist/mediables-vue.mjs +2 -2
- package/dist/services/VideoJobClient.d.ts +7 -4
- package/dist/style.css +1 -1
- package/dist/types/api.d.ts +20 -18
- package/package.json +2 -2
- package/dist/index-6yUGA--H.cjs +0 -42
- package/dist/index-6yUGA--H.cjs.map +0 -1
- package/dist/index-DTUgsw7J.cjs +0 -76
- package/dist/index-DTUgsw7J.cjs.map +0 -1
- package/dist/index-VrUG0lmk.js.map +0 -1
package/dist/index-DTUgsw7J.cjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";var pd=Object.defineProperty;var fd=(n,o,t)=>o in n?pd(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t;var O=(n,o,t)=>fd(n,typeof o!="symbol"?o+"":o,t);const ma=require("pinia"),e=require("vue"),De=require("pixi.js"),no=require("./index-6yUGA--H.cjs"),Gs=require("pixi-filters"),I=require("@ionic/vue");function Hs(n){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(o,t,a.get?a:{enumerable:!0,get:()=>n[t]})}}return o.default=n,Object.freeze(o)}const Ae=Hs(De),Ie=Hs(Gs);let yt={apiBaseUrl:"/api/v1",isAdmin:!1};function Cn(n){yt={...yt,...n}}function Js(){return{...yt}}function qs(n){yt={...n}}function Ks(n){const o=Js();return Cn(n),()=>{qs(o)}}const hd=async(n,o={})=>{var l;const t=(l=document.querySelector('meta[name="csrf-token"]'))==null?void 0:l.getAttribute("content"),a={Accept:"application/json",...o.headers};t&&(a["X-CSRF-TOKEN"]=t),o.body instanceof FormData||(a["Content-Type"]="application/json");const i={method:o.method||"GET",headers:a,credentials:"include"};o.body instanceof FormData?i.body=o.body:o.body!==void 0&&(i.body=JSON.stringify(o.body));const s=await fetch(n,i);if(!s.ok){const c=await s.json().catch(()=>({message:"Request failed"}));throw new Error(c.message||`HTTP ${s.status}`)}if(s.status!==204)return await s.json()},vt=ma.defineStore("media",()=>{const n=e.ref([]),o=e.ref([]),t=e.ref(!1),a=e.ref(null),r=e.ref(1),i=e.ref(1),s=e.ref(24),l=e.ref({type:null,uuid:null}),c=e.ref([]),d=e.ref(!1),u=e.ref(null),p=e.ref(new Map),m=e.ref(new Map),h=e.ref(new Set),g=e.ref(new Map),v=e.ref({}),x=5*60*1e3,B=e.computed(()=>{if(yt.apiScope)return yt.apiScope;if(yt.isAdmin)return"admin"}),E=e.computed(()=>B.value==="admin");function y(){return yt.httpClient||hd}function f(q){const ue=yt.apiBaseUrl||"/api/v1",ve=B.value?`/${B.value}`:"";return`${ue}${ve}${q}`}function w(q,ue){return`${B.value??"default"}-${q}-${JSON.stringify(ue)}`}function $(q){return Date.now()-q<x}function C(){g.value.clear(),v.value={}}function b(q){if(!q||!q.data)return;const ue={};q.data.forEach(ve=>{const we=`${ve.file_name}-${ve.collection_name||"default"}`,oe=ue[we];(!oe||Object.keys(ve.generated_conversions||{}).length>Object.keys(oe.generated_conversions||{}).length)&&(ue[we]=ve)}),n.value=Object.values(ue),q.meta&&(r.value=q.meta.current_page,i.value=Math.ceil(q.meta.total/q.meta.per_page))}async function N(q=1,ue={}){const ve=w(q,ue),we=g.value.get(ve);if(we&&$(we.timestamp)){const oe=we.data;return b(oe),oe}t.value=!0,a.value=null;try{const oe=new URLSearchParams;oe.append("page",q.toString()),oe.append("per_page",s.value.toString()),E.value&&oe.append("linked","1");for(const Ze in ue)if(Object.prototype.hasOwnProperty.call(ue,Ze)){const Ke=ue[Ze];Ke!=null&&Ke!==""&&oe.append(Ze,String(Ke))}const fe=await y()(f(`/media?${oe}`));return g.value.set(ve,{data:fe,timestamp:Date.now()}),b(fe),fe}catch(oe){throw a.value=oe instanceof Error?oe.message:"Failed to fetch media",n.value=[],new Error(a.value)}finally{t.value=!1}}async function P(q,ue){t.value=!0,a.value=null;const ve=`${q.name}-${Date.now()}`,we={file:q,progress:0,status:"uploading"};p.value.set(ve,we);try{const oe=new FormData;oe.append("file",q),oe.append("collection",ue.collection),ue.ownerUuid&&(oe.append("owner_uuid",ue.ownerUuid),oe.append("owner_type",ue.ownerType||"")),ue.usageUuid&&(oe.append("usage_uuid",ue.usageUuid),oe.append("usage_type",ue.usageType||""),oe.append("usage_purpose",ue.usagePurpose||"")),ue.customProperties&&oe.append("custom_properties",JSON.stringify(ue.customProperties));const fe=await y()(f("/media"),{method:"POST",body:oe});return we.status="completed",we.progress=100,we.media=fe==null?void 0:fe.data,r.value===1&&(fe!=null&&fe.data)&&(n.value=[fe.data,...n.value]),C(),(fe==null?void 0:fe.data)||null}catch(oe){throw we.status="error",we.error=oe instanceof Error?oe.message:"Upload failed",a.value=we.error,new Error(a.value)}finally{t.value=!1,setTimeout(()=>{p.value.delete(ve)},5e3)}}async function k(q){t.value=!0,a.value=null;const ue=n.value.findIndex(we=>we.uuid===q);let ve;ue!==-1&&(ve=n.value.splice(ue,1)[0]);try{return await y()(f(`/media/${q}`),{method:"DELETE"}),h.value.delete(q),C(),!0}catch(we){throw ve&&ue!==-1&&n.value.splice(ue,0,ve),a.value=we instanceof Error?we.message:"Failed to delete media",new Error(a.value)}finally{t.value=!1}}async function T(q,ue){t.value=!0,a.value=null;try{const we=await y()(f(`/media/${q}`),{method:"PATCH",body:ue,data:ue});if(we!=null&&we.data){const oe=n.value.findIndex(ye=>ye.uuid===q);return oe!==-1&&(n.value[oe]={...n.value[oe],...we.data}),C(),we.data}return null}catch(ve){throw a.value=ve instanceof Error?ve.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function F(){t.value=!0,a.value=null;try{const ue=await y()(f("/media/collections"));return o.value=(ue==null?void 0:ue.data)||[],o.value}catch(q){throw a.value=q instanceof Error?q.message:"Failed to fetch collections",o.value=[],new Error(a.value)}finally{t.value=!1}}async function D(q,ue,ve="images",we){d.value=!0,u.value=null;try{const oe=new URLSearchParams;oe.append("collection",ve),we&&oe.append("search",we);const fe=await y()(f(`/media/model/${q}/${ue}?${oe}`));return fe!=null&&fe.data?(c.value=fe.data,fe.data):[]}catch(oe){throw u.value=oe instanceof Error?oe.message:"Failed to fetch model media",c.value=[],new Error(u.value)}finally{d.value=!1}}async function R(q,ue,ve,we="images"){d.value=!0,u.value=null;const oe=[...c.value];try{const fe=await y()(f(`/media/model/${q}/${ue}/attach`),{method:"POST",body:{media_uuids:ve,collection:we}});return await D(q,ue,we),(fe==null?void 0:fe.data)||[]}catch(ye){throw c.value=oe,u.value=ye instanceof Error?ye.message:"Failed to attach media",new Error(u.value)}finally{d.value=!1}}async function W(q,ue,ve,we="images"){d.value=!0,u.value=null;const oe=[...c.value];c.value=c.value.filter(ye=>ye.uuid!==ve);try{return await y()(f(`/media/model/${q}/${ue}/detach`),{method:"POST",body:{media_uuid:ve,collection:we}}),!0}catch(ye){throw c.value=oe,u.value=ye instanceof Error?ye.message:"Failed to detach media",new Error(u.value)}finally{d.value=!1}}async function L(q,ue,ve,we="images"){d.value=!0,u.value=null;const oe=[...c.value],ye=new Map(c.value.map(fe=>[fe.uuid,fe]));c.value=ve.map(fe=>ye.get(fe)).filter(fe=>fe!==void 0);try{return await y()(f(`/media/model/${q}/${ue}/reorder`),{method:"POST",body:{media_uuids:ve,collection:we}}),!0}catch(fe){throw c.value=oe,u.value=fe instanceof Error?fe.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function _(q,ue,ve={}){const we=y(),oe=yt.apiBaseUrl||"/api/v1",ye={image_data:ue.imageData,filters:ue.metadata.filters,crop_data:ue.metadata.cropRect,save_as_new:!0,as_variant:ve.asVariant===!0};return ve.name!==void 0&&(ye.name=ve.name),(await we(`${oe}/editor/${q}/save`,{method:"POST",body:ye})).media}function A(q,ue,ve){l.value=ve!==void 0?{type:q,uuid:ue,collection:ve}:{type:q,uuid:ue},v.value[`${q}-${ue}`]={timestamp:Date.now()}}function Z(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function H(){if(!l.value.type||!l.value.uuid)return;const q=await D(l.value.type,l.value.uuid,l.value.collection||"images");c.value=q||[]}function me(){n.value.forEach(q=>h.value.add(q.uuid))}function Te(){h.value.clear()}function Be(q){h.value.has(q)?h.value.delete(q):h.value.add(q)}function ie(q){return h.value.has(q)}function M(){return Array.from(p.value.values()).some(q=>q.status==="uploading")}function j(q){return p.value.get(q)||m.value.get(q)}function te(){return[...Array.from(p.value.values()),...Array.from(m.value.values())]}async function ae(){const q=Array.from(h.value);let ue=0;for(const ve of q)try{await k(ve),ue++}catch{}return Te(),ue}function re(q,ue){var ve;return ue&&((ve=q.conversion_urls)!=null&&ve[ue])?q.conversion_urls[ue]||"":q.original_url||q.url||""}return{items:n,collections:o,loading:t,error:a,currentPage:r,totalPages:i,itemsPerPage:s,isAdmin:E,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:h,uploadProgress:p,uploadQueue:m,cachedResponses:v,fetchMedia:N,uploadFile:P,deleteMedia:k,updateMedia:T,clearCache:C,fetchCollections:F,fetchModelMedia:D,attachMedia:R,detachMedia:W,reorderMedia:L,saveEditedImage:_,setModelContext:A,clearModelContext:Z,refreshModelMedia:H,selectAllItems:me,clearSelection:Te,toggleSelection:Be,isSelected:ie,deleteSelectedItems:ae,hasActiveUploads:M,getUploadProgress:j,getAllUploadProgress:te,getMediaUrl:re}}),Qs=()=>((yt.apiScope!=="admin"||yt.isAdmin!==!0)&&Cn({...yt,apiScope:"admin",isAdmin:!0}),vt()),jt=new Map,Gn=new Map;function Ne(n){var o;return jt.has(n.id),jt.set(n.id,n),Gn.has(n.category)||Gn.set(n.category,[]),(o=Gn.get(n.category))==null||o.push(n.id),n}function el(n){return jt.get(n)}function oo(){return Array.from(jt.values())}function vd(){oo().map(a=>a.id);const n=Ie,o=Object.entries(Ie).filter(([a])=>/Filter$/.test(a)&&typeof n[a]=="function");process.env.NODE_ENV;let t=0;o.forEach(([a,r])=>{const i=a.replace(/Filter$/,"").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();jt.has(i)||(process.env.NODE_ENV,t++,Ne({id:i,name:a.replace(/Filter$/,""),category:"unlisted",defaultParams:{},controls:[],createFilter:(s={})=>{try{return new r(s)}catch{return null}}}))}),process.env.NODE_ENV!=="production"&&t>0}function tl(n){return(Gn.get(n)||[]).map(t=>jt.get(t)).filter(Boolean)}function gd(){return Array.from(Gn.keys())}function yd(){return Array.from(jt.values()).map(n=>({id:n.id,name:n.name,category:n.category,controls:n.controls}))}if(typeof window<"u"){window.__DEBUG_FILTERS_LIST=Array.from(jt.keys()),window.getAllFilters=oo,window.getFilter=el,window.getFiltersByCategory=tl,window.getRegisteredFilters=yd;const n=Ne;window.registerFilter=o=>{const t=n(o);return window.__DEBUG_FILTERS_LIST=Array.from(jt.keys()),t}}typeof window<"u"&&(window.initializeFilterRegistry=window.initializeFilterRegistry||function(){return[]});const{AdjustmentFilter:bd}=Ie,{ColorMatrixFilter:wd}=Ae;Ne({id:"adjustment",name:"Adjustment",category:"adjust",description:"Adjust basic image properties like brightness, contrast, and saturation",createFilter:n=>{try{const o={gamma:n.gamma??1,saturation:n.saturation??1,contrast:n.contrast??1,brightness:n.brightness??1,red:n.red??1,green:n.green??1,blue:n.blue??1,alpha:n.alpha??1};try{const t=new bd(o);return t._customParams={...n},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"gamma":this.gamma=Number(r);break;case"saturation":this.saturation=Number(r);break;case"contrast":this.contrast=Number(r);break;case"brightness":this.brightness=Number(r);break;case"red":this.red=Number(r);break;case"green":this.green=Number(r);break;case"blue":this.blue=Number(r);break;case"alpha":this.alpha=Number(r);break;default:a in this&&(this[a]=Number(r));break}}catch{}},t}catch{const a=new wd;return a._customParams={...n},typeof a.brightness=="function"&&a.brightness(n.brightness,!1),typeof a.contrast=="function"&&a.contrast(n.contrast,!1),typeof a.saturate=="function"&&a.saturate(n.saturation,!1),a.updateUIParam=function(r,i){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"brightness":typeof this.brightness=="function"&&this.brightness(i,!1);break;case"contrast":typeof this.contrast=="function"&&this.contrast(i,!1);break;case"saturation":typeof this.saturate=="function"&&this.saturate(i,!1);break;default:r in this&&(this[r]=i);break}}catch{}},a}}catch{return null}},defaultParams:{gamma:1,saturation:1,contrast:1,brightness:1,red:1,green:1,blue:1,alpha:1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"gamma",type:"slider",label:"Gamma",property:"gamma",min:.1,max:3,step:.01,default:1},{id:"red",type:"slider",label:"Red",property:"red",min:0,max:2,step:.01,default:1},{id:"green",type:"slider",label:"Green",property:"green",min:0,max:2,step:.01,default:1},{id:"blue",type:"slider",label:"Blue",property:"blue",min:0,max:2,step:.01,default:1},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const{ColorMatrixFilter:kd}=Ae;Ne({id:"adjustment-advanced",name:"Advanced Adjustment",category:"adjust",description:"Comprehensive image adjustments including brightness, contrast, saturation, hue, and more",createFilter:n=>{try{const o=new kd;return o._customParams={...n},o.reset(),n.brightness!==1&&o.brightness(n.brightness,!1),n.contrast!==1&&o.contrast(n.contrast,!1),n.saturation!==1&&o.saturate(n.saturation,!1),n.hue!==0&&o.hue(n.hue,!1),n.sepia>0&&o.sepia(!1),n.negative&&o.negative(!1),o.updateUIParam=function(t,a){try{const r=this._customParams||{};this._customParams=r,r[t]=a,this.reset();const i=r;i.brightness!==1&&this.brightness(i.brightness,!1),i.contrast!==1&&this.contrast(i.contrast,!1),i.saturation!==1&&this.saturate(i.saturation,!1),i.hue!==0&&this.hue(i.hue,!1),i.sepia>0&&this.sepia(!1),i.negative&&this.negative(!1)}catch{}},o}catch{return null}},defaultParams:{brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"hue",type:"slider",label:"Hue Rotation",property:"hue",min:0,max:360,step:1,default:0},{id:"sepia",type:"slider",label:"Sepia",property:"sepia",min:0,max:1,step:.01,default:0},{id:"negative",type:"toggle",label:"Negative",property:"negative",default:!1}]});Ne({id:"alpha",name:"Alpha",category:"adjust",description:"Adjust the transparency of the image",createFilter:n=>{try{const o=n.alpha!==void 0?n.alpha:1,t=new Ae.ColorMatrixFilter;return t.alpha=o,t._customParams={alpha:o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};if(this._customParams=i,a==="alpha"){const s=Number(r);this.alpha=s,i.alpha=s}else a in this&&(this[a]=r)}catch{}},t}catch{return null}},defaultParams:{alpha:1},controls:[{id:"alpha",type:"slider",label:"Transparency",property:"alpha",min:0,max:1,step:.01,default:1}]});Ne({id:"blur",name:"Blur",category:"blur",description:"Apply a smooth blur effect to the entire image",createFilter:n=>{try{const o=new Ae.BlurFilter({strength:n.strength||8,quality:n.quality||4,kernelSize:n.kernelSize||5});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"quality":this.quality=a;break;case"kernelSize":this.blurXFilter.kernelSize=a,this.blurYFilter.kernelSize=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:8,quality:4,kernelSize:5},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:20,step:.1,default:8},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5}]});Ne({id:"color-matrix",name:"Color Matrix",category:"adjustment",description:"Advanced color adjustments including sepia, hue rotation, and more",createFilter:n=>{const o=Ae.ColorMatrixFilter;if(!o)return null;const t=new o;try{return typeof t.reset=="function"&&t.reset(),n.brightness!==1&&typeof t.brightness=="function"&&t.brightness(n.brightness,!1),n.contrast!==1&&typeof t.contrast=="function"&&t.contrast(n.contrast,!1),n.saturation!==1&&typeof t.saturate=="function"&&t.saturate(n.saturation,!1),n.hue!==0&&typeof t.hue=="function"&&t.hue(n.hue,!1),n.sepia>0&&typeof t.sepia=="function"&&t.sepia(n.sepia),n.negative&&typeof t.negative=="function"&&t.negative(!1),t}catch{return t}},defaultParams:{brightness:1,contrast:1,saturation:1,hue:0,sepia:0,negative:!1},controls:[{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:2,step:.01,default:1},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:0,max:2,step:.01,default:1},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:0,max:2,step:.01,default:1},{id:"hue",type:"slider",label:"Hue Rotation",property:"hue",min:0,max:360,step:1,default:0},{id:"sepia",type:"slider",label:"Sepia",property:"sepia",min:0,max:1,step:.01,default:0},{id:"negative",type:"toggle",label:"Negative",property:"negative",default:!1}]});const{ColorOverlayFilter:xd}=Ie;Ne({id:"colorOverlay",name:"Color Overlay",category:"color",description:"Apply a colored tint or overlay to the entire image",createFilter:n=>{try{let o=16711680;n.color&&(typeof n.color=="string"?o=parseInt(n.color.replace("#","0x"),16):typeof n.color=="number"&&(o=n.color));const t=new xd({color:o,alpha:n.alpha||.5});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"color":typeof r=="string"?this.color=parseInt(r.replace("#","0x"),16):typeof r=="number"&&(this.color=r);break;case"alpha":this.alpha=r;break;default:a in this&&(this[a]=r);break}return!0},t}catch{return null}},defaultParams:{color:"#ff0000",alpha:.5},controls:[{id:"color",type:"color",label:"Color",property:"color",default:"#ff0000"},{id:"alpha",type:"slider",label:"Opacity",property:"alpha",min:0,max:1,step:.01,default:.5}]});Ne({id:"drop-shadow",name:"Drop Shadow",category:"effects",description:"Add a soft drop shadow to the image",createFilter:n=>{try{const o=n.color?n.color.replace("#","0x"):"0x000000",t=n.distance!==void 0?n.distance:5,a=n.angle!==void 0?n.angle:90,r={x:t*Math.cos(a*Math.PI/180),y:t*Math.sin(a*Math.PI/180)},i=new Ie.DropShadowFilter({offset:r,color:parseInt(o,16),alpha:n.alpha!==void 0?n.alpha:.5,blur:n.blur!==void 0?n.blur:2,quality:n.quality!==void 0?n.quality:3,shadowOnly:n.shadowOnly!==void 0?n.shadowOnly:!1,pixelSize:{x:n.pixelSizeX!==void 0?n.pixelSizeX:1,y:n.pixelSizeY!==void 0?n.pixelSizeY:1}});return i._customParams={...n,_offset:r,_distance:t,_angle:a},i.updateUIParam=function(s,l){try{const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"color":if(typeof l=="string"){const u=parseInt(l.replace("#","0x"),16);this.color=u}break;case"alpha":this.alpha=Number(l);break;case"blur":this.blur=Number(l);break;case"quality":this.quality=Number(l);break;case"shadowOnly":this.shadowOnly=!!l;break;case"pixelSizeX":this.pixelSizeX=Number(l),c.pixelSizeX=Number(l);break;case"pixelSizeY":this.pixelSizeY=Number(l),c.pixelSizeY=Number(l);break;case"distance":case"angle":s==="distance"?c._distance=Number(l):c._angle=Number(l);const d={x:c._distance*Math.cos(c._angle*Math.PI/180),y:c._distance*Math.sin(c._angle*Math.PI/180)};c._offset=d,this.offset=d;break;default:s in this&&(this[s]=l);break}return!0}catch{return this._customParams&&(this._customParams[s]=l),!1}},i}catch{return null}},defaultParams:{alpha:.5,blur:2,color:"#000000",distance:5,angle:90,quality:3,shadowOnly:!1,pixelSizeX:1,pixelSizeY:1},controls:[{id:"alpha",type:"slider",label:"Opacity",property:"alpha",min:0,max:1,step:.01,default:.5},{id:"blur",type:"slider",label:"Blur",property:"blur",min:0,max:20,step:.1,default:2},{id:"color",type:"color",label:"Color",property:"color",default:"#000000"},{id:"distance",type:"slider",label:"Distance",property:"distance",min:0,max:50,step:1,default:5},{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:90},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:3},{id:"shadowOnly",type:"toggle",label:"Shadow Only",property:"shadowOnly",default:!1},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:8,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:8,step:.5,default:1}]});Ne({id:"grayscale",name:"Grayscale",category:"color",description:"Convert the image to black and white with adjustable intensity",createFilter:n=>{try{const o=new De.ColorMatrixFilter;o._customParams={...n};const t=n.intensity!==void 0?n.intensity:1;return Yi(o,t),o.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"intensity":Yi(this,r);break;default:a in this&&(this[a]=r);break}return!0},o}catch{return null}},defaultParams:{intensity:.35},controls:[{id:"intensity",type:"slider",label:"Intensity",property:"intensity",min:0,max:1,step:.01,default:.35}]});function Yi(n,o){n.reset(),n.greyscale(o,!1)}const{HslAdjustmentFilter:Sd}=Ie;Ne({id:"hsl-adjustment",name:"HSL Adjustment",category:"color",description:"Control hue, saturation, and lightness independently",createFilter:n=>{try{const o=new Sd({hue:n.hue!==void 0?n.hue:0,saturation:n.saturation!==void 0?n.saturation:0,lightness:n.lightness!==void 0?n.lightness:0,colorize:n.colorize!==void 0?n.colorize:!1,alpha:n.alpha!==void 0?n.alpha:1});return o._customParams={...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"hue":this.hue=Number(a);break;case"saturation":this.saturation=Number(a);break;case"lightness":this.lightness=Number(a);break;case"colorize":this.colorize=!!a;break;case"alpha":this.alpha=Number(a);break;default:t in this&&(this[t]=a);break}return!0}catch{return this._customParams&&(this._customParams[t]=a),!1}},o}catch{return null}},defaultParams:{hue:0,saturation:0,lightness:0,colorize:!1,alpha:1},controls:[{id:"hue",type:"slider",label:"Hue",property:"hue",min:-180,max:180,step:1,default:0},{id:"saturation",type:"slider",label:"Saturation",property:"saturation",min:-1,max:1,step:.01,default:0},{id:"lightness",type:"slider",label:"Lightness",property:"lightness",min:-1,max:1,step:.01,default:0},{id:"colorize",type:"toggle",label:"Colorize",property:"colorize",default:!1},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const{KawaseBlurFilter:Ed}=Ie;Ne({id:"kawase-blur",name:"Kawase Blur",category:"blur",description:"A more optimized blur algorithm that is faster than standard blur",createFilter:n=>{try{const o=new Ed({strength:n.strength||4,quality:n.quality||3,clamp:n.clamp||!1,pixelSize:n.pixelSize||1});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"quality":this.quality=a;break;case"clamp":this.clamp=a;break;case"pixelSize":typeof a=="number"?this.pixelSize=a:typeof a=="object"&&a!==null&&"x"in a&&"y"in a&&(this.pixelSize=a);break;case"pixelSizeX":this.pixelSizeX=a;break;case"pixelSizeY":this.pixelSizeY=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:4,quality:3,clamp:!1,pixelSize:1},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:20,step:.1,default:4},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:3},{id:"clamp",type:"toggle",label:"Clamp Edges",property:"clamp",default:!1},{id:"pixelSize",type:"slider",label:"Pixel Size",property:"pixelSize",min:.5,max:10,step:.5,default:1},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:10,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:10,step:.5,default:1}]});const{MotionBlurFilter:Cd}=Ie;Ne({id:"motion-blur",name:"Motion Blur",category:"blur",description:"Creates a directional blur effect simulating motion",createFilter:n=>{try{const o=new Cd({velocity:{x:n.velocityX!==void 0?n.velocityX:0,y:n.velocityY!==void 0?n.velocityY:0},kernelSize:n.kernelSize||5,offset:n.offset!==void 0?n.offset:0});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"velocityX":this.velocityX=a;break;case"velocityY":this.velocityY=a;break;case"kernelSize":this.kernelSize=a;break;case"offset":this.offset=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{velocityX:0,velocityY:0,kernelSize:5,offset:0},controls:[{id:"velocityX",type:"slider",label:"Velocity X",property:"velocityX",min:-40,max:40,step:.5,default:0},{id:"velocityY",type:"slider",label:"Velocity Y",property:"velocityY",min:-40,max:40,step:.5,default:0},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5},{id:"offset",type:"slider",label:"Offset",property:"offset",min:0,max:20,step:.1,default:0}]});const{RadialBlurFilter:Vd}=Ie;Ne({id:"radial-blur",name:"Radial Blur",category:"blur",description:"Creates a circular blur effect emanating from a center point",createFilter:n=>{try{const o=new Vd({angle:n.angle||10,center:{x:n.centerX||0,y:n.centerY||0},kernelSize:n.kernelSize||5,radius:n.radius??-1});return o._customParams={centerX:n.centerX||0,centerY:n.centerY||0},o.updateUIParam=function(t,a){try{switch(t){case"angle":this.angle=Number(a);break;case"centerX":this._customParams.centerX=Number(a),this.center={x:Number(a),y:this._customParams.centerY};break;case"centerY":this._customParams.centerY=Number(a),this.center={x:this._customParams.centerX,y:Number(a)};break;case"kernelSize":this.kernelSize=Number(a);break;case"radius":this.radius=Number(a);break;default:}}catch{}},o}catch{return null}},defaultParams:{angle:10,centerX:0,centerY:0,kernelSize:5,radius:-1},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:10},{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:-1,max:1,step:.01,default:0},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:-1,max:1,step:.01,default:0},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"3",value:3},{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5},{id:"radius",type:"slider",label:"Radius",property:"radius",min:-1,max:1e3,step:10,default:-1}]});const{TiltShiftFilter:Nd}=Ie;Ne({id:"tilt-shift",name:"Tilt Shift",category:"blur",description:"Creates a depth-of-field effect simulating miniature photography",createFilter:n=>{try{const o=typeof n.blur=="number"?n.blur:100,t=typeof n.gradientBlur=="number"?n.gradientBlur:600,a=typeof n.startX=="number"?n.startX:0,r=typeof n.startY=="number"?n.startY:.5,i=typeof n.endX=="number"?n.endX:1,s=typeof n.endY=="number"?n.endY:.5,l=new Nd({blur:Number(o),gradientBlur:Number(t),start:{x:Number(a),y:Number(r)},end:{x:Number(i),y:Number(s)}});return l._customParams={blur:o,gradientBlur:t,startX:a,startY:r,endX:i,endY:s},l.updateUIParam=function(c,d){try{const u=Number(d),p=this._customParams||{};switch(this._customParams=p,p[c]=u,c){case"blur":this.blur=u;break;case"gradientBlur":this.gradientBlur=u;break;case"startX":this.start&&typeof this.start=="object"&&(this.start.x=u);break;case"startY":this.start&&typeof this.start=="object"&&(this.start.y=u);break;case"endX":this.end&&typeof this.end=="object"&&(this.end.x=u);break;case"endY":this.end&&typeof this.end=="object"&&(this.end.y=u);break;default:c in this&&(this[c]=u);break}}catch{}},l}catch{return null}},defaultParams:{blur:100,gradientBlur:600,startX:0,startY:.5,endX:1,endY:.5},controls:[{id:"blur",type:"slider",label:"Blur Strength",property:"blur",min:0,max:300,step:1,default:100},{id:"gradientBlur",type:"slider",label:"Gradient Width",property:"gradientBlur",min:100,max:2e3,step:10,default:600},{id:"startX",type:"slider",label:"Start X",property:"startX",min:0,max:1,step:.01,default:0},{id:"startY",type:"slider",label:"Start Y",property:"startY",min:0,max:1,step:.01,default:.5},{id:"endX",type:"slider",label:"End X",property:"endX",min:0,max:1,step:.01,default:1},{id:"endY",type:"slider",label:"End Y",property:"endY",min:0,max:1,step:.01,default:.5}]});const{ZoomBlurFilter:_d}=Ie;Ne({id:"zoom-blur",name:"Zoom Blur",category:"blur",description:"Creates a zoom blur effect from a center point",createFilter:n=>{try{const o=new _d({strength:n.strength||.1,center:{x:n.centerX!==void 0?n.centerX:.5,y:n.centerY!==void 0?n.centerY:.5},innerRadius:n.innerRadius||0,radius:n.radius!==void 0?n.radius:-1,maxKernelSize:n.maxKernelSize||32});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=a;break;case"centerX":this.centerX=a;break;case"centerY":this.centerY=a;break;case"innerRadius":this.innerRadius=a;break;case"radius":this.radius=a;break;default:t in this&&(this[t]=a);break}return!0},o}catch{return null}},defaultParams:{strength:.1,centerX:.5,centerY:.5,innerRadius:0,radius:-1,maxKernelSize:32},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:.5,step:.01,default:.1},{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"innerRadius",type:"slider",label:"Inner Radius",property:"innerRadius",min:0,max:300,step:1,default:0},{id:"radius",type:"slider",label:"Outer Radius",property:"radius",min:-1,max:1e3,step:10,default:-1},{id:"maxKernelSize",type:"select",label:"Quality",property:"maxKernelSize",options:[{label:"Low",value:16},{label:"Medium",value:32},{label:"High",value:48},{label:"Very High",value:64}],default:32}]});const{ColorGradientFilter:Gi}=Ie;Ne({id:"color-gradient",name:"Color Gradient",category:"color",description:"Applies a linear, radial or conic color gradient over the image with multiple color stops",createFilter:n=>{try{let o=[];o=(n.colorStops||[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha:1}]).map(a=>({offset:a.offset,color:typeof a.color=="string"?parseInt(a.color.replace("#","0x")):a.color,alpha:a.alpha})),o.length<2&&(o=[{offset:0,color:16711680,alpha:1},{offset:1,color:255,alpha:1}]),o.sort((a,r)=>a.offset-r.offset);const t=new Gi({type:n.gradientType,stops:o,angle:n.angle,alpha:n.alpha,maxColors:n.maxColors||0,replace:n.replace});return t._customParams={...n},t.getColorStopsForUI=function(){return!this.stops||!Array.isArray(this.stops)?[]:this.stops.map(r=>({offset:r.offset,color:typeof r.color=="number"?"#"+r.color.toString(16).padStart(6,"0"):r.color,alpha:r.alpha}))},t.getDynamicControls=function(){const a=this.getColorStopsForUI(),r=[];return a.forEach((i,s)=>{r.push({id:`colorStop-${s}-color`,type:"color",label:`Stop ${s+1} Color`,property:`colorStops[${s}].color`,default:i.color}),r.push({id:`colorStop-${s}-offset`,type:"slider",label:`Stop ${s+1} Position`,property:`colorStops[${s}].offset`,min:0,max:1,step:.01,default:i.offset}),r.push({id:`colorStop-${s}-alpha`,type:"slider",label:`Stop ${s+1} Alpha`,property:`colorStops[${s}].alpha`,min:0,max:1,step:.01,default:i.alpha})}),r},t.handleButtonAction=function(a){(a==="addColorStop"||a==="removeColorStop")&&this.updateUIParam(a,!0)},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"gradientType":this.type=r;break;case"angle":case"alpha":case"maxColors":case"replace":a in this&&(this[a]=r);break;case"addColorStop":const s=[...this.stops],d={offset:1,alpha:1,color:(()=>{const p=Math.floor(Math.random()*255),m=Math.floor(Math.random()*255),h=Math.floor(Math.random()*255);return p<<16|m<<8|h})()};if(s.length>0){for(let m=0;m<s.length;m++)s[m].offset*=.8;d.offset=1}s.push(d),this.stops=s,i.colorStops=this.stops.map(p=>({offset:p.offset,color:typeof p.color=="number"?"#"+p.color.toString(16).padStart(6,"0"):p.color,alpha:p.alpha}));break;case"removeColorStop":const u=[...this.stops];u.length>2&&(u.pop(),this.stops=u,i.colorStops=this.stops.map(p=>({offset:p.offset,color:typeof p.color=="number"?"#"+p.color.toString(16).padStart(6,"0"):p.color,alpha:p.alpha})));break;case"cssGradient":if(r&&typeof r=="string"&&r.trim()!=="")try{const p=new Gi({css:r});this.type=p.type,this.angle=p.angle,this.stops=[...p.stops],i.colorStops=this.stops.map(m=>({offset:m.offset,color:typeof m.color=="number"?"#"+m.color.toString(16).padStart(6,"0"):m.color,alpha:m.alpha}))}catch{}break;case"colorStops":if(Array.isArray(r)){const p=r.map(m=>({offset:m.offset,color:typeof m.color=="string"?parseInt(m.color.replace("#","0x")):m.color,alpha:m.alpha}));p.sort((m,h)=>m.offset-h.offset),this.stops=p}break;default:if(/colorStops\[\d+\]\..*/.test(a)){const p=a.match(/colorStops\[(\d+)\]\.(.*)/);if(p){const[m,h,g]=p,v=parseInt(h),x=[...this.stops];if(v>=0&&v<x.length)return g==="color"&&typeof r=="string"?x[v].color=parseInt(r.replace("#","0x")):(g==="offset"||g==="alpha")&&(x[v][g]=r),this.stops=x,this.stops.sort((B,E)=>B.offset-E.offset),i.colorStops=this.getColorStopsForUI(),!0}}else a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{gradientType:0,colorStops:[{offset:0,color:"#ff0000",alpha:1},{offset:1,color:"#0000ff",alpha:1}],addColorStop:!1,removeColorStop:!1,cssGradient:"",angle:90,alpha:.75,maxColors:0,replace:!1},controls:[{id:"gradientType",type:"select",label:"Gradient Type",property:"gradientType",options:[{label:"Linear",value:0},{label:"Radial",value:1},{label:"Conic",value:2}],default:0},{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:90},{id:"alpha",type:"slider",label:"Overall Alpha",property:"alpha",min:0,max:1,step:.01,default:.75},{id:"maxColors",type:"slider",label:"Max Colors",property:"maxColors",min:0,max:24,step:1,default:0},{id:"replace",type:"toggle",label:"Replace Original Colors",property:"replace",default:!1},{id:"addColorStop",type:"button",label:"Add New Color Stop",action:"addColorStop"},{id:"removeColorStop",type:"button",label:"Remove Last Color Stop",action:"removeColorStop"},{id:"cssGradient",type:"text",label:"CSS Gradient",property:"cssGradient",default:"",tooltip:'Enter a CSS gradient like "linear-gradient(to right, red, blue)"'}]});Ne({id:"color-map",name:"Color Map",category:"color",description:"Maps colors using a reference texture as a lookup table",createFilter:n=>{try{const o=Ie.ColorMapFilter;if(!o)return null;let t=null;n.texturePath?t=Ae.Texture.from(n.texturePath):t=Ae.Texture.from("/examples/filters-main/examples/images/colormap.png");const a=new o({colorMap:t,nearest:n.nearest,mix:n.mix});return a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"texturePath":i&&(this.colorMap=Ae.Texture.from(i));break;case"mix":this.mix=i;break;case"nearest":this.nearest=i;break;default:r in this&&(this[r]=i);break}return!0},a}catch{return null}},defaultParams:{texturePath:"",mix:1,nearest:!1},controls:[{id:"texturePath",type:"select",label:"Color Map",property:"texturePath",options:[{label:"Default",value:"/examples/filters-main/examples/images/colormap.png"},{label:"Grayscale",value:"/examples/filters-main/examples/images/colormap-grayscale.png"},{label:"Sepia",value:"/examples/filters-main/examples/images/colormap-sepia.png"}],default:"/examples/filters-main/examples/images/colormap.png"},{id:"mix",type:"slider",label:"Mix",property:"mix",min:0,max:1,step:.01,default:1},{id:"nearest",type:"toggle",label:"Nearest Neighbor Sampling",property:"nearest",default:!1}]});const Td=Ie.ColorReplaceFilter;Ne({id:"color-replace",name:"Color Replace",category:"color",description:"Replaces a specific color in the image with another color",createFilter:n=>{try{let o=16711680;n.originalColor&&(typeof n.originalColor=="string"?o=parseInt(n.originalColor.replace("#","0x"),16):typeof n.originalColor=="number"&&(o=n.originalColor));let t=255;n.targetColor&&(typeof n.targetColor=="string"?t=parseInt(n.targetColor.replace("#","0x"),16):typeof n.targetColor=="number"&&(t=n.targetColor));const a=new Td({originalColor:o,targetColor:t,tolerance:n.tolerance||.4});return a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"originalColor":typeof i=="string"?this.originalColor=parseInt(i.replace("#","0x"),16):typeof i=="number"&&(this.originalColor=i);break;case"targetColor":typeof i=="string"?this.targetColor=parseInt(i.replace("#","0x"),16):typeof i=="number"&&(this.targetColor=i);break;case"tolerance":this.tolerance=i;break;default:r in this&&(this[r]=i);break}return!0},a}catch{return null}},defaultParams:{originalColor:"#ff0000",targetColor:"#0000ff",tolerance:.4},controls:[{id:"originalColor",type:"color",label:"Original Color",property:"originalColor",default:"#ff0000"},{id:"targetColor",type:"color",label:"Target Color",property:"targetColor",default:"#0000ff"},{id:"tolerance",type:"slider",label:"Tolerance",property:"tolerance",min:0,max:1,step:.01,default:.4}]});const Md=Ie.MultiColorReplaceFilter;Ne({id:"multi-color-replace",name:"Multi-Color Replace",category:"color",description:"Replaces multiple colors in the image with different target colors",createFilter:n=>{try{const o=[];if(n.originalColor1&&n.targetColor1){const a=typeof n.originalColor1=="string"?parseInt(n.originalColor1.replace("#","0x"),16):n.originalColor1,r=typeof n.targetColor1=="string"?parseInt(n.targetColor1.replace("#","0x"),16):n.targetColor1;o.push([a,r])}if(n.originalColor2&&n.targetColor2){const a=typeof n.originalColor2=="string"?parseInt(n.originalColor2.replace("#","0x"),16):n.originalColor2,r=typeof n.targetColor2=="string"?parseInt(n.targetColor2.replace("#","0x"),16):n.targetColor2;o.push([a,r])}if(n.enableThirdPair&&n.originalColor3&&n.targetColor3){const a=typeof n.originalColor3=="string"?parseInt(n.originalColor3.replace("#","0x"),16):n.originalColor3,r=typeof n.targetColor3=="string"?parseInt(n.targetColor3.replace("#","0x"),16):n.targetColor3;o.push([a,r])}const t=new Md({replacements:o,tolerance:n.tolerance||.05,maxColors:3});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};if(this._customParams=i,i[a]=r,a==="originalColor1"||a==="targetColor1"||a==="originalColor2"||a==="targetColor2"||a==="originalColor3"||a==="targetColor3"||a==="enableThirdPair"){const s=[];if(i.originalColor1&&i.targetColor1){const l=typeof i.originalColor1=="string"?parseInt(i.originalColor1.replace("#","0x"),16):i.originalColor1,c=typeof i.targetColor1=="string"?parseInt(i.targetColor1.replace("#","0x"),16):i.targetColor1;s.push([l,c])}if(i.originalColor2&&i.targetColor2){const l=typeof i.originalColor2=="string"?parseInt(i.originalColor2.replace("#","0x"),16):i.originalColor2,c=typeof i.targetColor2=="string"?parseInt(i.targetColor2.replace("#","0x"),16):i.targetColor2;s.push([l,c])}if(i.enableThirdPair&&i.originalColor3&&i.targetColor3){const l=typeof i.originalColor3=="string"?parseInt(i.originalColor3.replace("#","0x"),16):i.originalColor3,c=typeof i.targetColor3=="string"?parseInt(i.targetColor3.replace("#","0x"),16):i.targetColor3;s.push([l,c])}this.replacements=s,this.refresh()}else a==="tolerance"?this.tolerance=r:a in this&&(this[a]=r);return!0},t}catch{return null}},defaultParams:{originalColor1:"#ff0000",targetColor1:"#0000ff",originalColor2:"#00ff00",targetColor2:"#ffff00",enableThirdPair:!1,originalColor3:"#ff00ff",targetColor3:"#00ffff",tolerance:.05},controls:[{id:"originalColor1",type:"color",label:"Original Color 1",property:"originalColor1",default:"#ff0000"},{id:"targetColor1",type:"color",label:"Target Color 1",property:"targetColor1",default:"#0000ff"},{id:"originalColor2",type:"color",label:"Original Color 2",property:"originalColor2",default:"#00ff00"},{id:"targetColor2",type:"color",label:"Target Color 2",property:"targetColor2",default:"#ffff00"},{id:"enableThirdPair",type:"toggle",label:"Enable Third Color Pair",property:"enableThirdPair",default:!1},{id:"originalColor3",type:"color",label:"Original Color 3",property:"originalColor3",default:"#ff00ff"},{id:"targetColor3",type:"color",label:"Target Color 3",property:"targetColor3",default:"#00ffff"},{id:"tolerance",type:"slider",label:"Tolerance",property:"tolerance",min:0,max:.5,step:.01,default:.05}]});const{RGBSplitFilter:Fd}=Ie;Ne({id:"rgb-split",name:"RGB Split",category:"color",description:"Shifts the red, green, and blue channels to create a retro 3D or glitch effect",createFilter:n=>{try{const o={x:n.redX!==void 0?n.redX:-10,y:n.redY!==void 0?n.redY:0},t={x:n.greenX!==void 0?n.greenX:0,y:n.greenY!==void 0?n.greenY:10},a={x:n.blueX!==void 0?n.blueX:0,y:n.blueY!==void 0?n.blueY:0},r=new Fd({red:o,green:t,blue:a});return r._customParams={...n},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"redX":this.redX=Number(s);break;case"redY":this.redY=Number(s);break;case"greenX":this.greenX=Number(s);break;case"greenY":this.greenY=Number(s);break;case"blueX":this.blueX=Number(s);break;case"blueY":this.blueY=Number(s);break;default:i in this&&(this[i]=s);break}return!0}catch{return this._customParams&&(this._customParams[i]=s),!1}},r}catch{return null}},defaultParams:{redX:-10,redY:0,greenX:0,greenY:10,blueX:0,blueY:0},controls:[{id:"redX",type:"slider",label:"Red X Offset",property:"redX",min:-20,max:20,step:1,default:-10},{id:"redY",type:"slider",label:"Red Y Offset",property:"redY",min:-20,max:20,step:1,default:0},{id:"greenX",type:"slider",label:"Green X Offset",property:"greenX",min:-20,max:20,step:1,default:0},{id:"greenY",type:"slider",label:"Green Y Offset",property:"greenY",min:-20,max:20,step:1,default:10},{id:"blueX",type:"slider",label:"Blue X Offset",property:"blueX",min:-20,max:20,step:1,default:0},{id:"blueY",type:"slider",label:"Blue Y Offset",property:"blueY",min:-20,max:20,step:1,default:0}]});const{AdvancedBloomFilter:Id}=Ie;Ne({id:"advanced-bloom",name:"Advanced Bloom",category:"light",description:"Adds a sophisticated bloom/glow effect with fine-grained control",createFilter:n=>{try{const o=new Id({threshold:n.threshold||.5,bloomScale:n.bloomScale||1,brightness:n.brightness||1,blur:n.blur||8,quality:n.quality||4,pixelSize:{x:n.pixelSizeX||1,y:n.pixelSizeY||1}});return o._customParams={pixelSizeX:n.pixelSizeX||1,pixelSizeY:n.pixelSizeY||1},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"threshold":this.threshold=Number(a);break;case"bloomScale":this.bloomScale=Number(a);break;case"brightness":this.brightness=Number(a);break;case"blur":this.blur=Number(a);break;case"quality":this.quality=Number(a);break;case"pixelSizeX":r.pixelSizeX=Number(a),this.pixelSize={x:Number(a),y:r.pixelSizeY};break;case"pixelSizeY":r.pixelSizeY=Number(a),this.pixelSize={x:r.pixelSizeX,y:Number(a)};break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{threshold:.5,bloomScale:1,brightness:1,blur:8,quality:4,pixelSizeX:1,pixelSizeY:1},controls:[{id:"threshold",type:"slider",label:"Threshold",property:"threshold",min:0,max:1,step:.01,default:.5},{id:"bloomScale",type:"slider",label:"Bloom Intensity",property:"bloomScale",min:0,max:3,step:.1,default:1},{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:3,step:.1,default:1},{id:"blur",type:"slider",label:"Blur Strength",property:"blur",min:0,max:20,step:1,default:8},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"pixelSizeX",type:"slider",label:"Pixel Size X",property:"pixelSizeX",min:.5,max:10,step:.5,default:1},{id:"pixelSizeY",type:"slider",label:"Pixel Size Y",property:"pixelSizeY",min:.5,max:10,step:.5,default:1}]});const Bd=Ie.AsciiFilter;Ne({id:"ascii",name:"ASCII",category:"stylize",description:"Convert image to ASCII text characters",createFilter:n=>{try{const o=typeof n.size=="number"?n.size:8;let t=n.color;typeof t=="string"&&t.startsWith("#")&&(t=parseInt(t.replace("#","0x"),16));const a=n.replaceColor===!0,r=new Bd({size:o,color:t,replaceColor:a});return r._customParams={size:o,color:t,replaceColor:a},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"size":this.size=Number(s);break;case"color":typeof s=="string"&&s.startsWith("#")?(l.color=s,this.color=parseInt(s.replace("#","0x"),16)):this.color=s;break;case"replaceColor":this.replaceColor=!!s;break;default:i in this&&(this[i]=s);break}}catch{}},r}catch{return null}},defaultParams:{size:8,color:"#ffffff",replaceColor:!1},controls:[{id:"size",type:"slider",label:"Character Size",property:"size",min:2,max:20,step:1,default:8},{id:"color",type:"color",label:"Character Color",property:"color",default:"#ffffff"},{id:"replaceColor",type:"toggle",label:"Replace Original Colors",property:"replaceColor",default:!1}]});const Rd=Ie.BackdropBlurFilter;Ne({id:"backdrop-blur",name:"Backdrop Blur",category:"blur",description:"Blurs what is behind the object, creating a glass-like effect",createFilter:n=>{try{const o=new Rd({strength:n.strength||20,quality:n.quality||4,resolution:n.resolution||.5,kernelSize:n.kernelSize||9});return o._customParams={...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"strength":this.strength=Number(a),this.blur=Number(a)/4;break;case"quality":this.quality=Number(a);break;case"resolution":this.resolution=Number(a);break;case"kernelSize":const i=Number(a);this.blurXFilter&&this.blurYFilter?(this.blurXFilter.kernelSize=i,this.blurYFilter.kernelSize=i):this.kernelSize=i;break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{strength:20,quality:4,resolution:.5,kernelSize:9},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:50,step:1,default:20},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"resolution",type:"slider",label:"Resolution",property:"resolution",min:.1,max:1,step:.1,default:.5},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:9}]});const{BevelFilter:Pd}=Ie;Ne({id:"bevel",name:"Bevel",category:"effects",description:"Add a 3D-like beveled edge effect to the image",createFilter:n=>{try{const o=n.lightColor?n.lightColor.replace("#","0x"):"0xffffff",t=n.shadowColor?n.shadowColor.replace("#","0x"):"0x000000",a=new Pd({rotation:n.rotation!==void 0?n.rotation:45,thickness:n.thickness!==void 0?n.thickness:2,lightColor:parseInt(o,16),lightAlpha:n.lightAlpha!==void 0?n.lightAlpha:.7,shadowColor:parseInt(t,16),shadowAlpha:n.shadowAlpha!==void 0?n.shadowAlpha:.7});return a._customParams={...n},a.updateUIParam=function(r,i){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"rotation":this.rotation=Number(i);break;case"thickness":this.thickness=Number(i);break;case"lightColor":if(typeof i=="string"){const l=parseInt(i.replace("#","0x"),16);this.lightColor=l}break;case"lightAlpha":this.lightAlpha=Number(i);break;case"shadowColor":if(typeof i=="string"){const l=parseInt(i.replace("#","0x"),16);this.shadowColor=l}break;case"shadowAlpha":this.shadowAlpha=Number(i);break;default:r in this&&(this[r]=i);break}return!0}catch{return this._customParams&&(this._customParams[r]=i),!1}},a}catch{return null}},defaultParams:{rotation:45,thickness:2,lightColor:"#ffffff",lightAlpha:.7,shadowColor:"#000000",shadowAlpha:.7},controls:[{id:"rotation",type:"slider",label:"Angle",property:"rotation",min:0,max:360,step:1,default:45},{id:"thickness",type:"slider",label:"Thickness",property:"thickness",min:0,max:20,step:.1,default:2},{id:"lightColor",type:"color",label:"Light Color",property:"lightColor",default:"#ffffff"},{id:"lightAlpha",type:"slider",label:"Light Opacity",property:"lightAlpha",min:0,max:1,step:.01,default:.7},{id:"shadowColor",type:"color",label:"Shadow Color",property:"shadowColor",default:"#000000"},{id:"shadowAlpha",type:"slider",label:"Shadow Opacity",property:"shadowAlpha",min:0,max:1,step:.01,default:.7}]});const{BloomFilter:$d}=Ie;Ne({id:"bloom",name:"Bloom/Glow",category:"light",description:"Add a subtle glow effect to bright areas of the image",createFilter:n=>{try{const o=typeof n.strengthX=="number"?n.strengthX:2,t=typeof n.strengthY=="number"?n.strengthY:2,a=typeof n.quality=="number"?n.quality:4,r=typeof n.resolution=="number"?n.resolution:1,i=typeof n.kernelSize=="number"?n.kernelSize:5,s=new $d({strength:{x:Number(o),y:Number(t)},quality:Number(a),resolution:Number(r),kernelSize:Number(i)}),l=s;return s._customParams={strengthX:o,strengthY:t,quality:a,resolution:r,kernelSize:i},s.updateUIParam=function(c,d){var u,p;try{const m=Number(d),h=this._customParams||{};switch(this._customParams=h,h[c]=m,c){case"strengthX":this.strength&&typeof this.strength=="object"&&(this.strength.x=m,(u=this._updateStrength)==null||u.call(this));break;case"strengthY":this.strength&&typeof this.strength=="object"&&(this.strength.y=m,(p=this._updateStrength)==null||p.call(this));break;case"quality":this.quality=m;break;case"resolution":this.resolution=m;break;case"kernelSize":this.kernelSize=m;break;default:c in this&&(this[c]=m);break}}catch{}},s}catch{return null}},defaultParams:{strengthX:2,strengthY:2,quality:4,resolution:1,kernelSize:5},controls:[{id:"strengthX",type:"slider",label:"Horizontal Strength",property:"strengthX",min:0,max:20,step:.1,default:2},{id:"strengthY",type:"slider",label:"Vertical Strength",property:"strengthY",min:0,max:20,step:.1,default:2},{id:"quality",type:"slider",label:"Quality",property:"quality",min:1,max:10,step:1,default:4},{id:"kernelSize",type:"select",label:"Kernel Size",property:"kernelSize",options:[{label:"5",value:5},{label:"7",value:7},{label:"9",value:9},{label:"11",value:11},{label:"13",value:13},{label:"15",value:15}],default:5}]});const{BulgePinchFilter:zd}=Ie;Ne({id:"bulge-pinch",name:"Bulge/Pinch",category:"distortion",description:"Creates a bulge or pinch effect in a circular area",createFilter:n=>{try{const o=n.centerX??.5,t=n.centerY??.5,a=n.radius??100,r=n.strength??1,i=new zd({center:{x:o,y:t},radius:a,strength:r});return i._customParams={...n},i.updateUIParam=function(s,l){const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=l;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=l;break;case"radius":case"strength":this[s]=l;break;default:s in this&&(this[s]=l);break}return!0},i}catch{return null}},defaultParams:{centerX:.5,centerY:.5,radius:100,strength:1},controls:[{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"radius",type:"slider",label:"Radius",property:"radius",min:1,max:500,step:1,default:100},{id:"strength",type:"slider",label:"Strength",property:"strength",min:-1,max:1,step:.01,default:1}]});const{ConvolutionFilter:Ad}=Ie,wn={normal:[0,0,0,0,1,0,0,0,0],gaussianBlur:[.045,.122,.045,.122,.332,.122,.045,.122,.045],boxBlur:[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],edgeDetection:[-1,-1,-1,-1,8,-1,-1,-1,-1],edgeEnhance:[0,0,0,-1,1,0,0,0,0],emboss:[-2,-1,0,-1,1,1,0,1,2],sharpen:[0,-1,0,-1,5,-1,0,-1,0],sobelHorizontal:[1,2,1,0,0,0,-1,-2,-1],sobelVertical:[1,0,-1,2,0,-2,1,0,-1]};Ne({id:"convolution",name:"Convolution Matrix",category:"effects",description:"Apply custom image effects using matrix convolution",createFilter:n=>{try{let o;if(n.customMatrix)o=[n.m00,n.m01,n.m02,n.m10,n.m11,n.m12,n.m20,n.m21,n.m22];else{const a=n.preset;o=wn[a]||wn.normal}const t=new Ad({matrix:new Float32Array(o),width:n.width||200,height:n.height||200});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"preset":if(!i.customMatrix){const s=r;wn[s]&&(this.matrix=wn[s])}break;case"customMatrix":if(r){const s=this.matrix;i.m00=s[0],i.m01=s[1],i.m02=s[2],i.m10=s[3],i.m11=s[4],i.m12=s[5],i.m20=s[6],i.m21=s[7],i.m22=s[8]}else{const s=i.preset;this.matrix=wn[s]||wn.normal}break;case"m00":case"m01":case"m02":case"m10":case"m11":case"m12":case"m20":case"m21":case"m22":if(i.customMatrix){const s=[...this.matrix],c={m00:0,m01:1,m02:2,m10:3,m11:4,m12:5,m20:6,m21:7,m22:8}[a];c!==void 0&&(s[c]=r,this.matrix=s)}break;case"width":this.width=r;break;case"height":this.height=r;break;default:a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{preset:"normal",customMatrix:!1,m00:0,m01:0,m02:0,m10:0,m11:1,m12:0,m20:0,m21:0,m22:0,width:200,height:200},controls:[{id:"preset",type:"select",label:"Effect Preset",property:"preset",options:[{value:"normal",label:"Normal"},{value:"gaussianBlur",label:"Gaussian Blur"},{value:"boxBlur",label:"Box Blur"},{value:"edgeDetection",label:"Edge Detection"},{value:"edgeEnhance",label:"Edge Enhance"},{value:"emboss",label:"Emboss"},{value:"sharpen",label:"Sharpen"},{value:"sobelHorizontal",label:"Sobel Horizontal"},{value:"sobelVertical",label:"Sobel Vertical"}],default:"normal"},{id:"customMatrix",type:"toggle",label:"Use Custom Matrix",property:"customMatrix",default:!1},{id:"width",type:"slider",label:"Width",property:"width",min:50,max:500,step:10,default:200},{id:"height",type:"slider",label:"Height",property:"height",min:50,max:500,step:10,default:200},{id:"m00",type:"slider",label:"Matrix [0,0]",property:"m00",min:-5,max:5,step:.1,default:0},{id:"m01",type:"slider",label:"Matrix [0,1]",property:"m01",min:-5,max:5,step:.1,default:0},{id:"m02",type:"slider",label:"Matrix [0,2]",property:"m02",min:-5,max:5,step:.1,default:0},{id:"m10",type:"slider",label:"Matrix [1,0]",property:"m10",min:-5,max:5,step:.1,default:0},{id:"m11",type:"slider",label:"Matrix [1,1]",property:"m11",min:-5,max:5,step:.1,default:1},{id:"m12",type:"slider",label:"Matrix [1,2]",property:"m12",min:-5,max:5,step:.1,default:0},{id:"m20",type:"slider",label:"Matrix [2,0]",property:"m20",min:-5,max:5,step:.1,default:0},{id:"m21",type:"slider",label:"Matrix [2,1]",property:"m21",min:-5,max:5,step:.1,default:0},{id:"m22",type:"slider",label:"Matrix [2,2]",property:"m22",min:-5,max:5,step:.1,default:0}]});Ne({id:"cross-hatch",name:"Cross Hatch",category:"stylize",description:"Creates a crosshatching effect like in a pencil drawing",createFilter:n=>{try{const o=typeof n.thickness=="number"?n.thickness:10,t=new Ie.CrossHatchFilter;t._customParams={thickness:o};const a=t;try{a.uniforms&&a.uniforms.thickness===void 0&&Object.defineProperty(a.uniforms,"thickness",{get:()=>t._customParams.thickness/10,set:r=>t._customParams.thickness=r*10,enumerable:!0,configurable:!0})}catch{}return t.updateUIParam=function(r,i){try{const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"thickness":s.thickness=Number(i),this.uniforms&&this.uniforms.thickness!==void 0&&(this.uniforms.thickness=Number(i)/10);break;default:r in this&&(this[r]=i);break}}catch{}},t}catch{return null}},defaultParams:{thickness:10},controls:[{id:"thickness",type:"slider",label:"Line Thickness",property:"thickness",min:2,max:20,step:1,default:10}]});Ne({id:"crt",name:"CRT Screen",category:"stylize",description:"Simulates an old CRT screen with scan lines and noise",createFilter:n=>{try{const o={lineWidth:typeof n.lineWidth=="number"?n.lineWidth:1,noise:typeof n.noise=="number"?n.noise:.3,curvature:typeof n.curvature=="number"?n.curvature:1,lineContrast:typeof n.lineContrast=="number"?n.lineContrast:.25,verticalLine:n.verticalLine===!0,noiseSize:typeof n.noiseSize=="number"?n.noiseSize:1,vignetting:typeof n.vignetting=="number"?n.vignetting:.3,vignettingAlpha:typeof n.vignettingAlpha=="number"?n.vignettingAlpha:1,vignettingBlur:typeof n.vignettingBlur=="number"?n.vignettingBlur:.3,time:typeof n.time=="number"?n.time:0,seed:typeof n.seed=="number"?n.seed:Math.random()},t=new Ie.CRTFilter(o);return t._customParams={...o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"lineWidth":this.lineWidth=Number(r);break;case"noise":this.noise=Number(r);break;case"curvature":this.curvature=Number(r);break;case"lineContrast":this.lineContrast=Number(r);break;case"verticalLine":this.verticalLine=!!r;break;case"noiseSize":this.noiseSize=Number(r);break;case"vignetting":this.vignetting=Number(r);break;case"vignettingAlpha":this.vignettingAlpha=Number(r);break;case"vignettingBlur":this.vignettingBlur=Number(r);break;case"time":this.time=Number(r);break;case"seed":this.seed=Number(r);break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{lineWidth:1,noise:.3,curvature:1,lineContrast:.25,verticalLine:!1,noiseSize:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0,seed:1},controls:[{id:"lineWidth",type:"slider",label:"Scan Line Width",property:"lineWidth",min:0,max:5,step:.1,default:1},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.3},{id:"curvature",type:"slider",label:"Screen Curvature",property:"curvature",min:0,max:10,step:.1,default:1},{id:"lineContrast",type:"slider",label:"Line Contrast",property:"lineContrast",min:0,max:1,step:.01,default:.25},{id:"verticalLine",type:"toggle",label:"Vertical Lines",property:"verticalLine",default:!1},{id:"noiseSize",type:"slider",label:"Noise Size",property:"noiseSize",min:.5,max:5,step:.1,default:1},{id:"vignetting",type:"slider",label:"Vignette Size",property:"vignetting",min:0,max:1,step:.01,default:.3},{id:"vignettingAlpha",type:"slider",label:"Vignette Opacity",property:"vignettingAlpha",min:0,max:1,step:.01,default:1},{id:"vignettingBlur",type:"slider",label:"Vignette Blur",property:"vignettingBlur",min:0,max:1,step:.01,default:.3},{id:"time",type:"slider",label:"Animation Time",property:"time",min:0,max:10,step:.1,default:0}]});const Dd=Ae.DisplacementFilter,Ud=Ae.Sprite,Ja=Ae.Texture;Ne({id:"displacement",name:"Displacement Map",category:"distortion",description:"Distorts the image using a displacement map texture",createFilter:n=>{try{const o=n.mapTexture||"/assets/images/displacement_map.png";let t;try{t=Ja.from(o),t.source.addressMode="repeat"}catch{const s=document.createElement("canvas");s.width=256,s.height=256;const l=s.getContext("2d");if(l){l.fillStyle="#ffffff",l.fillRect(0,0,s.width,s.height),l.fillStyle="#000000";for(let c=0;c<10;c++)for(let d=0;d<10;d++)(c+d)%2===0&&l.fillRect(c*25,d*25,25,25)}t=Ja.from(s)}const a=new Ud(t),r=new Dd(a,n.scale||50);return r.scale.x=n.scaleX||50,r.scale.y=n.scaleY||50,r._customParams={...n},r._displacementSprite=a,r.updateUIParam=function(i,s){const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"scaleX":this.scale.x=s;break;case"scaleY":this.scale.y=s;break;case"mapTexture":try{const c=this._displacementSprite;if(c){const d=Ja.from(s);d.source.addressMode="repeat",c.texture=d}}catch{}break;default:i in this?this[i]=s:i in this.scale&&(this.scale[i]=s);break}return!0},r}catch{return null}},defaultParams:{mapTexture:"/assets/images/displacement_map.png",scale:50,scaleX:50,scaleY:50},controls:[{id:"mapTexture",type:"select",label:"Displacement Map",property:"mapTexture",options:[{label:"Default",value:"/assets/images/displacement_map.png"},{label:"Clouds",value:"/assets/images/clouds.png"},{label:"Ripple",value:"/assets/images/ripple.png"}],default:"/assets/images/displacement_map.png"},{id:"scaleX",type:"slider",label:"Scale X",property:"scaleX",min:0,max:200,step:1,default:50},{id:"scaleY",type:"slider",label:"Scale Y",property:"scaleY",min:0,max:200,step:1,default:50}]});Ne({id:"dot",name:"Dot Screen",category:"stylize",description:"Simulates a halftone printing pattern with dots",createFilter:n=>{try{const o={scale:typeof n.scale=="number"?n.scale:1,angle:typeof n.angle=="number"?n.angle:5,grayscale:n.grayscale===!0},t=new Ie.DotFilter(o);return t._customParams={...o},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"scale":this.scale=Number(r);break;case"angle":this.angle=Number(r);break;case"grayscale":this.grayscale=!!r;break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{scale:1,angle:5,grayscale:!0},controls:[{id:"scale",type:"slider",label:"Dot Scale",property:"scale",min:.5,max:10,step:.1,default:1},{id:"angle",type:"slider",label:"Dot Angle",property:"angle",min:0,max:10,step:.1,default:5},{id:"grayscale",type:"toggle",label:"Grayscale",property:"grayscale",default:!0}]});const{ConvolutionFilter:Od}=Ie;Ne({id:"emboss",name:"Emboss",category:"stylize",description:"Creates an embossed relief effect",createFilter:n=>{try{const o=typeof n.strength=="number"?n.strength:5,t=o/3,a=[-t,-t,0,-t,1,t,0,t,t],r=new Od({matrix:new Float32Array(a),width:3,height:3});return r.bias=.5,r._customParams={strength:o},r.updateUIParam=function(i,s){try{const l=this._customParams||{};switch(this._customParams=l,l[i]=s,i){case"strength":const c=Math.max(Number(s),1);l.strength=c;const d=c/3;this.matrix[0]=-d,this.matrix[1]=-d,this.matrix[3]=-d,this.matrix[4]=1,this.matrix[5]=d,this.matrix[7]=d,this.matrix[8]=d,this.bias=.5;break;case"grayscale":l.grayscale=!!s;break;default:i in this&&(this[i]=s);break}}catch{}},r}catch{return null}},defaultParams:{strength:5,grayscale:!1},controls:[{id:"strength",type:"slider",label:"Strength",property:"strength",min:1,max:20,step:1,default:5},{id:"grayscale",type:"toggle",label:"Grayscale",property:"grayscale",default:!1}]});const{GlitchFilter:Ld}=Ie,Kt={TRANSPARENT:0,ORIGINAL:1,LOOP:2,CLAMP:3,MIRROR:4};Ne({id:"glitch",name:"Glitch",category:"effects",description:"Apply digital distortion and glitch effects",createFilter:n=>{try{const o={x:n.redX,y:n.redY},t={x:n.greenX,y:n.greenY},a={x:n.blueX,y:n.blueY},r=new Ld({slices:n.slices,offset:n.offset,direction:n.direction,fillMode:n.fillMode,seed:n.seed,average:n.average,minSize:n.minSize,sampleSize:n.sampleSize,red:o,green:t,blue:a});r.animating=n.animating||!1,r._customParams={...n},typeof r.refresh=="function"&&r.refresh();let i=null;const s=()=>{r.animating&&(r.seed=Math.random()),i=requestAnimationFrame(s)};return r.animating&&(i=requestAnimationFrame(s)),r._stopAnimation=()=>{i!==null&&(cancelAnimationFrame(i),i=null)},r.updateUIParam=function(l,c){const d=this._customParams||{};switch(this._customParams=d,d[l]=c,l){case"animating":this.animating=c,c&&!i&&(i=requestAnimationFrame(s));break;case"slices":this.slices=Math.round(c);break;case"redX":case"redY":const u=this.red;l==="redX"?u.x=c:u.y=c,this.red=u;break;case"greenX":case"greenY":const p=this.green;l==="greenX"?p.x=c:p.y=c,this.green=p;break;case"blueX":case"blueY":const m=this.blue;l==="blueX"?m.x=c:m.y=c,this.blue=m;break;case"seed":this.animating||(this.seed=c);break;case"randomizeSeed":c&&!d.animating&&(this.seed=Math.random());break;case"refresh":if(c)try{this.refresh()}catch{}break;case"offset":case"direction":case"fillMode":case"average":case"minSize":case"sampleSize":l in this&&(this[l]=c);break;default:l in this&&(this[l]=c);break}},r}catch{return null}},defaultParams:{slices:10,offset:100,direction:0,fillMode:Kt.LOOP,seed:.5,average:!1,minSize:8,sampleSize:512,redX:2,redY:2,greenX:-2,greenY:0,blueX:0,blueY:-2,animating:!1,randomizeSeed:!1,refresh:!1},controls:[{id:"animating",type:"toggle",label:"Animate Automatically",property:"animating",default:!1},{id:"slices",type:"slider",label:"Slices",property:"slices",min:2,max:20,step:1,default:10},{id:"offset",type:"slider",label:"Offset Amount",property:"offset",min:0,max:400,step:1,default:100},{id:"direction",type:"slider",label:"Direction",property:"direction",min:-180,max:180,step:1,default:0},{id:"fillMode",type:"select",label:"Fill Mode",property:"fillMode",options:[{value:Kt.TRANSPARENT,label:"Transparent"},{value:Kt.ORIGINAL,label:"Original"},{value:Kt.LOOP,label:"Loop"},{value:Kt.CLAMP,label:"Clamp"},{value:Kt.MIRROR,label:"Mirror"}],default:Kt.LOOP},{id:"seed",type:"slider",label:"Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"},{id:"refresh",type:"button",label:"Refresh Filter",action:"refresh"},{id:"average",type:"toggle",label:"Average Slices",property:"average",default:!1},{id:"redX",type:"slider",label:"Red X Offset",property:"redX",min:-20,max:20,step:.5,default:2},{id:"redY",type:"slider",label:"Red Y Offset",property:"redY",min:-20,max:20,step:.5,default:2},{id:"greenX",type:"slider",label:"Green X Offset",property:"greenX",min:-20,max:20,step:.5,default:-2},{id:"greenY",type:"slider",label:"Green Y Offset",property:"greenY",min:-20,max:20,step:.5,default:0},{id:"blueX",type:"slider",label:"Blue X Offset",property:"blueX",min:-20,max:20,step:.5,default:0},{id:"blueY",type:"slider",label:"Blue Y Offset",property:"blueY",min:-20,max:20,step:.5,default:-2}]});const{GlowFilter:Wd}=Ie;Ne({id:"glow",name:"Glow",category:"light",description:"Adds a customizable glow effect around the image",createFilter:n=>{try{const o=parseInt(n.color.replace("#","0x"),16),t=new Wd({distance:n.distance||10,outerStrength:n.outerStrength||4,innerStrength:n.innerStrength||0,color:o,alpha:n.alpha??1,quality:n.quality||.1,knockout:n.knockout||!1});return t._customParams={color:n.color||"#ffffff",...n},t.updateUIParam=function(a,r){try{const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"distance":this.distance=Number(r);break;case"outerStrength":this.outerStrength=Number(r);break;case"innerStrength":this.innerStrength=Number(r);break;case"color":i.color=r,this.color=parseInt(r.replace("#","0x"),16);break;case"alpha":this.alpha=Number(r);break;case"quality":this.quality=Number(r);break;case"knockout":this.knockout=!!r;break;default:a in this&&(this[a]=r);break}}catch{}},t}catch{return null}},defaultParams:{distance:10,outerStrength:4,innerStrength:0,color:"#ffffff",alpha:1,quality:.1,knockout:!1},controls:[{id:"distance",type:"slider",label:"Distance",property:"distance",min:0,max:20,step:1,default:10},{id:"outerStrength",type:"slider",label:"Outer Strength",property:"outerStrength",min:0,max:20,step:.1,default:4},{id:"innerStrength",type:"slider",label:"Inner Strength",property:"innerStrength",min:0,max:20,step:.1,default:0},{id:"color",type:"color",label:"Color",property:"color",default:"#ffffff"},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1},{id:"quality",type:"slider",label:"Quality",property:"quality",min:.01,max:1,step:.01,default:.1},{id:"knockout",type:"toggle",label:"Show Glow Only",property:"knockout",default:!1}]});const{GodrayFilter:jd}=Ie;Ne({id:"godray",name:"Godray",category:"light",description:"Creates volumetric light-ray effects (crepuscular rays)",createFilter:n=>{try{const o=new jd({angle:n.angle||30,parallel:n.parallel??!0,center:{x:n.centerX||0,y:n.centerY||0},gain:n.gain||.5,lacunarity:n.lacunarity||2.5,time:n.time||0,alpha:n.alpha||1});return o._customParams={centerX:n.centerX||0,centerY:n.centerY||0,...n},o.updateUIParam=function(t,a){try{const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"angle":this.angle=Number(a);break;case"parallel":this.parallel=!!a;break;case"centerX":r.centerX=Number(a),this.center={x:Number(a),y:r.centerY};break;case"centerY":r.centerY=Number(a),this.center={x:r.centerX,y:Number(a)};break;case"gain":this.gain=Number(a);break;case"lacunarity":this.lacunarity=Number(a);break;case"time":this.time=Number(a);break;case"alpha":this.alpha=Number(a);break;default:t in this&&(this[t]=a);break}}catch{}},o}catch{return null}},defaultParams:{angle:30,parallel:!0,centerX:0,centerY:0,gain:.5,lacunarity:2.5,time:0,alpha:1},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:0,max:360,step:1,default:30},{id:"parallel",type:"toggle",label:"Parallel Rays",property:"parallel",default:!0},{id:"centerX",type:"slider",label:"Light Source X",property:"centerX",min:-1,max:1,step:.01,default:0},{id:"centerY",type:"slider",label:"Light Source Y",property:"centerY",min:-1,max:1,step:.01,default:0},{id:"gain",type:"slider",label:"Gain/Intensity",property:"gain",min:0,max:1,step:.01,default:.5},{id:"lacunarity",type:"slider",label:"Density",property:"lacunarity",min:.1,max:10,step:.1,default:2.5},{id:"time",type:"slider",label:"Time",property:"time",min:0,max:10,step:.1,default:0},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1}]});const Xd=Ie.SimpleLightmapFilter,Hi=Ae.Texture;Ne({id:"lightmap",name:"Lightmap",category:"light",description:"Applies lighting effects using a reference texture as a light map",createFilter:n=>{try{const o=n.textureType||"default",t=n.color||"#000000",a=typeof n.alpha=="number"?n.alpha:1,r=document.createElement("canvas");r.width=256,r.height=256;const i=r.getContext("2d");if(!i)throw new Error("Canvas 2D context not available");if(o==="spotlight"){i.fillStyle="black",i.fillRect(0,0,256,256);const d=i.createRadialGradient(128,128,5,128,128,80);d.addColorStop(0,"white"),d.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),d.addColorStop(1,"rgba(0, 0, 0, 0)"),i.fillStyle=d,i.beginPath(),i.arc(128,128,100,0,Math.PI*2),i.fill()}else if(o==="softlight"){const d=i.createLinearGradient(0,0,256,256);d.addColorStop(0,"white"),d.addColorStop(.3,"rgba(220, 220, 220, 1)"),d.addColorStop(.7,"rgba(150, 150, 150, 1)"),d.addColorStop(1,"rgba(80, 80, 80, 1)"),i.fillStyle=d,i.fillRect(0,0,256,256)}else{const d=i.createRadialGradient(128,128,10,128,128,160);d.addColorStop(0,"white"),d.addColorStop(.3,"rgba(220, 220, 220, 1)"),d.addColorStop(.6,"rgba(150, 150, 150, 1)"),d.addColorStop(1,"black"),i.fillStyle=d,i.fillRect(0,0,256,256)}const s=Hi.from(r);let l;try{typeof t=="string"&&t.startsWith("#")?l=parseInt(t.replace("#","0x"),16):l=0}catch{l=0}const c=new Xd(s,l,a);return c._customParams={textureType:o,color:t,alpha:a},c.updateUIParam=function(d,u){try{const p=this._customParams||{};switch(this._customParams=p,p[d]=u,d){case"textureType":p.textureType=u;const m=document.createElement("canvas");m.width=256,m.height=256;const h=m.getContext("2d");if(h){if(u==="spotlight"){h.fillStyle="black",h.fillRect(0,0,256,256);const v=h.createRadialGradient(128,128,5,128,128,80);v.addColorStop(0,"white"),v.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),v.addColorStop(1,"rgba(0, 0, 0, 0)"),h.fillStyle=v,h.beginPath(),h.arc(128,128,100,0,Math.PI*2),h.fill()}else if(u==="softlight"){const v=h.createLinearGradient(0,0,256,256);v.addColorStop(0,"white"),v.addColorStop(.3,"rgba(220, 220, 220, 1)"),v.addColorStop(.7,"rgba(150, 150, 150, 1)"),v.addColorStop(1,"rgba(80, 80, 80, 1)"),h.fillStyle=v,h.fillRect(0,0,256,256)}else{const v=h.createRadialGradient(128,128,10,128,128,160);v.addColorStop(0,"white"),v.addColorStop(.3,"rgba(220, 220, 220, 1)"),v.addColorStop(.6,"rgba(150, 150, 150, 1)"),v.addColorStop(1,"black"),h.fillStyle=v,h.fillRect(0,0,256,256)}const g=Hi.from(m);if(this.lightMap=g,this.enabled!==void 0){const v=this.enabled;this.enabled=!1,setTimeout(()=>{this.enabled=v},0)}}break;case"color":p.color=u;try{typeof u=="string"&&u.startsWith("#")?this.color=parseInt(u.replace("#","0x"),16):this.color=0}catch{this.color=0}break;case"alpha":this.alpha=Number(u);break;default:d in this&&(this[d]=u);break}}catch{}},c}catch{return null}},defaultParams:{textureType:"default",color:"#000000",alpha:1},controls:[{id:"textureType",type:"select",label:"Light Map Type",property:"textureType",options:[{label:"Default",value:"default"},{label:"Spotlight",value:"spotlight"},{label:"Soft Light",value:"softlight"}],default:"default"},{id:"color",type:"color",label:"Ambient Color",property:"color",default:"#000000"},{id:"alpha",type:"slider",label:"Intensity",property:"alpha",min:0,max:1,step:.01,default:1}]});const{NoiseFilter:Zd}=Ae;Ne({id:"noise",name:"Noise",category:"effects",description:"Add random noise to the image",createFilter:n=>{try{const o=new Zd({noise:n.noise||.5,seed:n.seed||Math.random()});o.animating=n.animating||!1,o._customParams={...n};let t=null;const a=()=>{o.animating&&(o.seed=Math.random()),t=requestAnimationFrame(a)};return o.animating&&(t=requestAnimationFrame(a)),o._stopAnimation=()=>{t!==null&&(cancelAnimationFrame(t),t=null)},o.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"animating":this.animating=i,i&&!t&&(t=requestAnimationFrame(a));break;case"noise":this.noise=Math.max(0,Math.min(1,i));break;case"seed":this.animating||(this.seed=i);break;case"randomizeSeed":i&&(this.seed=Math.random());break;default:r in this&&(this[r]=i);break}},o}catch{return null}},defaultParams:{noise:.5,seed:.5,animating:!1,randomizeSeed:!1},controls:[{id:"animating",type:"toggle",label:"Animate Noise",property:"animating",default:!1},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.5},{id:"seed",type:"slider",label:"Random Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"}]});const{OldFilmFilter:Yd}=Ie;Ne({id:"old-film",name:"Old Film",category:"effects",description:"Apply a vintage film effect with scratches and grain",createFilter:n=>{try{const o=new Yd({sepia:n.sepia,noise:n.noise,noiseSize:n.noiseSize,scratch:n.scratch,scratchDensity:n.scratchDensity,scratchWidth:n.scratchWidth,vignetting:n.vignetting,vignettingAlpha:n.vignettingAlpha,vignettingBlur:n.vignettingBlur,seed:n.seed||Math.random()});o.animating=n.animating||!1,o._customParams={...n};let t=null;const a=()=>{o.animating&&(o.seed=Math.random()),t=requestAnimationFrame(a)};return o.animating&&(t=requestAnimationFrame(a)),o._stopAnimation=()=>{t!==null&&(cancelAnimationFrame(t),t=null)},o.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"animating":this.animating=i,i&&!t&&(t=requestAnimationFrame(a));break;case"seed":this.animating||(this.seed=i);break;case"randomizeSeed":i&&(this.seed=Math.random());break;case"sepia":case"noise":case"noiseSize":case"scratch":case"scratchDensity":case"scratchWidth":case"vignetting":case"vignettingAlpha":case"vignettingBlur":r in this&&(this[r]=i);break;default:r in this&&(this[r]=i);break}},o}catch{return null}},defaultParams:{sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,seed:.5,animating:!1,randomizeSeed:!1},controls:[{id:"animating",type:"toggle",label:"Animate Film",property:"animating",default:!1},{id:"sepia",type:"slider",label:"Sepia Tone",property:"sepia",min:0,max:1,step:.01,default:.3},{id:"noise",type:"slider",label:"Noise Amount",property:"noise",min:0,max:1,step:.01,default:.3},{id:"noiseSize",type:"slider",label:"Noise Size",property:"noiseSize",min:1,max:10,step:.1,default:1},{id:"scratch",type:"slider",label:"Scratch Amount",property:"scratch",min:-1,max:1,step:.01,default:.5},{id:"scratchDensity",type:"slider",label:"Scratch Density",property:"scratchDensity",min:0,max:1,step:.01,default:.3},{id:"scratchWidth",type:"slider",label:"Scratch Width",property:"scratchWidth",min:1,max:20,step:1,default:1},{id:"vignetting",type:"slider",label:"Vignette Size",property:"vignetting",min:0,max:1,step:.01,default:.3},{id:"vignettingAlpha",type:"slider",label:"Vignette Opacity",property:"vignettingAlpha",min:0,max:1,step:.01,default:1},{id:"vignettingBlur",type:"slider",label:"Vignette Blur",property:"vignettingBlur",min:0,max:1,step:.01,default:.3},{id:"seed",type:"slider",label:"Random Seed",property:"seed",min:0,max:1,step:.01,default:.5},{id:"randomizeSeed",type:"button",label:"Randomize Seed",action:"randomizeSeed"}]});const{OutlineFilter:Gd}=Ie;Ne({id:"outline",name:"Outline",category:"effects",description:"Add an outline or stroke around the image",createFilter:n=>{try{let o=n.color;typeof o=="string"&&(o=parseInt(o.replace("#","0x"),16));const t=new Gd({thickness:n.thickness||1,color:o,alpha:n.alpha||1,quality:n.quality||.1,knockout:n.knockout||!1});return t._customParams={...n},t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"thickness":this.thickness=Math.max(0,r);break;case"color":typeof r=="string"?(this.color=parseInt(r.replace("#","0x"),16),i.color=r):this.color=r;break;case"alpha":this.alpha=Math.max(0,Math.min(1,r));break;case"quality":this.quality=Math.max(.01,Math.min(1,r));break;case"knockout":this.knockout=!!r;break;default:a in this&&(this[a]=r);break}},t}catch{return null}},defaultParams:{thickness:2,color:"#000000",alpha:1,quality:.1,knockout:!1},controls:[{id:"thickness",type:"slider",label:"Thickness",property:"thickness",min:0,max:10,step:.1,default:2},{id:"color",type:"color",label:"Color",property:"color",default:"#000000"},{id:"alpha",type:"slider",label:"Alpha",property:"alpha",min:0,max:1,step:.01,default:1},{id:"quality",type:"slider",label:"Quality",property:"quality",min:.01,max:1,step:.01,default:.1,tooltip:"Higher values give better quality but slower performance"},{id:"knockout",type:"toggle",label:"Outline Only",property:"knockout",default:!1,tooltip:"Only show the outline, not the image content"}]});const{PixelateFilter:Hd}=Ie;Ne({id:"pixelate",name:"Pixelate",category:"effects",description:"Create a pixelated or mosaic effect",createFilter:n=>{try{const o=new Hd(n.useUniform?Math.max(2,n.size||10):[Math.max(2,n.sizeX||10),Math.max(2,n.sizeY||10)]);return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"useUniform":if(r.useUniform=a,a){const i=Math.round((this.sizeX+this.sizeY)/2);this.size=Math.max(2,i),r.size=i}else{const i=Array.isArray(this.size)?this.size[0]:this.size;this.sizeX=Math.max(2,i),this.sizeY=Math.max(2,i),r.sizeX=this.sizeX,r.sizeY=this.sizeY}break;case"size":r.useUniform&&(this.size=Math.max(2,a));break;case"sizeX":r.useUniform||(this.sizeX=Math.max(2,a));break;case"sizeY":r.useUniform||(this.sizeY=Math.max(2,a));break;default:t in this&&(this[t]=a);break}},o}catch{return null}},defaultParams:{useUniform:!0,size:10,sizeX:10,sizeY:10},controls:[{id:"useUniform",type:"toggle",label:"Uniform Pixels",property:"useUniform",default:!0,tooltip:"Use the same size for both X and Y dimensions"},{id:"size",type:"slider",label:"Pixel Size",property:"size",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in both dimensions"},{id:"sizeX",type:"slider",label:"Horizontal Size",property:"sizeX",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in the horizontal direction"},{id:"sizeY",type:"slider",label:"Vertical Size",property:"sizeY",min:2,max:40,step:1,default:10,tooltip:"Size of the pixels in the vertical direction"}]});const{ReflectionFilter:Jd}=Ie;Ne({id:"reflection",name:"Reflection",category:"distortion",description:"Creates a water reflection effect with configurable waves",createFilter:n=>{try{const o={mirror:n.mirror??!0,boundary:n.boundary??.5,amplitude:[n.amplitudeStart??0,n.amplitudeEnd??20],waveLength:[n.wavelengthStart??30,n.wavelengthEnd??100],alpha:[n.alphaStart??1,n.alphaEnd??1],time:n.time??0},t=new Jd(o);return t._customParams={...n},t.animating=n.animating??!1,t.updateUIParam=function(a,r){const i=this._customParams||{};switch(this._customParams=i,i[a]=r,a){case"mirror":case"boundary":case"time":this[a]=r;break;case"amplitudeStart":Array.isArray(this.amplitude)||(this.amplitude=[0,this._customParams.amplitudeEnd||20]),this.amplitude[0]=r;break;case"amplitudeEnd":Array.isArray(this.amplitude)||(this.amplitude=[this._customParams.amplitudeStart||0,20]),this.amplitude[1]=r;break;case"wavelengthStart":Array.isArray(this.waveLength)||(this.waveLength=[30,this._customParams.wavelengthEnd||100]),this.waveLength[0]=r;break;case"wavelengthEnd":Array.isArray(this.waveLength)||(this.waveLength=[this._customParams.wavelengthStart||30,100]),this.waveLength[1]=r;break;case"alphaStart":Array.isArray(this.alpha)||(this.alpha=[1,this._customParams.alphaEnd||1]),this.alpha[0]=r;break;case"alphaEnd":Array.isArray(this.alpha)||(this.alpha=[this._customParams.alphaStart||1,1]),this.alpha[1]=r;break;case"animating":this.animating=r;break;default:a in this&&(this[a]=r);break}return!0},t}catch{return null}},defaultParams:{mirror:!0,boundary:.5,amplitudeStart:0,amplitudeEnd:20,wavelengthStart:30,wavelengthEnd:100,alphaStart:1,alphaEnd:1,time:0,animating:!1},controls:[{id:"mirror",type:"toggle",label:"Mirror Image",property:"mirror",default:!0},{id:"boundary",type:"slider",label:"Boundary Line",property:"boundary",min:0,max:1,step:.01,default:.5},{id:"amplitudeStart",type:"slider",label:"Wave Height (Start)",property:"amplitudeStart",min:0,max:50,step:1,default:0},{id:"amplitudeEnd",type:"slider",label:"Wave Height (End)",property:"amplitudeEnd",min:0,max:50,step:1,default:20},{id:"wavelengthStart",type:"slider",label:"Wave Length (Start)",property:"wavelengthStart",min:10,max:200,step:1,default:30},{id:"wavelengthEnd",type:"slider",label:"Wave Length (End)",property:"wavelengthEnd",min:10,max:200,step:1,default:100},{id:"alphaStart",type:"slider",label:"Opacity (Start)",property:"alphaStart",min:0,max:1,step:.01,default:1},{id:"alphaEnd",type:"slider",label:"Opacity (End)",property:"alphaEnd",min:0,max:1,step:.01,default:1},{id:"time",type:"slider",label:"Animation Time",property:"time",min:0,max:10,step:.1,default:0},{id:"animating",type:"toggle",label:"Auto Animate",property:"animating",default:!1}]});const{ShockwaveFilter:qd}=Ie;Ne({id:"shockwave",name:"Shockwave",category:"distortion",description:"Creates a rippling shockwave or blast wave effect",createFilter:n=>{try{const o=n.centerX??.5,t=n.centerY??.5,a={x:o,y:t},r=n.amplitude??30,i=n.wavelength??160,s=n.speed??500,l=n.brightness??1,c=n.radius??-1,d=n.time??0,u=new qd({center:a,amplitude:r,wavelength:i,speed:s,brightness:l,radius:c,time:d});return u._customParams={...n},u.animating=n.animating??!1,u.updateUIParam=function(p,m){const h=this._customParams||{};switch(this._customParams=h,h[p]=m,p){case"centerX":this.center||(this.center={x:.5,y:.5}),this.center.x=m;break;case"centerY":this.center||(this.center={x:.5,y:.5}),this.center.y=m;break;case"amplitude":case"wavelength":case"speed":case"brightness":case"radius":case"time":this[p]=m;break;case"animating":this.animating=m;break;default:p in this&&(this[p]=m);break}return!0},u}catch{return null}},defaultParams:{centerX:.5,centerY:.5,amplitude:30,wavelength:160,speed:500,brightness:1,radius:-1,time:0,animating:!1},controls:[{id:"centerX",type:"slider",label:"Center X",property:"centerX",min:0,max:1,step:.01,default:.5},{id:"centerY",type:"slider",label:"Center Y",property:"centerY",min:0,max:1,step:.01,default:.5},{id:"amplitude",type:"slider",label:"Amplitude",property:"amplitude",min:0,max:100,step:1,default:30},{id:"wavelength",type:"slider",label:"Wavelength",property:"wavelength",min:10,max:500,step:1,default:160},{id:"speed",type:"slider",label:"Speed",property:"speed",min:1,max:1e3,step:10,default:500},{id:"brightness",type:"slider",label:"Brightness",property:"brightness",min:0,max:5,step:.1,default:1},{id:"radius",type:"slider",label:"Max Radius",property:"radius",min:-1,max:1e3,step:10,default:-1},{id:"time",type:"slider",label:"Time",property:"time",min:0,max:5,step:.1,default:0},{id:"animating",type:"toggle",label:"Auto Animate",property:"animating",default:!1}]});const{SimplexNoiseFilter:Kd}=Ie;Ne({id:"simplex-noise",name:"Simplex Noise",category:"effects",description:"Apply procedural noise to create texture effects",createFilter:n=>{try{const o=n.animating?0:n.offsetZ||0,t=new Kd({strength:n.strength,noiseScale:n.noiseScale,offsetX:n.offsetX,offsetY:n.offsetY,offsetZ:o,step:n.step});t.animating=n.animating||!1,t.animationSpeed=n.animationSpeed||.01,t._customParams={...n};let a=null,r=0;const i=()=>{t.animating&&(r+=t.animationSpeed,t.offsetZ=r),a=requestAnimationFrame(i)};return t.animating&&(a=requestAnimationFrame(i)),t._stopAnimation=()=>{a!==null&&(cancelAnimationFrame(a),a=null)},t.updateUIParam=function(s,l){const c=this._customParams||{};switch(this._customParams=c,c[s]=l,s){case"animating":this.animating=l,l&&!a&&(a=requestAnimationFrame(i));break;case"animationSpeed":this.animationSpeed=l;break;case"offsetZ":this.animating||(this.offsetZ=l);break;case"randomizeSeed":if(l){const d=()=>Math.random()*100-50;this.offsetX=d(),this.offsetY=d(),this.offsetZ=d(),c.offsetX=this.offsetX,c.offsetY=this.offsetY,c.offsetZ=this.offsetZ}break;case"strength":case"noiseScale":case"offsetX":case"offsetY":case"step":s in this&&(this[s]=l);break;default:s in this&&(this[s]=l);break}},t}catch{return null}},defaultParams:{strength:.5,noiseScale:10,offsetX:0,offsetY:0,offsetZ:0,step:-1,animating:!1,animationSpeed:.01,randomizeSeed:!1},controls:[{id:"strength",type:"slider",label:"Noise Strength",property:"strength",min:0,max:1,step:.01,default:.5},{id:"noiseScale",type:"slider",label:"Noise Scale",property:"noiseScale",min:1,max:50,step:.5,default:10},{id:"offsetX",type:"slider",label:"X Offset",property:"offsetX",min:-50,max:50,step:.5,default:0},{id:"offsetY",type:"slider",label:"Y Offset",property:"offsetY",min:-50,max:50,step:.5,default:0},{id:"offsetZ",type:"slider",label:"Z Offset",property:"offsetZ",min:-50,max:50,step:.5,default:0},{id:"step",type:"slider",label:"Step Threshold",property:"step",min:-1,max:1,step:.01,default:-1,tooltip:"Values above 0 create a blocky effect"},{id:"animating",type:"toggle",label:"Animate Noise",property:"animating",default:!1},{id:"animationSpeed",type:"slider",label:"Animation Speed",property:"animationSpeed",min:.001,max:.05,step:.001,default:.01},{id:"randomizeSeed",type:"button",label:"Randomize Pattern",action:"randomizeSeed"}]});const{TwistFilter:Qd}=Ie;Ne({id:"twist",name:"Twist",category:"distortion",description:"Creates a twisting distortion effect around a central point",createFilter:n=>{try{const o=n.radius??200,t=n.angle??4,a=new Qd({radius:o,angle:t,padding:n.padding??20,offset:{x:n.offsetX??.5,y:n.offsetY??.5}});return a._offset=a.offset,n.offsetX=n.offsetX??.5,n.offsetY=n.offsetY??.5,a._customParams={...n},a.updateUIParam=function(r,i){const s=this._customParams||{};switch(this._customParams=s,s[r]=i,r){case"radius":case"angle":this[r]=i;break;case"offsetX":!this.offset||typeof this.offset!="object"?(this.offset={x:i,y:.5},this._offset=this.offset):this.offset.x=i,s.offsetX=i;break;case"offsetY":!this.offset||typeof this.offset!="object"?(this.offset={x:.5,y:i},this._offset=this.offset):this.offset.y=i,s.offsetY=i;break;case"padding":break;default:r in this&&(this[r]=i);break}},a}catch{return null}},defaultParams:{radius:200,angle:4,offsetX:.5,offsetY:.5,padding:20},controls:[{id:"angle",type:"slider",label:"Angle",property:"angle",min:-10,max:10,step:.1,default:4},{id:"radius",type:"slider",label:"Radius",property:"radius",min:1,max:500,step:1,default:200},{id:"offsetX",type:"slider",label:"Center X",property:"offsetX",min:0,max:1,step:.01,default:.5},{id:"offsetY",type:"slider",label:"Center Y",property:"offsetY",min:0,max:1,step:.01,default:.5}]});const{AdjustmentFilter:eu}=Ie;function Mo(n){const o=typeof n=="string"?parseInt(n.replace("#","0x"),16):n;return[(o>>16&255)/255,(o>>8&255)/255,(o&255)/255]}class tu extends eu{constructor(o={}){super({brightness:1,contrast:1,saturation:1,alpha:1}),this._radius=.8,this._strength=1,this._colorRgb=[0,0,0],this._colorValue="#000000",this._radius=o.radius??.8,this._strength=o.strength??1,o.color!==void 0&&(typeof o.color=="string"?(this._colorValue=o.color,this._colorRgb=Mo(o.color)):(this._colorValue="#"+o.color.toString(16).padStart(6,"0"),this._colorRgb=Mo(o.color))),this.updateVignette()}updateVignette(){const o=1-this._radius/2,t=this._strength*o;this.brightness=Math.max(.5,1-t*.5),this.contrast=1+t*.2,(this._colorRgb[0]>0||this._colorRgb[1]>0||this._colorRgb[2]>0)&&(this.saturation=1-t*.3)}get radius(){return this._radius}set radius(o){this._radius=Math.max(.1,Math.min(1.5,o)),this.updateVignette()}get strength(){return this._strength}set strength(o){this._strength=Math.max(0,Math.min(2,o)),this.updateVignette()}get color(){return this._colorValue}set color(o){typeof o=="string"?(this._colorValue=o,this._colorRgb=Mo(o)):(this._colorValue="#"+o.toString(16).padStart(6,"0"),this._colorRgb=Mo(o)),this.updateVignette()}}Ne({id:"vignette",name:"Vignette",category:"effects",description:"Add a classic darkened border effect to the image",createFilter:n=>{try{const o=new tu({radius:n.radius||.8,strength:n.strength||1,color:n.color||"#000000"});return o._customParams={...n},o.updateUIParam=function(t,a){const r=this._customParams||{};switch(this._customParams=r,r[t]=a,t){case"radius":this.radius=Math.max(.1,Math.min(1.5,a));break;case"strength":this.strength=Math.max(0,a);break;case"color":this.color=a,typeof a=="string"&&(r.color=a);break;default:t in this&&(this[t]=a);break}},o}catch{return null}},defaultParams:{radius:.8,strength:1,color:"#000000"},controls:[{id:"radius",type:"slider",label:"Radius",property:"radius",min:.1,max:1.5,step:.01,default:.8,tooltip:"Size of the vignette effect (larger values create a smaller vignette)"},{id:"strength",type:"slider",label:"Strength",property:"strength",min:0,max:2,step:.01,default:1,tooltip:"Intensity of the vignette effect"},{id:"color",type:"color",label:"Color",property:"color",default:"#000000",tooltip:"Color of the vignette (usually black)"}]});function nu(){try{let n=[],o=[];try{n=oo(),n.length===0&&vd()}catch{}try{n=oo(),o=gd()}catch{n||(n=[]),o||(o=[])}return n.length,n}catch{return[]}}const ou=e.defineComponent({__name:"ImageEditor",props:{initialImage:{},theme:{default:"auto"},cropShape:{default:"square"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null);let i=null,s=null;function l(){if(!i)return;const u=i.exportImage("png",.92);if(!u)return;const p=i.getState(),m=p.crop,h=p.activeFilters,g=p.filterValues,v=i._renderer.sprite,x={width:Math.round((v==null?void 0:v.width)??0),height:Math.round((v==null?void 0:v.height)??0)},B={imageData:u,dimensions:x,metadata:{hasCrop:(m==null?void 0:m.rect)!=null,cropRect:(m==null?void 0:m.rect)??null,filters:h?Array.from(h):[],filterValues:g??{},aspectRatio:(m==null?void 0:m.aspect)??"free",dimensions:x}};a("save",B)}function c(){a("cancel")}function d(){!r.value||i||(window.PIXI=Ae,nu(),i=new no.VanillaImageEditor(r.value,{theme:t.theme,cropShape:t.cropShape==="circle"?"circle":"free",initialAspectRatio:t.cropShape==="circle"?"1:1":"free"}),i.setFilterRegistry({getAllFilters:oo,getFilter:el,getFiltersByCategory:tl}),i.save=function(){l()},i.on("cancel",c),t.initialImage&&i.loadImage(t.initialImage))}return e.onMounted(()=>{r.value&&(r.value.clientWidth>0?d():(s=new ResizeObserver(u=>{const p=u[0];p&&p.contentRect.width>0&&!i&&(d(),s==null||s.disconnect(),s=null)}),s.observe(r.value)))}),e.watch(()=>t.initialImage,u=>{i&&u&&i.loadImage(u)}),e.onUnmounted(()=>{s==null||s.disconnect(),s=null,i&&(i.destroy(),i=null)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),_e=(n,o)=>{const t=n.__vccOpts||n;for(const[a,r]of o)t[a]=r;return t},nl=_e(ou,[["__scopeId","data-v-725cff78"]]),au={class:"editor-modal-panel"},ru={class:"editor-fill"},iu=e.defineComponent({__name:"ImageEditorModal",props:{modelValue:{type:Boolean,default:!1},initialImage:{},acceptedFormats:{default:"image/jpeg,image/png,image/webp,image/gif"},maxFileSize:{default:10},onSave:{},theme:{default:"auto"},cropShape:{default:"square"},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["update:modelValue","save","cancel","error"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(t.modelValue),i=e.ref(null),s=e.ref(!1),l=v=>new Promise((x,B)=>{const E=new FileReader;E.onload=y=>{var w;const f=(w=y.target)==null?void 0:w.result;typeof f=="string"?x(f):B(new Error("Failed to read file"))},E.onerror=()=>B(new Error("Failed to read file")),E.readAsDataURL(v)}),c=v=>{a("error",v)},d=async()=>{if(t.initialImage instanceof File)try{const v=await l(t.initialImage);i.value=v}catch(v){c(v)}else typeof t.initialImage=="string"&&(i.value=t.initialImage)};e.watch(()=>t.modelValue,v=>{r.value=v,v&&t.initialImage&&d()},{immediate:!0}),e.watch(()=>t.initialImage,v=>{v&&r.value&&d()});const u=async v=>{try{s.value=!0,t.onSave&&await t.onSave(v),a("save",v),h()}catch(x){c(x)}finally{s.value=!1}},p=()=>{a("cancel"),h()},m=()=>{s.value||h()},h=()=>{r.value=!1,a("update:modelValue",!1),setTimeout(()=>{i.value=null},300)},g=v=>{v.key==="Escape"&&r.value&&!s.value&&h()};return e.onMounted(()=>{document.addEventListener("keydown",g)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",g)}),t.modelValue&&t.initialImage&&d(),(v,x)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(m,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:m}),e.createElementVNode("div",au,[e.createElementVNode("div",ru,[e.createVNode(nl,{"initial-image":i.value??v.initialImage,theme:v.theme,"crop-shape":v.cropShape,"primary-color":v.primaryColor,"secondary-color":v.secondaryColor,"save-button-color":v.saveButtonColor,"download-button-color":v.downloadButtonColor,onSave:u,onCancel:p},null,8,["initial-image","theme","crop-shape","primary-color","secondary-color","save-button-color","download-button-color"])])])],32)):e.createCommentVNode("",!0)]))}}),ol=_e(iu,[["__scopeId","data-v-2a304fe7"]]),su={class:"media-workspace"},lu={class:"media-workspace-toolbar"},cu={class:"media-workspace-label"},du=["value"],uu={class:"media-workspace-grid"},mu=["onClick"],pu=e.defineComponent({__name:"MediaWorkspace",props:{apiScope:{},subScopes:{},initialScopeId:{}},emits:["scope-change","update:media","upload","preview"],setup(n,{emit:o}){var p;const t=n,a=o,r=vt(),i=e.ref(t.initialScopeId??((p=t.subScopes[0])==null?void 0:p.id)??""),s=e.computed(()=>t.subScopes),l=e.computed(()=>s.value.find(m=>m.id===i.value));let c=null;function d(){c&&(c(),c=null),t.apiScope&&(c=Ks({apiScope:t.apiScope,isAdmin:t.apiScope==="admin"}))}async function u(){var h;const m={};(h=l.value)!=null&&h.collection&&(m.collection=l.value.collection),await r.fetchMedia(1,m),a("update:media",[...r.items])}return e.watch(()=>t.initialScopeId,m=>{m&&m!==i.value&&(i.value=m)}),e.watch(()=>t.subScopes,m=>{if(m.length===0){i.value="";return}m.some(h=>h.id===i.value)||(i.value=m[0].id)},{deep:!0}),e.watch(()=>t.apiScope,()=>{d(),u()}),e.watch(i,m=>{m&&(a("scope-change",m),u())}),e.onMounted(()=>{d(),u()}),e.onUnmounted(()=>{c&&(c(),c=null)}),(m,h)=>(e.openBlock(),e.createElementBlock("div",su,[e.createElementVNode("div",lu,[e.createElementVNode("label",cu,[h[2]||(h[2]=e.createElementVNode("span",{class:"media-workspace-label-text"},"Scope",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[0]||(h[0]=g=>i.value=g),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,g=>(e.openBlock(),e.createElementBlock("option",{key:g.id,value:g.id},e.toDisplayString(g.label),9,du))),128))],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("button",{type:"button",class:"media-workspace-upload","data-testid":"upload-button",onClick:h[1]||(h[1]=g=>a("upload"))}," Upload ")]),e.createElementVNode("div",uu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r).items,g=>(e.openBlock(),e.createElementBlock("button",{key:g.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:v=>a("preview",g)},e.toDisplayString(g.file_name),9,mu))),128))])]))}}),fu=_e(pu,[["__scopeId","data-v-895f26fe"]]),hu={class:"managed-media-gallery"},vu={class:"gallery-grid"},gu=e.defineComponent({__name:"ManagedMediaGallery",props:{media:{},selectable:{type:Boolean},multiple:{type:Boolean}},emits:["select","remove"],setup(n){return(o,t)=>(e.openBlock(),e.createElementBlock("div",hu,[e.createElementVNode("div",vu,[e.renderSlot(o.$slots,"default",{},void 0,!0)])]))}}),yu=_e(gu,[["__scopeId","data-v-a60fdcd7"]]),bu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 176v160M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ir="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M256 112v288M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",wu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm0 319.91a20 20 0 1120-20 20 20 0 01-20 20zm21.72-201.15l-5.74 122a16 16 0 01-32 0l-5.74-121.94v-.05a21.74 21.74 0 1143.44 0z'/></svg>",Br="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 166.05L256 288l5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 6z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 367.91a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",ku="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M244 400L100 256l144-144M120 256h292' class='ionicon-fill-none'/></svg>",xu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M268 112l144 144-144 144M392 256H100' class='ionicon-fill-none'/></svg>",Ln="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M452.37 59.63h0a40.49 40.49 0 00-57.26 0L184 294.74c23.08 4.7 46.12 27.29 49.26 49.26l219.11-227.11a40.49 40.49 0 000-57.26zM138 336c-29.88 0-54 24.5-54 54.86 0 23.95-20.88 36.57-36 36.57C64.56 449.74 92.82 464 120 464c39.78 0 72-32.73 72-73.14 0-30.36-24.12-54.86-54-54.86z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Su="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M350.54 148.68l-26.62-42.06C318.31 100.08 310.62 96 302 96h-92c-8.62 0-16.31 4.08-21.92 10.62l-26.62 42.06C155.85 155.23 148.62 160 140 160H80a32 32 0 00-32 32v192a32 32 0 0032 32h352a32 32 0 0032-32V192a32 32 0 00-32-32h-59c-8.65 0-16.85-4.77-22.46-11.32z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='272' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M124 158v-22h-24v22' class='ionicon-fill-none ionicon-stroke-width'/></svg>",al="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm108.25 138.29l-134.4 160a16 16 0 01-12 5.71h-.27a16 16 0 01-11.89-5.3l-57.6-64a16 16 0 1123.78-21.4l45.29 50.32 122.59-145.91a16 16 0 0124.5 20.58z'/></svg>",rl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M416 128L192 384l-96-96' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ji="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M328 112L184 256l144 144' class='ionicon-fill-none'/></svg>",Eu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M112 184l144 144 144-144' class='ionicon-fill-none'/></svg>",Cu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",qi="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' stroke-width='48' d='M184 112l144 144-144 144' class='ionicon-fill-none'/></svg>",ao="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 368L144 144M368 144L144 368' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ki="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8-69 0-113.44 45.79-128 91.2-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M320 255.79l-64-64-64 64M256 448.21V207.79' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Vu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='184' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='344' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='168' cy='328' r='120' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ht="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M430.11 347.9c-6.6-6.1-16.3-7.6-24.6-9-11.5-1.9-15.9-4-22.6-10-14.3-12.7-14.3-31.1 0-43.8l30.3-26.9c46.4-41 46.4-108.2 0-149.2-34.2-30.1-80.1-45-127.8-45-55.7 0-113.9 20.3-158.8 60.1-83.5 73.8-83.5 194.7 0 268.5 41.5 36.7 97.5 55 152.9 55.4h1.7c55.4 0 110-17.9 148.8-52.4 14.4-12.7 11.99-36.6.1-47.7z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='144' cy='208' r='32'/><circle cx='152' cy='311' r='32'/><circle cx='224' cy='144' r='32'/><circle cx='256' cy='367' r='48'/><circle cx='328' cy='144' r='32'/></svg>",Nu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 416V304h112M314.2 314.23L432 432M208 96v112H96M197.8 197.77L80 80M416 208H304V96M314.23 197.8L432 80M96 304h112v112M197.77 314.2L80 432' class='ionicon-fill-none ionicon-stroke-width'/></svg>",$n="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='208' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 464c-114.88 0-208-93.12-208-208S141.12 48 256 48z'/></svg>",_u="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><rect x='128' y='128' width='336' height='336' rx='57' ry='57' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Tu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M459.94 53.25a16.06 16.06 0 00-23.22-.56L424.35 65a8 8 0 000 11.31l11.34 11.32a8 8 0 0011.34 0l12.06-12c6.1-6.09 6.67-16.01.85-22.38zM399.34 90L218.82 270.2a9 9 0 00-2.31 3.93L208.16 299a3.91 3.91 0 004.86 4.86l24.85-8.35a9 9 0 003.93-2.31L422 112.66a9 9 0 000-12.66l-9.95-10a9 9 0 00-12.71 0z'/></svg>",Qi="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M144 48v272a48 48 0 0048 48h272' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M368 304V192a48 48 0 00-48-48H208M368 368v96M144 144H48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",il="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='104' cy='152' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='104' cy='360' r='56' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M157 175l-11 15 37 15s3.46-6.42 7-10z' stroke-linecap='square' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M154.17 334.43L460 162c-2.5-6.7-28-12-64-4-29.12 6.47-121.16 29.05-159.16 56.05C205.85 236.06 227 272 192 298c-25.61 19-44.43 22.82-44.43 22.82zM344.47 278.24L295 306.67c14.23 6.74 65.54 33.27 117 36.33 14.92.89 30 .39 39-6z' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='240' r='32' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",pa="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M336 176h40a40 40 0 0140 40v208a40 40 0 01-40 40H136a40 40 0 01-40-40V216a40 40 0 0140-40h40' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M176 272l80 80 80-80M256 48v288' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Mu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Fu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M432 320v112H320M421.8 421.77L304 304M80 192V80h112M90.2 90.23L208 208M320 80h112v112M421.77 90.2L304 208M192 432H80V320M90.23 421.8L208 304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Iu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z'/><path d='M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z'/></svg>",Wn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",es="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M80 464V68.14a8 8 0 014-6.9C91.81 56.66 112.92 48 160 48c64 0 145 48 192 48a199.53 199.53 0 0077.23-15.77 2 2 0 012.77 1.85v219.36a4 4 0 01-2.39 3.65C421.37 308.7 392.33 320 352 320c-48 0-128-32-192-32s-80 16-80 16' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",qa="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Bu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M496 152a56 56 0 00-56-56H220.11a23.89 23.89 0 01-13.31-4L179 73.41A55.77 55.77 0 00147.89 64H72a56 56 0 00-56 56v48a8 8 0 008 8h464a8 8 0 008-8zM16 392a56 56 0 0056 56h368a56 56 0 0056-56V216a8 8 0 00-8-8H24a8 8 0 00-8 8z'/></svg>",Ru="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='129' cy='96' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='129' cy='416' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M129 144v224' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='385' cy='288' r='48' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M129 144c0 96 112 144 208 144' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ka="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M432 112V96a48.14 48.14 0 00-48-48H64a48.14 48.14 0 00-48 48v256a48.14 48.14 0 0048 48h16' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><rect x='96' y='128' width='400' height='336' rx='45.99' ry='45.99' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><ellipse cx='372.92' cy='219.64' rx='30.77' ry='30.55' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M342.15 372.17L255 285.78a30.93 30.93 0 00-42.18-1.21L96 387.64M265.23 464l118.59-117.73a31 31 0 0141.46-1.87L496 402.91' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Pu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M248 64C146.39 64 64 146.39 64 248s82.39 184 184 184 184-82.39 184-184S349.61 64 248 64z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M220 220h32v116' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 340h88' class='ionicon-fill-none ionicon-stroke-width'/><path d='M248 130a26 26 0 1026 26 26 26 0 00-26-26z'/></svg>",$u="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M368 128h80M64 128h240M368 384h80M64 384h240M208 256h240M64 256h80' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='128' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='176' cy='256' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='336' cy='384' r='32' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",zu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M208 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16zM352 432h-48a16 16 0 01-16-16V96a16 16 0 0116-16h48a16 16 0 0116 16v320a16 16 0 01-16 16z'/></svg>",Au="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm-32 272a16 16 0 01-32 0V192a16 16 0 0132 0zm96 0a16 16 0 01-32 0V192a16 16 0 0132 0z'/></svg>",sl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M208 192v128M304 192v128' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Du="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M176 96h16v320h-16zM320 96h16v320h-16z' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Uu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M133 440a35.37 35.37 0 01-17.5-4.67c-12-6.8-19.46-20-19.46-34.33V111c0-14.37 7.46-27.53 19.46-34.33a35.13 35.13 0 0135.77.45l247.85 148.36a36 36 0 010 61l-247.89 148.4A35.5 35.5 0 01133 440z'/></svg>",Ou="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M30.71 229.47l188.87-113a30.54 30.54 0 0131.09-.39 33.74 33.74 0 0116.76 29.47v79.05l180.72-108.16a30.54 30.54 0 0131.09-.39A33.74 33.74 0 01496 145.52v221A33.73 33.73 0 01479.24 396a30.54 30.54 0 01-31.09-.39L267.43 287.4v79.08A33.73 33.73 0 01250.67 396a30.54 30.54 0 01-31.09-.39l-188.87-113a31.27 31.27 0 010-53z'/></svg>",Lu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M480 145.52v221c0 13.28-13 21.72-23.63 15.35L267.5 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113C467 123.8 480 132.24 480 145.52zM251.43 145.52v221c0 13.28-13 21.72-23.63 15.35L38.93 268.8c-9.24-5.53-9.24-20.07 0-25.6l188.87-113c10.64-6.4 23.63 2.04 23.63 15.32z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Wu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M256 48C141.31 48 48 141.31 48 256s93.31 208 208 208 208-93.31 208-208S370.69 48 256 48zm74.77 217.3l-114.45 69.14a10.78 10.78 0 01-16.32-9.31V186.87a10.78 10.78 0 0116.32-9.31l114.45 69.14a10.89 10.89 0 010 18.6z'/></svg>",ll="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M216.32 334.44l114.45-69.14a10.89 10.89 0 000-18.6l-114.45-69.14a10.78 10.78 0 00-16.32 9.31v138.26a10.78 10.78 0 0016.32 9.31z'/></svg>",ju="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M481.29 229.47l-188.87-113a30.54 30.54 0 00-31.09-.39 33.74 33.74 0 00-16.76 29.47v79.05L63.85 116.44a30.54 30.54 0 00-31.09-.39A33.74 33.74 0 0016 145.52v221A33.74 33.74 0 0032.76 396a30.54 30.54 0 0031.09-.39L244.57 287.4v79.08A33.74 33.74 0 00261.33 396a30.54 30.54 0 0031.09-.39l188.87-113a31.27 31.27 0 000-53z'/></svg>",Xu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M32 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113C45 123.8 32 132.24 32 145.52zM260.57 145.52v221c0 13.28 13 21.72 23.63 15.35l188.87-113c9.24-5.53 9.24-20.07 0-25.6l-188.87-113c-10.64-6.47-23.63 1.97-23.63 15.25z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Zu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Yu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 111v290c0 17.44-17 28.52-31 20.16L121.09 272.79c-12.12-7.25-12.12-26.33 0-33.58L369 90.84c14-8.36 31 2.72 31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M112 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Gu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M400 80v352' class='ionicon-fill-none ionicon-stroke-width'/></svg>",co="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M320 146s24.36-12-64-12a160 160 0 10160 160' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M256 58l80 80-80 80' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Hu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M448 256c0-106-86-192-192-192S64 150 64 256s86 192 192 192 192-86 192-192z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-linejoin='round' d='M336 256H176' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ju="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 256H112' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ts="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 96h112v112M405.77 106.2L111.98 400.02M208 416H96V304' class='ionicon-fill-none ionicon-stroke-width'/></svg>",cl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",qu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><circle cx='256' cy='256' r='48'/><path d='M470.39 300l-.47-.38-31.56-24.75a16.11 16.11 0 01-6.1-13.33v-11.56a16 16 0 016.11-13.22L469.92 212l.47-.38a26.68 26.68 0 005.9-34.06l-42.71-73.9a1.59 1.59 0 01-.13-.22A26.86 26.86 0 00401 92.14l-.35.13-37.1 14.93a15.94 15.94 0 01-14.47-1.29q-4.92-3.1-10-5.86a15.94 15.94 0 01-8.19-11.82l-5.59-39.59-.12-.72A27.22 27.22 0 00298.76 26h-85.52a26.92 26.92 0 00-26.45 22.39l-.09.56-5.57 39.67a16 16 0 01-8.13 11.82 175.21 175.21 0 00-10 5.82 15.92 15.92 0 01-14.43 1.27l-37.13-15-.35-.14a26.87 26.87 0 00-32.48 11.34l-.13.22-42.77 73.95a26.71 26.71 0 005.9 34.1l.47.38 31.56 24.75a16.11 16.11 0 016.1 13.33v11.56a16 16 0 01-6.11 13.22L42.08 300l-.47.38a26.68 26.68 0 00-5.9 34.06l42.71 73.9a1.59 1.59 0 01.13.22 26.86 26.86 0 0032.45 11.3l.35-.13 37.07-14.93a15.94 15.94 0 0114.47 1.29q4.92 3.11 10 5.86a15.94 15.94 0 018.19 11.82l5.56 39.59.12.72A27.22 27.22 0 00213.24 486h85.52a26.92 26.92 0 0026.45-22.39l.09-.56 5.57-39.67a16 16 0 018.18-11.82c3.42-1.84 6.76-3.79 10-5.82a15.92 15.92 0 0114.43-1.27l37.13 14.95.35.14a26.85 26.85 0 0032.48-11.34 2.53 2.53 0 01.13-.22l42.71-73.89a26.7 26.7 0 00-5.89-34.11zm-134.48-40.24a80 80 0 11-83.66-83.67 80.21 80.21 0 0183.66 83.67z'/></svg>",Qa="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M400 304l48 48-48 48M400 112l48 48-48 48M64 352h85.19a80 80 0 0066.56-35.62L256 256' class='ionicon-fill-none ionicon-stroke-width'/><path d='M64 160h85.19a80 80 0 0166.56 35.62l80.5 120.76A80 80 0 00362.81 352H416M416 160h-53.19a80 80 0 00-66.56 35.62L288 208' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Gt="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='ionicon'><path d='M259.92 262.91L216.4 149.77a9 9 0 00-16.8 0l-43.52 113.14a9 9 0 01-5.17 5.17L37.77 311.6a9 9 0 000 16.8l113.14 43.52a9 9 0 015.17 5.17l43.52 113.14a9 9 0 0016.8 0l43.52-113.14a9 9 0 015.17-5.17l113.14-43.52a9 9 0 000-16.8l-113.14-43.52a9 9 0 01-5.17-5.17zM108 68L88 16 68 68 16 88l52 20 20 52 20-52 52-20-52-20zM426.67 117.33L400 48l-26.67 69.33L304 144l69.33 26.67L400 240l26.67-69.33L496 144l-69.33-26.67z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",zn="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M256 48v48M256 416v48M403.08 108.92l-33.94 33.94M142.86 369.14l-33.94 33.94M464 256h-48M96 256H48M403.08 403.08l-33.94-33.94M142.86 142.86l-33.94-33.94' class='ionicon-fill-none ionicon-stroke-width'/><circle cx='256' cy='256' r='80' stroke-linecap='round' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ns="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M304 48l112 112-112 112M398.87 160H96M208 464L96 352l112-112M114 352h302' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Ku="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M512 128v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64zM32 384a32 32 0 0032 32h384a32 32 0 0032-32V128a32 32 0 00-32-32H64a32 32 0 00-32 32z'/><path d='M0 128a64.07 64.07 0 0164-64h384a64.07 64.07 0 0164 64v256a64.07 64.07 0 01-64 64H64a64.07 64.07 0 01-64-64V128m480 256V128a32 32 0 00-32-32H64a32 32 0 00-32 32v256a32 32 0 0032 32h384a32 32 0 0032-32m-16 0a16 16 0 01-16 16H64a16 16 0 01-16-16V128a16 16 0 0116-16h384a16 16 0 0116 16v256z'/></svg>",dl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-linejoin='round' d='M32 415.5l120-320 120 320M230 303.5H74M326 239.5c12.19-28.69 41-48 74-48h0c46 0 80 32 80 80v144' class='ionicon-fill-none ionicon-stroke-width'/><path d='M320 358.5c0 36 26.86 58 60 58 54 0 100-27 100-106v-15c-20 0-58 1-92 5-32.77 3.86-68 19-68 58z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",Qu="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M112 112l20 320c.95 18.49 14.4 32 32 32h184c17.67 0 30.87-13.51 32-32l20-320' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path stroke-linecap='round' stroke-miterlimit='10' d='M80 112h352' class='ionicon-stroke-width'/><path d='M192 112V72h0a23.93 23.93 0 0124-24h80a23.93 23.93 0 0124 24h0v40M256 176v224M184 176l8 224M328 176l-8 224' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",ul="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M374.79 308.78L457.5 367a16 16 0 0022.5-14.62V159.62A16 16 0 00457.5 145l-82.71 58.22A16 16 0 00368 216.3v79.4a16 16 0 006.79 13.08z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M268 384H84a52.15 52.15 0 01-52-52V180a52.15 52.15 0 0152-52h184.48A51.68 51.68 0 01320 179.52V332a52.15 52.15 0 01-52 52z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/></svg>",em="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M232 416a23.88 23.88 0 01-14.2-4.68 8.27 8.27 0 01-.66-.51L125.76 336H56a24 24 0 01-24-24V200a24 24 0 0124-24h69.75l91.37-74.81a8.27 8.27 0 01.66-.51A24 24 0 01256 120v272a24 24 0 01-24 24zm-106.18-80zm-.27-159.86zM320 336a16 16 0 01-14.29-23.19c9.49-18.87 14.3-38 14.3-56.81 0-19.38-4.66-37.94-14.25-56.73a16 16 0 0128.5-14.54C346.19 208.12 352 231.44 352 256c0 23.86-6 47.81-17.7 71.19A16 16 0 01320 336z'/><path d='M368 384a16 16 0 01-13.86-24C373.05 327.09 384 299.51 384 256c0-44.17-10.93-71.56-29.82-103.94a16 16 0 0127.64-16.12C402.92 172.11 416 204.81 416 256c0 50.43-13.06 83.29-34.13 120a16 16 0 01-13.87 8z'/><path d='M416 432a16 16 0 01-13.39-24.74C429.85 365.47 448 323.76 448 256c0-66.5-18.18-108.62-45.49-151.39a16 16 0 1127-17.22C459.81 134.89 480 181.74 480 256c0 64.75-14.66 113.63-50.6 168.74A16 16 0 01416 432z'/></svg>",tm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M296 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H120a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01320 119.83v272.34a24 24 0 01-24 24zM384 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C410.2 208.16 416 231.47 416 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01384 336z'/></svg>",nm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M264 416.19a23.92 23.92 0 01-14.21-4.69l-.66-.51-91.46-75H88a24 24 0 01-24-24V200a24 24 0 0124-24h69.65l91.46-75 .66-.51A24 24 0 01288 119.83v272.34a24 24 0 01-24 24zM352 336a16 16 0 01-14.29-23.18c9.49-18.9 14.3-38 14.3-56.82 0-19.36-4.66-37.92-14.25-56.73a16 16 0 0128.5-14.54C378.2 208.16 384 231.47 384 256c0 23.83-6 47.78-17.7 71.18A16 16 0 01352 336z'/><path d='M400 384a16 16 0 01-13.87-24C405 327.05 416 299.45 416 256c0-44.12-10.94-71.52-29.83-103.95A16 16 0 01413.83 136C434.92 172.16 448 204.88 448 256c0 50.36-13.06 83.24-34.12 120a16 16 0 01-13.88 8z'/></svg>",om="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M157.65 192H88a8 8 0 00-8 8v112a8 8 0 008 8h69.65a16 16 0 0110.14 3.63l91.47 75a8 8 0 0012.74-6.46V119.83a8 8 0 00-12.74-6.44l-91.47 75a16 16 0 01-10.14 3.61zM352 320c9.74-19.41 16-40.81 16-64 0-23.51-6-44.4-16-64M400 368c19.48-34 32-64 32-112s-12-77.7-32-112' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>",am="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M243.33 98.86a23.89 23.89 0 00-25.55 1.82l-.66.51-28.52 23.35a8 8 0 00-.59 11.85l54.33 54.33a8 8 0 0013.66-5.66v-64.49a24.51 24.51 0 00-12.67-21.71zM251.33 335.29L96.69 180.69A16 16 0 0085.38 176H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l92 75.31a23.9 23.9 0 0025.87 1.69A24.51 24.51 0 00256 391.45v-44.86a16 16 0 00-4.67-11.3zM352 256c0-24.56-5.81-47.87-17.75-71.27a16 16 0 10-28.5 14.55C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l14.36 14.36a8 8 0 0013.55-4.31A146 146 0 00352 256zM416 256c0-51.18-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26L389 337.4a8 8 0 0013.13-2.79C411 311.76 416 287.26 416 256z'/><path d='M480 256c0-74.25-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 46.19-8.43 80.27-22.43 110.53a8 8 0 001.59 9l11.92 11.92a8 8 0 0012.92-2.16C471.6 344.9 480 305 480 256z'/></svg>",rm="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path stroke-linecap='round' stroke-miterlimit='10' d='M416 432L64 80' class='ionicon-fill-none ionicon-stroke-width'/><path d='M224 136.92v33.8a4 4 0 001.17 2.82l24 24a4 4 0 006.83-2.82v-74.15a24.53 24.53 0 00-12.67-21.72 23.91 23.91 0 00-25.55 1.83 8.27 8.27 0 00-.66.51l-31.94 26.15a4 4 0 00-.29 5.92l17.05 17.06a4 4 0 005.37.26zM224 375.08l-78.07-63.92a32 32 0 00-20.28-7.16H64v-96h50.72a4 4 0 002.82-6.83l-24-24a4 4 0 00-2.82-1.17H56a24 24 0 00-24 24v112a24 24 0 0024 24h69.76l91.36 74.8a8.27 8.27 0 00.66.51 23.93 23.93 0 0025.85 1.69A24.49 24.49 0 00256 391.45v-50.17a4 4 0 00-1.17-2.82l-24-24a4 4 0 00-6.83 2.82zM125.82 336zM352 256c0-24.56-5.81-47.88-17.75-71.27a16 16 0 00-28.5 14.54C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 002.32 6.25l19.66 19.67a4 4 0 006.75-2A146.89 146.89 0 00352 256zM416 256c0-51.19-13.08-83.89-34.18-120.06a16 16 0 00-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 001.9 8.26l16.77 16.76a4 4 0 006.52-1.27C410.09 315.88 416 289.91 416 256z'/><path d='M480 256c0-74.26-20.19-121.11-50.51-168.61a16 16 0 10-27 17.22C429.82 147.38 448 189.5 448 256c0 47.45-8.9 82.12-23.59 113a4 4 0 00.77 4.55L443 391.39a4 4 0 006.4-1C470.88 348.22 480 307 480 256z'/></svg>",im="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M85.57 446.25h340.86a32 32 0 0028.17-47.17L284.18 82.58c-12.09-22.44-44.27-22.44-56.36 0L57.4 399.08a32 32 0 0028.17 47.17z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M250.26 195.39l5.74 122 5.73-121.95a5.74 5.74 0 00-5.79-6h0a5.74 5.74 0 00-5.68 5.95z' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/><path d='M256 397.25a20 20 0 1120-20 20 20 0 01-20 20z'/></svg>",Fo="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' class='ionicon' viewBox='0 0 512 512'><path d='M400 320c0 88.37-55.63 144-144 144s-144-55.63-144-144c0-94.83 103.23-222.85 134.89-259.88a12 12 0 0118.23 0C296.77 97.15 400 225.17 400 320z' stroke-miterlimit='10' class='ionicon-fill-none ionicon-stroke-width'/><path d='M344 328a72 72 0 01-72 72' stroke-linecap='round' stroke-linejoin='round' class='ionicon-fill-none ionicon-stroke-width'/></svg>";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const os=()=>{};function sm(n,o){function t(...a){return new Promise((r,i)=>{Promise.resolve(n(()=>o.apply(this,a),{fn:o,thisArg:this,args:a})).then(r).catch(i)})}return t}function lm(n,o={}){let t,a,r=os;const i=c=>{clearTimeout(c),r(),r=os};let s;return c=>{const d=e.toValue(n),u=e.toValue(o.maxWait);return t&&i(t),d<=0||u!==void 0&&u<=0?(a&&(i(a),a=null),Promise.resolve(c())):new Promise((p,m)=>{r=o.rejectOnCancel?m:p,s=c,u&&!a&&(a=setTimeout(()=>{t&&i(t),a=null,p(s())},u)),t=setTimeout(()=>{a&&i(a),a=null,p(c())},d)})}}function cm(n,o=200,t={}){return sm(lm(o,t),n)}const An=new Map;function dm(n){const o=e.getCurrentScope();function t(l){var c;const d=An.get(n)||new Set;d.add(l),An.set(n,d);const u=()=>r(l);return(c=o==null?void 0:o.cleanups)==null||c.push(u),u}function a(l){function c(...d){r(c),l(...d)}return t(c)}function r(l){const c=An.get(n);c&&(c.delete(l),c.size||i())}function i(){An.delete(n)}function s(l,c){var d;(d=An.get(n))==null||d.forEach(u=>u(l,c))}return{on:t,once:a,off:r,emit:s,reset:i}}function um(){var i,s;const n=typeof window<"u"&&"Capacitor"in window&&((s=(i=window.Capacitor)==null?void 0:i.isNativePlatform)==null?void 0:s.call(i));return{selection:()=>{var l,c;if(n)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"LIGHT"})}catch{}else"vibrate"in navigator&&navigator.vibrate(10)},success:()=>{var l,c;if(n)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"MEDIUM"})}catch{}else"vibrate"in navigator&&navigator.vibrate(30)},error:()=>{var l,c;if(n)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.impact({style:"HEAVY"})}catch{}else"vibrate"in navigator&&navigator.vibrate([50,50,50])},notification:()=>{var l,c;if(n)try{const d=(c=(l=window.Capacitor)==null?void 0:l.Plugins)==null?void 0:c.Haptics;d&&d.notification({type:"SUCCESS"})}catch{}else"vibrate"in navigator&&navigator.vibrate([20,100,20])}}}function mm(n){const o=e.ref(new Set),t=e.ref(null),a=e.ref(-1),r=dm("media-selection"),i=um(),s=e.computed(()=>n.value.filter(w=>o.value.has(w.uuid))),l=e.computed(()=>o.value.size);e.watch(o,w=>{r.emit({type:"selection:changed",count:w.size,selectedIds:Array.from(w)})},{deep:!0});const c=e.computed(()=>n.value.length>0&&n.value.every(w=>o.value.has(w.uuid))),d=e.computed(()=>n.value.some(w=>o.value.has(w.uuid)));function u(w){return o.value.has(w)}function p(w){o.value.has(w)?(o.value.delete(w),t.value===w&&(t.value=null,a.value=-1)):(o.value.add(w),t.value=w,a.value=n.value.findIndex($=>$.uuid===w),o.value.size===1&&i.selection())}function m(w){o.value.add(w),t.value=w,a.value=n.value.findIndex($=>$.uuid===w)}function h(w){o.value.delete(w),t.value===w&&(t.value=null,a.value=-1)}function g(){n.value.forEach(w=>o.value.add(w.uuid))}function v(){o.value.clear(),t.value=null,a.value=-1}function x(){c.value?v():g()}function B(w,$){const C=n.value.findIndex(b=>b.uuid===w);if(C!==-1)if($!=null&&$.shiftKey&&a.value!==-1){const b=Math.min(a.value,C),N=Math.max(a.value,C);for(let P=b;P<=N;P++)o.value.add(n.value[P].uuid)}else p(w)}function E(){if(n.value.length===0)return;let w=a.value+1;w>=n.value.length&&(w=0),v(),m(n.value[w].uuid)}function y(){if(n.value.length===0)return;let w=a.value-1;w<0&&(w=n.value.length-1),v(),m(n.value[w].uuid)}function f(w){switch(w.key){case"ArrowDown":w.preventDefault(),E();break;case"ArrowUp":w.preventDefault(),y();break;case"a":(w.ctrlKey||w.metaKey)&&(w.preventDefault(),g());break;case"Escape":w.preventDefault(),v();break;case" ":t.value&&(w.preventDefault(),p(t.value));break}}return{selectedIds:e.computed(()=>o.value),selectedItems:s,selectedCount:l,isAllSelected:c,isSomeSelected:d,lastSelectedId:e.computed(()=>t.value),isSelected:u,toggle:p,select:m,deselect:h,selectAll:g,clear:v,toggleAll:x,rangeSelect:B,selectNext:E,selectPrevious:y,handleKeydown:f,selectionBus:r}}const pm={class:"flex items-center justify-between w-full px-4"},fm={class:"p-4"},hm={key:0,class:"mb-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg"},vm={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"},gm=["value"],ym={class:"flex gap-2 mt-4"},bm={class:"flex justify-end mb-4"},wm={key:1,class:"flex justify-center items-center h-64"},km={key:2,class:"flex flex-col items-center justify-center h-64 text-center"},xm={class:"text-sm text-theme-secondary"},Sm={key:0},Em={class:"mb-4"},Cm={class:"mb-4"},Vm={class:"flex gap-2"},Nm={class:"flex items-center justify-between px-4 py-2"},_m={class:"text-sm text-theme-secondary"},Tm={key:0},Mm={key:0},Fm={key:1},Im={class:"flex gap-2"},Bm=e.defineComponent({__name:"AdminMediaBrowser",props:{isOpen:{type:Boolean},selectionMode:{default:"single"},selectedItems:{default:()=>[]},modelType:{},modelId:{},collection:{default:"images"},maxSelection:{}},emits:["close","confirm"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("recent"),i=e.ref("grid"),s=e.ref(""),l=e.ref(!1),c=e.ref([]),{selectedItems:d}=e.toRefs(t),u=e.ref(new Set(d.value)),p=e.ref(!1),m=e.ref({}),h=e.ref(["images","documents","videos"]),g=e.ref(1),v=e.ref(!0),x=e.ref(!1),B=Qs(),E=mm(c);function y(M){var ve;const j=M.conversion_urls||{},te=M.proxy_url||M.original_url||M.url||"",ae=j.thumb||j.preview||M.preview_url||M.thumbnail_url||te,re=M.custom_properties||{},q=re.width,ue=re.height;return{...M,uuid:M.uuid,name:M.name||M.file_name,file_name:M.file_name,filename:M.file_name,mime_type:M.mime_type,size:M.size,collection_name:M.collection_name||"images",disk:M.disk,original_url:te,url:te,thumbnail_url:ae,conversions:M.conversions||{},conversion_urls:j,generated_conversions:M.generated_conversions||{},custom_properties:re,caption:M.caption||null,alt_text:M.alt_text||null,created_at:M.created_at,updated_at:M.updated_at,is_image:((ve=M.mime_type)==null?void 0:ve.startsWith("image/"))||!1,...typeof q=="number"?{width:q}:{},...typeof ue=="number"?{height:ue}:{},...M.formatted_size!==void 0?{formatted_size:M.formatted_size}:{}}}e.watch(()=>t.selectedItems,M=>{u.value=new Set(M),E.clear(),M.forEach(j=>E.select(j))});const f=e.computed(()=>{var j;let M=c.value;return(j=m.value.types)!=null&&j.length&&(M=M.filter(te=>{var re,q;const ae=(re=te.mime_type)==null?void 0:re.split("/")[0];return(q=m.value.types)==null?void 0:q.includes(ae)})),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&(M=M.filter(te=>{const ae=te.size/1048576;return!(m.value.sizeMin!==void 0&&ae<m.value.sizeMin||m.value.sizeMax!==void 0&&ae>m.value.sizeMax)})),M}),w=e.computed(()=>{var j;let M=0;return m.value.search&&M++,m.value.collection&&M++,(m.value.dateFrom||m.value.dateTo)&&M++,(j=m.value.types)!=null&&j.length&&(M+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&M++,M}),$=e.computed(()=>{const M=E.selectedCount.value;return M===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${M} ${M===1?"Item":"Items"}`:"Item"}`}),C=e.computed(()=>{const M=E.selectedCount.value;return!!(M===0||t.selectionMode==="single"&&M>1||t.maxSelection&&M>t.maxSelection)}),b=e.computed(()=>{switch(r.value){case"recent":return"Recent Uploads";case"model":return"Model Media";case"library":return"Media Library";default:return"Media Browser"}});async function N(M=!0){M?(l.value=!0,c.value=[],g.value=1,v.value=!0):x.value=!0;try{const j={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(j.search=s.value||m.value.search||""),m.value.dateFrom&&(j.from_date=m.value.dateFrom),m.value.dateTo&&(j.to_date=m.value.dateTo),r.value){case"recent":await B.fetchMedia(g.value,j),M?c.value=B.items.map(te=>y(te)):c.value=[...c.value,...B.items.map(te=>y(te))],v.value=B.currentPage<B.totalPages;break;case"model":if(t.modelType&&t.modelId){const te=await B.fetchModelMedia(t.modelType,t.modelId,j.collection,j.search);c.value=te?te.map(ae=>y(ae)):[],v.value=!1}break;case"library":await B.fetchMedia(g.value,j),M?c.value=B.items.map(te=>y(te)):c.value=[...c.value,...B.items.map(te=>y(te))],v.value=B.currentPage<B.totalPages;break}}catch{}finally{l.value=!1,x.value=!1}}async function P(M){if(!v.value||x.value){M!=null&&M.target&&M.target.complete();return}g.value++,await N(!1),M!=null&&M.target&&(M.target.complete(),v.value||(M.target.disabled=!0))}function k(M){return M==="recent"||M==="model"||M==="library"}function T(M){r.value=M,N()}function F(M){typeof M=="string"&&k(M)&&T(M)}async function D(M){t.selectionMode==="single"?(E.clear(),E.select(M.uuid)):(E.toggle(M.uuid),t.maxSelection&&E.selectedCount.value>t.maxSelection&&(E.deselect(M.uuid),await(await I.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function R(){a("confirm",E.selectedItems.value)}function W(){a("close")}function L(M){}const _=e.ref(null),A=e.ref(!1);function Z(M){_.value=M,A.value=!0}function H(M){const j=c.value.findIndex(ae=>ae.uuid===M.uuid);j!==-1&&(c.value[j]=M);const te={};M.alt_text!==void 0&&(te.alt_text=M.alt_text),M.caption!==void 0&&(te.caption=M.caption),M.custom_properties!==void 0&&(te.custom_properties=M.custom_properties),B.updateMedia(M.uuid,te)}function me(){N()}function Te(){m.value={},s.value="",N()}const Be=cm(()=>{N(!0)},300);e.watch(s,()=>{t.isOpen&&Be()});async function ie(M){try{await(await I.alertController.create({header:"Delete Media",message:"Are you sure you want to delete this media item?",buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"destructive",handler:async()=>{await B.deleteMedia(M),await N()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,M=>{M&&N()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(M=>E.select(M))}),(M,j)=>{const te=e.resolveComponent("AdminMediaGrid"),ae=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":M.isOpen,onDidDismiss:W,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:W},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(b.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",pm,[e.createVNode(e.unref(I.IonSegment),{value:r.value,onIonChange:j[0]||(j[0]=re=>F(re.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[15]||(j[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(I.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[16]||(j[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[17]||(j[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(I.IonButton),{fill:"clear",size:"small",onClick:j[1]||(j[1]=re=>p.value=!p.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[w.value>0?(e.openBlock(),e.createBlock(e.unref(I.IonBadge),{key:0,color:"primary",class:"absolute -top-1 -right-1 min-w-[20px] h-5 rounded-full flex items-center justify-center text-xs"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.value),1)]),_:1})):e.createCommentVNode("",!0)]),_:1})])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",fm,[p.value?(e.openBlock(),e.createElementBlock("div",hm,[e.createElementVNode("div",vm,[e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[18]||(j[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":j[2]||(j[2]=re=>m.value.collection=re),class:"w-full p-2 border rounded"},[j[19]||(j[19]=e.createElementVNode("option",{value:""},"All Collections",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,re=>(e.openBlock(),e.createElementBlock("option",{key:re,value:re},e.toDisplayString(re),9,gm))),128))],512),[[e.vModelSelect,m.value.collection]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[20]||(j[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[3]||(j[3]=re=>m.value.dateFrom=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateFrom]])]),e.createElementVNode("div",null,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[21]||(j[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[4]||(j[4]=re=>m.value.dateTo=re),type:"date",class:"w-full p-2 border rounded"},null,512),[[e.vModelText,m.value.dateTo]])])]),e.createElementVNode("div",ym,[e.createVNode(e.unref(I.IonButton),{size:"small",onClick:me},{default:e.withCtx(()=>[...j[22]||(j[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{size:"small",fill:"clear",onClick:Te},{default:e.withCtx(()=>[...j[23]||(j[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":j[5]||(j[5]=re=>s.value=re),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",bm,[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:i.value==="grid"?"solid":"clear",size:"small",onClick:j[6]||(j[6]=re=>i.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(I.IonButton),{fill:i.value==="list"?"solid":"clear",size:"small",onClick:j[7]||(j[7]=re=>i.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",wm,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",km,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),j[24]||(j[24]=e.createElementVNode("h3",{class:"text-lg font-medium text-theme mb-2"}," No Media Found ",-1)),e.createElementVNode("p",xm,e.toDisplayString(s.value?"Try adjusting your search":"No media items available"),1)])):i.value==="grid"?(e.openBlock(),e.createBlock(te,{key:3,"media-items":f.value,"selected-items":e.unref(E).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:D,onPreview:L,onEdit:Z,onDelete:ie},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(I.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(re,q)=>(e.openBlock(),e.createBlock(ae,{key:re.uuid,media:re,selected:e.unref(E).isSelected(re.uuid),"selection-mode":!0,index:q,onToggleSelect:D,onPreview:L,onEdit:Z,onDelete:ie},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&f.value.length>0&&r.value!=="model"?(e.openBlock(),e.createBlock(e.unref(I.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:j[8]||(j[8]=re=>P(re))},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(I.IonModal),{"is-open":A.value,onDidDismiss:j[14]||(j[14]=re=>A.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{onClick:j[9]||(j[9]=re=>A.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[...j[25]||(j[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"p-4"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("div",Sm,[e.createElementVNode("div",Em,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[26]||(j[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[10]||(j[10]=re=>_.value.caption=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter caption..."},null,512),[[e.vModelText,_.value.caption]])]),e.createElementVNode("div",Cm,[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...j[27]||(j[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[11]||(j[11]=re=>_.value.alt_text=re),type:"text",class:"w-full p-2 border rounded mt-1",placeholder:"Enter alt text..."},null,512),[[e.vModelText,_.value.alt_text]])]),e.createElementVNode("div",Vm,[e.createVNode(e.unref(I.IonButton),{onClick:j[12]||(j[12]=re=>H(_.value))},{default:e.withCtx(()=>[...j[28]||(j[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:j[13]||(j[13]=re=>A.value=!1)},{default:e.withCtx(()=>[...j[29]||(j[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Nm,[e.createElementVNode("div",_m,[e.unref(E).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Tm,[e.createTextVNode(e.toDisplayString(e.unref(E).selectedCount.value)+" selected ",1),t.maxSelection?(e.openBlock(),e.createElementBlock("span",Mm," / "+e.toDisplayString(t.maxSelection)+" max ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("span",Fm," Select "+e.toDisplayString(t.selectionMode==="multiple"?"items":"an item"),1))]),e.createElementVNode("div",Im,[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:W},{default:e.withCtx(()=>[...j[30]||(j[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{disabled:C.value,onClick:R},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Rm=_e(Bm,[["__scopeId","data-v-9a8c0954"]]),Pm={key:1,class:"flex flex-col items-center justify-center py-16"},$m=["draggable","onDragstart","onDragover","onDrop"],zm={key:0,class:"absolute top-2 left-2 z-20"},Am=["checked","onChange"],Dm={key:2,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-move"},Um=["data-media-id"],Om={key:0,class:"w-full h-full flex items-center justify-center"},Lm=["src","alt","onError","onLoad"],Wm={key:2,class:"w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-700"},jm={class:"text-center"},Xm={class:"text-4xl text-gray-400 mb-2"},Zm={class:"text-sm font-medium text-gray-500"},Ym={class:"absolute inset-0 bg-black/70 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2"},Gm=["onClick"],Hm=["onClick"],Jm=["onClick"],qm={class:"p-3"},Km={class:"text-sm font-medium truncate mb-1"},Qm={class:"text-xs text-gray-600 dark:text-gray-400"},ep={key:0},tp={key:0,class:"text-xs text-gray-500 dark:text-gray-500 mt-1 truncate"},np=e.defineComponent({__name:"MediaGrid",props:{mediaItems:{default:()=>[]},selectedItems:{default:()=>[]},isLoading:{type:Boolean,default:!1},selectionMode:{type:Boolean,default:!1},reorderable:{type:Boolean,default:!1},showEditButton:{type:Boolean,default:!1},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})}},emits:["toggleSelect","preview","edit","delete","reorder","upload"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null),i=e.ref(null),s=e.ref(new Set),l=e.ref(null),c=C=>t.selectedItems.some(b=>b.uuid===C.uuid),d=e.computed(()=>{const C=t.columns,b=["grid","gap-4"];switch(C.mobile){case 1:b.push("grid-cols-1");break;case 2:b.push("grid-cols-2");break;case 3:b.push("grid-cols-3");break;case 4:b.push("grid-cols-4");break;default:b.push("grid-cols-2");break}switch(C.sm){case 1:b.push("sm:grid-cols-1");break;case 2:b.push("sm:grid-cols-2");break;case 3:b.push("sm:grid-cols-3");break;case 4:b.push("sm:grid-cols-4");break;case 5:b.push("sm:grid-cols-5");break;default:b.push("sm:grid-cols-3");break}switch(C.md){case 2:b.push("md:grid-cols-2");break;case 3:b.push("md:grid-cols-3");break;case 4:b.push("md:grid-cols-4");break;case 5:b.push("md:grid-cols-5");break;case 6:b.push("md:grid-cols-6");break;default:b.push("md:grid-cols-4");break}switch(C.lg){case 3:b.push("lg:grid-cols-3");break;case 4:b.push("lg:grid-cols-4");break;case 5:b.push("lg:grid-cols-5");break;case 6:b.push("lg:grid-cols-6");break;case 7:b.push("lg:grid-cols-7");break;default:b.push("lg:grid-cols-5");break}switch(C.xl){case 4:b.push("xl:grid-cols-4");break;case 5:b.push("xl:grid-cols-5");break;case 6:b.push("xl:grid-cols-6");break;case 7:b.push("xl:grid-cols-7");break;case 8:b.push("xl:grid-cols-8");break;default:b.push("xl:grid-cols-6");break}return b.join(" ")});function u(C,b,N){t.reorderable&&(r.value=b,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/html","")))}function p(C,b){t.reorderable&&(C.preventDefault(),i.value=b)}function m(){i.value=null}function h(C,b){if(!t.reorderable||!r.value)return;C.preventDefault();const N=[...t.mediaItems],P=N.findIndex(k=>{var T;return k.uuid===((T=r.value)==null?void 0:T.uuid)});if(P!==-1&&P!==b&&r.value){const[k]=N.splice(P,1);N.splice(b,0,k),a("reorder",N)}r.value=null,i.value=null}function g(C){return C<1024?C+" B":C<1024*1024?(C/1024).toFixed(1)+" KB":(C/(1024*1024)).toFixed(1)+" MB"}function v(C){var N;return C.thumbnail_url||((N=C.conversion_urls)==null?void 0:N.thumb)||C.original_url||C.url||""}function x(C){var P,k,T;const b=((P=C.mime_type)==null?void 0:P.startsWith("image/"))||!1,N=!!(C.thumbnail_url||(k=C.conversion_urls)!=null&&k.thumb||(T=C.conversion_urls)!=null&&T.preview||C.original_url||C.url);return b&&N}function B(C){var b;return((b=C.split(".").pop())==null?void 0:b.toUpperCase())||""}function E(C){var N;const b=((N=C.mime_type)==null?void 0:N.toLowerCase())||"";return b.startsWith("image/")?"image":b.startsWith("video/")?"videocam":b.startsWith("audio/")?"musical-notes":b.includes("pdf")?"document-text":b.includes("zip")||b.includes("rar")?"archive":b.includes("sheet")||b.includes("excel")?"grid":b.includes("document")||b.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(C=>{C.forEach(b=>{var N;if(b.isIntersecting){const P=b.target.getAttribute("data-media-id");P&&(s.value.add(P),(N=l.value)==null||N.unobserve(b.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function y(C){return!0}function f(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(b=>{var P;const N=b.getAttribute("data-media-id");N&&!s.value.has(N)&&((P=l.value)==null||P.observe(b))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),f()},{immediate:!0,deep:!0});function w(C,b){const N=C.target;delete N.dataset.fallbackIndex}function $(C,b){const N=C.target,P=N.closest("[data-media-id]"),k=[b.original_url,b.url,b.thumbnail_url,"preview_url"in b?b.preview_url:void 0].filter(T=>T&&T.trim()!==""&&T!==N.src);if(k.length>0&&N.dataset.fallbackIndex){const T=parseInt(N.dataset.fallbackIndex);if(T<k.length){N.dataset.fallbackIndex=(T+1).toString(),N.src=k[T]||"";return}}else if(k.length>0){N.dataset.fallbackIndex="1",N.src=k[0]||"";return}if(N.style.display="none",P&&!P.querySelector(".media-fallback-icon")){const F=document.createElement("div");F.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",F.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${E(b)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${B(b.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,P.appendChild(F)}}return(C,b)=>C.isLoading?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(d.value)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(12,N=>e.createElementVNode("div",{key:`skeleton-${N}`,class:"relative"},[...b[1]||(b[1]=[e.createStaticVNode('<div class="bg-white dark:bg-gray-800 rounded-lg shadow" data-v-f0c343b7><div class="aspect-square bg-gray-200 dark:bg-gray-700 animate-pulse rounded-t-lg" data-v-f0c343b7></div><div class="p-3" data-v-f0c343b7><div class="h-4 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-3/4 mb-2" data-v-f0c343b7></div><div class="h-3 bg-gray-200 dark:bg-gray-700 animate-pulse rounded w-1/2" data-v-f0c343b7></div></div></div>',1)])])),64))],2)):!C.mediaItems||!C.mediaItems.length?(e.openBlock(),e.createElementBlock("div",Pm,[b[2]||(b[2]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-16 h-16 text-gray-400 mb-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})],-1)),b[3]||(b[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),b[4]||(b[4]=e.createElementVNode("p",{class:"text-sm text-gray-600 dark:text-gray-400 mb-4"}," Upload some files to get started ",-1)),e.createElementVNode("button",{onClick:b[0]||(b[0]=N=>a("upload")),class:"px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"}," Upload Media ")])):(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass(d.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.mediaItems,(N,P)=>(e.openBlock(),e.createElementBlock("div",{key:N.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":i.value===P}]),draggable:C.reorderable,onDragstart:k=>u(k,N),onDragover:k=>p(k,P),onDragleave:m,onDrop:k=>h(k,P)},[C.selectionMode?(e.openBlock(),e.createElementBlock("div",zm,[e.createElementVNode("input",{type:"checkbox",checked:c(N),onChange:k=>a("toggleSelect",N),class:"w-5 h-5 bg-white dark:bg-gray-800 rounded cursor-pointer"},null,40,Am)])):e.createCommentVNode("",!0),C.$slots.badge?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute top-2 z-20",C.selectionMode?"left-10":"left-2"])},[e.renderSlot(C.$slots,"badge",{media:N,index:P},void 0,!0)],2)):e.createCommentVNode("",!0),C.reorderable?(e.openBlock(),e.createElementBlock("div",Dm,[...b[5]||(b[5]=[e.createElementVNode("div",{class:"bg-black/70 text-white p-2 rounded"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-4 h-4"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"})])],-1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden h-full",{"ring-2 ring-blue-500":c(N)}])},[e.createElementVNode("div",{class:"relative aspect-square bg-gray-100 dark:bg-gray-700 overflow-hidden","data-media-id":N.uuid},[x(N)&&!y(N.uuid)?(e.openBlock(),e.createElementBlock("div",Om,[...b[6]||(b[6]=[e.createElementVNode("div",{class:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"},null,-1)])])):e.createCommentVNode("",!0),x(N)&&y(N.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:v(N),alt:N.alt_text||N.file_name,class:"w-full h-full object-cover",loading:"lazy",onError:k=>$(k,N),onLoad:k=>w(k)},null,40,Lm)):(e.openBlock(),e.createElementBlock("div",Wm,[e.createElementVNode("div",jm,[e.createElementVNode("div",Xm,e.toDisplayString(E(N)),1),e.createElementVNode("p",Zm,e.toDisplayString(B(N.file_name)),1)])])),e.createElementVNode("div",Ym,[e.createElementVNode("button",{onClick:k=>a("preview",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Preview"},[...b[7]||(b[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,Gm),C.showEditButton&&x(N)?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:k=>a("edit",N),class:"p-2 bg-white/20 text-white rounded hover:bg-white/30",title:"Edit"},[...b[8]||(b[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"})],-1)])],8,Hm)):e.createCommentVNode("",!0),e.createElementVNode("button",{onClick:k=>a("delete",N.uuid),class:"p-2 bg-red-500/20 text-red-300 rounded hover:bg-red-500/30",title:"Delete"},[...b[9]||(b[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","stroke-width":"1.5",stroke:"currentColor",class:"w-5 h-5"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M14.74 9l-.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 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"})],-1)])],8,Jm)])],8,Um),e.createElementVNode("div",qm,[e.createElementVNode("h4",Km,e.toDisplayString(N.file_name),1),e.createElementVNode("p",Qm,[e.createTextVNode(e.toDisplayString(g(N.size))+" ",1),N.width&&N.height?(e.openBlock(),e.createElementBlock("span",ep," • "+e.toDisplayString(N.width)+"x"+e.toDisplayString(N.height),1)):e.createCommentVNode("",!0)]),N.caption?(e.openBlock(),e.createElementBlock("p",tp,e.toDisplayString(N.caption),1)):e.createCommentVNode("",!0)])],2)],42,$m))),128))],2))}}),op=_e(np,[["__scopeId","data-v-f0c343b7"]]),ap={class:"model-media-manager"},rp=["accept","multiple"],ip={class:"flex items-center justify-between mb-4"},sp={key:0,class:"text-lg font-medium"},lp={class:"flex gap-2"},cp={key:0,class:"flex items-center justify-center py-8"},dp={key:1,class:"flex flex-col items-center justify-center py-12 text-center border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg"},up={class:"text-gray-600 dark:text-gray-400"},mp={class:"flex gap-2 mt-4"},pp={key:0,class:"px-2 py-1 bg-blue-500 text-white text-xs font-medium rounded"},fp=e.defineComponent({__name:"ModelMediaManager",props:{mediableType:{},mediableId:{},collection:{},mode:{default:"user"},initialMedia:{},maxFiles:{},acceptedMimeTypes:{},maxFileSize:{},allowReorder:{type:Boolean,default:!0},allowUpload:{type:Boolean,default:!0},allowBrowse:{type:Boolean,default:!0},allowDetach:{type:Boolean,default:!0},allowEdit:{type:Boolean,default:!1},editMode:{default:"replace"},showPrimaryBadge:{type:Boolean,default:!0},emptyText:{default:"No media attached"},title:{default:"Media"}},emits:["loading","update:media","error","attach","detach","reorder","upload-progress","edit-complete"],setup(n,{emit:o}){const t=n,a=o,r=vt(),i=e.ref(!1),s=e.ref(!1),l=e.ref(!1),c=e.ref(!1),d=e.ref(null),u=e.ref(null),p=e.ref(null),m=e.computed(()=>{if(t.maxFiles!==void 0)return Math.max(0,t.maxFiles-r.modelMedia.length)}),h=e.computed(()=>r.modelMedia.map(L=>L.uuid)),g=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")}),v=e.computed(()=>{if(d.value)return w(d.value)??void 0});function x(){Cn({isAdmin:t.mode==="admin"})}async function B(L){await(await I.toastController.create({message:L,duration:3e3,color:"danger",position:"bottom"})).present()}async function E(){if(!s.value)if(s.value=!0,x(),r.setModelContext(t.mediableType,t.mediableId,t.collection),t.initialMedia&&t.initialMedia.length>0)r.modelMedia=[...t.initialMedia],a("update:media",r.modelMedia);else{i.value=!0,a("loading",!0);try{await r.fetchModelMedia(t.mediableType,t.mediableId,t.collection),a("update:media",r.modelMedia)}catch(L){const _=L instanceof Error?L.message:"Failed to fetch media";a("error",{operation:"fetch",message:_,details:L})}finally{i.value=!1,a("loading",!1)}}}e.watch(()=>r.modelMedia,L=>{s.value&&a("update:media",L)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,E()}),e.watch(()=>t.mode,()=>{x()}),e.onMounted(()=>{E()}),e.onUnmounted(()=>{r.clearModelContext()});function y(){return r.modelMedia.length>0}function f(){return t.maxFiles===void 0?!1:r.modelMedia.length>=t.maxFiles}function w(L){var A,Z,H;if(!((A=L.mime_type)!=null&&A.startsWith("image/")))return null;const _=L.original_url||L.url||((Z=L.conversion_urls)==null?void 0:Z.preview)||((H=L.conversion_urls)==null?void 0:H.thumb)||L.thumbnail_url;return _&&_.trim()!==""?_:null}function $(){l.value=!0}function C(){var L;(L=p.value)==null||L.click()}function b(){l.value=!1}function N(L){!t.allowEdit||!w(L)||(d.value=L,c.value=!0)}function P(){c.value=!1,d.value=null}async function k(L){if(!d.value)throw new Error("No media selected for editing");const _=d.value,A=t.editMode==="variant";try{u.value=null;const Z=await r.saveEditedImage(_.uuid,L,{asVariant:A,name:_.file_name});A||await r.detachMedia(t.mediableType,t.mediableId,_.uuid,t.collection),await r.attachMedia(t.mediableType,t.mediableId,[Z.uuid],t.collection),a("edit-complete",{originalMedia:_,editedMedia:Z,mode:t.editMode}),c.value=!1,d.value=null}catch(Z){const H=Z instanceof Error?Z.message:"Failed to save edited image";throw u.value=H,await B(H),Z}}function T(L){if(u.value===L.message){u.value=null;return}B(L.message)}async function F(L){const _=L.target,A=_.files;if(!(!A||A.length===0)){for(let Z=0;Z<A.length;Z++){const H=A[Z];if(m.value!==void 0&&m.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(H.type)){a("error",{operation:"upload",message:`File type ${H.type} is not accepted`,details:{file:H.name}});continue}if(t.maxFileSize!==void 0&&H.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:H.name,size:H.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:H});try{const me=await r.uploadFile(H,{collection:t.collection});me!=null&&me.uuid&&(await r.attachMedia(t.mediableType,t.mediableId,[me.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:H}),a("attach",[me]))}catch(me){const Te=me instanceof Error?me.message:"Upload failed";a("error",{operation:"upload",message:Te,details:me}),a("upload-progress",{status:"error",progress:0,file:H,error:Te})}}_.value=""}}async function D(L){const _=L.map(A=>A.uuid);try{await r.reorderMedia(t.mediableType,t.mediableId,_,t.collection),a("reorder",r.modelMedia)}catch(A){const Z=A instanceof Error?A.message:"Failed to reorder media";a("error",{operation:"reorder",message:Z,details:A}),await B(Z)}}async function R(L){const _=r.modelMedia.find(A=>A.uuid===L);try{await r.detachMedia(t.mediableType,t.mediableId,L,t.collection),_&&a("detach",_)}catch(A){const Z=A instanceof Error?A.message:"Failed to detach media";a("error",{operation:"detach",message:Z,details:A}),await B(Z)}}async function W(L){l.value=!1;const _=L.map(H=>H.uuid),A=new Set(h.value);let Z=Array.from(new Set(_)).filter(H=>!A.has(H));if(m.value!==void 0&&Z.length>m.value&&(Z=Z.slice(0,m.value)),Z.length!==0)try{await r.attachMedia(t.mediableType,t.mediableId,Z,t.collection);const H=r.modelMedia.filter(me=>Z.includes(me.uuid));a("attach",H)}catch(H){const me=H instanceof Error?H.message:"Failed to attach media";a("error",{operation:"attach",message:me,details:H})}}return(L,_)=>(e.openBlock(),e.createElementBlock("div",ap,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:p,type:"file",accept:g.value,multiple:m.value===void 0||m.value>1,class:"hidden","data-testid":"upload-input",onChange:F},null,40,rp),e.createElementVNode("div",ip,[L.title?(e.openBlock(),e.createElementBlock("h3",sp,e.toDisplayString(L.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",lp,[L.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small",disabled:f(),"data-testid":"browse-button",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(Ka)},null,8,["icon"]),_[1]||(_[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),L.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small",disabled:f(),"data-testid":"upload-button",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(Ki)},null,8,["icon"]),_[2]||(_[2]=e.createTextVNode(" Upload ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0)])]),i.value||e.unref(r).isLoadingModelMedia?(e.openBlock(),e.createElementBlock("div",cp,[e.createVNode(e.unref(I.IonSpinner),{"data-testid":"spinner"})])):y()?(e.openBlock(),e.createBlock(op,{key:2,"media-items":e.unref(r).modelMedia,reorderable:!!L.allowReorder,"is-loading":i.value||e.unref(r).isLoadingModelMedia,"show-edit-button":!!L.allowEdit,"selection-mode":!1,onReorder:D,onDelete:R,onEdit:N},e.createSlots({_:2},[L.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:A})=>[A===0?(e.openBlock(),e.createElementBlock("div",pp," Primary ")):e.createCommentVNode("",!0)]),key:"0"}:void 0]),1032,["media-items","reorderable","is-loading","show-edit-button"])):(e.openBlock(),e.createElementBlock("div",dp,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ka),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",up,e.toDisplayString(L.emptyText),1),e.createElementVNode("div",mp,[L.allowBrowse?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(Ka)},null,8,["icon"]),_[3]||(_[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),L.allowUpload?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"start",icon:e.unref(Ki)},null,8,["icon"]),_[4]||(_[4]=e.createTextVNode(" Upload Files ",-1))]),_:1})):e.createCommentVNode("",!0)])])),e.createVNode(Rm,e.mergeProps({"is-open":l.value,"selected-items":h.value,collection:L.collection},m.value!==null&&m.value!==void 0?{maxSelection:m.value}:{},{onConfirm:W,onClose:b}),null,16,["is-open","selected-items","collection"]),e.createVNode(ol,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=A=>c.value=A)},v.value?{initialImage:v.value}:{},{"on-save":k,onCancel:P,onError:T}),null,16,["modelValue"])]))}}),hp=_e(fp,[["__scopeId","data-v-71504dc3"]]),vp=["src"],gp={class:"preview-controls"},yp=["aria-label"],bp={class:"time-display"},wp={class:"current-time"},kp={class:"total-time"},xp={key:0,class:"fps-display"},Sp={key:0,class:"loading-overlay"},Ep={key:1,class:"error-overlay"},Cp=e.defineComponent({__name:"VideoPreview",props:{source:{},filters:{},playhead:{},isPlaying:{type:Boolean,default:!1},showFps:{type:Boolean,default:!1},targetFps:{default:30},fitMode:{default:"contain"},active:{type:Boolean,default:!0}},emits:["frame-update","play-pause","duration-change","error"],setup(n,{expose:o,emit:t}){const{ColorMatrixFilter:a,BlurFilter:r}=Ae,i=n,s=t,l=e.ref(),c=e.ref(),d=e.ref(),u=e.ref(!0),p=e.ref(),m=e.ref(0),h=e.ref(0),g=e.ref(!1);let v,x,B=null,E=null,y=null,f=[],w="",$=null,C=0,b=0,N=0,P=0,k=!1,T=0,F=0,D,R=null,W=!1;const L=e.computed(()=>i.source&&typeof i.source=="string"?i.source:"");async function _(){var pe,ke;if(c.value&&!v&&!(!d.value||d.value.readyState<3))try{let U=((pe=l.value)==null?void 0:pe.clientWidth)||800,ne=((ke=l.value)==null?void 0:ke.clientHeight)||450;if((U<=0||ne<=0)&&(U=d.value.videoWidth||800,ne=d.value.videoHeight||450),v=new Ae.Application,await v.init({width:U,height:ne,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(v.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!v&&_()},100),v&&(v.destroy(!0),v=null);return}C=d.value.videoWidth,b=d.value.videoHeight,E=document.createElement("canvas"),E.width=C,E.height=b,y=E.getContext("2d"),y.drawImage(d.value,0,0,C,b);const K=Ae.Texture.from(E);B=K.source,x=new Ae.Sprite(K),x.visible=!0,x.alpha=1,fe(),v.stage.addChild(x),v.renderer&&!v.renderer.destroyed&&v.render()}me(),i.targetFps<60?A():v.ticker.add(Z),g.value=!0,"ResizeObserver"in window&&($=new ResizeObserver(K=>{k||(k=!0,requestAnimationFrame(()=>{k=!1;const ee=K[K.length-1],{width:be,height:Y}=ee.contentRect;if(be<=0||Y<=0)return;const se=Math.round(be),xe=Math.round(Y);se===N&&xe===P||(N=se,P=xe,fe())}))}),$.observe(l.value)),i.filters&&i.filters.length>0&&me(),i.showFps&&ve()}catch{p.value="Failed to initialize video preview"}}function A(){const pe=1e3/i.targetFps;let ke=performance.now();function U(){if(W||!v)return;const ne=performance.now(),K=ne-ke;K>=pe&&(Z(),ke=ne-K%pe),R=requestAnimationFrame(U)}R=requestAnimationFrame(U)}function Z(){if(!(!v||!x||W)&&i.active)try{y&&E&&B&&d.value&&(d.value.readyState>=2&&(y.drawImage(d.value,0,0,E.width,E.height),B.update()),d.value.paused||s("frame-update",ie())),i.showFps&&F++,v.renderer&&!v.renderer.destroyed&&v.render()}catch{W=!0}}function H(){for(const pe of f)try{pe.destroy()}catch{}f=[]}function me(){if(x){if(!i.filters||i.filters.length===0){x.filters=null,H();return}H(),i.filters.forEach(pe=>{const ke=Te(pe);ke&&f.push(ke)}),x.filters=f.length>0?f:null,w=JSON.stringify(i.filters),v&&v.render()}}function Te(pe){const ke=pe.filterId,U=pe.params||{},ne=no.getFilter(ke);if(ne&&ne.createFilter)try{return ne.createFilter(U)}catch{}const K=(ee,be,Y)=>Math.min(Y,Math.max(be,ee));switch(ke){case"brightness":{const ee=new a,be=K(typeof U.brightness=="number"?U.brightness:typeof U.value=="number"?U.value:1,0,5);return ee.brightness(be,!0),ee}case"contrast":{const ee=new a,be=K(typeof U.contrast=="number"?U.contrast:typeof U.value=="number"?U.value:1,0,5);return ee.contrast(be,!0),ee}case"saturation":{const ee=new a,be=K(typeof U.saturation=="number"?U.saturation:typeof U.value=="number"?U.value:1,0,5);return ee.saturate(be,!0),ee}case"hue":{const ee=new a,be=K(typeof U.value=="number"?U.value:0,-180,180);return ee.hue(be,!0),ee}case"gaussian-blur":case"blur":{const ee=K(typeof U.blur=="number"?U.blur:typeof U.value=="number"?U.value:2,0,10);return new r(ee)}case"grayscale":{const ee=new a;return ee.desaturate(),ee}case"sepia":case"color-matrix":{const ee=new a;return ee.sepia(!0),ee}case"vignette":{const ee=typeof U.value=="number"?U.value:.3;return Be(K(ee,0,1))}default:return null}}function Be(pe){const ke=`
|
|
7
|
-
precision mediump float;
|
|
8
|
-
varying vec2 vTextureCoord;
|
|
9
|
-
uniform sampler2D uSampler;
|
|
10
|
-
uniform float strength;
|
|
11
|
-
void main(void){
|
|
12
|
-
vec2 uv = vTextureCoord - 0.5;
|
|
13
|
-
float dist = length(uv) * 2.0;
|
|
14
|
-
float vignette = smoothstep(1.0, 1.0 - strength, dist);
|
|
15
|
-
vec4 color = texture2D(uSampler, vTextureCoord);
|
|
16
|
-
gl_FragColor = vec4(color.rgb * (1.0 - vignette), color.a);
|
|
17
|
-
}
|
|
18
|
-
`;return new Ae.Filter(void 0,ke,{strength:pe})}function ie(){var ke;return!v||!x?null:{dataUrl:v.canvas.toDataURL("image/jpeg",.8),timestamp:((ke=d.value)==null?void 0:ke.currentTime)||0,width:C||0,height:b||0}}function M(){var pe;m.value=((pe=d.value)==null?void 0:pe.duration)||0,s("duration-change",m.value)}function j(){u.value=!1,p.value=void 0}function te(){u.value&&(u.value=!1),!g.value&&i.active?_():g.value}function ae(){var ke,U,ne;const pe=((ke=d.value)==null?void 0:ke.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:pe,width:((U=d.value)==null?void 0:U.videoWidth)||0,height:((ne=d.value)==null?void 0:ne.videoHeight)||0})}function re(){s("play-pause")}function q(pe){var U;const ke=pe.target;if(ke!=null&&ke.error)switch(ke.error.code){case ke.error.MEDIA_ERR_ABORTED:p.value="Video playback aborted";break;case ke.error.MEDIA_ERR_NETWORK:p.value="Network error loading video";break;case ke.error.MEDIA_ERR_DECODE:p.value="Video format not supported";break;case ke.error.MEDIA_ERR_SRC_NOT_SUPPORTED:p.value=`Video source not supported: ${(U=ke.src)==null?void 0:U.substring(0,100)}`;break;default:p.value="Failed to load video"}else p.value="Failed to load video";s("error",p.value),u.value=!1}function ue(pe){d.value&&(d.value.currentTime=Math.max(0,Math.min(pe,m.value)))}function ve(){D=window.setInterval(()=>{const pe=performance.now(),ke=pe-T;h.value=Math.round(F*1e3/ke),F=0,T=pe},1e3)}function we(pe){const ke=Math.floor(pe/60),U=Math.floor(pe%60);return`${ke.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`}function oe(){p.value=void 0,u.value=!0,d.value&&d.value.load()}function ye(){v&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,fe()})))}function fe(){if(!v||!x||!C||!b||!l.value)return;const pe=Math.round(l.value.clientWidth),ke=Math.round(l.value.clientHeight);if(pe<=0||ke<=0)return;v.renderer.resize(pe,ke);const U=v.screen.width/C,ne=v.screen.height/b;let K=1;switch(i.fitMode){case"cover":K=Math.max(U,ne);break;case"none":K=1;break;case"contain":default:K=Math.min(U,ne);break}x.scale.set(K),x.anchor.set(.5),x.position.set(v.screen.width/2,v.screen.height/2),x.visible=!0,x.alpha=1,v.renderer&&!v.renderer.destroyed&&v.render()}e.watch(()=>i.filters,()=>{g.value&&me()},{deep:!0}),e.watch(()=>i.active,async pe=>{if(pe&&!v&&d.value&&d.value.readyState>=2){await _();return}v&&(pe&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),x&&y&&E&&B&&(d.value&&d.value.readyState>=2&&(y.drawImage(d.value,0,0,E.width,E.height),B.update()),fe(),v.renderer&&!v.renderer.destroyed&&v.render())),i.targetFps>=60&&v.ticker&&(pe?v.ticker.start():v.ticker.stop()))}),e.watch(L,pe=>{pe?(u.value=!0,p.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,p.value="No video source provided")},{immediate:!0}),e.watch(()=>i.isPlaying,pe=>{d.value&&(pe?d.value.play():d.value.pause())}),e.watch(()=>i.playhead,pe=>{d.value&&Math.abs(d.value.currentTime-pe)>.5&&ue(pe)}),e.watch(()=>i.fitMode,()=>{fe()}),e.onMounted(()=>{W=!1,e.nextTick(()=>{l.value&&l.value.getBoundingClientRect(),d.value}),window.addEventListener("resize",ye),T=performance.now(),e.nextTick(()=>{d.value&&d.value.readyState>=2&&!g.value&&_()})}),e.onUnmounted(()=>{if(W=!0,R&&(cancelAnimationFrame(R),R=null),window.removeEventListener("resize",ye),$&&($.disconnect(),$=null),D&&clearInterval(D),v&&v.ticker&&(v.ticker.stop(),v.ticker.remove(Z)),v){try{v.destroy(!0,{children:!0,texture:!0})}catch{}v=null}f.forEach(pe=>{try{pe.destroy()}catch{}}),f=[],x=null,B=null,E=null,y=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function Ze(pe){if(!await Ke()||!d.value||!y||!E||!B)return null;const U=d.value,ne=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite(U.duration)&&U.duration>0?U.duration:0,K=Math.max(0,Math.min(pe,ne));await new Promise(ee=>{let be=!1,Y=0;const se=()=>{be||(be=!0,U.removeEventListener("seeked",xe),window.clearTimeout(Y),ee())},xe=()=>{se()},Ce=Number.isFinite(U.currentTime)?U.currentTime:0;if(Math.abs(Ce-K)<.016){requestAnimationFrame(()=>se());return}U.addEventListener("seeked",xe),Y=window.setTimeout(()=>se(),700),U.currentTime=K});try{y.drawImage(U,0,0,E.width,E.height),B.update(),v.render()}catch{return null}return v.canvas}async function Ke(){if(!d.value)return!1;if(!v){if(!(d.value.readyState>=2))return!1;await _()}if(!v||!x||!y||!E||!B)return!1;if(i.filters&&i.filters.length>0){const pe=x.filters,ke=Array.isArray(pe)?pe.length:0,ne=JSON.stringify(i.filters)!==w;(ke===0||ke!==i.filters.length||ne)&&me()}return await e.nextTick(),await new Promise(pe=>{requestAnimationFrame(()=>pe())}),!0}return o({captureFrameAt:Ze,ensureReadyForCapture:Ke,duration:m,pixiCanvas:e.computed(()=>v?v.canvas:null),videoElement:e.computed(()=>d.value??null)}),(pe,ke)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview",ref_key:"containerRef",ref:l},[e.createElementVNode("div",{class:"canvas-container",ref_key:"canvasContainerRef",ref:c},null,512),e.createElementVNode("video",{ref_key:"videoRef",ref:d,src:L.value,onLoadedmetadata:M,onLoadeddata:j,onCanplay:te,onTimeupdate:ae,onEnded:re,onError:q,style:e.normalizeStyle({display:g.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:pe.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,vp),e.createElementVNode("div",gp,[e.createElementVNode("button",{class:"play-button",onClick:ke[0]||(ke[0]=U=>pe.$emit("play-pause")),"aria-label":pe.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:pe.isPlaying?e.unref(sl):e.unref(ll)},null,8,["icon"])],8,yp),e.createElementVNode("div",bp,[e.createElementVNode("span",wp,e.toDisplayString(we(pe.playhead)),1),ke[1]||(ke[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",kp,e.toDisplayString(we(m.value)),1)]),pe.showFps?(e.openBlock(),e.createElementBlock("div",xp,e.toDisplayString(h.value)+" FPS ",1)):e.createCommentVNode("",!0)]),u.value?(e.openBlock(),e.createElementBlock("div",Sp,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),ke[2]||(ke[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",Ep,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(p.value),1),e.createElementVNode("button",{onClick:oe},"Retry")])):e.createCommentVNode("",!0)],512))}}),as=_e(Cp,[["__scopeId","data-v-e2065e0f"]]);var Rr=(n,o,t)=>{if(!o.has(n))throw TypeError("Cannot "+t)},z=(n,o,t)=>(Rr(n,o,"read from private field"),t?t.call(n):o.get(n)),Fe=(n,o,t)=>{if(o.has(n))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(n):o.set(n,t)},tt=(n,o,t,a)=>(Rr(n,o,"write to private field"),o.set(n,t),t),Vp=(n,o,t,a)=>({set _(r){tt(n,o,r)},get _(){return z(n,o,a)}}),Pe=(n,o,t)=>(Rr(n,o,"access private method"),t),$e=new Uint8Array(8),$t=new DataView($e.buffer),qe=n=>[(n%256+256)%256],ze=n=>($t.setUint16(0,n,!1),[$e[0],$e[1]]),Np=n=>($t.setInt16(0,n,!1),[$e[0],$e[1]]),ml=n=>($t.setUint32(0,n,!1),[$e[1],$e[2],$e[3]]),ge=n=>($t.setUint32(0,n,!1),[$e[0],$e[1],$e[2],$e[3]]),_p=n=>($t.setInt32(0,n,!1),[$e[0],$e[1],$e[2],$e[3]]),cn=n=>($t.setUint32(0,Math.floor(n/2**32),!1),$t.setUint32(4,n,!1),[$e[0],$e[1],$e[2],$e[3],$e[4],$e[5],$e[6],$e[7]]),Pr=n=>($t.setInt16(0,2**8*n,!1),[$e[0],$e[1]]),Bt=n=>($t.setInt32(0,2**16*n,!1),[$e[0],$e[1],$e[2],$e[3]]),er=n=>($t.setInt32(0,2**30*n,!1),[$e[0],$e[1],$e[2],$e[3]]),kt=(n,o=!1)=>{let t=Array(n.length).fill(null).map((a,r)=>n.charCodeAt(r));return o&&t.push(0),t},Ko=n=>n&&n[n.length-1],$r=n=>{let o;for(let t of n)(!o||t.presentationTimestamp>o.presentationTimestamp)&&(o=t);return o},Pt=(n,o,t=!0)=>{let a=n*o;return t?Math.round(a):a},pl=n=>{let o=n*(Math.PI/180),t=Math.cos(o),a=Math.sin(o);return[t,a,0,-a,t,0,0,0,1]},fl=pl(0),hl=n=>[Bt(n[0]),Bt(n[1]),er(n[2]),Bt(n[3]),Bt(n[4]),er(n[5]),Bt(n[6]),Bt(n[7]),er(n[8])],Hn=n=>!n||typeof n!="object"?n:Array.isArray(n)?n.map(Hn):Object.fromEntries(Object.entries(n).map(([o,t])=>[o,Hn(t)])),Vn=n=>n>=0&&n<2**32,He=(n,o,t)=>({type:n,contents:o&&new Uint8Array(o.flat(10)),children:t}),Le=(n,o,t,a,r)=>He(n,[qe(o),ml(t),a??[]],r),Tp=n=>{let o=512;return n.fragmented?He("ftyp",[kt("iso5"),ge(o),kt("iso5"),kt("iso6"),kt("mp41")]):He("ftyp",[kt("isom"),ge(o),kt("isom"),n.holdsAvc?kt("avc1"):[],kt("mp41")])},mr=n=>({type:"mdat",largeSize:n}),Mp=n=>({type:"free",size:n}),Uo=(n,o,t=!1)=>He("moov",null,[Fp(o,n),...n.map(a=>Ip(a,o)),t?df(n):null]),Fp=(n,o)=>{let t=Pt(Math.max(0,...o.filter(s=>s.samples.length>0).map(s=>{const l=$r(s.samples);return l.presentationTimestamp+l.duration})),hr),a=Math.max(...o.map(s=>s.id))+1,r=!Vn(n)||!Vn(t),i=r?cn:ge;return Le("mvhd",+r,0,[i(n),i(n),ge(hr),i(t),Bt(1),Pr(1),Array(10).fill(0),hl(fl),Array(24).fill(0),ge(a)])},Ip=(n,o)=>He("trak",null,[Bp(n,o),Rp(n,o)]),Bp=(n,o)=>{let t=$r(n.samples),a=Pt(t?t.presentationTimestamp+t.duration:0,hr),r=!Vn(o)||!Vn(a),i=r?cn:ge,s;return n.info.type==="video"?s=typeof n.info.rotation=="number"?pl(n.info.rotation):n.info.rotation:s=fl,Le("tkhd",+r,3,[i(o),i(o),ge(n.id),ge(0),i(a),Array(8).fill(0),ze(0),ze(0),Pr(n.info.type==="audio"?1:0),ze(0),hl(s),Bt(n.info.type==="video"?n.info.width:0),Bt(n.info.type==="video"?n.info.height:0)])},Rp=(n,o)=>He("mdia",null,[Pp(n,o),$p(n.info.type==="video"?"vide":"soun"),zp(n)]),Pp=(n,o)=>{let t=$r(n.samples),a=Pt(t?t.presentationTimestamp+t.duration:0,n.timescale),r=!Vn(o)||!Vn(a),i=r?cn:ge;return Le("mdhd",+r,0,[i(o),i(o),ge(n.timescale),i(a),ze(21956),ze(0)])},$p=n=>Le("hdlr",0,0,[kt("mhlr"),kt(n),ge(0),ge(0),ge(0),kt("mp4-muxer-hdlr",!0)]),zp=n=>He("minf",null,[n.info.type==="video"?Ap():Dp(),Up(),Wp(n)]),Ap=()=>Le("vmhd",0,1,[ze(0),ze(0),ze(0),ze(0)]),Dp=()=>Le("smhd",0,0,[ze(0),ze(0)]),Up=()=>He("dinf",null,[Op()]),Op=()=>Le("dref",0,0,[ge(1)],[Lp()]),Lp=()=>Le("url ",0,1),Wp=n=>{const o=n.compositionTimeOffsetTable.length>1||n.compositionTimeOffsetTable.some(t=>t.sampleCompositionTimeOffset!==0);return He("stbl",null,[jp(n),of(n),af(n),rf(n),sf(n),lf(n),o?cf(n):null])},jp=n=>Le("stsd",0,0,[ge(1)],[n.info.type==="video"?Xp(wf[n.info.codec],n):ef(xf[n.info.codec],n)]),Xp=(n,o)=>He(n,[Array(6).fill(0),ze(1),ze(0),ze(0),Array(12).fill(0),ze(o.info.width),ze(o.info.height),ge(4718592),ge(4718592),ge(0),ze(1),Array(32).fill(0),ze(24),Np(65535)],[kf[o.info.codec](o),o.info.decoderConfig.colorSpace?Hp(o):null]),Zp={bt709:1,bt470bg:5,smpte170m:6},Yp={bt709:1,smpte170m:6,"iec61966-2-1":13},Gp={rgb:0,bt709:1,bt470bg:5,smpte170m:6},Hp=n=>He("colr",[kt("nclx"),ze(Zp[n.info.decoderConfig.colorSpace.primaries]),ze(Yp[n.info.decoderConfig.colorSpace.transfer]),ze(Gp[n.info.decoderConfig.colorSpace.matrix]),qe((n.info.decoderConfig.colorSpace.fullRange?1:0)<<7)]),Jp=n=>n.info.decoderConfig&&He("avcC",[...new Uint8Array(n.info.decoderConfig.description)]),qp=n=>n.info.decoderConfig&&He("hvcC",[...new Uint8Array(n.info.decoderConfig.description)]),Kp=n=>{if(!n.info.decoderConfig)return null;let o=n.info.decoderConfig;if(!o.colorSpace)throw new Error("'colorSpace' is required in the decoder config for VP9.");let t=o.codec.split("."),a=Number(t[1]),r=Number(t[2]),l=(Number(t[3])<<4)+(0<<1)+Number(o.colorSpace.fullRange);return Le("vpcC",1,0,[qe(a),qe(r),qe(l),qe(2),qe(2),qe(2),ze(0)])},Qp=()=>{let t=(1<<7)+1;return He("av1C",[t,0,0,0])},ef=(n,o)=>He(n,[Array(6).fill(0),ze(1),ze(0),ze(0),ge(0),ze(o.info.numberOfChannels),ze(16),ze(0),ze(0),Bt(o.info.sampleRate)],[Sf[o.info.codec](o)]),tf=n=>{let o=new Uint8Array(n.info.decoderConfig.description);return Le("esds",0,0,[ge(58753152),qe(32+o.byteLength),ze(1),qe(0),ge(75530368),qe(18+o.byteLength),qe(64),qe(21),ml(0),ge(130071),ge(130071),ge(92307584),qe(o.byteLength),...o,ge(109084800),qe(1),qe(2)])},nf=n=>{var r;let o=3840,t=0;const a=(r=n.info.decoderConfig)==null?void 0:r.description;if(a){if(a.byteLength<18)throw new TypeError("Invalid decoder description provided for Opus; must be at least 18 bytes long.");const i=ArrayBuffer.isView(a)?new DataView(a.buffer,a.byteOffset,a.byteLength):new DataView(a);o=i.getUint16(10,!0),t=i.getInt16(14,!0)}return He("dOps",[qe(0),qe(n.info.numberOfChannels),ze(o),ge(n.info.sampleRate),Pr(t),qe(0)])},of=n=>Le("stts",0,0,[ge(n.timeToSampleTable.length),n.timeToSampleTable.map(o=>[ge(o.sampleCount),ge(o.sampleDelta)])]),af=n=>{if(n.samples.every(t=>t.type==="key"))return null;let o=[...n.samples.entries()].filter(([,t])=>t.type==="key");return Le("stss",0,0,[ge(o.length),o.map(([t])=>ge(t+1))])},rf=n=>Le("stsc",0,0,[ge(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(o=>[ge(o.firstChunk),ge(o.samplesPerChunk),ge(1)])]),sf=n=>Le("stsz",0,0,[ge(0),ge(n.samples.length),n.samples.map(o=>ge(o.size))]),lf=n=>n.finalizedChunks.length>0&&Ko(n.finalizedChunks).offset>=2**32?Le("co64",0,0,[ge(n.finalizedChunks.length),n.finalizedChunks.map(o=>cn(o.offset))]):Le("stco",0,0,[ge(n.finalizedChunks.length),n.finalizedChunks.map(o=>ge(o.offset))]),cf=n=>Le("ctts",0,0,[ge(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(o=>[ge(o.sampleCount),ge(o.sampleCompositionTimeOffset)])]),df=n=>He("mvex",null,n.map(uf)),uf=n=>Le("trex",0,0,[ge(n.id),ge(1),ge(0),ge(0),ge(0)]),rs=(n,o)=>He("moof",null,[mf(n),...o.map(pf)]),mf=n=>Le("mfhd",0,0,[ge(n)]),vl=n=>{let o=0,t=0,a=0,r=0,i=n.type==="delta";return t|=+i,i?o|=1:o|=2,o<<24|t<<16|a<<8|r},pf=n=>He("traf",null,[ff(n),hf(n),vf(n)]),ff=n=>{let o=0;o|=8,o|=16,o|=32,o|=131072;let t=n.currentChunk.samples[1]??n.currentChunk.samples[0],a={duration:t.timescaleUnitsToNextSample,size:t.size,flags:vl(t)};return Le("tfhd",0,o,[ge(n.id),ge(a.duration),ge(a.size),ge(a.flags)])},hf=n=>Le("tfdt",1,0,[cn(Pt(n.currentChunk.startTimestamp,n.timescale))]),vf=n=>{let o=n.currentChunk.samples.map(v=>v.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(v=>v.size),a=n.currentChunk.samples.map(vl),r=n.currentChunk.samples.map(v=>Pt(v.presentationTimestamp-v.decodeTimestamp,n.timescale)),i=new Set(o),s=new Set(t),l=new Set(a),c=new Set(r),d=l.size===2&&a[0]!==a[1],u=i.size>1,p=s.size>1,m=!d&&l.size>1,h=c.size>1||[...c].some(v=>v!==0),g=0;return g|=1,g|=4*+d,g|=256*+u,g|=512*+p,g|=1024*+m,g|=2048*+h,Le("trun",1,g,[ge(n.currentChunk.samples.length),ge(n.currentChunk.offset-n.currentChunk.moofOffset||0),d?ge(a[0]):[],n.currentChunk.samples.map((v,x)=>[u?ge(o[x]):[],p?ge(t[x]):[],m?ge(a[x]):[],h?_p(r[x]):[]])])},gf=n=>He("mfra",null,[...n.map(yf),bf()]),yf=(n,o)=>Le("tfra",1,0,[ge(n.id),ge(63),ge(n.finalizedChunks.length),n.finalizedChunks.map(a=>[cn(Pt(a.startTimestamp,n.timescale)),cn(a.moofOffset),ge(o+1),ge(1),ge(1)])]),bf=()=>Le("mfro",0,0,[ge(0)]),wf={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},kf={avc:Jp,hevc:qp,vp9:Kp,av1:Qp},xf={aac:"mp4a",opus:"Opus"},Sf={aac:tf,opus:nf},fa=class{},gl=class extends fa{constructor(){super(...arguments),this.buffer=null}},yl=class extends fa{constructor(n){if(super(),this.options=n,typeof n!="object")throw new TypeError("StreamTarget requires an options object to be passed to its constructor.");if(n.onData){if(typeof n.onData!="function")throw new TypeError("options.onData, when provided, must be a function.");if(n.onData.length<2)throw new TypeError("options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.")}if(n.chunked!==void 0&&typeof n.chunked!="boolean")throw new TypeError("options.chunked, when provided, must be a boolean.");if(n.chunkSize!==void 0&&(!Number.isInteger(n.chunkSize)||n.chunkSize<1024))throw new TypeError("options.chunkSize, when provided, must be an integer and not smaller than 1024.")}},Ef=class extends fa{constructor(n,o){if(super(),this.stream=n,this.options=o,!(n instanceof FileSystemWritableFileStream))throw new TypeError("FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.");if(o!==void 0&&typeof o!="object")throw new TypeError("FileSystemWritableFileStreamTarget's options, when provided, must be an object.");if(o&&o.chunkSize!==void 0&&(!Number.isInteger(o.chunkSize)||o.chunkSize<=0))throw new TypeError("options.chunkSize, when provided, must be a positive integer")}},Qt,kn,bl=class{constructor(){this.pos=0,Fe(this,Qt,new Uint8Array(8)),Fe(this,kn,new DataView(z(this,Qt).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){z(this,kn).setUint32(0,n,!1),this.write(z(this,Qt).subarray(0,4))}writeU64(n){z(this,kn).setUint32(0,Math.floor(n/2**32),!1),z(this,kn).setUint32(4,n,!1),this.write(z(this,Qt).subarray(0,8))}writeAscii(n){for(let o=0;o<n.length;o++)z(this,kn).setUint8(o%8,n.charCodeAt(o)),o%8===7&&this.write(z(this,Qt));n.length%8!==0&&this.write(z(this,Qt).subarray(0,n.length%8))}writeBox(n){if(this.offsets.set(n,this.pos),n.contents&&!n.children)this.writeBoxHeader(n,n.size??n.contents.byteLength+8),this.write(n.contents);else{let o=this.pos;if(this.writeBoxHeader(n,0),n.contents&&this.write(n.contents),n.children)for(let r of n.children)r&&this.writeBox(r);let t=this.pos,a=n.size??t-o;this.seek(o),this.writeBoxHeader(n,a),this.seek(t)}}writeBoxHeader(n,o){this.writeU32(n.largeSize?1:o),this.writeAscii(n.type),n.largeSize&&this.writeU64(o)}measureBoxHeader(n){return 8+(n.largeSize?8:0)}patchBox(n){let o=this.pos;this.seek(this.offsets.get(n)),this.writeBox(n),this.seek(o)}measureBox(n){if(n.contents&&!n.children)return this.measureBoxHeader(n)+n.contents.byteLength;{let o=this.measureBoxHeader(n);if(n.contents&&(o+=n.contents.byteLength),n.children)for(let t of n.children)t&&(o+=this.measureBox(t));return o}}};Qt=new WeakMap;kn=new WeakMap;var Oo,sn,ro,jn,Lo,pr,Cf=class extends bl{constructor(n){super(),Fe(this,Lo),Fe(this,Oo,void 0),Fe(this,sn,new ArrayBuffer(2**16)),Fe(this,ro,new Uint8Array(z(this,sn))),Fe(this,jn,0),tt(this,Oo,n)}write(n){Pe(this,Lo,pr).call(this,this.pos+n.byteLength),z(this,ro).set(n,this.pos),this.pos+=n.byteLength,tt(this,jn,Math.max(z(this,jn),this.pos))}finalize(){Pe(this,Lo,pr).call(this,this.pos),z(this,Oo).buffer=z(this,sn).slice(0,Math.max(z(this,jn),this.pos))}};Oo=new WeakMap;sn=new WeakMap;ro=new WeakMap;jn=new WeakMap;Lo=new WeakSet;pr=function(n){let o=z(this,sn).byteLength;for(;o<n;)o*=2;if(o===z(this,sn).byteLength)return;let t=new ArrayBuffer(o),a=new Uint8Array(t);a.set(z(this,ro),0),tt(this,sn,t),tt(this,ro,a)};var Vf=2**24,Nf=2,Jn,en,Xn,Lt,bt,Qo,fr,zr,wl,Ar,kl,qn,ea,Dr=class extends bl{constructor(n){var o,t;super(),Fe(this,Qo),Fe(this,zr),Fe(this,Ar),Fe(this,qn),Fe(this,Jn,void 0),Fe(this,en,[]),Fe(this,Xn,void 0),Fe(this,Lt,void 0),Fe(this,bt,[]),tt(this,Jn,n),tt(this,Xn,((o=n.options)==null?void 0:o.chunked)??!1),tt(this,Lt,((t=n.options)==null?void 0:t.chunkSize)??Vf)}write(n){z(this,en).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){var t,a;if(z(this,en).length===0)return;let n=[],o=[...z(this,en)].sort((r,i)=>r.start-i.start);n.push({start:o[0].start,size:o[0].data.byteLength});for(let r=1;r<o.length;r++){let i=n[n.length-1],s=o[r];s.start<=i.start+i.size?i.size=Math.max(i.size,s.start+s.data.byteLength-i.start):n.push({start:s.start,size:s.data.byteLength})}for(let r of n){r.data=new Uint8Array(r.size);for(let i of z(this,en))r.start<=i.start&&i.start<r.start+r.size&&r.data.set(i.data,i.start-r.start);z(this,Xn)?(Pe(this,Qo,fr).call(this,r.data,r.start),Pe(this,qn,ea).call(this)):(a=(t=z(this,Jn).options).onData)==null||a.call(t,r.data,r.start)}z(this,en).length=0}finalize(){z(this,Xn)&&Pe(this,qn,ea).call(this,!0)}};Jn=new WeakMap;en=new WeakMap;Xn=new WeakMap;Lt=new WeakMap;bt=new WeakMap;Qo=new WeakSet;fr=function(n,o){let t=z(this,bt).findIndex(l=>l.start<=o&&o<l.start+z(this,Lt));t===-1&&(t=Pe(this,Ar,kl).call(this,o));let a=z(this,bt)[t],r=o-a.start,i=n.subarray(0,Math.min(z(this,Lt)-r,n.byteLength));a.data.set(i,r);let s={start:r,end:r+i.byteLength};if(Pe(this,zr,wl).call(this,a,s),a.written[0].start===0&&a.written[0].end===z(this,Lt)&&(a.shouldFlush=!0),z(this,bt).length>Nf){for(let l=0;l<z(this,bt).length-1;l++)z(this,bt)[l].shouldFlush=!0;Pe(this,qn,ea).call(this)}i.byteLength<n.byteLength&&Pe(this,Qo,fr).call(this,n.subarray(i.byteLength),o+i.byteLength)};zr=new WeakSet;wl=function(n,o){let t=0,a=n.written.length-1,r=-1;for(;t<=a;){let i=Math.floor(t+(a-t+1)/2);n.written[i].start<=o.start?(t=i+1,r=i):a=i-1}for(n.written.splice(r+1,0,o),(r===-1||n.written[r].end<o.start)&&r++;r<n.written.length-1&&n.written[r].end>=n.written[r+1].start;)n.written[r].end=Math.max(n.written[r].end,n.written[r+1].end),n.written.splice(r+1,1)};Ar=new WeakSet;kl=function(n){let t={start:Math.floor(n/z(this,Lt))*z(this,Lt),data:new Uint8Array(z(this,Lt)),written:[],shouldFlush:!1};return z(this,bt).push(t),z(this,bt).sort((a,r)=>a.start-r.start),z(this,bt).indexOf(t)};qn=new WeakSet;ea=function(n=!1){var o,t;for(let a=0;a<z(this,bt).length;a++){let r=z(this,bt)[a];if(!(!r.shouldFlush&&!n)){for(let i of r.written)(t=(o=z(this,Jn).options).onData)==null||t.call(o,r.data.subarray(i.start,i.end),r.start+i.start);z(this,bt).splice(a--,1)}}};var _f=class extends Dr{constructor(n){var o;super(new yl({onData:(t,a)=>n.stream.write({type:"write",data:t,position:a}),chunked:!0,chunkSize:(o=n.options)==null?void 0:o.chunkSize}))}},hr=1e3,Tf=["avc","hevc","vp9","av1"],Mf=["aac","opus"],Ff=2082844800,If=["strict","offset","cross-track-offset"],Ee,Ve,ta,gt,at,et,xn,Sn,Ur,tn,nn,Kn,vr,xl,gr,Sl,Or,El,yr,Cl,Lr,Vl,Wo,br,It,Ot,Wr,Nl,Qn,na,oa,jr,Nn,uo,jo,wr,Bf=class{constructor(n){if(Fe(this,vr),Fe(this,gr),Fe(this,Or),Fe(this,yr),Fe(this,Lr),Fe(this,Wo),Fe(this,It),Fe(this,Wr),Fe(this,Qn),Fe(this,oa),Fe(this,Nn),Fe(this,jo),Fe(this,Ee,void 0),Fe(this,Ve,void 0),Fe(this,ta,void 0),Fe(this,gt,void 0),Fe(this,at,null),Fe(this,et,null),Fe(this,xn,Math.floor(Date.now()/1e3)+Ff),Fe(this,Sn,[]),Fe(this,Ur,1),Fe(this,tn,[]),Fe(this,nn,[]),Fe(this,Kn,!1),Pe(this,vr,xl).call(this,n),n.video=Hn(n.video),n.audio=Hn(n.audio),n.fastStart=Hn(n.fastStart),this.target=n.target,tt(this,Ee,{firstTimestampBehavior:"strict",...n}),n.target instanceof gl)tt(this,Ve,new Cf(n.target));else if(n.target instanceof yl)tt(this,Ve,new Dr(n.target));else if(n.target instanceof Ef)tt(this,Ve,new _f(n.target));else throw new Error(`Invalid target: ${n.target}`);Pe(this,yr,Cl).call(this),Pe(this,gr,Sl).call(this)}addVideoChunk(n,o,t,a){if(!(n instanceof EncodedVideoChunk))throw new TypeError("addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.");if(o&&typeof o!="object")throw new TypeError("addVideoChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.");if(a!==void 0&&!Number.isFinite(a))throw new TypeError("addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.");let r=new Uint8Array(n.byteLength);n.copyTo(r),this.addVideoChunkRaw(r,n.type,t??n.timestamp,n.duration,o,a)}addVideoChunkRaw(n,o,t,a,r,i){if(!(n instanceof Uint8Array))throw new TypeError("addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.");if(o!=="key"&&o!=="delta")throw new TypeError("addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(a)||a<0)throw new TypeError("addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addVideoChunkRaw's fifth argument (meta), when provided, must be an object.");if(i!==void 0&&!Number.isFinite(i))throw new TypeError("addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.");if(Pe(this,jo,wr).call(this),!z(this,Ee).video)throw new Error("No video track declared.");if(typeof z(this,Ee).fastStart=="object"&&z(this,at).samples.length===z(this,Ee).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${z(this,Ee).fastStart.expectedVideoChunks}).`);let s=Pe(this,Wo,br).call(this,z(this,at),n,o,t,a,r,i);if(z(this,Ee).fastStart==="fragmented"&&z(this,et)){for(;z(this,nn).length>0&&z(this,nn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=z(this,nn).shift();Pe(this,It,Ot).call(this,z(this,et),l)}s.decodeTimestamp<=z(this,et).lastDecodeTimestamp?Pe(this,It,Ot).call(this,z(this,at),s):z(this,tn).push(s)}else Pe(this,It,Ot).call(this,z(this,at),s)}addAudioChunk(n,o,t){if(!(n instanceof EncodedAudioChunk))throw new TypeError("addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.");if(o&&typeof o!="object")throw new TypeError("addAudioChunk's second argument (meta), when provided, must be an object.");if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError("addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.");let a=new Uint8Array(n.byteLength);n.copyTo(a),this.addAudioChunkRaw(a,n.type,t??n.timestamp,n.duration,o)}addAudioChunkRaw(n,o,t,a,r){if(!(n instanceof Uint8Array))throw new TypeError("addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.");if(o!=="key"&&o!=="delta")throw new TypeError("addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.");if(!Number.isFinite(t)||t<0)throw new TypeError("addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.");if(!Number.isFinite(a)||a<0)throw new TypeError("addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.");if(r&&typeof r!="object")throw new TypeError("addAudioChunkRaw's fifth argument (meta), when provided, must be an object.");if(Pe(this,jo,wr).call(this),!z(this,Ee).audio)throw new Error("No audio track declared.");if(typeof z(this,Ee).fastStart=="object"&&z(this,et).samples.length===z(this,Ee).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${z(this,Ee).fastStart.expectedAudioChunks}).`);let i=Pe(this,Wo,br).call(this,z(this,et),n,o,t,a,r);if(z(this,Ee).fastStart==="fragmented"&&z(this,at)){for(;z(this,tn).length>0&&z(this,tn)[0].decodeTimestamp<=i.decodeTimestamp;){let s=z(this,tn).shift();Pe(this,It,Ot).call(this,z(this,at),s)}i.decodeTimestamp<=z(this,at).lastDecodeTimestamp?Pe(this,It,Ot).call(this,z(this,et),i):z(this,nn).push(i)}else Pe(this,It,Ot).call(this,z(this,et),i)}finalize(){if(z(this,Kn))throw new Error("Cannot finalize a muxer more than once.");if(z(this,Ee).fastStart==="fragmented"){for(let o of z(this,tn))Pe(this,It,Ot).call(this,z(this,at),o);for(let o of z(this,nn))Pe(this,It,Ot).call(this,z(this,et),o);Pe(this,oa,jr).call(this,!1)}else z(this,at)&&Pe(this,Qn,na).call(this,z(this,at)),z(this,et)&&Pe(this,Qn,na).call(this,z(this,et));let n=[z(this,at),z(this,et)].filter(Boolean);if(z(this,Ee).fastStart==="in-memory"){let o;for(let a=0;a<2;a++){let r=Uo(n,z(this,xn)),i=z(this,Ve).measureBox(r);o=z(this,Ve).measureBox(z(this,gt));let s=z(this,Ve).pos+i+o;for(let l of z(this,Sn)){l.offset=s;for(let{data:c}of l.samples)s+=c.byteLength,o+=c.byteLength}if(s<2**32)break;o>=2**32&&(z(this,gt).largeSize=!0)}let t=Uo(n,z(this,xn));z(this,Ve).writeBox(t),z(this,gt).size=o,z(this,Ve).writeBox(z(this,gt));for(let a of z(this,Sn))for(let r of a.samples)z(this,Ve).write(r.data),r.data=null}else if(z(this,Ee).fastStart==="fragmented"){let o=z(this,Ve).pos,t=gf(n);z(this,Ve).writeBox(t);let a=z(this,Ve).pos-o;z(this,Ve).seek(z(this,Ve).pos-4),z(this,Ve).writeU32(a)}else{let o=z(this,Ve).offsets.get(z(this,gt)),t=z(this,Ve).pos-o;z(this,gt).size=t,z(this,gt).largeSize=t>=2**32,z(this,Ve).patchBox(z(this,gt));let a=Uo(n,z(this,xn));if(typeof z(this,Ee).fastStart=="object"){z(this,Ve).seek(z(this,ta)),z(this,Ve).writeBox(a);let r=o-z(this,Ve).pos;z(this,Ve).writeBox(Mp(r))}else z(this,Ve).writeBox(a)}Pe(this,Nn,uo).call(this),z(this,Ve).finalize(),tt(this,Kn,!0)}};Ee=new WeakMap;Ve=new WeakMap;ta=new WeakMap;gt=new WeakMap;at=new WeakMap;et=new WeakMap;xn=new WeakMap;Sn=new WeakMap;Ur=new WeakMap;tn=new WeakMap;nn=new WeakMap;Kn=new WeakMap;vr=new WeakSet;xl=function(n){if(typeof n!="object")throw new TypeError("The muxer requires an options object to be passed to its constructor.");if(!(n.target instanceof fa))throw new TypeError("The target must be provided and an instance of Target.");if(n.video){if(!Tf.includes(n.video.codec))throw new TypeError(`Unsupported video codec: ${n.video.codec}`);if(!Number.isInteger(n.video.width)||n.video.width<=0)throw new TypeError(`Invalid video width: ${n.video.width}. Must be a positive integer.`);if(!Number.isInteger(n.video.height)||n.video.height<=0)throw new TypeError(`Invalid video height: ${n.video.height}. Must be a positive integer.`);const o=n.video.rotation;if(typeof o=="number"&&![0,90,180,270].includes(o))throw new TypeError(`Invalid video rotation: ${o}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(o)&&(o.length!==9||o.some(t=>typeof t!="number")))throw new TypeError(`Invalid video transformation matrix: ${o.join()}`);if(n.video.frameRate!==void 0&&(!Number.isInteger(n.video.frameRate)||n.video.frameRate<=0))throw new TypeError(`Invalid video frame rate: ${n.video.frameRate}. Must be a positive integer.`)}if(n.audio){if(!Mf.includes(n.audio.codec))throw new TypeError(`Unsupported audio codec: ${n.audio.codec}`);if(!Number.isInteger(n.audio.numberOfChannels)||n.audio.numberOfChannels<=0)throw new TypeError(`Invalid number of audio channels: ${n.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(n.audio.sampleRate)||n.audio.sampleRate<=0)throw new TypeError(`Invalid audio sample rate: ${n.audio.sampleRate}. Must be a positive integer.`)}if(n.firstTimestampBehavior&&!If.includes(n.firstTimestampBehavior))throw new TypeError(`Invalid first timestamp behavior: ${n.firstTimestampBehavior}`);if(typeof n.fastStart=="object"){if(n.video){if(n.fastStart.expectedVideoChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedVideoChunks'.");if(!Number.isInteger(n.fastStart.expectedVideoChunks)||n.fastStart.expectedVideoChunks<0)throw new TypeError("'expectedVideoChunks' must be a non-negative integer.")}if(n.audio){if(n.fastStart.expectedAudioChunks===void 0)throw new TypeError("'fastStart' is an object but is missing property 'expectedAudioChunks'.");if(!Number.isInteger(n.fastStart.expectedAudioChunks)||n.fastStart.expectedAudioChunks<0)throw new TypeError("'expectedAudioChunks' must be a non-negative integer.")}}else if(![!1,"in-memory","fragmented"].includes(n.fastStart))throw new TypeError("'fastStart' option must be false, 'in-memory', 'fragmented' or an object.");if(n.minFragmentDuration!==void 0&&(!Number.isFinite(n.minFragmentDuration)||n.minFragmentDuration<0))throw new TypeError("'minFragmentDuration' must be a non-negative number.")};gr=new WeakSet;Sl=function(){var n;if(z(this,Ve).writeBox(Tp({holdsAvc:((n=z(this,Ee).video)==null?void 0:n.codec)==="avc",fragmented:z(this,Ee).fastStart==="fragmented"})),tt(this,ta,z(this,Ve).pos),z(this,Ee).fastStart==="in-memory")tt(this,gt,mr(!1));else if(z(this,Ee).fastStart!=="fragmented"){if(typeof z(this,Ee).fastStart=="object"){let o=Pe(this,Or,El).call(this);z(this,Ve).seek(z(this,Ve).pos+o)}tt(this,gt,mr(!0)),z(this,Ve).writeBox(z(this,gt))}Pe(this,Nn,uo).call(this)};Or=new WeakSet;El=function(){if(typeof z(this,Ee).fastStart!="object")return;let n=0,o=[z(this,Ee).fastStart.expectedVideoChunks,z(this,Ee).fastStart.expectedAudioChunks];for(let t of o)t&&(n+=8*Math.ceil(2/3*t),n+=4*t,n+=12*Math.ceil(2/3*t),n+=4*t,n+=8*t);return n+=4096,n};yr=new WeakSet;Cl=function(){if(z(this,Ee).video&&tt(this,at,{id:1,info:{type:"video",codec:z(this,Ee).video.codec,width:z(this,Ee).video.width,height:z(this,Ee).video.height,rotation:z(this,Ee).video.rotation??0,decoderConfig:null},timescale:z(this,Ee).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),z(this,Ee).audio&&(tt(this,et,{id:z(this,Ee).video?2:1,info:{type:"audio",codec:z(this,Ee).audio.codec,numberOfChannels:z(this,Ee).audio.numberOfChannels,sampleRate:z(this,Ee).audio.sampleRate,decoderConfig:null},timescale:z(this,Ee).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),z(this,Ee).audio.codec==="aac")){let n=Pe(this,Lr,Vl).call(this,2,z(this,Ee).audio.sampleRate,z(this,Ee).audio.numberOfChannels);z(this,et).info.decoderConfig={codec:z(this,Ee).audio.codec,description:n,numberOfChannels:z(this,Ee).audio.numberOfChannels,sampleRate:z(this,Ee).audio.sampleRate}}};Lr=new WeakSet;Vl=function(n,o,t){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(o),i=t,s="";s+=n.toString(2).padStart(5,"0"),s+=r.toString(2).padStart(4,"0"),r===15&&(s+=o.toString(2).padStart(24,"0")),s+=i.toString(2).padStart(4,"0");let l=Math.ceil(s.length/8)*8;s=s.padEnd(l,"0");let c=new Uint8Array(s.length/8);for(let d=0;d<s.length;d+=8)c[d/8]=parseInt(s.slice(d,d+8),2);return c};Wo=new WeakSet;br=function(n,o,t,a,r,i,s){let l=a/1e6,c=(a-(s??0))/1e6,d=r/1e6,u=Pe(this,Wr,Nl).call(this,l,c,n);return l=u.presentationTimestamp,c=u.decodeTimestamp,i!=null&&i.decoderConfig&&(n.info.decoderConfig===null?n.info.decoderConfig=i.decoderConfig:Object.assign(n.info.decoderConfig,i.decoderConfig)),{presentationTimestamp:l,decodeTimestamp:c,duration:d,data:o,size:o.byteLength,type:t,timescaleUnitsToNextSample:Pt(d,n.timescale)}};It=new WeakSet;Ot=function(n,o){z(this,Ee).fastStart!=="fragmented"&&n.samples.push(o);const t=Pt(o.presentationTimestamp-o.decodeTimestamp,n.timescale);if(n.lastTimescaleUnits!==null){let r=Pt(o.decodeTimestamp,n.timescale,!1),i=Math.round(r-n.lastTimescaleUnits);if(n.lastTimescaleUnits+=i,n.lastSample.timescaleUnitsToNextSample=i,z(this,Ee).fastStart!=="fragmented"){let s=Ko(n.timeToSampleTable);s.sampleCount===1?(s.sampleDelta=i,s.sampleCount++):s.sampleDelta===i?s.sampleCount++:(s.sampleCount--,n.timeToSampleTable.push({sampleCount:2,sampleDelta:i}));const l=Ko(n.compositionTimeOffsetTable);l.sampleCompositionTimeOffset===t?l.sampleCount++:n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t})}}else n.lastTimescaleUnits=0,z(this,Ee).fastStart!=="fragmented"&&(n.timeToSampleTable.push({sampleCount:1,sampleDelta:Pt(o.duration,n.timescale)}),n.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:t}));n.lastSample=o;let a=!1;if(!n.currentChunk)a=!0;else{let r=o.presentationTimestamp-n.currentChunk.startTimestamp;if(z(this,Ee).fastStart==="fragmented"){let i=z(this,at)??z(this,et);const s=z(this,Ee).minFragmentDuration??1;n===i&&o.type==="key"&&r>=s&&(a=!0,Pe(this,oa,jr).call(this))}else a=r>=.5}a&&(n.currentChunk&&Pe(this,Qn,na).call(this,n),n.currentChunk={startTimestamp:o.presentationTimestamp,samples:[]}),n.currentChunk.samples.push(o)};Wr=new WeakSet;Nl=function(n,o,t){var s,l;const a=z(this,Ee).firstTimestampBehavior==="strict",r=t.lastDecodeTimestamp===-1;if(a&&r&&o!==0)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${o}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want.
|
|
19
|
-
|
|
20
|
-
If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.
|
|
21
|
-
`);if(z(this,Ee).firstTimestampBehavior==="offset"||z(this,Ee).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=o);let c;z(this,Ee).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=z(this,at))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=z(this,et))==null?void 0:l.firstDecodeTimestamp)??1/0),o-=c,n-=c}if(o<t.lastDecodeTimestamp)throw new Error(`Timestamps must be monotonically increasing (DTS went from ${t.lastDecodeTimestamp*1e6} to ${o*1e6}).`);return t.lastDecodeTimestamp=o,{presentationTimestamp:n,decodeTimestamp:o}};Qn=new WeakSet;na=function(n){if(z(this,Ee).fastStart==="fragmented")throw new Error("Can't finalize individual chunks if 'fastStart' is set to 'fragmented'.");if(n.currentChunk){if(n.finalizedChunks.push(n.currentChunk),z(this,Sn).push(n.currentChunk),(n.compactlyCodedChunkTable.length===0||Ko(n.compactlyCodedChunkTable).samplesPerChunk!==n.currentChunk.samples.length)&&n.compactlyCodedChunkTable.push({firstChunk:n.finalizedChunks.length,samplesPerChunk:n.currentChunk.samples.length}),z(this,Ee).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=z(this,Ve).pos;for(let o of n.currentChunk.samples)z(this,Ve).write(o.data),o.data=null;Pe(this,Nn,uo).call(this)}};oa=new WeakSet;jr=function(n=!0){if(z(this,Ee).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let o=[z(this,at),z(this,et)].filter(l=>l&&l.currentChunk);if(o.length===0)return;let t=Vp(this,Ur)._++;if(t===1){let l=Uo(o,z(this,xn),!0);z(this,Ve).writeBox(l)}let a=z(this,Ve).pos,r=rs(t,o);z(this,Ve).writeBox(r);{let l=mr(!1),c=0;for(let u of o)for(let p of u.currentChunk.samples)c+=p.size;let d=z(this,Ve).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=z(this,Ve).measureBox(l)+c),l.size=d,z(this,Ve).writeBox(l)}for(let l of o){l.currentChunk.offset=z(this,Ve).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)z(this,Ve).write(c.data),c.data=null}let i=z(this,Ve).pos;z(this,Ve).seek(z(this,Ve).offsets.get(r));let s=rs(t,o);z(this,Ve).writeBox(s),z(this,Ve).seek(i);for(let l of o)l.finalizedChunks.push(l.currentChunk),z(this,Sn).push(l.currentChunk),l.currentChunk=null;n&&Pe(this,Nn,uo).call(this)};Nn=new WeakSet;uo=function(){z(this,Ve)instanceof Dr&&z(this,Ve).flush()};jo=new WeakSet;wr=function(){if(z(this,Kn))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};const io=30;class so extends Error{constructor({message:t="",code:a=""},...r){super(t,...r);O(this,"message");O(this,"code");this.code=a,this.message=t}}class Wt extends so{}class Ge extends so{}class is extends so{}function Rf(n,o=io){if(o<1)throw new Ge({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n*o)}function En(n,o=io){if(o<1)throw new Ge({code:"invalidArgument",message:"FPS must be greater or equal to 1"});return Math.round(n/o*1e3)}class de{constructor(o=0){O(this,"time");this.time=Math.round(o)}get millis(){return this.time}set millis(o){this.time=Math.round(o)}get frames(){return Rf(this.millis/1e3)}set frames(o){this.millis=En(o)}get seconds(){return this.millis/1e3}set seconds(o){this.millis=o*1e3}addMillis(o){return this.millis=this.millis+o,this}addFrames(o){const t=En(o);return this.millis=this.millis+t,this}add(o){return new de(o.millis+this.millis)}subtract(o){return new de(this.millis-o.millis)}static fromSeconds(o){const t=new de;return t.millis=o*1e3,t}static fromFrames(o,t){const a=new de;return a.millis=En(o,t),a}copy(){return new de(this.millis)}toJSON(){return this.millis}static fromJSON(o){return new de(o)}}function ss(n,o){return[n.slice(0,o),n.slice(o)].filter(t=>t.length>0)}function Xo(n,o){return o?Math.floor(Math.random()*(o-n+1)+n):n}function Pf(n,o,t){t<0&&(t=0);const a=n[o];n.splice(o,1),n.splice(t,0,a)}function ls(n){return typeof n!="function"?!1:/^class\s/.test(Function.prototype.toString.call(n))}async function $f(n,o="untitled"){const t=document.createElement("a");if(document.head.appendChild(t),t.download=o,typeof n=="string"&&n.startsWith("data:image/svg+xml;base64,")){const a=n.split(",")[1],r=atob(a),i=new Array(r.length);for(let c=0;c<r.length;c++)i[c]=r.charCodeAt(c);const s=new Uint8Array(i),l=new Blob([s],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.download=o.split(".")[0]+".svg"}else typeof n=="string"?t.href=n:t.href=URL.createObjectURL(n);t.click(),t.remove()}function cs(n){return`${n.hours.toString().padStart(2,"0")}:${n.minutes.toString().padStart(2,"0")}:${n.seconds.toString().padStart(2,"0")},`+n.milliseconds.toString().padStart(3,"0")}function ds(n){const o=new Date(1970,0,1);return o.setSeconds(n),o.setMilliseconds(Math.round(n%1*1e3)),{hours:o.getHours(),minutes:o.getMinutes(),seconds:o.getSeconds(),milliseconds:o.getMilliseconds()}}class Io{constructor(o){O(this,"words",[]);o&&(this.words=o)}get duration(){return this.stop.subtract(this.start)}get text(){return this.words.map(({text:o})=>o).join(" ")}get start(){var o;return((o=this.words.at(0))==null?void 0:o.start)??new de}get stop(){var o;return((o=this.words.at(-1))==null?void 0:o.stop)??new de}}var kr=(n=>(n.en="en",n.de="de",n))(kr||{});class us{constructor(o,t,a,r){O(this,"id",crypto.randomUUID());O(this,"text");O(this,"start");O(this,"stop");O(this,"confidence");this.text=o,this.start=new de(t),this.stop=new de(a),this.confidence=r}get duration(){return this.stop.subtract(this.start)}}class an{constructor(o=[],t=kr.en){O(this,"id",crypto.randomUUID());O(this,"language",kr.en);O(this,"groups",[]);this.groups=o,this.language=t}get text(){return this.groups.map(({text:o})=>o).join(" ")}get words(){return this.groups.flatMap(({words:o})=>o)}*iter({count:o,duration:t,length:a}){for(const r of this.groups){let i;for(const[s,l]of r.words.entries())i&&(o&&i.words.length>=Xo(...o)?(yield i,i=void 0):t&&(i==null?void 0:i.duration.seconds)>=Xo(...t)?(yield i,i=void 0):a&&i.text.length>=Xo(...a)&&(yield i,i=void 0)),i?i.words.push(l):i=new Io([l]),s==r.words.length-1&&(yield i)}}optimize(){const o=this.groups.flatMap(t=>t.words);for(let t=0;t<o.length-1;t++){const a=o[t],r=o[t+1];r.start.millis-a.stop.millis<0?r.start.millis=a.stop.millis+1:a.stop.millis=r.start.millis-1}return this}toSRT(o={}){let t=1,a="";for(const r of this.iter(o)){const i=ds(r.start.seconds),s=ds(r.stop.seconds);a+=`${t}
|
|
22
|
-
`+cs(i)+" --> "+cs(s)+`
|
|
23
|
-
${r.text}
|
|
24
|
-
|
|
25
|
-
`,t+=1}return{text:a,blob:new Blob([a],{type:"text/plain;charset=utf8"})}}toJSON(){return this.groups.map(o=>o.words.map(t=>({token:t.text,start:t.start.millis,stop:t.stop.millis})))}slice(o,t=!0){let a=0;const r=[];for(const i of this.groups)for(const s of i.words)if(r.length==0&&t&&(a=s.start.millis),r.push(new us(s.text,s.start.millis-a,s.stop.millis-a)),r.length==o)return new an([new Io(r)]);return new an([new Io(r)])}copy(){return an.fromJSON(this.toJSON())}static fromJSON(o){const t=new an;for(const a of o){const r=new Io;for(const i of a)r.words.push(new us(i.token,i.start,i.stop));t.groups.push(r)}return t}static async from(o,t){const a=await fetch(o,t);if(!a.ok)throw new Wt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});return an.fromJSON(await a.json())}}function Zo(n,o,t){return n+(o-n)*t}function zf(n,o,t){const a=Number.parseInt(n.slice(1),16),r=Number.parseInt(o.slice(1),16),i=a>>16&255,s=a>>8&255,l=a&255,c=r>>16&255,d=r>>8&255,u=r&255,p=Math.round(Zo(i,c,t)),m=Math.round(Zo(s,d,t)),h=Math.round(Zo(l,u,t));return`#${((1<<24)+(p<<16)+(m<<8)+h).toString(16).slice(1)}`}const Af={linear:n=>n,easeIn:n=>n*n,easeOut:n=>n*(2-n),easeInOut:n=>n<.5?2*n*n:-1+(4-2*n)*n};class Se{constructor(o,t,a={}){O(this,"input");O(this,"output");O(this,"options");if(o.length!==t.length)throw new Ge({code:"invalidKeyframes",message:"inputRange and outputRange must have the same length"});this.input=o.map(r=>En(r)),this.output=t,this.options={extrapolate:"clamp",easing:"linear",type:"number",...JSON.parse(JSON.stringify(a))}}normalize(o){const{input:t}=this;if(o<t[0])return this.options.extrapolate==="clamp"?{t:0,segment:0}:{t:(o-t[0])/(t[1]-t[0]),segment:0};if(o>t[t.length-1])return this.options.extrapolate==="clamp"?{t:1,segment:t.length-2}:{t:(o-t[t.length-2])/(t[t.length-1]-t[t.length-2]),segment:t.length-2};for(let a=0;a<t.length-1;a++){const r=t[a],i=t[a+1];if(o>=r&&o<=i)return{t:(o-r)/(i-r),segment:a}}return{t:0,segment:0}}interpolate(o,t){const a=this.output[t],r=this.output[t+1],i=Af[this.options.easing](o);if(typeof a=="number"&&typeof r=="number")return Zo(a,r,i);if(typeof a=="string"&&typeof r=="string")return zf(a,r,i);if(this.output.length==1)return this.output[0];throw new Ge({code:"invalidKeyframes",message:"Unsupported output range types"})}value(o){const{t,segment:a}=this.normalize(typeof o=="number"?o:o.millis);return this.interpolate(t,a)}push(o,t){return this.input.push(En(o)),this.output.push(t),this}toJSON(){return this}static fromJSON(o){const t=new Se([],[]);return Object.assign(t,o),t}}class xt{constructor(){O(this,"id",crypto.randomUUID())}toJSON(){const o={};return(this.constructor.__serializableProperties||[]).forEach(({propertyKey:t,serializer:a})=>{const r=this[t];a&&r instanceof a?o[t]=r.toJSON():o[t]=r}),o}static fromJSON(o){const t=new this;return(this.__serializableProperties||[]).forEach(({propertyKey:a,serializer:r})=>{if(o.hasOwnProperty(a))if(r){const i=r.fromJSON(o[a]);t[a]=i}else t[a]=o[a]}),t}}function he(n){return function(o,t){o.constructor.__serializableProperties||(o.constructor.__serializableProperties=[]),o.constructor.__serializableProperties.push({propertyKey:t,serializer:n})}}function mo(n){return class extends n{constructor(){super(...arguments);O(this,"_handlers",{})}on(t,a){if(typeof a!="function")throw new Error("The callback of an event listener needs to be a function.");const r=crypto.randomUUID();return this._handlers[t]?this._handlers[t][r]=a:this._handlers[t]={[r]:a},r}off(t,...a){if(t){if(t==="*"){this._handlers={};return}for(const r of Object.values(this._handlers))t in r&&delete r[t];for(const r of a)this.off(r)}}trigger(t,a){var i,s;const r=new CustomEvent(t,{detail:a});Object.defineProperty(r,"currentTarget",{writable:!1,value:this});for(const l in this._handlers[t]??{})(i=this._handlers[t])==null||i[l](r);for(const l in this._handlers["*"]??{})(s=this._handlers["*"])==null||s[l](r)}bubble(t){return this.on("*",a=>{t.trigger(a.type,a.detail)})}resolve(t){return(a,r)=>{this.on("error",r),this.on(t,a)}}}}function Xr(n,o,t=0){if(!(n instanceof De.Container||n instanceof De.Filter||t==3))for(const a in n){const r=n[a];a&&(r instanceof Se&&(n[a]=r.value(o)),r!=null&&typeof r=="object"&&Object.keys(r).length&&Xr(r,o,t+1))}}var Df=Object.defineProperty,ha=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Df(o,t,r),r};const po=class _l extends mo(xt){constructor(t={}){super();O(this,"_name");O(this,"_start",new de);O(this,"_stop",de.fromSeconds(16));O(this,"type","base");O(this,"source");O(this,"view",new De.Container);O(this,"createdAt",new Date);O(this,"disabled",!1);O(this,"state","IDLE");O(this,"track");Object.assign(this,t)}get name(){var t;return this._name??((t=this.source)==null?void 0:t.name)}set name(t){this._name=t}get start(){return this._start}get stop(){return this._stop}async connect(t){this.state="ATTACHED",this.track=t,this.trigger("attach",void 0)}set start(t){typeof t=="number"?this.start.frames=t:this._start=t,this.start.millis>=this.stop.millis&&(this.stop.millis=this.start.millis+1),this.trigger("frame",this.start.frames)}set stop(t){typeof t=="number"?this.stop.frames=t:this._stop=t,this.stop.millis<=this.start.millis&&(this.start.millis=this.stop.millis-1),this.trigger("frame",this.stop.frames)}offsetBy(t){return typeof t=="number"?(this.start.addFrames(t),this.stop.addFrames(t),this.trigger("offsetBy",de.fromFrames(t))):(this.start.addMillis(t.millis),this.stop.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}async init(){}enter(){}update(t){}exit(){}detach(){var t;return(t=this.track)==null||t.remove(this),this}async split(t){var i,s;if(t||(t=(s=(i=this.track)==null?void 0:i.composition)==null?void 0:s.frame),typeof t=="number"&&(t=de.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ge({code:"splitOutOfRange",message:"Cannot split clip at the specified time"});if(!this.track)throw new Ge({code:"trackNotAttached",message:"Track must be attached to a track"});const a=this.copy();this.stop=t.copy(),a.start=t.copy().addMillis(1),Xr(a,a.start.subtract(this.start));const r=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,r+1),a}copy(){return _l.fromJSON(JSON.parse(JSON.stringify(this)))}set(t){return t&&Object.assign(this,t),this.trigger("update",void 0),this}};ha([he()],po.prototype,"_name");ha([he(de)],po.prototype,"_start");ha([he(de)],po.prototype,"_stop");ha([he()],po.prototype,"disabled");let fo=po;var Uf=Object.defineProperty,un=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Uf(o,t,r),r};class zt extends mo(xt){constructor(){super(...arguments);O(this,"state","IDLE");O(this,"metadata");O(this,"objectURL");O(this,"duration",de.fromSeconds(16));O(this,"added",!1);O(this,"type","base");O(this,"name","");O(this,"mimeType");O(this,"externalURL");O(this,"external",!1);O(this,"file")}async createObjectURL(){return this.objectURL?this.objectURL:(this.objectURL=URL.createObjectURL(await this.getFile()),this.objectURL)}async getFile(){if(!this.file&&this.state=="LOADING"&&await new Promise(this.resolve("load")),!this.file)throw new Ge({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async loadFile(t){this.name=t.name,this.mimeType=Er(t.type),this.external=!1,this.file=t}async loadUrl(t,a){const r=await fetch(t,a);if(!(r!=null&&r.ok))throw new Wt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});const i=await r.blob();this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.file=new File([i],this.name,{type:i.type}),this.externalURL=t,this.mimeType=Er(i.type)}async from(t,a){try{this.state="LOADING",t instanceof File?await this.loadFile(t):await this.loadUrl(t,a),this.state="READY",this.trigger("load",void 0)}catch(r){throw this.state=="ERROR",this.trigger("error",new Error(String(r))),r}return this}async arrayBuffer(){return await(await this.getFile()).arrayBuffer()}async remove(){this.state="IDLE",this.objectURL&&(URL.revokeObjectURL(this.objectURL),this.objectURL=void 0),delete this.file}async download(){const t=await this.getFile();$f(t,this.name)}async thumbnail(){return document.createElement("div")}static async from(t,a,r=new this){return r.from(t,a)}}un([he()],zt.prototype,"objectURL");un([he()],zt.prototype,"duration");un([he()],zt.prototype,"type");un([he()],zt.prototype,"name");un([he()],zt.prototype,"mimeType");un([he()],zt.prototype,"externalURL");un([he()],zt.prototype,"external");const ms="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3C/svg%3E";function Of(n){const o=new TextEncoder().encode(n);let t="";const a=o.byteLength;for(let r=0;r<a;r++)t+=String.fromCharCode(o[r]);return btoa(t)}function ps(n){if(!n||!n.body)return ms;const o=n.body.scrollWidth,t=n.body.scrollHeight,a=n.cloneNode(!0),r=a.getElementsByTagName("style").item(0),i=a.getElementsByTagName("body").item(0);if(i==null||i.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),!i)return ms;const s=new XMLSerializer,l=r?s.serializeToString(r):"",c=s.serializeToString(i),d=`
|
|
26
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${t}">
|
|
27
|
-
body { padding: 0; }
|
|
28
|
-
${l}
|
|
29
|
-
<foreignObject width="100%" height="100%">
|
|
30
|
-
${c}
|
|
31
|
-
</foreignObject>
|
|
32
|
-
</svg>`;return"data:image/svg+xml;base64,"+Of(d)}class fs extends zt{constructor(){super();O(this,"type","html");O(this,"iframe");const t=document.createElement("iframe");t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.border="0",t.style.visibility="hidden",document.body.appendChild(t),this.iframe=t}get document(){var t;return(t=this.iframe.contentWindow)==null?void 0:t.document}async createObjectURL(){return!this.file&&this.state=="LOADING"&&await new Promise(this.resolve("load")),this.objectURL?this.objectURL:(this.objectURL=ps(this.document),this.objectURL)}async loadUrl(t,a){await super.loadUrl(t,a),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((r,i)=>{this.iframe.onload=()=>r(),this.iframe.onerror=s=>i(s)})}async loadFile(t){await super.loadFile(t),this.iframe.setAttribute("src",URL.createObjectURL(this.file)),await new Promise((a,r)=>{this.iframe.onload=()=>a(),this.iframe.onerror=i=>r(i)})}update(){this.objectURL&&(this.objectURL=ps(this.document))}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-contain w-full aspect-video h-auto",t}}function Lf(n,o={}){const{threshold:t=.02,hopSize:a=1024,minDuration:r=500}=o,i=[],s=n.getChannelData(0),l=n.sampleRate,c=Math.floor(r/1e3*l);let d=null,u=0;for(let p=0;p<s.length;p+=a){let m=0;const h=Math.min(p+a,s.length);for(let g=p;g<h;g++)m+=s[g]*s[g];m=Math.sqrt(m/(h-p)),m<t?(u+=a,d===null&&(d=p)):(d!==null&&u>=c&&i.push({start:de.fromSeconds(d/l),stop:de.fromSeconds(p/l)}),d=null,u=0)}return d!==null&&u>=c&&i.push({start:de.fromSeconds(d/l),stop:de.fromSeconds(s.length/l)}),i}const tr=3e3;class Jt extends zt{constructor(){super(...arguments);O(this,"type","audio");O(this,"decoding",!1);O(this,"_silences");O(this,"transcript");O(this,"audioBuffer")}async decode(t=2,a=48e3,r=!1){if(this.decoding&&r&&(await new Promise(this.resolve("update")),this.audioBuffer))return this.audioBuffer;this.decoding=!0;const i=await this.arrayBuffer(),s=await new OfflineAudioContext(t,1,a).decodeAudioData(i);return this.duration.seconds=s.duration,r&&(this.audioBuffer=s),this.decoding=!1,this.trigger("update",void 0),s}async samples(t=60,a=50,r=0){const i=this.audioBuffer??await this.decode(1,3e3,!0),s=Math.round(i.sampleRate/a),l=i.sampleRate*i.duration-s,c=Math.ceil(l/t),d=i.getChannelData(0),u=[];for(let p=0;p<l;p+=c){let m=0;for(let h=p;h<p+s;h++)m+=Math.abs(d[p]);u.push(Math.log1p(m/s*100))}return u.map(p=>Math.round(p/Math.max(...u)*(100-r))+r)}async fastsampler({length:t=60,start:a=0,stop:r,logarithmic:i=!1}={}){typeof a=="object"&&(a=a.millis),typeof r=="object"&&(r=r.millis);const s=this.audioBuffer??await this.decode(1,tr,!0),l=s.getChannelData(0),c=Math.floor(Math.max(a*tr/1e3,0)),d=r?Math.floor(Math.min(r*tr/1e3,s.length)):s.length,u=Math.floor((d-c)/t),p=new Float32Array(t);for(let m=0;m<t;m++){const h=c+m*u,g=h+u;let v=-1/0;for(let x=h;x<g;x++){const B=l[x];B>v&&(v=B)}p[m]=i?Math.log2(1+v):v}return p}async thumbnail(...t){const a=await this.samples(...t),r=document.createElement("div");r.className="flex flex-row absolute space-between inset-0 audio-samples";for(const i of a){const s=document.createElement("div");s.className="audio-sample-item",s.style.height=`${i}%`,r.appendChild(s)}return r}async silences(t={}){if(this._silences)return this._silences;const a=await this.arrayBuffer(),r=new AudioContext,i=await r.decodeAudioData(a);return this._silences=Lf(i,t),r.close(),this._silences}}class aa extends zt{constructor(){super(...arguments);O(this,"type","image")}async thumbnail(){const t=new Image;return t.src=await this.createObjectURL(),t.className="object-cover w-full aspect-video h-auto",t}}class ra extends Jt{constructor(){super(...arguments);O(this,"type","video");O(this,"downloadInProgress",!0)}async loadUrl(t,a){const r=await fetch(t,a);if(!(r!=null&&r.ok))throw new Wt({code:"unexpectedIOError",message:"An unexpected error occurred while fetching the file"});this.name=t.toString().split("/").at(-1)??"",this.external=!0,this.externalURL=t,this.objectURL=String(t),this.mimeType=Er(r.headers.get("Content-type")),this.getBlob(r)}async getFile(){if(!this.file&&this.downloadInProgress&&await new Promise(this.resolve("load")),!this.file)throw new Ge({code:"fileNotAccessible",message:"The desired file cannot be accessed"});return this.file}async thumbnail(){const t=document.createElement("video");return t.className="object-cover w-full aspect-video h-auto",t.controls=!1,t.addEventListener("loadedmetadata",()=>{this.duration.seconds=t.duration,this.trigger("update",void 0)}),t.addEventListener("mousemove",a=>{const r=a.currentTarget,i=r==null?void 0:r.getBoundingClientRect(),s=a.clientX-((i==null?void 0:i.left)??0),l=r==null?void 0:r.duration;l&&i&&i.width>0&&(r.currentTime=Math.round(l*(s/i.width)))}),t.src=await this.createObjectURL(),t}async getBlob(t){try{this.downloadInProgress=!0;const a=await t.blob();this.file=new File([a],this.name,{type:a.type}),this.trigger("load",void 0)}catch(a){this.state=="ERROR",this.trigger("error",new Error(String(a)))}finally{this.downloadInProgress=!1}}}class Wf{static fromJSON(o){return[new de(o[0]),new de(o[1])]}}var jf=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,_n=(n,o,t,a)=>{for(var r=a>1?void 0:a?Xf(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&jf(o,t,r),r};const mn=class Tl extends fo{constructor(t={}){super();O(this,"source",new Jt);O(this,"_offset",new de);O(this,"playing",!1);O(this,"duration",new de);O(this,"range",[new de,this.duration]);Object.assign(this,t)}get transcript(){return this.source.transcript}set transcript(t){this.source.transcript=t}get start(){return this.range[0].add(this.offset)}get stop(){return this.range[1].add(this.offset)}set start(t){typeof t=="number"&&(t=de.fromFrames(t));const a=t.subtract(this.offset);a.millis>=0&&a.millis<this.range[1].millis?this.range[0].millis=a.millis:a.millis<0?this.range[0].millis=0:this.range[0].millis=this.range[1].millis-1,this.trigger("frame",void 0)}set stop(t){typeof t=="number"&&(t=de.fromFrames(t));const a=t.subtract(this.offset);a.millis>this.range[0].millis&&a.millis<=this.duration.millis?this.range[1]=a:a.millis>this.duration.millis?this.range[1]=this.duration:this.range[1].millis=this.range[0].millis+1,this.trigger("frame",void 0)}get offset(){return this._offset}set offset(t){typeof t=="number"?this._offset.frames=t:this._offset=t,this.trigger("frame",this.offset.frames)}offsetBy(t){return typeof t=="number"?(this.offset.addFrames(t),this.trigger("offsetBy",de.fromFrames(t))):(this.offset.addMillis(t.millis),this.trigger("offsetBy",t)),this.trigger("frame",void 0),this}get muted(){var t;return((t=this.element)==null?void 0:t.muted)??!1}set muted(t){this.element&&(this.element.muted=t)}seek(t){return new Promise((a,r)=>{if(!this.element)return r(new is({code:"elementNotDefined",message:"Cannot seek on undefined element"}));(t.millis<this.start.millis||t.millis>this.stop.millis)&&(t=this.start),this.element.onerror=()=>{var i;return r((i=this.element)==null?void 0:i.error)},this.element.pause(),this.element.currentTime=t.subtract(this.offset).seconds,this.element.onseeked=()=>a()})}subclip(t,a){if(t||(t=this.range[0]),a||(a=this.range[1]),typeof t=="number"&&(t=de.fromFrames(t)),typeof a=="number"&&(a=de.fromFrames(a)),t.millis>=a.millis)throw new Ge({code:"invalidKeyframe",message:"Start can't lower than or equal the stop"});return t.millis<0&&(this.range[0].millis=0,t=this.range[0]),a.millis>this.duration.millis&&this.duration.millis&&(a=this.duration),this.range=[t,a],this.trigger("frame",void 0),this}get volume(){var t;return((t=this.element)==null?void 0:t.volume)??1}set volume(t){this.element&&(this.element.volume=t)}copy(){const t=Tl.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}async split(t){var i,s;if(t||(t=(s=(i=this.track)==null?void 0:i.composition)==null?void 0:s.frame),typeof t=="number"&&(t=de.fromFrames(t)),!t||t.millis<=this.start.millis||t.millis>=this.stop.millis)throw new Ge({code:"invalidKeyframe",message:"Cannot split clip at the specified time"});if(!this.track)throw new is({code:"trackNotDefined",message:"Clip must be attached to a track"});t=t.subtract(this.offset);const a=this.copy();this.range[1]=t.copy(),a.range[0]=t.copy().addMillis(1),Xr(a,a.start.subtract(this.start));const r=this.track.clips.findIndex(l=>l.id==this.id);return await this.track.add(a,r+1),a}async addCaptions(t){var a;if(!((a=this.track)!=null&&a.composition))throw new Ge({code:"compositionNotDefined",message:"Captions can only be generated after the clip has been added to the composition"});return await this.track.composition.createTrack("caption").from(this).generate(t)}set(t){return super.set(t)}async generateCaptions(t){return this.addCaptions(t)}async removeSilences(t={}){["READY","ATTACHED"].includes(this.state)||await this.init();const a=(await this.source.silences(t)).filter(s=>hs(s,this.range)).sort((s,l)=>s.start.millis-l.start.millis);if(a.length==0)return[this];const r=t.padding??500,i=[this];for(const s of a){const l=i.at(-1);if(!l)break;if(!hs(s,l.range))continue;const c=new de(Math.min(s.start.millis+r,s.stop.millis));if(s.start.millis>l.range[0].millis&&s.stop.millis<l.range[1].millis){const d=l.copy();l.range[1]=c,d.range[0]=s.stop,i.push(d)}else s.start.millis<=l.range[0].millis?l.range[0]=s.stop:s.stop.millis>=l.range[1].millis&&(l.range[1]=c)}return i}};_n([he(de)],mn.prototype,"_offset",2);_n([he(de)],mn.prototype,"duration",2);_n([he(Wf)],mn.prototype,"range",2);_n([he(an)],mn.prototype,"transcript",1);_n([he()],mn.prototype,"muted",1);_n([he()],mn.prototype,"volume",1);let va=mn;function hs(n,o){return n.start.millis>=o[0].millis&&n.start.millis<=o[1].millis||n.stop.millis<=o[1].millis&&n.stop.millis>=o[0].millis}class Bo{static fromJSON(o){return typeof o=="object"?Se.fromJSON(o):o}}class nr{static fromJSON(o){return typeof o.x=="object"&&(o.x=Se.fromJSON(o.x)),typeof o.y=="object"&&(o.y=Se.fromJSON(o.y)),o}}let Zf=class{constructor(n){O(this,"target");O(this,"animation");this.target=n}init(n,o,t=0,a){if(!(n in this.target))throw new Error(`Property [${String(n)}] cannot be assigned`);const r=[t],i=[o];typeof this.target[n]==typeof o&&t!=0&&(r.unshift(0),i.unshift(this.target[n])),this.target[n]=this.animation=new Se(r,i,{easing:a})}};function Yf(n){const o=new Proxy(n,{get(t,a){return a=="to"?(r,i)=>{if(!t.animation)throw new Ge({code:"undefinedKeyframe",message:"Cannot use 'to() before selecting a property"});const s=new de(t.animation.input.at(-1)).frames+i;return t.animation.push(s,r),o}:(r,i,s)=>(t.init(a,r,i,s),o)}});return o}class Gf extends Zf{}var Hf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,Yt=(n,o,t,a)=>{for(var r=a>1?void 0:a?Jf(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&Hf(o,t,r),r};function ga(n){class o extends n{constructor(){super(...arguments);O(this,"filters");O(this,"_height");O(this,"_width");O(this,"_position",{x:this.view.position.x,y:this.view.position.y});O(this,"_scale");O(this,"rotation",this.view.angle);O(this,"alpha",1);O(this,"translate",{x:0,y:0})}get position(){return this._position}set position(r){typeof r=="string"?(this._position={x:"50%",y:"50%"},this.anchor={x:.5,y:.5}):this._position=r}get scale(){return this._scale??{x:this.view.scale.x,y:this.view.scale.y}}set scale(r){typeof r=="number"||r instanceof Se||typeof r=="function"?this._scale={x:r,y:r}:this._scale=r}get x(){return this._position.x}set x(r){this._position.x=r}get y(){return this._position.y}set y(r){this._position.y=r}get translateX(){return this.translate.x}set translateX(r){this.translate.x=r}get translateY(){return this.translate.y}set translateY(r){this.translate.y=r}get height(){return this._height??this.view.height}set height(r){this._height=r}get width(){return this._width??this.view.width}set width(r){this._width=r}get mask(){return this.view.mask}set mask(r){this.view.mask=r??null}get anchor(){return this.view.children[0]instanceof De.Sprite?{x:this.view.children[0].anchor.x,y:this.view.children[0].anchor.y}:{x:0,y:0}}set anchor(r){const i=typeof r=="number"?{x:r,y:r}:r;for(const s of this.view.children)s instanceof De.Sprite&&s.anchor.set(i.x,i.y)}enter(){this.filters&&!this.view.filters&&(this.view.filters=this.filters)}exit(){this.filters&&this.view.filters&&(this.view.filters=null)}animate(){return Yf(new Gf(this))}}return Yt([he(Bo)],o.prototype,"_height",2),Yt([he(Bo)],o.prototype,"_width",2),Yt([he(nr)],o.prototype,"_position",2),Yt([he(nr)],o.prototype,"_scale",2),Yt([he(Bo)],o.prototype,"rotation",2),Yt([he(Bo)],o.prototype,"alpha",2),Yt([he(nr)],o.prototype,"translate",2),Yt([he()],o.prototype,"anchor",1),o}function ya(n,o,t){const a=t.value;return t.value=function(...r){var p,m,h,g;const i=r[0].subtract(this.start),s={width:((m=(p=this.track)==null?void 0:p.composition)==null?void 0:m.width)??1920,height:((g=(h=this.track)==null?void 0:h.composition)==null?void 0:g.height)??1080};let l;typeof this.translate.x=="number"?l=this.translate.x:typeof this.translate.x=="function"?l=this.translate.x.bind(this)(i):l=this.translate.x.value(i);let c;typeof this.translate.y=="number"?c=this.translate.y:typeof this.translate.y=="function"?c=this.translate.y.bind(this)(i):c=this.translate.y.value(i);let d;typeof this._position.x=="number"?d=this._position.x:typeof this._position.x=="string"?d=Number.parseFloat(this._position.x)*s.width/100:typeof this._position.x=="function"?d=this._position.x.bind(this)(i):d=this._position.x.value(i);let u;if(typeof this._position.y=="number"?u=this._position.y:typeof this._position.y=="string"?u=Number.parseFloat(this._position.y)*s.height/100:typeof this._position.y=="function"?u=this._position.y.bind(this)(i):u=this._position.y.value(i),this.view.position.set(d+l,u+c),typeof this._height=="string"?this.view.height=Math.round(Number.parseFloat(this._height)*s.height/100):typeof this._height=="object"?this.view.height=this._height.value(i):typeof this._height=="function"?this.view.height=this._height.bind(this)(i):this._height&&(this.view.height=this._height),this._height&&!this._width&&this.view.scale.set(this.view.scale.y),typeof this._width=="string"?this.view.width=Math.round(Number.parseFloat(this._width)*s.width/100):typeof this._width=="object"?this.view.width=this._width.value(i):typeof this._width=="function"?this.view.width=this._width.bind(this)(i):this._width&&(this.view.width=this._width),this._width&&!this._height&&this.view.scale.set(this.view.scale.x),this._scale){let v;typeof this._scale.x=="number"?v=this._scale.x:typeof this._scale.x=="function"?v=this._scale.x.bind(this)(i):v=this._scale.x.value(i);let x;typeof this._scale.y=="number"?x=this._scale.y:typeof this._scale.y=="function"?x=this._scale.y.bind(this)(i):x=this._scale.y.value(i),(this._width||this._height)&&(v*=this.view.scale._x,x*=this.view.scale._y),this.view.scale.set(v,x)}return typeof this.rotation=="number"?this.view.angle=this.rotation:typeof this.rotation=="function"?this.view.angle=this.rotation.bind(this)(i):this.view.angle=this.rotation.value(i),typeof this.alpha=="number"?this.view.alpha=this.alpha:typeof this.alpha=="function"?this.view.alpha=this.alpha.bind(this)(i):this.view.alpha=this.alpha.value(i),a.apply(this,r)},t}var qf=Object.defineProperty,Kf=Object.getOwnPropertyDescriptor,Qf=(n,o,t,a)=>{for(var r=Kf(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&qf(o,t,r),r};const Ml=class Fl extends ga(fo){constructor(t,a={}){super();O(this,"type","image");O(this,"element",new Image);O(this,"source",new aa);O(this,"sprite",new De.Sprite);this.view.addChild(this.sprite),t instanceof aa&&(this.source=t),t instanceof File&&this.source.from(t),Object.assign(this,a)}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{this.sprite.texture=De.Texture.from(this.element),this.state="READY",t()},this.element.onerror=r=>{this.state="ERROR",a(new Wt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Fl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};Qf([ya],Ml.prototype,"update");let xr=Ml;const Ro={"The Bold Font":{weights:["500"],url:"https://diffusion-studio-public.s3.eu-central-1.amazonaws.com/fonts/the-bold-font.ttf"},"Komika Axis":{weights:["400"],url:"https://diffusion-studio-public.s3.eu-central-1.amazonaws.com/fonts/komika-axis.ttf"},Geologica:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/geologica/v1/oY1l8evIr7j9P3TN9YwNAdyjzUyDKkKdAGOJh1UlCDUIhAIdhCZOn1fLsig7jfvCCPHZckUWE1lELWNN-w.woff2"},Figtree:{weights:["300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/figtree/v5/_Xms-HUzqDCFdgfMm4S9DaRvzig.woff2"},Urbanist:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/urbanist/v15/L0x-DF02iFML4hGCyMqlbS1miXK2.woff2"},Montserrat:{weights:["100","200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/montserrat/v26/JTUSjIg1_i6t8kCHKm459WlhyyTh89Y.woff2"},Bangers:{weights:["400"],url:"https://fonts.gstatic.com/s/bangers/v20/FeVQS0BTqb0h60ACH55Q2J5hm24.woff2"},Chewy:{weights:["400"],url:"https://fonts.gstatic.com/s/chewy/v18/uK_94ruUb-k-wn52KjI9OPec.woff2"},"Source Code Pro":{weights:["200","300","400","500","600","700","800","900"],url:"https://fonts.gstatic.com/s/sourcecodepro/v22/HI_SiYsKILxRpg3hIP6sJ7fM7PqlPevWnsUnxg.woff2"}};var eh=Object.defineProperty,ba=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&eh(o,t,r),r};const ho=class Sr extends mo(xt){constructor(t){super();O(this,"loaded",!1);O(this,"family");O(this,"weight");O(this,"source");O(this,"style");t!=null&&t.source.startsWith("https://")&&(t.source=`url(${t.source})`),this.family=(t==null?void 0:t.family)??"Arial",this.source=t==null?void 0:t.source,this.style=t==null?void 0:t.style,this.weight=t==null?void 0:t.weight}get name(){return this.family+" "+(this.style??this.weight)}async load(){if(this.loaded||!this.source||!this.family)return this;const t=new FontFace(this.name,this.source);return this.weight&&(t.weight=this.weight),await new Promise(a=>{t.load().then(r=>{document.fonts.add(r),a(null)})}),this.loaded=!0,this.trigger("load",void 0),this}copy(){const t=Sr.fromJSON(JSON.parse(JSON.stringify(this)));return t.loaded=this.loaded,t}static async localFonts(){const t={};"queryLocalFonts"in window||Object.assign(window,{queryLocalFonts:()=>[]});for(const a of await window.queryLocalFonts()){if(a.family in t){t[a.family].push(a);continue}t[a.family]=[a]}return Object.keys(t).map(a=>({family:a,variants:t[a].map(r=>({family:a,style:r.style,source:`local('${r.fullName}'), local('${r.postscriptName}')`}))}))}static webFonts(){return Object.keys(Ro).map(t=>({family:t,variants:Ro[t].weights.map(a=>({family:t,source:`url(${Ro[t].url})`,weight:a}))}))}static fromFamily({family:t,weight:a}){return new Sr({family:t,source:`url(${Ro[t].url})`,weight:a})}};ba([he()],ho.prototype,"family");ba([he()],ho.prototype,"weight");ba([he()],ho.prototype,"source");ba([he()],ho.prototype,"style");let st=ho;const Rt=4,Il={center:.5,justify:.5,left:0,right:1},Bl={alphabetic:0,top:0,middle:.5,hanging:1,bottom:1,ideographic:1};var th=Object.defineProperty,nh=Object.getOwnPropertyDescriptor,ft=(n,o,t,a)=>{for(var r=nh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&th(o,t,r),r};const dt=class Rl extends ga(fo){constructor(t){super();O(this,"type","text");O(this,"_text","");O(this,"_textCase");O(this,"_anchor",{x:0,y:0});O(this,"_font",new st);O(this,"style",new De.TextStyle({fill:"#FFFFFF",fontFamily:this._font.family,fontSize:16}));this.style.padding=20,typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate()),this.on("update",this.reflectUpdate.bind(this))}get text(){return this._text}set text(t){if(this._text=t,!this.view.children.length){const a=new De.Text({text:this.transformedText,style:this.style,resolution:Rt,scale:Rt});this.view.addChild(a)}this.view.children[0]instanceof De.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get name(){return this._text}get font(){return this._font}set font(t){if(this._font=t,t.loaded){this.style.fontFamily=t.name;return}this._font.load().then(()=>{this.style.fontFamily=t.name,this.trigger("update",void 0)})}get maxWidth(){if(this.style.wordWrap)return this.style.wordWrapWidth*Rt}set maxWidth(t){t?(this.style.wordWrap=!0,this.style.wordWrapWidth=t/Rt):this.style.wordWrap=!1}get textAlign(){return this.style.align}set textAlign(t){this.style.align=t,this.anchor.x=Il[t]}get padding(){return this.style.padding}set padding(t){this.style.padding=t}get textBaseline(){return this.style.textBaseline}set textBaseline(t){this.style.textBaseline=t,this.anchor.y=Bl[t]}get fillStyle(){const{fill:t}=this.style;return new De.Color(t.toString()).toHex().toUpperCase()}set fillStyle(t){this.style.fill=t}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor={x:t,y:t}:this._anchor=t}get stroke(){if(!this.style.stroke)return;let{color:t="#000000",alpha:a=1,width:r=3,join:i="round",miterLimit:s}=this.style.stroke;return t=new De.Color(t).toHex().toUpperCase(),{color:t,alpha:a,width:r,join:i,miterLimit:s}}set stroke(t){if(!t){this.style.stroke=void 0;return}const{color:a="#000000",alpha:r=1,width:i=3,join:s="round",miterLimit:l}=t;this.style.stroke={color:a,alpha:r,width:i,join:s,miterLimit:l}}get textCase(){return this._textCase}set textCase(t){this._textCase=t,this.view.children[0]instanceof De.Text&&this.transformedText&&(this.view.children[0].text=this.transformedText)}get shadow(){if(!this.style.dropShadow)return;const{alpha:t,angle:a,blur:r,color:i,distance:s}=this.style.dropShadow,l=new De.Color(i).toHex().toUpperCase();return{alpha:t,angle:a,blur:r,color:l,distance:s}}set shadow(t){t?this.style.dropShadow=t:this.style.dropShadow=!1}get fontFamily(){return Array.isArray(this.style.fontFamily)?this.style.fontFamily[0]:this.style.fontFamily}get fontSize(){return this.style.fontSize}set fontSize(t){this.style.fontSize=t}get leading(){return this.style.leading}set leading(t){this.style.leading=t}update(t){}copy(){const t=Rl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}get transformedText(){return this.textCase=="lower"?this._text.toLocaleLowerCase():this.textCase=="upper"?this._text.toUpperCase():this._text}reflectUpdate(){var i,s,l;const t=((i=this.view.children[0])==null?void 0:i.width)??0,a=((s=this.view.children[0])==null?void 0:s.height)??0,r=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Rt;this.view.pivot={x:(t-r)*this._anchor.x,y:(a-r)*this._anchor.y}}set(t){return super.set(t)}};ft([he()],dt.prototype,"text");ft([he(st)],dt.prototype,"font");ft([he()],dt.prototype,"maxWidth");ft([he()],dt.prototype,"textAlign");ft([he()],dt.prototype,"padding");ft([he()],dt.prototype,"textBaseline");ft([he()],dt.prototype,"fillStyle");ft([he()],dt.prototype,"anchor");ft([he()],dt.prototype,"stroke");ft([he()],dt.prototype,"textCase");ft([he()],dt.prototype,"shadow");ft([he()],dt.prototype,"fontSize");ft([he()],dt.prototype,"leading");ft([ya],dt.prototype,"update");let Tn=dt;function or(n){const o=n.split(" ").map(t=>`${t} `);return o[o.length-1]=o[o.length-1].replace(/ $/,""),o}const oh={get(n,o){const t=n[o];return typeof t=="number"?t*Rt:Array.isArray(t)&&typeof t[0]=="number"?t.map(a=>a*Rt):t}};function ah(n){return new Proxy(n,oh)}class rh{constructor(){O(this,"tokens",[])}get width(){return this.tokens.reduce((o,t)=>o+t.metrics.lineWidths[0],0)}get height(){return Math.max(...this.tokens.map(o=>o.metrics.lineHeight))}}class vs{constructor(){O(this,"lines",[])}get width(){return Math.max(...this.lines.map(o=>o.width))}get height(){return this.lines.reduce((o,t)=>o+t.height,0)}}class ih{static fromJSON(o){return o.map(t=>(t.font&&(t.font=st.fromJSON(t.font)),t))}}var sh=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,Mn=(n,o,t,a)=>{for(var r=a>1?void 0:a?lh(o,t):o,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=(a?s(o,t,r):s(r))||r);return a&&r&&sh(o,t,r),r};const pn=class Pl extends Tn{constructor(t){super();O(this,"type","complex_text");O(this,"_maxWidth");O(this,"_textAlign","left");O(this,"_textBaseline","top");O(this,"model",new De.Container);O(this,"segments",[]);O(this,"metrics",new vs);O(this,"background");O(this,"styles");this.view.addChild(this.model),typeof t=="string"?(this.text=t,this.reflectUpdate()):t&&(Object.assign(this,t),this.reflectUpdate())}get text(){return this._text}set text(t){this._text=t}get maxWidth(){return this._maxWidth}set maxWidth(t){this._maxWidth=t}get textAlign(){return this._textAlign}set textAlign(t){this._textAlign=t,this._anchor.x=Il[t];const a=this.metrics.width;for(const r of this.metrics.lines){let i=0;(t=="center"||t=="justify")&&(i=(a-r.width)/2),t=="right"&&(i=a-r.width);for(const s of r.tokens)this.model.children[s.index].x=i,i+=s.metrics.lineWidths[0]}}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline=t,this._anchor.y=Bl[t];let a=0;for(const r of this.metrics.lines){const i=r.height;for(const s of r.tokens){let l=0;t=="middle"&&(l=(i-s.metrics.lineHeight)/2),t=="bottom"&&(l=i-s.metrics.lineHeight),this.model.children[s.index].y=a+l}a+=i}}copy(){const t=Pl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.font=this.font,t}createRenderSplits(t=[]){var i,s;const a=this.transformedText??"",r=[{index:void 0,tokens:or(a.substring(0,(i=t==null?void 0:t.at(0))==null?void 0:i.start))}];for(let l=0;l<t.length;l++)r.push({index:t[l].index,tokens:or(a.substring(t[l].start,t[l].stop))}),!((t[l].stop??a.length)>=a.length)&&r.push({index:void 0,tokens:or(a.substring(t[l].stop,(s=t.at(l+1))==null?void 0:s.start))});return r.filter(l=>l.tokens.join("").trim().length)}createTextMetrics(t,a){var i,s,l;const r=new vs;for(const c of t){const d=c.index!=null?a[c.index]:this.style;for(let u=0;u<c.tokens.length;u++){const p=ah(De.CanvasTextMetrics.measureText(c.tokens[u],d)),m=(((i=r.lines.at(-1))==null?void 0:i.width)??0)+p.lineWidths[0],h=this.maxWidth??Number.POSITIVE_INFINITY,g=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>h||g||!r.lines.length)&&r.lines.push(new rh),this.model.addChild(new De.Text({text:c.tokens[u],style:d,resolution:Rt,scale:Rt})),(l=r.lines.at(-1))==null||l.tokens.push({metrics:p,index:this.model.children.length-1})}}return r}createTextStyles(){var t;return((t=this.styles)==null?void 0:t.map(a=>{var i;const r=this.style.clone();return r.fill=a.fillStyle??this.style.fill,r.fontSize=a.fontSize??this.style.fontSize,r.stroke=a.stroke??this.style.stroke,r.fontFamily=((i=a.font)==null?void 0:i.name)??this.style.fontFamily,r}))??[]}drawBackground(){var l,c;if(this.view.children.length>1&&this.view.removeChildAt(0),!this.background)return;const t=this.model.width,a=this.model.height,r=((l=this.background.padding)==null?void 0:l.x)??40,i=((c=this.background.padding)==null?void 0:c.y)??10,s=new De.Graphics;s.roundRect(0-r/2,2-i/2,t+r,a+i,this.background.borderRadius??20),s.fill(this.background.fill??"#000000"),s.alpha=this.background.alpha??1,this.view.addChildAt(s,0)}reflectUpdate(){var l;if(!this.transformedText)return;this.model.removeChildren();const t=this.createRenderSplits(this.segments),a=this.createTextStyles();this.metrics=this.createTextMetrics(t,a),this.textAlign=this.textAlign,this.textBaseline=this.textBaseline;const r=this.view.width,i=this.view.height,s=(((l=this.style.dropShadow)==null?void 0:l.distance)??0)*Rt;this.view.pivot={x:(r-s)*this._anchor.x,y:(i-s)*this._anchor.y},this.drawBackground()}};Mn([he()],pn.prototype,"background",2);Mn([he(ih)],pn.prototype,"styles",2);Mn([he()],pn.prototype,"text",1);Mn([he()],pn.prototype,"maxWidth",1);Mn([he()],pn.prototype,"textAlign",1);Mn([he()],pn.prototype,"textBaseline",1);let wa=pn;const $l="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBtPSh0PT4odFt0LkFWTUVESUFfVFlQRV9VTktOT1dOPS0xXT0iQVZNRURJQV9UWVBFX1VOS05PV04iLHRbdC5BVk1FRElBX1RZUEVfVklERU89MF09IkFWTUVESUFfVFlQRV9WSURFTyIsdFt0LkFWTUVESUFfVFlQRV9BVURJTz0xXT0iQVZNRURJQV9UWVBFX0FVRElPIix0W3QuQVZNRURJQV9UWVBFX0RBVEE9Ml09IkFWTUVESUFfVFlQRV9EQVRBIix0W3QuQVZNRURJQV9UWVBFX1NVQlRJVExFPTNdPSJBVk1FRElBX1RZUEVfU1VCVElUTEUiLHRbdC5BVk1FRElBX1RZUEVfQVRUQUNITUVOVD00XT0iQVZNRURJQV9UWVBFX0FUVEFDSE1FTlQiLHRbdC5BVk1FRElBX1RZUEVfTkI9NV09IkFWTUVESUFfVFlQRV9OQiIsdCkpKG18fHt9KSxvPSh0PT4odC5GRm1wZWdXb3JrZXJMb2FkZWQ9IkZGbXBlZ1dvcmtlckxvYWRlZCIsdC5XQVNNUnVudGltZUluaXRpYWxpemVkPSJXQVNNUnVudGltZUluaXRpYWxpemVkIix0LkxvYWRXQVNNPSJMb2FkV0FTTSIsdC5HZXRBVlBhY2tldD0iR2V0QVZQYWNrZXQiLHQuR2V0QVZQYWNrZXRzPSJHZXRBVlBhY2tldHMiLHQuR2V0QVZTdHJlYW09IkdldEFWU3RyZWFtIix0LkdldEFWU3RyZWFtcz0iR2V0QVZTdHJlYW1zIix0LlJlYWRBVlBhY2tldD0iUmVhZEFWUGFja2V0Iix0LkFWUGFja2V0U3RyZWFtPSJBVlBhY2tldFN0cmVhbSIsdC5SZWFkTmV4dEFWUGFja2V0PSJSZWFkTmV4dEFWUGFja2V0Iix0LlN0b3BSZWFkQVZQYWNrZXQ9IlN0b3BSZWFkQVZQYWNrZXQiLHQpKShvfHx7fSk7Y29uc3QgQT0iS0daMWJtTjBhVzl1S0NsN0luVnpaU0J6ZEhKcFkzUWlPMnhsZENCbU8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2SWtaR2JYQmxaMWR2Y210bGNreHZZV1JsWkNKOUtTeHpaV3htTG1Ga1pFVjJaVzUwVEdsemRHVnVaWElvSW0xbGMzTmhaMlVpTEdGemVXNWpJR1oxYm1OMGFXOXVLR3dwZTJOdmJuTjBlM1I1Y0dVNmRDeGtZWFJoT21NOWUzMHNiWE5uU1dRNmIzMDliQzVrWVhSaE8zUnllWHRwWmloMFBUMDlJa3h2WVdSWFFWTk5JaWw3WTI5dWMzUjdkMkZ6YlV4dllXUmxjbEJoZEdnNlpYMDlZM3g4ZTMwN1pqMWhkMkZwZENoaGQyRnBkQ0JwYlhCdmNuUW9aU2twTG1SbFptRjFiSFFvS1gxbGJITmxJR2xtS0hROVBUMGlSMlYwUVZaVGRISmxZVzBpS1h0amIyNXpkSHRtYVd4bE9tVXNjM1J5WldGdFZIbHdaVHB6TEhOMGNtVmhiVWx1WkdWNE9tRjlQV01zY2oxbUxtZGxkRUZXVTNSeVpXRnRLR1VzY3l4aEtUdHpaV3htTG5CdmMzUk5aWE56WVdkbEtIdDBlWEJsT25Rc2JYTm5TV1E2Ynl4eVpYTjFiSFE2Y24wc1czSXVZMjlrWldOd1lYSXVaWGgwY21Ga1lYUmhMbUoxWm1abGNsMHBmV1ZzYzJVZ2FXWW9kRDA5UFNKSFpYUkJWbE4wY21WaGJYTWlLWHRqYjI1emRIdG1hV3hsT21WOVBXTXNjejFtTG1kbGRFRldVM1J5WldGdGN5aGxLVHR6Wld4bUxuQnZjM1JOWlhOellXZGxLSHQwZVhCbE9uUXNiWE5uU1dRNmJ5eHlaWE4xYkhRNmMzMHNjeTV0WVhBb1lUMCtZUzVqYjJSbFkzQmhjaTVsZUhSeVlXUmhkR0V1WW5WbVptVnlLU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBJaWw3WTI5dWMzUjdabWxzWlRwbExIUnBiV1U2Y3l4emRISmxZVzFVZVhCbE9tRXNjM1J5WldGdFNXNWtaWGc2Y24wOVl5eHVQV1l1WjJWMFFWWlFZV05yWlhRb1pTeHpMR0VzY2lrN2MyVnNaaTV3YjNOMFRXVnpjMkZuWlNoN2RIbHdaVHAwTEcxelowbGtPbThzY21WemRXeDBPbTU5TEZ0dUxtUmhkR0V1WW5WbVptVnlYU2w5Wld4elpTQnBaaWgwUFQwOUlrZGxkRUZXVUdGamEyVjBjeUlwZTJOdmJuTjBlMlpwYkdVNlpTeDBhVzFsT25OOVBXTXNZVDFtTG1kbGRFRldVR0ZqYTJWMGN5aGxMSE1wTzNObGJHWXVjRzl6ZEUxbGMzTmhaMlVvZTNSNWNHVTZkQ3h0YzJkSlpEcHZMSEpsYzNWc2REcGhmU3hoTG0xaGNDaHlQVDV5TG1SaGRHRXVZblZtWm1WeUtTbDlaV3h6WlNCcFppaDBQVDA5SWxKbFlXUkJWbEJoWTJ0bGRDSXBlMk52Ym5OMGUyWnBiR1U2WlN4emRHRnlkRHB6TEdWdVpEcGhMSE4wY21WaGJWUjVjR1U2Y2l4emRISmxZVzFKYm1SbGVEcHVmVDFqTEdROVppNXlaV0ZrUVZaUVlXTnJaWFFvYnl4bExITXNZU3h5TEc0cE8zTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEhKbGMzVnNkRHBrZlNsOWZXTmhkR05vS0dVcGUzTmxiR1l1Y0c5emRFMWxjM05oWjJVb2UzUjVjR1U2ZEN4dGMyZEpaRHB2TEdWeWNrMXpaenBsSUdsdWMzUmhibU5sYjJZZ1JYSnliM0kvWlM1dFpYTnpZV2RsT2lKVmJtdHViM2R1SUVWeWNtOXlJbjBwZlgwcGZTa29LVHNLIixnPXQ9PlVpbnQ4QXJyYXkuZnJvbShhdG9iKHQpLGU9PmUuY2hhckNvZGVBdCgwKSksVj10eXBlb2Ygc2VsZjwidSImJnNlbGYuQmxvYiYmbmV3IEJsb2IoW2coQSldLHt0eXBlOiJ0ZXh0L2phdmFzY3JpcHQ7Y2hhcnNldD11dGYtOCJ9KTtmdW5jdGlvbiBFKHQpe2xldCBlO3RyeXtpZihlPVYmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLmNyZWF0ZU9iamVjdFVSTChWKSwhZSl0aHJvdyIiO2NvbnN0IHM9bmV3IFdvcmtlcihlLHtuYW1lOnQ/Lm5hbWV9KTtyZXR1cm4gcy5hZGRFdmVudExpc3RlbmVyKCJlcnJvciIsKCk9Pnsoc2VsZi5VUkx8fHNlbGYud2Via2l0VVJMKS5yZXZva2VPYmplY3RVUkwoZSl9KSxzfWNhdGNoe3JldHVybiBuZXcgV29ya2VyKCJkYXRhOnRleHQvamF2YXNjcmlwdDtiYXNlNjQsIitBLHtuYW1lOnQ/Lm5hbWV9KX1maW5hbGx5e2UmJihzZWxmLlVSTHx8c2VsZi53ZWJraXRVUkwpLnJldm9rZU9iamVjdFVSTChlKX19Y29uc3QgdT0xZTY7Y2xhc3MgcHtmZm1wZWdXb3JrZXI7ZmZtcGVnV29ya2VyTG9hZFN0YXR1czttc2dJZDtmaWxlO2NvbnN0cnVjdG9yKGUpe3RoaXMuZmZtcGVnV29ya2VyPW5ldyBFLHRoaXMuZmZtcGVnV29ya2VyTG9hZFN0YXR1cz1uZXcgUHJvbWlzZSgocyxhKT0+e3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGk9Pntjb25zdHt0eXBlOnIsZXJyTXNnOmR9PWkuZGF0YTtyPT09by5GRm1wZWdXb3JrZXJMb2FkZWQmJnRoaXMucG9zdChvLkxvYWRXQVNNLHt3YXNtTG9hZGVyUGF0aDplLndhc21Mb2FkZXJQYXRofSkscj09PW8uV0FTTVJ1bnRpbWVJbml0aWFsaXplZCYmcyghMCkscj09PW8uTG9hZFdBU00mJmQmJmEoZCl9KX0pLHRoaXMubXNnSWQ9MH1wb3N0KGUscyxhKXt0aGlzLmZmbXBlZ1dvcmtlci5wb3N0TWVzc2FnZSh7dHlwZTplLG1zZ0lkOmE/P3RoaXMubXNnSWQrKyxkYXRhOnN9KX1hc3luYyBsb2FkKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5mZm1wZWdXb3JrZXJMb2FkU3RhdHVzO3JldHVybiB0aGlzLmZpbGU9ZSxzfWRlc3Ryb3koKXt0aGlzLmZpbGU9dm9pZCAwLHRoaXMuZmZtcGVnV29ya2VyLnRlcm1pbmF0ZSgpfWdldEFWU3RyZWFtKGU9bS5BVk1FRElBX1RZUEVfVklERU8scz0tMSl7cmV0dXJuIG5ldyBQcm9taXNlKChhLGkpPT57aWYoIXRoaXMuZmlsZSl7aSgiZmlsZSBpcyBub3QgbG9hZGVkIik7cmV0dXJufWNvbnN0IHI9dGhpcy5tc2dJZCxkPSh7ZGF0YTpufSk9PntuLnR5cGU9PT1vLkdldEFWU3RyZWFtJiZuLm1zZ0lkPT09ciYmKG4uZXJyTXNnP2kobi5lcnJNc2cpOmEobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGQpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsZCksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW0se2ZpbGU6dGhpcy5maWxlLHN0cmVhbVR5cGU6ZSxzdHJlYW1JbmRleDpzfSl9KX1nZXRBVlN0cmVhbXMoKXtyZXR1cm4gbmV3IFByb21pc2UoKGUscyk9PntpZighdGhpcy5maWxlKXtzKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgYT10aGlzLm1zZ0lkLGk9KHtkYXRhOnJ9KT0+e3IudHlwZT09PW8uR2V0QVZTdHJlYW1zJiZyLm1zZ0lkPT09YSYmKHIuZXJyTXNnP3Moci5lcnJNc2cpOmUoci5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGkpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsaSksdGhpcy5wb3N0KG8uR2V0QVZTdHJlYW1zLHtmaWxlOnRoaXMuZmlsZX0pfSl9Z2V0QVZQYWNrZXQoZSxzPW0uQVZNRURJQV9UWVBFX1ZJREVPLGE9LTEpe3JldHVybiBuZXcgUHJvbWlzZSgoaSxyKT0+e2lmKCF0aGlzLmZpbGUpe3IoImZpbGUgaXMgbm90IGxvYWRlZCIpO3JldHVybn1jb25zdCBkPXRoaXMubXNnSWQsbj1oPT57Y29uc3QgbD1oLmRhdGE7bC50eXBlPT09by5HZXRBVlBhY2tldCYmbC5tc2dJZD09PWQmJihsLmVyck1zZz9yKGwuZXJyTXNnKTppKGwucmVzdWx0KSx0aGlzLmZmbXBlZ1dvcmtlci5yZW1vdmVFdmVudExpc3RlbmVyKCJtZXNzYWdlIixuKSl9O3RoaXMuZmZtcGVnV29ya2VyLmFkZEV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLG4pLHRoaXMucG9zdChvLkdldEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSx0aW1lOmUsc3RyZWFtVHlwZTpzLHN0cmVhbUluZGV4OmF9KX0pfWdldEFWUGFja2V0cyhlKXtyZXR1cm4gbmV3IFByb21pc2UoKHMsYSk9PntpZighdGhpcy5maWxlKXthKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgaT10aGlzLm1zZ0lkLHI9ZD0+e2NvbnN0IG49ZC5kYXRhO24udHlwZT09PW8uR2V0QVZQYWNrZXRzJiZuLm1zZ0lkPT09aSYmKG4uZXJyTXNnP2Eobi5lcnJNc2cpOnMobi5yZXN1bHQpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLHIpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsciksdGhpcy5wb3N0KG8uR2V0QVZQYWNrZXRzLHtmaWxlOnRoaXMuZmlsZSx0aW1lOmV9KX0pfXJlYWRBVlBhY2tldChlPTAscz0wLGE9bS5BVk1FRElBX1RZUEVfVklERU8saT0tMSl7Y29uc3Qgcj1uZXcgQ291bnRRdWV1aW5nU3RyYXRlZ3koe2hpZ2hXYXRlck1hcms6MX0pLGQ9dGhpcy5tc2dJZDtsZXQgbj0wO3JldHVybiBuZXcgUmVhZGFibGVTdHJlYW0oe3N0YXJ0Omg9PntpZighdGhpcy5maWxlKXtoLmVycm9yKCJmaWxlIGlzIG5vdCBsb2FkZWQiKTtyZXR1cm59Y29uc3QgbD1mPT57Y29uc3QgYz1mLmRhdGE7Yy50eXBlPT09by5SZWFkQVZQYWNrZXQmJmMubXNnSWQ9PT1kJiZjLmVyck1zZyYmKGguZXJyb3IoYy5lcnJNc2cpLHRoaXMuZmZtcGVnV29ya2VyLnJlbW92ZUV2ZW50TGlzdGVuZXIoIm1lc3NhZ2UiLGwpKSxjLnR5cGU9PT1vLkFWUGFja2V0U3RyZWFtJiZjLm1zZ0lkPT09ZCYmKGMucmVzdWx0P2guZW5xdWV1ZShjLnJlc3VsdCk6aC5jbG9zZSgpKX07dGhpcy5mZm1wZWdXb3JrZXIuYWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsbCksdGhpcy5wb3N0KG8uUmVhZEFWUGFja2V0LHtmaWxlOnRoaXMuZmlsZSxzdGFydDplLGVuZDpzLHN0cmVhbVR5cGU6YSxzdHJlYW1JbmRleDppfSl9LHB1bGw6KCk9PntuPjAmJnRoaXMucG9zdChvLlJlYWROZXh0QVZQYWNrZXQsdm9pZCAwLGQpLG4rK30sY2FuY2VsOigpPT57dGhpcy5wb3N0KG8uU3RvcFJlYWRBVlBhY2tldCx2b2lkIDAsZCl9fSxyKX1nZXRWaWRlb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9WSURFTyxlKX1nZXRBdWRpb1N0cmVhbShlKXtyZXR1cm4gdGhpcy5nZXRBVlN0cmVhbShtLkFWTUVESUFfVFlQRV9BVURJTyxlKX1zZWVrVmlkZW9QYWNrZXQoZSl7cmV0dXJuIHRoaXMuZ2V0QVZQYWNrZXQoZSxtLkFWTUVESUFfVFlQRV9WSURFTyl9c2Vla0F1ZGlvUGFja2V0KGUpe3JldHVybiB0aGlzLmdldEFWUGFja2V0KGUsbS5BVk1FRElBX1RZUEVfQVVESU8pfXJlYWRWaWRlb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfVklERU8pfXJlYWRBdWRpb1BhY2tldChlLHMpe3JldHVybiB0aGlzLnJlYWRBVlBhY2tldChlLHMsbS5BVk1FRElBX1RZUEVfQVVESU8pfWdlblZpZGVvRGVjb2RlckNvbmZpZyhlKXtyZXR1cm57Y29kZWM6ZS5jb2RlY3Bhci5jb2RlY19zdHJpbmcsY29kZWRXaWR0aDplLmNvZGVjcGFyLndpZHRoLGNvZGVkSGVpZ2h0OmUuY29kZWNwYXIuaGVpZ2h0LGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRWaWRlb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZFZpZGVvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1nZW5BdWRpb0RlY29kZXJDb25maWcoZSl7cmV0dXJue2NvZGVjOmUuY29kZWNwYXIuY29kZWNfc3RyaW5nfHwiIixzYW1wbGVSYXRlOmUuY29kZWNwYXIuc2FtcGxlX3JhdGUsbnVtYmVyT2ZDaGFubmVsczplLmNvZGVjcGFyLmNoYW5uZWxzLGRlc2NyaXB0aW9uOmUuY29kZWNwYXIuZXh0cmFkYXRhPy5sZW5ndGg+MD9lLmNvZGVjcGFyLmV4dHJhZGF0YTp2b2lkIDB9fWdlbkVuY29kZWRBdWRpb0NodW5rKGUpe3JldHVybiBuZXcgRW5jb2RlZEF1ZGlvQ2h1bmsoe3R5cGU6ZS5rZXlmcmFtZT09PTE/ImtleSI6ImRlbHRhIix0aW1lc3RhbXA6ZS50aW1lc3RhbXAqdSxkdXJhdGlvbjplLmR1cmF0aW9uKnUsZGF0YTplLmRhdGF9KX1hc3luYyBnZXRWaWRlb0RlY29kZXJDb25maWcoKXtjb25zdCBlPWF3YWl0IHRoaXMuZ2V0VmlkZW9TdHJlYW0oKTtyZXR1cm4gdGhpcy5nZW5WaWRlb0RlY29kZXJDb25maWcoZSl9YXN5bmMgc2Vla0VuY29kZWRWaWRlb0NodW5rKGUpe2NvbnN0IHM9YXdhaXQgdGhpcy5zZWVrVmlkZW9QYWNrZXQoZSk7cmV0dXJuIHRoaXMuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsocyl9YXN5bmMgZ2V0QXVkaW9EZWNvZGVyQ29uZmlnKCl7Y29uc3QgZT1hd2FpdCB0aGlzLmdldEF1ZGlvU3RyZWFtKCk7cmV0dXJuIHRoaXMuZ2VuQXVkaW9EZWNvZGVyQ29uZmlnKGUpfWFzeW5jIHNlZWtFbmNvZGVkQXVkaW9DaHVuayhlKXtjb25zdCBzPWF3YWl0IHRoaXMuc2Vla0F1ZGlvUGFja2V0KGUpO3JldHVybiB0aGlzLmdlbkVuY29kZWRBdWRpb0NodW5rKHMpfX1jbGFzcyBre3ZpZGVvO2N1cnJlbnRGcmFtZXM9MDt0b3RhbEZyYW1lcztjdXJyZW50VGltZTtmcHM7Zmlyc3RUaW1lc3RhbXA7Y29uc3RydWN0b3IoZSxzKXt0aGlzLmN1cnJlbnRUaW1lPWVbMF0qMWU2LHRoaXMuZmlyc3RUaW1lc3RhbXA9ZVswXSoxZTYsdGhpcy50b3RhbEZyYW1lcz0oZVsxXS1lWzBdKSpzKzEsdGhpcy5mcHM9cyx0aGlzLnZpZGVvPW5ldyBWaWRlb0RlY29kZXIoe291dHB1dDp0aGlzLmhhbmRsZUZyYW1lT3V0cHV0LmJpbmQodGhpcyksZXJyb3I6dGhpcy5oYW5kbGVFcnJvci5iaW5kKHRoaXMpfSl9cG9zdEZyYW1lKGUpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImZyYW1lIixmcmFtZTplfSksdGhpcy5jdXJyZW50VGltZSs9TWF0aC5mbG9vcigxL3RoaXMuZnBzKjFlNiksdGhpcy5jdXJyZW50RnJhbWVzKz0xfWhhbmRsZUZyYW1lT3V0cHV0KGUpe2NvbnN0IHM9ZS50aW1lc3RhbXAsYT1lLmR1cmF0aW9uPz8wLGk9cythO2lmKCF0aGlzLmlzRnJhbWVJblJhbmdlKHMpKXtlLmNsb3NlKCk7cmV0dXJufWZvcig7aT50aGlzLmN1cnJlbnRUaW1lJiZ0aGlzLmN1cnJlbnRGcmFtZXM8PXRoaXMudG90YWxGcmFtZXM7KXRoaXMucG9zdEZyYW1lKGUpO2UuY2xvc2UoKX1pc0ZyYW1lSW5SYW5nZShlKXtyZXR1cm4gZT49dGhpcy5maXJzdFRpbWVzdGFtcH1oYW5kbGVFcnJvcihlKXtjb25zb2xlLmVycm9yKCJlcnJvciBpbiB3b3JrZXIiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOmUubWVzc2FnZT8/IkFuIHVua25vd24gd29ya2VyIGVycm9yIG9jY3VycmVkIn0pLHNlbGYuY2xvc2UoKX19ZnVuY3Rpb24gSSh0KXtyZXR1cm4gYXN5bmMgZT0+e3RyeXthd2FpdCB0KGUpfWNhdGNoKHMpe3NlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImVycm9yIixtZXNzYWdlOnM/Lm1lc3NhZ2U/PyJBbiB1bmtvd24gd29ya2VyIGVycm9yIG9jY3VyZWQifSl9fX1mdW5jdGlvbiBXKHQpe3JldHVybiB0LmNvZGVjPT0idnAwOSImJih0LmNvZGVjPSJ2cDA5LjAwLjEwLjA4IiksdH1jb25zdCBaPTMwO2FzeW5jIGZ1bmN0aW9uIFAodCl7aWYodC5kYXRhPy50eXBlIT0iaW5pdCIpcmV0dXJuO2NvbnN0e2ZpbGU6ZSxyYW5nZTpzLGZwczphfT10LmRhdGEsaT1uZXcgcCh7d2FzbUxvYWRlclBhdGg6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vQGRpZmZ1c2lvbnN0dWRpby9mZm1wZWctd2FzbUAxLjAuMC9kaXN0L2ZmbXBlZy5qcyJ9KTthd2FpdCBpLmxvYWQoZSk7Y29uc3Qgcj1hd2FpdCBpLmdldFZpZGVvRGVjb2RlckNvbmZpZygpO1cocik7Y29uc3QgZD1uZXcgayhzLGEpO2QudmlkZW8uY29uZmlndXJlKHIpO2NvbnN0IG49aS5yZWFkQVZQYWNrZXQoc1swXSxzWzFdKS5nZXRSZWFkZXIoKTtuLnJlYWQoKS50aGVuKGFzeW5jIGZ1bmN0aW9uIGgoe2RvbmU6bCx2YWx1ZTpmfSl7aWYobCl7YXdhaXQgZC52aWRlby5mbHVzaCgpLHNlbGYucG9zdE1lc3NhZ2Uoe3R5cGU6ImRvbmUifSksc2VsZi5jbG9zZSgpO3JldHVybn1jb25zdCBjPWkuZ2VuRW5jb2RlZFZpZGVvQ2h1bmsoZik7cmV0dXJuIGQudmlkZW8uZGVjb2RlUXVldWVTaXplPlomJmF3YWl0IG5ldyBQcm9taXNlKEw9PntkLnZpZGVvLm9uZGVxdWV1ZT0oKT0+TCgpfSksYy50aW1lc3RhbXA8PXNbMV0qMWU2JiZkLnZpZGVvLmRlY29kZShjKSxuLnJlYWQoKS50aGVuKGgpfSl9c2VsZi5hZGRFdmVudExpc3RlbmVyKCJtZXNzYWdlIixJKFApKX0pKCk7Cg==",ch=n=>Uint8Array.from(atob(n),o=>o.charCodeAt(0)),gs=typeof self<"u"&&self.Blob&&new Blob([ch($l)],{type:"text/javascript;charset=utf-8"});function dh(n){let o;try{if(o=gs&&(self.URL||self.webkitURL).createObjectURL(gs),!o)throw"";const t=new Worker(o,{name:n==null?void 0:n.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(o)}),t}catch{return new Worker("data:text/javascript;base64,"+$l,{name:n==null?void 0:n.name})}finally{o&&(self.URL||self.webkitURL).revokeObjectURL(o)}}class uh{constructor(){O(this,"frames",[]);O(this,"state","active");O(this,"onenqueue");O(this,"onclose")}enqueue(o){var t;this.frames.unshift(o),(t=this.onenqueue)==null||t.call(this)}async dequeue(){if(this.frames.length==0&&this.state=="active"&&await this.waitFor(2e4),!(this.frames.length==0&&this.state=="closed"))return this.frames.pop()}close(){var o;this.state="closed",(o=this.onclose)==null||o.call(this)}terminate(){for(const o of this.frames)o.close()}async waitFor(o){await new Promise((t,a)=>{const r=setTimeout(()=>{a(`Promise timed out after ${o} ms`)},o);this.onenqueue=()=>{clearTimeout(r),t()},this.onclose=()=>{clearTimeout(r),t()}})}}function mh(n,o,t){const a=t.value;return t.value=function(...r){var i,s,l,c;return(s=(i=this.track)==null?void 0:i.composition)!=null&&s.rendering&&this.sprite.texture.source.uid!=this.textrues.canvas.source.uid&&(this.sprite.texture=this.textrues.canvas),!((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)&&this.sprite.texture.source.uid!=this.textrues.html5.source.uid&&(this.sprite.texture=this.textrues.html5),a.apply(this,r)},t}var ph=Object.defineProperty,fh=Object.getOwnPropertyDescriptor,hh=(n,o,t,a)=>{for(var r=fh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&ph(o,t,r),r};const zl=class Al extends ga(va){constructor(t,a={}){super();O(this,"source",new ra);O(this,"type","video");O(this,"worker");O(this,"buffer");O(this,"canvas",document.createElement("canvas"));O(this,"context",this.canvas.getContext("2d"));O(this,"element",document.createElement("video"));O(this,"textrues",{html5:De.Texture.from(this.element),canvas:De.Texture.from(this.canvas)});O(this,"sprite",new De.Sprite);this.element.controls=!1,this.element.playsInline=!0,this.element.style.display="hidden",this.element.crossOrigin="anonymous",this.textrues.html5.source.autoPlay=!1,this.textrues.html5.source.loop=!1,this.sprite.texture=this.textrues.html5,this.view.addChild(this.sprite),t instanceof ra&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),await new Promise((a,r)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const i=new Wt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});r(this.element.error??i)}})}async connect(t){var r;super.connect(t);const a=((r=t.composition)==null?void 0:r.frame)??0;await this.seek(de.fromFrames(a))}enter(){var t,a,r;super.enter(),(a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering&&((r=this.buffer)==null?void 0:r.state)!="active"&&this.decodeVideo()}update(t){var a,r,i,s,l,c;if((r=(a=this.track)==null?void 0:a.composition)!=null&&r.playing&&!this.playing)this.element.play();else if(!((s=(i=this.track)==null?void 0:i.composition)!=null&&s.playing)&&this.playing)this.element.pause();else if((c=(l=this.track)==null?void 0:l.composition)!=null&&c.rendering)return this.nextFrame()}exit(){this.playing&&this.element.pause(),this.filters&&this.view.filters&&(this.view.filters=null)}copy(){const t=Al.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}async decodeVideo(){var t,a;return this.buffer=new uh,this.worker=new dh,this.worker.addEventListener("message",r=>{var i,s;r.data.type=="frame"?(i=this.buffer)==null||i.enqueue(r.data.frame):r.data.type=="error"?this.cancelDecoding():r.data.type=="done"&&((s=this.buffer)==null||s.close())}),this.worker.postMessage({type:"init",file:await this.source.getFile(),range:this.demuxRange,fps:((a=(t=this.track)==null?void 0:t.composition)==null?void 0:a.fps)??io}),this.buffer}async nextFrame(){if(!this.buffer)return;const t=await this.buffer.dequeue();t&&(this.canvas.width=t.displayWidth,this.canvas.height=t.displayHeight,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(t,0,0),this.textrues.canvas.source.update(),t.close())}get demuxRange(){var i;const t=(i=this.track)==null?void 0:i.composition;let a;this.start.millis<0?a=Math.abs(this.offset.seconds):a=this.range[0].seconds;let r;return t&&this.stop.millis>t.duration.millis?r=t.duration.subtract(this.offset).seconds:r=this.range[1].seconds,[a,r]}cancelDecoding(){var t,a;(t=this.worker)==null||t.terminate(),this.worker=void 0,(a=this.buffer)==null||a.terminate(),this.buffer=void 0}};hh([ya,mh],zl.prototype,"update");let ia=zl;class sa extends va{constructor(t,a={}){super();O(this,"type","audio");O(this,"source",new Jt);O(this,"element",new Audio);t instanceof Jt&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("play",()=>{this.playing=!0}),this.element.addEventListener("pause",()=>{this.playing=!1}),Object.assign(this,a)}async init(){const t=await this.source.createObjectURL();this.element.setAttribute("src",t),this.element.load(),await new Promise((a,r)=>{this.element.oncanplay=()=>{this.duration.seconds=this.element.duration,this.state="READY",a()},this.element.onerror=()=>{this.state="ERROR";const i=new Wt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."});r(this.element.error??i)}})}update(){var t,a,r,i,s,l;if((a=(t=this.track)==null?void 0:t.composition)!=null&&a.rendering)return this.exit();(i=(r=this.track)==null?void 0:r.composition)!=null&&i.playing&&!this.playing?this.element.play():!((l=(s=this.track)==null?void 0:s.composition)!=null&&l.playing)&&this.playing&&this.element.pause()}exit(){this.playing&&this.element.pause()}copy(){const t=sa.fromJSON(JSON.parse(JSON.stringify(this)));return t.source=this.source,t}}const vh={IMAGE:{"image/jpeg":"jpg","image/png":"png","image/webp":"webp","image/svg+xml":"svg"},VIDEO:{"video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov"},AUDIO:{"audio/mp3":"mp3","audio/mpeg":"mp3","audio/aac":"aac","audio/wav":"wav","audio/x-wav":"wav"},DOCUMENT:{"text/html":"html"},get MIXED(){return{...this.IMAGE,...this.VIDEO,...this.AUDIO,...this.DOCUMENT}}};function Er(n){if(!Object.keys(vh.MIXED).includes(n??""))throw new Ge({message:`${n} is not an accepted mime type`,code:"invalid_mimetype"});return n}var gh=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,bh=(n,o,t,a)=>{for(var r=yh(o,t),i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&gh(o,t,r),r};const wh=class Dl extends ga(fo){constructor(t,a={}){super();O(this,"type","html");O(this,"source",new fs);O(this,"element",new Image);O(this,"canvas",document.createElement("canvas"));O(this,"context",this.canvas.getContext("2d"));O(this,"sprite",new De.Sprite);this.view.addChild(this.sprite),Object.assign(this,a),t instanceof fs&&(this.source=t),t instanceof File&&this.source.from(t),this.element.addEventListener("load",()=>{var s,l,c,d;const r=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,i=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;!r||!i||(this.canvas.width=r,this.canvas.height=i,this.context.imageSmoothingEnabled=!1,this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.drawImage(this.element,0,0),this.sprite.texture=De.Texture.from(this.canvas,!0),this.trigger("load",void 0))}),this.element.addEventListener("error",r=>{this.state="ERROR",this.trigger("error",new Wt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."})),this.track&&this.detach()}),this.on("update",async()=>{this.source.update(),this.element.setAttribute("src",await this.source.createObjectURL())})}async init(){this.element.setAttribute("src",await this.source.createObjectURL()),await new Promise((t,a)=>{this.element.onload=()=>{var s,l,c,d;const r=(l=(s=this.source.document)==null?void 0:s.body)==null?void 0:l.scrollWidth,i=(d=(c=this.source.document)==null?void 0:c.body)==null?void 0:d.scrollHeight;if(!r||!i)return a(new Wt({code:"sourceNotProcessable",message:"Cannot display source with height or width at 0"}));this.state="READY",t()},this.element.onerror=r=>{a(new Wt({code:"sourceNotProcessable",message:"An error occurred while processing the input medium."}))}})}update(t){}copy(){const t=Dl.fromJSON(JSON.parse(JSON.stringify(this)));return t.filters=this.filters,t.source=this.source,t}};bh([ya],wh.prototype,"update");const Ul=["DEFAULT","STACK"];class ys{constructor(){O(this,"mode",Ul[0]);O(this,"pauseAlignmet",!1)}add(o,t){let a=!0;for(let r=0;r<t.clips.length&&(a=ks(o,t.clips[r]),!!a);r++)ws(o,t.clips[r]);a&&(t.clips.push(o),t.clips.sort(bs))}update(o,t){if(!this.pauseAlignmet){t.clips.sort(bs);for(let a=0;a<t.clips.length;a++)if(o.id!=t.clips[a].id){if(!ks(o,t.clips[a]))break;ws(o,t.clips[a])}}}offset(o,t){this.pauseAlignmet=!0;for(const a of t.clips)a.offsetBy(o);this.pauseAlignmet=!1}}class kh{constructor(){O(this,"mode",Ul[1])}add(o,t,a=void 0){var i;let r=-1;(a!=null&&a>0||a==null)&&(r=((i=t.clips.at((a??0)-1))==null?void 0:i.stop.millis)??-1),o.offsetBy(new de(r-o.start.millis+1)),a==null?t.clips.push(o):(t.clips.splice(a,0,o),t.clips.slice(a+1).forEach(s=>{s.offsetBy(o.stop.subtract(o.start))}))}update(o,t){let a=0;for(const r of t.clips){if(r.start.millis!=a){const i=a-r.start.millis;r.offsetBy(new de(i))}a=r.stop.millis+1}}offset(){}}function bs(n,o){return n.start.millis-o.start.millis}function ws(n,o){n.start.millis>=o.start.millis&&n.start.millis<=o.stop.millis&&(n.start=o.stop.copy().addMillis(1)),n.stop.millis>=o.start.millis&&n.stop.millis<=o.stop.millis&&(n.stop=o.start.copy().addMillis(-1))}function ks(n,o){var t,a,r,i,s;if(n.start.millis>=o.start.millis&&n.stop.millis<=o.stop.millis){const l=(a=(t=o.track)==null?void 0:t.composition)==null?void 0:a.tracks.find(c=>c.type==n.type&&!c.clips.some(d=>n.id!=d.id&&n.start.millis>=d.start.millis&&n.stop.millis<=d.stop.millis));return l?(l.add(n.detach()),!1):((s=(i=(r=o.track)==null?void 0:r.composition)==null?void 0:i.createTrack(n.type))==null||s.add(n.detach()),!1)}return!0}class Fn extends mo(xt){constructor(){super(...arguments);O(this,"_disabled",!1);O(this,"view",new De.Container);O(this,"clips",[]);O(this,"pointer",0);O(this,"composition");O(this,"type","base");O(this,"strategy",new ys)}get disabled(){return this._disabled}set disabled(t){var a;t&&this.clipRef&&rr(this.clipRef)&&(this.view.removeChild(this.clipRef.view),(a=this.clipRef)==null||a.exit()),this._disabled=t,this.trigger("update",void 0)}connect(t){this.composition=t}stacked(t=!0){return t?(this.strategy=new kh,this.strategy.update(new fo,this)):this.strategy=new ys,this.trigger("update",void 0),this}layer(t){var l,c;const a=((l=this.composition)==null?void 0:l.tracks)??[],r=a.findIndex(d=>d.id==this.id),i=a.length-1;if(r==-1)return this;let s=0;return t=="bottom"?s=i:t=="top"||t<0?s=0:t>i?s=i:s=t,Pf(a,r,s),(c=this.composition)==null||c.stage.setChildIndex(this.view,i-s),this.trigger("update",void 0),this}seek(t){}offsetBy(t){return typeof t=="number"?this.strategy.offset(de.fromFrames(t),this):this.strategy.offset(t,this),this}update(t){var r,i;if(this.disabled||!this.clips.length)return;const{millis:a}=t;if(rr(this.clipRef)&&(!ar(a,this.clipRef)||(r=this.clipRef)!=null&&r.disabled)&&(this.clipRef&&this.view.removeChild(this.clipRef.view),(i=this.clipRef)==null||i.exit()),!!ar(a,this))for(let s=0;s<this.clips.length;s++){const l=(this.pointer+s)%this.clips.length,c=this.clips[l],d=this.clips[l-1];if(ar(a,c)&&!c.disabled)return this.pointer=l,rr(c)||(c.enter(),this.view.addChild(c.view)),c.update(t);if(a<c.start.millis&&a>((d==null?void 0:d.stop.millis)??0)){this.pointer=l;return}}}async add(t,a){return this.composition&&!this.composition.renderer&&await new Promise(this.composition.resolve("init")),await t.init(),await t.connect(this),await this.strategy.add(t,this,a),t.on("frame",()=>{this.strategy.update(t,this)}),t.bubble(this),this.trigger("attach",void 0),t}remove(t){const a=this.clips.findIndex(r=>r.id==t.id);if(t.state=="ATTACHED"&&(t.state="READY"),t.view.parent&&this.view.removeChild(t.view),a!=null&&a>=0)return this.clips.splice(a,1),this.strategy.update(t,this),this.trigger("detach",void 0),t.off("*"),t}get stop(){var t;return((t=this.clips.at(-1))==null?void 0:t.stop)??new de}get start(){var t;return((t=this.clips.at(0))==null?void 0:t.start)??new de}apply(t){this.clips.forEach(t)}detach(){var t;return(t=this.composition)==null||t.removeTrack(this),this}get clipRef(){return this.clips[this.pointer]}}function ar(n,o){return o?n>=o.start.millis&&n<=o.stop.millis:!1}function rr(n){return n?!!n.view.parent:!1}class xh{static fromType(o){switch(o.type){case"video":return new Sh;case"audio":return new Ch;case"html":return new Vh;case"image":return new Eh;case"text":return new xs;case"complex_text":return new xs;case"caption":return new _h;default:return new Fn}}}class Ol extends Fn{constructor(){super(...arguments);O(this,"clips",[])}async seek(t){for(const a of this.clips)await a.seek(t)}async removeSilences(t={}){const a=[];for(const r of this.clips.map(i=>i.detach()))a.push(...await r.removeSilences(t));for(const r of a)await this.add(r)}}class Sh extends Ol{constructor(){super(...arguments);O(this,"type","video")}async seek(t){var a;(a=this.composition)!=null&&a.rendering?this.view.removeChildren():super.seek(t)}}class Eh extends Fn{constructor(){super(...arguments);O(this,"type","image")}}class Ch extends Ol{constructor(){super(...arguments);O(this,"type","audio")}}class xs extends Fn{constructor(){super(...arguments);O(this,"type","text")}}class Vh extends Fn{constructor(){super(...arguments);O(this,"type","html")}}var Nh=Object.defineProperty,Zr=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Nh(o,t,r),r};class vo extends xt{constructor(t={}){super();O(this,"generatorOptions");O(this,"type","CLASSIC");O(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"Figtree",weight:"700"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))await t.add(new Tn({text:c.words.map(d=>d.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:21,fillStyle:"#FFFFFF",font:r,stroke:{color:"#000000",width:4,join:"round"},maxWidth:t.composition.width*.85,shadow:{color:"#000000",blur:0,distance:1.1,angle:Math.PI*.4,alpha:1},position:this.position,stop:c.stop.add(a),start:c.start.add(a),scale:new Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"})}))}}Zr([he()],vo.prototype,"generatorOptions");Zr([he()],vo.prototype,"type");Zr([he()],vo.prototype,"position");class _h extends Fn{constructor(){super(...arguments);O(this,"clip");O(this,"type","caption");O(this,"preset",new vo)}from(t){var a;return this.clip=t,(a=this.clip)==null||a.on("offsetBy",r=>this.offsetBy(r.detail)),this}async generate(t){let a=this.preset;return typeof t=="object"?a=t:t&&(a=new t),this.clips=[],this.trigger("update",void 0),this.preset=a,await a.applyTo(this),this.trigger("update",void 0),this}}var Th=Object.defineProperty,ka=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Th(o,t,r),r};class go extends xt{constructor(t={}){super();O(this,"generatorOptions");O(this,"type","SPOTLIGHT");O(this,"color");O(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.color=t.color??"#00FF4C",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(p=>p.text);await t.add(new wa({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:22,maxWidth:t.composition.width*.8,font:r,stroke:{width:5,color:"#000000"},shadow:{color:"#000000",blur:12,alpha:.7,angle:Math.PI/4,distance:2},position:this.position,styles:[{fillStyle:this.color}],segments:c.words.length>1?[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]:void 0,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a)}))}}}ka([he()],go.prototype,"generatorOptions");ka([he()],go.prototype,"type");ka([he()],go.prototype,"color");ka([he()],go.prototype,"position");var Mh=Object.defineProperty,Yr=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Mh(o,t,r),r};class xa extends xt{constructor(t={}){super();O(this,"type","GUINEA");O(this,"colors");O(this,"position");this.colors=t.colors??["#1BD724","#FFEE0C","#FF2E17"],this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l,c,d,u,p;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"The Bold Font",weight:"500"}).load();for(const m of t.clip.transcript.iter({length:[18]})){const{segments:h,words:g}=this.splitSequence(m);for(let v=0;v<m.words.length;v++){const x=(d=(c=g[v])==null?void 0:c.at(0))==null?void 0:d.start,B=(p=(u=g[v])==null?void 0:u.at(-1))==null?void 0:p.stop;!x||!B||await t.add(new wa({text:h.join(`
|
|
33
|
-
`),textAlign:"center",textBaseline:"middle",fontSize:20,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:16,alpha:.8,angle:Math.PI/4,distance:1},stroke:{width:4,color:"#000000"},maxWidth:t.composition.width*.8,leading:1.3,font:r,textCase:"upper",position:this.position,stop:B.add(a),start:x.add(a),styles:[{fillStyle:this.colors[0],fontSize:23},{fillStyle:this.colors[1],fontSize:23},{fillStyle:this.colors[2],fontSize:23}],segments:[{index:Xo(0,2),start:h.slice(0,v).join(" ").length,stop:h.slice(0,v+1).join(" ").length+v*2}]}))}}}splitSequence(t){const a=t.text,r=Math.ceil(a.length/2);let i=a.length;for(let c=r,d=r;c>0&&d<t.text.length-1;c--,d++){if(a[c].match(/ /)){i=c;break}if(a[d].match(/ /)){i=d;break}}const s=[...ss(a,i).map(c=>c.trim())],l=ss(t.words,s[0].split(/ /).length);return{segments:s,words:l}}}Yr([he()],xa.prototype,"type");Yr([he()],xa.prototype,"colors");Yr([he()],xa.prototype,"position");var Fh=Object.defineProperty,Gr=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Fh(o,t,r),r};class Sa extends xt{constructor(t={}){super();O(this,"generatorOptions");O(this,"type","CASCADE");O(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1.4]},this.position=t.position??{x:"12%",y:"44%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"Geologica",weight:"400"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=()=>c.words.length==1?c.text:c.words.map(p=>p.text).slice(0,d+1).join(" ");await t.add(new Tn({text:u(),textAlign:"left",textBaseline:"top",fillStyle:"#FFFFFF",fontSize:16,font:r,maxWidth:t.composition.width*.7,stroke:{color:"#000000",width:4,join:"round"},shadow:{color:"#000000",blur:8,alpha:.4,angle:Math.PI/4,distance:2},position:this.position,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a)}))}}}Gr([he()],Sa.prototype,"generatorOptions");Gr([he()],Sa.prototype,"type");Gr([he()],Sa.prototype,"position");var Ih=Object.defineProperty,Hr=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Ih(o,t,r),r};class Ea extends xt{constructor(t={}){super();O(this,"generatorOptions");O(this,"type","SOLAR");O(this,"position");this.generatorOptions=t.generatorOptions??{duration:[.2]},this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var s,l,c;if(!((s=t.clip)!=null&&s.transcript)||!((l=t.composition)!=null&&l.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=await st.fromFamily({family:"Urbanist",weight:"800"}).load(),r=((c=t.clip)==null?void 0:c.offset)??new de,i=new Gs.GlowFilter({color:"#fffe41",alpha:.25,distance:90,quality:.05});for(const d of t.clip.transcript.iter(this.generatorOptions))await t.add(new Tn({text:d.words.map(u=>u.text).join(" "),textAlign:"center",textBaseline:"middle",fontSize:19,fillStyle:"#fffe41",font:a,maxWidth:t.composition.width*.85,textCase:"upper",shadow:{color:"#ab7a00",blur:0,distance:2.1,angle:Math.PI/2.5,alpha:1},position:this.position,stop:d.stop.add(r),start:d.start.add(r),scale:new Se([0,8],[.96,1],{easing:"easeOut"}),alpha:new Se([0,4],[0,1],{easing:"easeOut"}),filters:i}))}}Hr([he()],Ea.prototype,"generatorOptions");Hr([he()],Ea.prototype,"type");Hr([he()],Ea.prototype,"position");var Bh=Object.defineProperty,Ca=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Bh(o,t,r),r};class yo extends xt{constructor(t={}){super();O(this,"generatorOptions");O(this,"type","WHISPER");O(this,"color");O(this,"position");this.generatorOptions=t.generatorOptions??{length:[20]},this.color=t.color??"#8c8c8c",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"Montserrat",weight:"300"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(p=>p.text);await t.add(new wa({text:u.join(" "),textAlign:"center",textBaseline:"middle",fillStyle:"#FFFFFF",fontSize:13,background:{alpha:.3,padding:{x:50,y:30}},maxWidth:t.composition.width*.8,font:r,position:this.position,styles:[{fillStyle:this.color}],stop:c.words[d].stop.add(a),start:c.words[d].start.add(a),segments:u.length>1?[{index:0,start:u.slice(0,d+1).join(" ").length}]:void 0}))}}}Ca([he()],yo.prototype,"generatorOptions");Ca([he()],yo.prototype,"type");Ca([he()],yo.prototype,"color");Ca([he()],yo.prototype,"position");var Rh=Object.defineProperty,Va=(n,o,t,a)=>{for(var r=void 0,i=n.length-1,s;i>=0;i--)(s=n[i])&&(r=s(o,t,r)||r);return r&&Rh(o,t,r),r};class Na extends xt{constructor(t={}){super();O(this,"type","VERDANT");O(this,"generatorOptions");O(this,"color");O(this,"position");this.generatorOptions=t.generatorOptions??{duration:[1]},this.color=t.color??"#69E34C",this.position=t.position??{x:"50%",y:"50%"}}async applyTo(t){var i,s,l;if(!((i=t.clip)!=null&&i.transcript)||!((s=t.composition)!=null&&s.width))throw new Ge({code:"referenceError",message:"Captions need to be applied with a defined transcript and composition"});const a=((l=t.clip)==null?void 0:l.offset)??new de,r=await st.fromFamily({family:"Montserrat",weight:"800"}).load();for(const c of t.clip.transcript.iter(this.generatorOptions))for(let d=0;d<c.words.length;d++){const u=c.words.map(p=>p.text);await t.add(new wa({text:u.join(" "),textAlign:"center",textBaseline:"middle",fontSize:15,fillStyle:"#FFFFFF",shadow:{color:"#000000",blur:4,alpha:.7,angle:Math.PI/4,distance:2},stroke:{width:3,color:"#000000"},maxWidth:t.composition.width*.5,leading:1.1,font:r,textCase:"upper",styles:[{fillStyle:this.color,fontSize:19}],position:this.position,stop:c.words[d].stop.add(a),start:c.words[d].start.add(a),segments:[{index:0,start:u.slice(0,d).join(" ").length,stop:u.slice(0,d+1).join(" ").length}]}))}}}Va([he()],Na.prototype,"type");Va([he()],Na.prototype,"generatorOptions");Va([he()],Na.prototype,"color");Va([he()],Na.prototype,"position");class Ph extends mo(xt){constructor({height:t=1080,width:a=1920,background:r="#000000",backend:i="webgpu"}={}){super();O(this,"_duration",new de);O(this,"renderer");O(this,"stage",new De.Container);O(this,"settings");O(this,"tracks",[]);O(this,"frame",0);O(this,"fixedDuration");O(this,"state","IDLE");O(this,"fps",io);O(this,"canvas");O(this,"context");this.settings={height:t,width:a,background:r,backend:i},this.on("update",this.update.bind(this)),this.on("attach",this.update.bind(this)),this.on("detach",this.update.bind(this)),this.on("load",this.update.bind(this)),this.on("frame",this.update.bind(this)),this.on("error",this.update.bind(this)),De.autoDetectRenderer({...this.settings,preference:i}).then(s=>{this.renderer=s,this.trigger("init",void 0)}).catch(s=>{this.trigger("error",new so({code:"backendDetectionError",message:`${s}`}))})}get playing(){return this.state=="PLAY"}get rendering(){return this.state=="RENDER"}get width(){return this.settings.width}get height(){return this.settings.height}get duration(){return this.fixedDuration?this.fixedDuration:this._duration}set duration(t){var a;t?t instanceof de?this.fixedDuration=t:this.fixedDuration=de.fromFrames(t):this.fixedDuration=void 0,this.trigger("frame",((a=this.fixedDuration)==null?void 0:a.frames)??0)}resize(t,a){var r;this.settings.width=t,this.settings.height=a,(r=this.renderer)==null||r.resize(t,a),this.canvas&&(this.canvas.height=a,this.canvas.width=t),this.trigger("resize",void 0),this.computeFrame()}attachPlayer(t){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.height=this.settings.height,this.canvas.width=this.settings.width,this.canvas.style.background="black",this.context=this.canvas.getContext("2d"),this.context.imageSmoothingEnabled=!1,this.computeFrame()),t.appendChild(this.canvas)}detachPlayer(t){this.canvas&&t.removeChild(this.canvas)}shiftTrack(t){const a=typeof t=="object"?t:new t;return a.connect(this),this.stage.addChild(a.view),this.tracks.unshift(a),a.bubble(this),this.trigger("update",void 0),a}createTrack(t){const a=xh.fromType({type:t});return this.shiftTrack(a),a}async add(t){return await this.createTrack(t.type).add(t),t}remove(t){for(const a of this.tracks)if(a.clips.find(r=>r.id==t.id))return a.remove(t)}removeTracks(t){const a=this.tracks.filter(r=>r instanceof t);return this.tracks=this.tracks.filter(r=>!(r instanceof t)),a.forEach(r=>this.removeTrack(r)),a}findTracks(t){return this.tracks.filter(a=>{let r;return ls(t)?r=a instanceof t:r=t(a),r})}findClips(t){const a=[];for(const r of this.tracks)for(const i of r.clips){let s;ls(t)?s=i instanceof t:s=t(i),s&&a.push(i)}return a}computeFrame(){var t,a;if(this.renderer){for(let r=0;r<this.tracks.length;r++)this.tracks[r].update(de.fromFrames(this.frame));this.renderer.render(this.stage),(t=this.context)==null||t.clearRect(0,0,this.settings.width,this.settings.height),(a=this.context)==null||a.drawImage(this.renderer.canvas,0,0),this.trigger("currentframe",this.frame),this.playing&&this.frame++}}screenshot(t="png",a=1){if(this.computeFrame(),!this.renderer)throw new so({code:"rendererNotDefined",message:"Please wait until the renderer is defined"});return this.renderer.canvas.toDataURL(`image/${t}`,a)}async seek(t){typeof t=="number"?this.frame=Math.round(t>0?t:0):this.frame=t.frames>0?t.frames:0,this.playing&&this.pause();for(const a of this.tracks)await a.seek(de.fromFrames(this.frame));this.rendering||this.computeFrame()}async play(){if(!this.rendering){this.state="PLAY",this.frame>=this.duration.frames&&(this.frame=0);for(const t of this.tracks)await t.seek(de.fromFrames(this.frame));this.ticker(),this.trigger("play",this.frame)}}async pause(){this.state="IDLE",this.computeFrame(),this.trigger("pause",this.frame)}async audio(t=2,a=48e3){var s;const r=this.duration.seconds*a,i=new OfflineAudioContext({sampleRate:a,length:r,numberOfChannels:t}).createBuffer(t,r,a);for(const l of this.findClips(va)){if(l.disabled||l.muted||(s=l.track)!=null&&s.disabled)continue;const c=Math.round(l.offset.seconds*i.sampleRate),d=Math.round(l.range[0].seconds*i.sampleRate),u=Math.round(l.range[1].seconds*i.sampleRate);try{const p=await l.source.decode(t,a),m=p.numberOfChannels-1;for(let h=0;h<t;h++){const g=i.getChannelData(h),v=p.getChannelData(h>m?m:h);for(let x=0;x<g.length-1;x++)x<c+d||x>c+u||x-c<0||(g[x]+=(v[x-c]??0)*l.volume,g[x]>1&&(g[x]=1),g[x]<-1&&(g[x]=-1));i.getChannelData(h).set(g)}}catch{}}return i}time(t){const a=En(this.frame),r=t!=null&&t.hours?11:14,i=t!=null&&t.milliseconds?23:19;return new Date(a).toISOString().slice(r,i)+" / "+new Date(this.duration.millis).toISOString().slice(r,i)}removeTrack(t){const a=this.tracks.findIndex(r=>r.id==t.id);if(t.view.parent&&this.stage.removeChild(t.view),a!=null&&a>=0)return this.tracks.splice(a,1),this.trigger("detach",void 0),t.off("*"),t}async ticker(){const t=1e3/io;let a=performance.now(),r=0;do{const i=await new Promise(requestAnimationFrame);i-a<t-r||(r=Math.min(t,r+i-a-t),a=i,this.computeFrame())}while(this.frame<=this.duration.frames&&this.playing);this.playing&&this.seek(0)}update(){this._duration.frames=Math.max(...this.tracks.filter(t=>!t.disabled).map(t=>{var a;return((a=t.stop)==null?void 0:a.frames)??0}),0),this.computeFrame()}}const eo={brightness:{id:"brightness",name:"Brightness",category:"adjust",cssFunction:n=>`brightness(${n.value}%)`,defaultParams:{value:100},controls:[{id:"value",type:"slider",label:"Brightness",property:"value",min:0,max:200,step:1,default:100,unit:"%"}]},contrast:{id:"contrast",name:"Contrast",category:"adjust",cssFunction:n=>`contrast(${n.value}%)`,defaultParams:{value:100},controls:[{id:"value",type:"slider",label:"Contrast",property:"value",min:0,max:200,step:1,default:100,unit:"%"}]},saturation:{id:"saturation",name:"Saturation",category:"adjust",cssFunction:n=>`saturate(${n.value}%)`,defaultParams:{value:100},controls:[{id:"value",type:"slider",label:"Saturation",property:"value",min:0,max:200,step:1,default:100,unit:"%"}]},hue:{id:"hue",name:"Hue Rotate",category:"color",cssFunction:n=>`hue-rotate(${n.degrees}deg)`,defaultParams:{degrees:0},controls:[{id:"degrees",type:"slider",label:"Hue Shift",property:"degrees",min:-180,max:180,step:1,default:0,unit:"°"}]},blur:{id:"blur",name:"Gaussian Blur",category:"blur",cssFunction:n=>`blur(${n.radius}px)`,defaultParams:{radius:0},controls:[{id:"radius",type:"slider",label:"Blur Radius",property:"radius",min:0,max:50,step:.5,default:0,unit:"px"}]},grayscale:{id:"grayscale",name:"Grayscale",category:"stylize",cssFunction:n=>`grayscale(${n.amount}%)`,defaultParams:{amount:0},controls:[{id:"amount",type:"slider",label:"Amount",property:"amount",min:0,max:100,step:1,default:0,unit:"%"}]},sepia:{id:"sepia",name:"Sepia",category:"stylize",cssFunction:n=>`sepia(${n.amount}%)`,defaultParams:{amount:0},controls:[{id:"amount",type:"slider",label:"Amount",property:"amount",min:0,max:100,step:1,default:0,unit:"%"}]},invert:{id:"invert",name:"Invert",category:"stylize",cssFunction:n=>`invert(${n.amount}%)`,defaultParams:{amount:0},controls:[{id:"amount",type:"slider",label:"Amount",property:"amount",min:0,max:100,step:1,default:0,unit:"%"}]},opacity:{id:"opacity",name:"Opacity",category:"light",cssFunction:n=>`opacity(${n.value}%)`,defaultParams:{value:100},controls:[{id:"value",type:"slider",label:"Opacity",property:"value",min:0,max:100,step:1,default:100,unit:"%"}]},dropShadow:{id:"dropShadow",name:"Drop Shadow",category:"light",cssFunction:n=>`drop-shadow(${n.x}px ${n.y}px ${n.blur}px ${n.color})`,defaultParams:{x:5,y:5,blur:5,color:"rgba(0,0,0,0.5)"},controls:[{id:"x",type:"slider",label:"X Offset",property:"x",min:-50,max:50,step:1,default:5,unit:"px"},{id:"y",type:"slider",label:"Y Offset",property:"y",min:-50,max:50,step:1,default:5,unit:"px"},{id:"blur",type:"slider",label:"Blur",property:"blur",min:0,max:50,step:1,default:5,unit:"px"},{id:"color",type:"color",label:"Shadow Color",property:"color",default:"#000000"}]},glow:{id:"glow",name:"Glow",category:"light",cssFunction:n=>`url(#glow-${n._instanceId})`,defaultParams:{radius:10,intensity:1,color:"#ffffff"},svgFilter:n=>`
|
|
34
|
-
<filter id="glow-${n._instanceId}">
|
|
35
|
-
<feGaussianBlur stdDeviation="${n.radius}" result="coloredBlur"/>
|
|
36
|
-
<feMerge>
|
|
37
|
-
<feMergeNode in="coloredBlur"/>
|
|
38
|
-
<feMergeNode in="SourceGraphic"/>
|
|
39
|
-
</feMerge>
|
|
40
|
-
</filter>
|
|
41
|
-
`,controls:[{id:"radius",type:"slider",label:"Glow Radius",property:"radius",min:0,max:50,step:1,default:10},{id:"intensity",type:"slider",label:"Intensity",property:"intensity",min:0,max:5,step:.1,default:1},{id:"color",type:"color",label:"Glow Color",property:"color",default:"#ffffff"}]},vignette:{id:"vignette",name:"Vignette",category:"stylize",cssFunction:n=>`url(#vignette-${n._instanceId})`,defaultParams:{radius:.5,darkness:.5},svgFilter:n=>`
|
|
42
|
-
<filter id="vignette-${n._instanceId}">
|
|
43
|
-
<feGaussianBlur in="SourceGraphic" stdDeviation="3"/>
|
|
44
|
-
<feComponentTransfer>
|
|
45
|
-
<feFuncA type="table" tableValues="0 ${1-n.darkness} 1"/>
|
|
46
|
-
</feComponentTransfer>
|
|
47
|
-
</filter>
|
|
48
|
-
`,controls:[{id:"radius",type:"slider",label:"Radius",property:"radius",min:0,max:1,step:.01,default:.5},{id:"darkness",type:"slider",label:"Darkness",property:"darkness",min:0,max:1,step:.01,default:.5}]},warmth:{id:"warmth",name:"Temperature",category:"color",cssFunction:n=>{const o=n.value>0?`sepia(${n.value}%)`:"",t=n.value<0?`hue-rotate(${n.value*2}deg)`:"";return`${o} ${t}`.trim()},defaultParams:{value:0},controls:[{id:"value",type:"slider",label:"Temperature",property:"value",min:-50,max:50,step:1,default:0}]},tint:{id:"tint",name:"Color Tint",category:"color",cssFunction:n=>`url(#tint-${n._instanceId})`,defaultParams:{color:"#ff0000",intensity:.3},svgFilter:n=>{const o=parseInt(n.color.slice(1,3),16)/255,t=parseInt(n.color.slice(3,5),16)/255,a=parseInt(n.color.slice(5,7),16)/255,r=n.intensity;return`
|
|
49
|
-
<filter id="tint-${n._instanceId}">
|
|
50
|
-
<feColorMatrix type="matrix" values="
|
|
51
|
-
${1-r+r*o} ${r*o} ${r*o} 0 0
|
|
52
|
-
${r*t} ${1-r+r*t} ${r*t} 0 0
|
|
53
|
-
${r*a} ${r*a} ${1-r+r*a} 0 0
|
|
54
|
-
0 0 0 1 0"/>
|
|
55
|
-
</filter>
|
|
56
|
-
`},controls:[{id:"color",type:"color",label:"Tint Color",property:"color",default:"#ff0000"},{id:"intensity",type:"slider",label:"Intensity",property:"intensity",min:0,max:1,step:.01,default:.3}]},vintage:{id:"vintage",name:"Vintage",category:"stylize",cssFunction:n=>`sepia(${n.sepia}%) saturate(${n.saturate}%) contrast(${n.contrast}%)`,defaultParams:{sepia:30,saturate:140,contrast:110},controls:[{id:"sepia",type:"slider",label:"Sepia",property:"sepia",min:0,max:100,step:1,default:30,unit:"%"},{id:"saturate",type:"slider",label:"Saturation",property:"saturate",min:0,max:200,step:1,default:140,unit:"%"},{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:50,max:150,step:1,default:110,unit:"%"}]},blackAndWhite:{id:"blackAndWhite",name:"Black & White",category:"stylize",cssFunction:n=>`grayscale(100%) contrast(${n.contrast}%)`,defaultParams:{contrast:120},controls:[{id:"contrast",type:"slider",label:"Contrast",property:"contrast",min:50,max:200,step:1,default:120,unit:"%"}]},cinematic:{id:"cinematic",name:"Cinematic",category:"stylize",cssFunction:()=>"contrast(120%) brightness(95%) saturate(85%)",defaultParams:{},controls:[]},dramatic:{id:"dramatic",name:"Dramatic",category:"stylize",cssFunction:()=>"contrast(140%) brightness(90%) saturate(110%) sepia(10%)",defaultParams:{},controls:[]},dreamy:{id:"dreamy",name:"Dreamy",category:"stylize",cssFunction:()=>"blur(0.5px) brightness(105%) saturate(90%) contrast(95%)",defaultParams:{},controls:[]},pixelate:{id:"pixelate",name:"Pixelate",category:"distort",cssFunction:n=>`url(#pixelate-${n._instanceId})`,defaultParams:{size:10},svgFilter:n=>`
|
|
57
|
-
<filter id="pixelate-${n._instanceId}">
|
|
58
|
-
<feFlood x="0" y="0" width="${n.size}" height="${n.size}"/>
|
|
59
|
-
<feComposite width="${n.size*2}" height="${n.size*2}"/>
|
|
60
|
-
<feTile result="tiled"/>
|
|
61
|
-
<feComposite in="SourceGraphic" in2="tiled" operator="over"/>
|
|
62
|
-
</filter>
|
|
63
|
-
`,controls:[{id:"size",type:"slider",label:"Pixel Size",property:"size",min:2,max:50,step:1,default:10}]},chromatic:{id:"chromatic",name:"Chromatic Aberration",category:"distort",cssFunction:n=>`url(#chromatic-${n._instanceId})`,defaultParams:{offset:5},svgFilter:n=>`
|
|
64
|
-
<filter id="chromatic-${n._instanceId}">
|
|
65
|
-
<feOffset in="SourceGraphic" dx="${-n.offset}" dy="0" result="red"/>
|
|
66
|
-
<feOffset in="SourceGraphic" dx="${n.offset}" dy="0" result="blue"/>
|
|
67
|
-
<feBlend mode="screen" in="red" in2="SourceGraphic" result="rb"/>
|
|
68
|
-
<feBlend mode="screen" in="rb" in2="blue"/>
|
|
69
|
-
</filter>
|
|
70
|
-
`,controls:[{id:"offset",type:"slider",label:"Offset",property:"offset",min:0,max:20,step:1,default:5}]}};class $h{constructor(){this.filters=new Map,this.svgContainer=null,this.instanceCounter=0,this.initSVGContainer()}initSVGContainer(){if(typeof document>"u")return;const o=document.getElementById("css-filter-svg-container");if(o){this.svgContainer=o;return}const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.id="css-filter-svg-container",t.style.position="absolute",t.style.width="0",t.style.height="0",t.style.overflow="hidden",document.body.appendChild(t),this.svgContainer=t}addFilter(o,t={}){const a=eo[o];if(!a)return"";const r=`${o}-${++this.instanceCounter}`,i={...a.defaultParams,...t,_instanceId:r},s={id:r,filterId:o,params:i,enabled:!0};if(this.filters.set(r,s),a.svgFilter&&this.svgContainer){const l=this.svgContainer.querySelector("defs")||this.svgContainer.appendChild(document.createElementNS("http://www.w3.org/2000/svg","defs")),c=document.createElementNS("http://www.w3.org/2000/svg","filter");c.innerHTML=a.svgFilter(i);const d=new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${a.svgFilter(i)}</svg>`,"image/svg+xml").documentElement.firstChild;d&&l.appendChild(d)}return r}updateFilter(o,t){const a=this.filters.get(o);if(!a)return;a.params={...a.params,...t};const r=eo[a.filterId];if(r.svgFilter&&this.svgContainer){const i=this.svgContainer.querySelector(`#${a.filterId}-${a.params._instanceId}`);i&&(i.innerHTML=r.svgFilter(a.params))}}removeFilter(o){const t=this.filters.get(o);if(t&&(this.filters.delete(o),this.svgContainer)){const a=this.svgContainer.querySelector(`#${t.filterId}-${t.params._instanceId}`);a==null||a.remove()}}getCSSFilterString(){const o=[];for(const t of this.filters.values()){if(!t.enabled)continue;const a=eo[t.filterId];if(!a)continue;const r=a.cssFunction(t.params);r&&o.push(r)}return o.join(" ")}applyToContext(o){const t=this.getCSSFilterString();t?o.filter=t:o.filter="none"}clear(){if(this.svgContainer){const o=this.svgContainer.querySelector("defs");o&&(o.innerHTML="")}this.filters.clear()}getFilters(){return Array.from(this.filters.values())}toggleFilter(o,t){const a=this.filters.get(o);a&&(a.enabled=t??!a.enabled)}createPreset(){return this.getFilters().map(o=>({...o}))}loadPreset(o){this.clear();for(const t of o){const a=this.addFilter(t.filterId,t.params),r=this.filters.get(a);r&&(r.enabled=t.enabled)}}}const zh={brightness:"brightness",contrast:"contrast",blur:"blur",grayscale:"grayscale",sepia:"sepia",hue:"hue",saturation:"saturation",invert:"invert",colorOverlay:"tint",alpha:"opacity",dropShadow:"dropShadow",glow:"glow",vignette:"vignette",pixelate:"pixelate",rgbSplit:"chromatic",vintage:"vintage",blackWhite:"blackAndWhite",oldFilm:"vintage",twist:null,bulge:null,displacement:null,shockwave:null,zoomBlur:null,motionBlur:null,radialBlur:null,tiltShift:null};async function Ah(n){var a,r;const o=(a=n.metadata)==null?void 0:a.source_url;if(o)return o;const t=(r=n.source)==null?void 0:r.media_uuid;if(t){if(typeof window<"u"){const i=window;if(i.MEDIABLES_MEDIA_URLS&&i.MEDIABLES_MEDIA_URLS[t])return i.MEDIABLES_MEDIA_URLS[t]}if(!t.startsWith("temp-"))try{if(typeof fetch<"u"){const i=await fetch(`/api/media/${t}`);if(i.ok){const s=await i.json();return s.playback_url||s.url||void 0}}}catch{}}}class Ll{constructor(o=1920,t=1080,a=30,r){this.clips=new Map,this.clipTimelineStart=new Map,this.resizeObserver=null,this.clipFilterManagers=new Map,this.currentFilterString="",this.originalComputeFrame=null,this.renderCanvas=null,this.renderContext=null,this.fps=a,this.fitMode=(r==null?void 0:r.fitMode)??"contain",this.composition=new Ph({width:o,height:t,background:"#000000"}),this.initPromise=new Promise(i=>{const s=()=>{this.setupRenderInterception(),i()};this.composition.renderer?s():this.composition.on("init",s)}),this.composition.on("pause",()=>{}),this.composition.on("play",()=>{})}setupRenderInterception(){this.originalComputeFrame=this.composition.computeFrame.bind(this.composition),this.renderCanvas=document.createElement("canvas"),this.renderCanvas.width=this.composition.width,this.renderCanvas.height=this.composition.height,this.renderContext=this.renderCanvas.getContext("2d"),this.composition.computeFrame=()=>{this.originalComputeFrame&&this.originalComputeFrame(),this.applyCSSFiltersToCanvas()}}applyCSSFiltersToCanvas(){var r;const o=this.composition,t=(o==null?void 0:o.canvas)||((r=o==null?void 0:o.renderer)==null?void 0:r.canvas);if(!t||!this.renderContext)return;const a=this.getCurrentClipId();if(a){const i=this.clipFilterManagers.get(a);i&&(this.currentFilterString=i.getCSSFilterString())}this.currentFilterString?this.renderContext.filter=this.currentFilterString:this.renderContext.filter="none",this.renderContext.clearRect(0,0,this.renderCanvas.width,this.renderCanvas.height),this.renderContext.drawImage(t,0,0),o.canvas&&o.context&&(o.context.clearRect(0,0,o.canvas.width,o.canvas.height),o.context.drawImage(this.renderCanvas,0,0))}getCurrentClipId(){var t;const o=this.composition.frame;for(const[a,r]of this.clipTimelineStart.entries()){const i=this.clips.get(a);if(!i)continue;const s=((t=i.duration)==null?void 0:t.frames)||0,l=r+s;if(o>=r&&o<l)return a}return null}async loadRecipe(o,t){var a;await this.initPromise,this.clips.clear(),this.clipTimelineStart.clear(),this.clipFilterManagers.clear();for(const r of o.timeline){const i=t==null?void 0:t[r.id];await this.addTimelineClip(r,i)}if(o.textOverlays)for(const r of o.textOverlays)await this.addTextOverlay(r);for(const r of o.timeline)(a=r.filters)!=null&&a.length&&this.applyFiltersToClip(r.id,r.filters);this.composition.seek(0),this.composition.computeFrame()}async loadFromRecipe(o){const t=await Ah(o),a=t?Object.fromEntries(o.timeline.map(r=>[r.id,t])):void 0;await this.loadRecipe(o,a)}moveClip(o,t){const a=this.clips.get(o);if(!a)return;const r=this.clipTimelineStart.get(o),i=r!==void 0?r/this.fps:0,s=t-i;a.offsetBy(de.fromSeconds(s)),this.clipTimelineStart.set(o,Math.round(t*this.fps)),this.composition.computeFrame()}trimClip(o,t,a){const r=this.clips.get(o);if(!r)return;const i=r;i.subclip&&(i.subclip(de.fromSeconds(t),de.fromSeconds(a)),this.composition.computeFrame())}applyFiltersToClip(o,t){if(!this.clips.get(o))return;let r=this.clipFilterManagers.get(o);r||(r=new $h,this.clipFilterManagers.set(o,r)),r.clear();for(const i of t){const s=zh[i.filterId]||i.filterId;if(!s||!eo[s])continue;const l={...i.params};i.intensity!==void 0&&i.intensity!==1&&(s==="tint"||s==="opacity"?l.intensity=i.intensity:eo[s].controls.some(c=>c.property==="amount")&&(l.amount=(l.amount||100)*i.intensity)),r.addFilter(s,l)}this.composition.computeFrame()}setClipFilters(o,t){this.applyFiltersToClip(o,t)}getCSSFilterStringForExport(o){var t;for(const[a,r]of this.clipTimelineStart.entries()){const i=this.clips.get(a);if(!i)continue;const s=((t=i.duration)==null?void 0:t.frames)||0,l=r+s;if(o>=r&&o<l){const c=this.clipFilterManagers.get(a);if(c)return c.getCSSFilterString()}}return""}async addTimelineClip(o,t){try{const a=o.url||t;if(!a)throw new Error("No video source URL available for clip");let r;if(/\.(jpg|jpeg|png|gif|webp)$/i.test(a)){const l=new xr(await aa.from(a),{duration:de.fromSeconds(o.duration||5)});r=l,o.transform&&(o.transform.x!==void 0&&(l.x=o.transform.x),o.transform.y!==void 0&&(l.y=o.transform.y),o.transform.scale!==void 0&&(l.scale={x:o.transform.scale,y:o.transform.scale})),o.scale!==void 0&&(!o.transform||o.transform.scale===void 0)&&(l.scale={x:o.scale,y:o.scale})}else{const l=new ia(await ra.from(a),{duration:de.fromSeconds(o.duration||10)});o.sourceIn&&l.subclip(de.fromSeconds(o.sourceIn)),r=l,o.transform&&(o.transform.x!==void 0&&(l.x=o.transform.x),o.transform.y!==void 0&&(l.y=o.transform.y),o.transform.scale!==void 0&&(l.scale={x:o.transform.scale,y:o.transform.scale})),o.scale!==void 0&&(!o.transform||o.transform.scale===void 0)&&(l.scale={x:o.scale,y:o.scale})}o.transform&&(o.transform.opacity!==void 0&&(r.alpha=o.transform.opacity),o.transform.rotation!==void 0&&(r.rotation=o.transform.rotation)),this.composition.createTrack("video").add(r),r.offsetBy(de.fromSeconds(o.timelineStart)),this.clips.set(o.id,r),this.clipTimelineStart.set(o.id,Math.round(o.timelineStart*this.fps)),this.applyFitToClip(r)}catch{}}async addTextOverlay(o){try{const t=new st({family:o.fontFamily||"Arial",weight:o.fontWeight||"400"}),a=new Tn({text:o.content,font:t,fontSize:o.fontSize||48,fillStyle:o.color||"#ffffff",textAlign:o.textAlign||"center",position:o.position||"center",textBaseline:o.textBaseline||"middle"});this.composition.createTrack("text").add(a),o.startTime!==void 0&&a.offsetBy(de.fromSeconds(o.startTime)),this.clips.set(o.id||`text-${Date.now()}`,a)}catch{}}applyFitToClip(o){if(this.fitMode!=="none")try{const t=this.composition.width,a=this.composition.height,r=o.source,i=(r==null?void 0:r.width)??(r==null?void 0:r.videoWidth),s=(r==null?void 0:r.height)??(r==null?void 0:r.videoHeight);if(!i||!s)return;let l=1;this.fitMode==="contain"?l=Math.min(t/i,a/s):this.fitMode==="cover"&&(l=Math.max(t/i,a/s)),o.scale={x:l,y:l}}catch{}}async attachPlayer(o){this.composition.attachPlayer(o),await this.initPromise}play(){this.composition.play()}pause(){this.composition.pause(),this.composition.computeFrame()}seek(o){this.composition.seek(o)}seekToTime(o){this.composition.seek(o*this.fps)}get duration(){return this.composition.duration}get durationInSeconds(){return this.composition.duration.seconds}get currentTimeInSeconds(){return this.composition.time().seconds}get width(){return this.composition.width}get height(){return this.composition.height}setFitMode(o){this.fitMode=o;for(const t of this.clips.values()){const a=t;(a instanceof ia||a instanceof xr)&&this.applyFitToClip(a)}this.composition.computeFrame()}dispose(){this.pause(),this.clipFilterManagers.forEach(o=>o.clear()),this.clipFilterManagers.clear(),this.clips.clear(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.renderCanvas&&(this.renderCanvas=null,this.renderContext=null),this.originalComputeFrame&&(this.composition.computeFrame=this.originalComputeFrame,this.originalComputeFrame=null)}destroy(){this.dispose()}}const Dh=["src"],Uh={class:"preview-controls"},Oh=["aria-label"],Lh={class:"time-display"},Wh={class:"current-time"},jh={class:"total-time"},Xh={key:2,class:"loading-overlay"},Zh={key:3,class:"error-overlay"},Yh=e.defineComponent({__name:"VideoPreviewEngine",props:{mediaUuid:{},recipe:{},media:{},autoPlay:{type:Boolean,default:!1},enableEngine:{type:Boolean,default:!0},fitMode:{default:"contain"}},emits:["time-update","duration-change","play-state-change","error","engine-ready"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(),s=e.ref(),l=e.ref(!1),c=e.ref("Initializing..."),d=e.ref(null),u=e.ref(!1),p=e.ref(0),m=e.ref(0);let h=null;const g=e.computed(()=>!!t.enableEngine&&!!t.recipe),v=e.computed(()=>{switch(t.fitMode){case"cover":return"cover";case"none":return"none";default:return"contain"}}),x=e.computed(()=>{var k,T;return(k=t.media)!=null&&k.url?t.media.url:(((T=t.media)==null?void 0:T.file)instanceof File,"")});async function B(){var k,T,F;if(!(!i.value||!t.recipe))try{l.value=!0,c.value="Initializing video engine...";const D=((k=t.recipe.source)==null?void 0:k.original_width)||1920,R=((T=t.recipe.source)==null?void 0:T.original_height)||1080,W=((F=t.recipe.output)==null?void 0:F.fps)||30;h=new Ll(D,R,W,{fitMode:t.fitMode}),h.attachPlayer(i.value),c.value="Loading composition...",await h.loadFromRecipe(t.recipe),m.value=h.durationInSeconds,E(),l.value=!1,a("engine-ready",h),t.autoPlay&&(h.play(),u.value=!0)}catch(D){const R=D instanceof Error?D.message:String(D);d.value=`Failed to initialize: ${R}`,l.value=!1}}function E(){if(!h)return;const k=setInterval(()=>{h&&u.value&&(p.value=h.currentTimeInSeconds,a("time-update",p.value))},100);P.value=k}function y(){g.value&&h?(u.value?h.pause():h.play(),u.value=!u.value,a("play-state-change",u.value)):s.value&&(u.value?s.value.pause():s.value.play(),u.value=!u.value,a("play-state-change",u.value))}function f(k){const T=Math.floor(k/60),F=Math.floor(k%60);return`${T}:${F.toString().padStart(2,"0")}`}function w(){d.value=null,g.value&&B()}function $(){!g.value&&s.value&&(m.value=s.value.duration,a("duration-change",m.value))}function C(){!g.value&&s.value&&(p.value=s.value.currentTime,a("time-update",p.value))}function b(){u.value=!1,a("play-state-change",!1)}function N(k){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{g.value&&t.recipe&&B()}),e.onUnmounted(()=>{h&&(h.destroy(),h=null),P.value&&(clearInterval(P.value),P.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async k=>{if(g.value&&k)if(h)try{await h.loadFromRecipe(k),m.value=h.durationInSeconds}catch{}else await B()}),e.watch(()=>t.enableEngine,async k=>{k?await B():h&&(P.value&&(clearInterval(P.value),P.value=null),h.destroy(),h=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!g.value||!h))try{h.setFitMode(k||"contain")}catch{}});const P=e.ref(null);return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:r},[g.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"videoEnginePlayer",ref:i,class:"video-engine-player",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"}},null,512)):(e.openBlock(),e.createElementBlock("video",{key:1,ref_key:"videoRef",ref:s,src:x.value,onLoadedmetadata:$,onTimeupdate:C,onEnded:b,onError:N,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:v.value}),playsinline:"",controls:""},null,44,Dh)),e.createElementVNode("div",Uh,[e.createElementVNode("button",{class:"play-button",onClick:y,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.value?e.unref(sl):e.unref(ll)},null,8,["icon"])],8,Oh),e.createElementVNode("div",Lh,[e.createElementVNode("span",Wh,e.toDisplayString(f(p.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",jh,e.toDisplayString(f(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Xh,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"}),e.createElementVNode("p",null,e.toDisplayString(c.value),1)])):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("div",Zh,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(d.value),1),e.createElementVNode("button",{onClick:w},"Retry")])):e.createCommentVNode("",!0)],512))}}),Ss=_e(Yh,[["__scopeId","data-v-17b615b8"]]),Gh=["aria-label"],Hh=["aria-label"],Jh={class:"clip-content"},qh={key:0,class:"clip-thumbnail"},Kh=["src","alt"],Qh={class:"clip-waveform"},e0={class:"clip-info"},t0={class:"clip-label"},n0={class:"clip-duration"},o0={key:1,class:"filter-indicators"},a0={key:2,class:"speed-indicator"},r0={key:0,class:"selection-overlay"},i0=e.defineComponent({__name:"TimelineClip",props:{clip:{},scale:{},scrollOffset:{default:0},selected:{type:Boolean,default:!1},isMobile:{type:Boolean,default:!1}},emits:["select","trim-start","trim-end","drag","trim-start-abs","trim-end-abs","drag-abs"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),s=e.ref(null),l=e.ref(0),c=e.ref(0),d=e.computed(()=>{const N=(t.clip.timelineEnd-t.clip.timelineStart)*t.scale;return{left:`${t.clip.timelineStart*t.scale-t.scrollOffset}px`,width:`${N}px`}}),u=e.computed(()=>t.clip.label||`Clip ${t.clip.id.slice(-4)}`),p=e.computed(()=>{const b=t.clip.timelineEnd-t.clip.timelineStart;return g(b)}),m=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),h=e.computed(()=>t.clip.filters||[]);function g(b){if(b<1)return`${Math.round(b*30)}f`;if(b<60)return`${b.toFixed(1)}s`;{const N=Math.floor(b/60),P=Math.floor(b%60);return`${N}:${P.toString().padStart(2,"0")}`}}function v(b){return!b||typeof b!="string"?ts:b.includes("color")||b.includes("brightness")?Ht:b.includes("blur")?Iu:b.includes("style")?Ln:b.includes("effect")?Gt:ts}function x(){i.value||a("select")}function B(b){b.button===0&&(f("move",b.clientX),b.preventDefault())}function E(b){if(b.touches.length!==1)return;const N=b.touches[0];f("move",N.clientX),b.preventDefault()}function y(b,N){const P="touches"in N?N.touches[0].clientX:N.clientX;s.value=b==="start"?"trim-start":"trim-end",f(s.value,P),N.preventDefault(),N.stopPropagation()}function f(b,N){i.value=!0,s.value=b,l.value=N,b==="move"?c.value=t.clip.timelineStart:b==="trim-start"?c.value=t.clip.sourceIn:b==="trim-end"&&(c.value=t.clip.sourceOut),document.addEventListener("mousemove",w),document.addEventListener("mouseup",$),document.addEventListener("touchmove",w),document.addEventListener("touchend",$),t.selected||a("select")}function w(b){if(!i.value||!s.value)return;const N="touches"in b?b.touches[0].clientX:b.clientX,k=N-l.value;s.value==="move"?(a("drag",k),a("drag-abs",N)):s.value==="trim-start"?(a("trim-start",k),a("trim-start-abs",N)):s.value==="trim-end"&&(a("trim-end",k),a("trim-end-abs",N))}function $(){i.value=!1,s.value=null,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",$),document.removeEventListener("touchmove",w),document.removeEventListener("touchend",$)}function C(){if(!r.value)return;const b=r.value,N=b.getContext("2d");if(!N)return;b.width=b.clientWidth*window.devicePixelRatio,b.height=b.clientHeight*window.devicePixelRatio,N.scale(window.devicePixelRatio,window.devicePixelRatio),N.strokeStyle="rgba(255, 255, 255, 0.3)",N.lineWidth=1,N.beginPath();const P=b.clientWidth,k=b.clientHeight,T=k/2;N.moveTo(0,T),N.lineTo(P,T);for(let F=0;F<P;F+=4){const D=Math.sin(F*.05)*(k*.3);N.moveTo(F,T-D),N.lineTo(F,T+D)}N.stroke()}return e.onMounted(()=>{C(),window.addEventListener("resize",C)}),e.onUnmounted(()=>{$(),window.removeEventListener("resize",C)}),(b,N)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:b.selected,mobile:b.isMobile,"has-filters":m.value}]),style:e.normalizeStyle(d.value),onClick:x,onMousedown:B,onTouchstart:E},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:N[0]||(N[0]=e.withModifiers(P=>y("start",P),["stop"])),onTouchstart:N[1]||(N[1]=e.withModifiers(P=>y("start",P),["stop"])),"aria-label":`Trim start of ${b.clip.label||"clip"}`},[...N[4]||(N[4]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Gh),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:N[2]||(N[2]=e.withModifiers(P=>y("end",P),["stop"])),onTouchstart:N[3]||(N[3]=e.withModifiers(P=>y("end",P),["stop"])),"aria-label":`Trim end of ${b.clip.label||"clip"}`},[...N[5]||(N[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Hh),e.createElementVNode("div",Jh,[b.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",qh,[e.createElementVNode("img",{src:b.clip.thumbnail,alt:b.clip.label||"Video clip"},null,8,Kh)])):e.createCommentVNode("",!0),e.createElementVNode("div",Qh,[e.createElementVNode("canvas",{ref_key:"waveformCanvas",ref:r},null,512)]),e.createElementVNode("div",e0,[e.createElementVNode("span",t0,e.toDisplayString(u.value),1),e.createElementVNode("span",n0,e.toDisplayString(p.value),1)]),m.value?(e.openBlock(),e.createElementBlock("div",o0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,P=>(e.openBlock(),e.createBlock(e.unref(I.IonIcon),{key:P.id||P.filterId,icon:v(P.filterId||P.id),title:`Filter: ${P.filterId||P.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),b.clip.speed&&b.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",a0,e.toDisplayString(b.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),b.selected?(e.openBlock(),e.createElementBlock("div",r0)):e.createCommentVNode("",!0)],38))}}),s0=_e(i0,[["__scopeId","data-v-e4f00ac9"]]);class Wl{constructor(o=30){this.fps=30,this.fps=o}setFps(o){this.fps=o}async convertTimelineClipToEngine(o,t){const a=new ia(t,{muted:o.muted||!1,scale:o.scale||1,position:"center"});if(o.sourceIn!==void 0||o.sourceOut!==void 0){const r=this.secondsToFrames(o.sourceIn||0),i=o.sourceOut?this.secondsToFrames(o.sourceOut):a.duration.frames;a.subclip(r,i)}return o.timelineStart&&o.timelineStart>0&&a.offsetBy(this.secondsToFrames(o.timelineStart)),o.transform&&this.applyTransformations(a,o.transform),a}convertEngineClipToTimeline(o,t,a){const r=this.framesToSeconds(o.duration.frames),i=o.offset?this.framesToSeconds(o.offset.frames):0;return{id:t,url:a,type:"video",timelineStart:i,timelineEnd:i+r,sourceIn:0,sourceOut:r,duration:r,muted:o.muted||!1,scale:o.scale.x||1}}async buildCompositionFromRecipe(o,t){var a;(a=t.clear)==null||a.call(t);for(const r of o.timeline)try{if(!r.url)continue;const i=await ra.from(r.url),s=await this.convertTimelineClipToEngine(r,i);await t.add(s)}catch{}o.duration&&(t.duration=de.fromFrames(this.secondsToFrames(o.duration)))}extractTimelineFromComposition(o){const t=[];return(o.clips||[]).forEach((r,i)=>{var s,l;r instanceof ia&&t.push(this.convertEngineClipToTimeline(r,`clip-${i}`,((s=r.source)==null?void 0:s.externalURL)||((l=r.source)==null?void 0:l.objectURL)||""))}),t}applyTransformations(o,t){(t.x!==void 0||t.y!==void 0)&&(o.x=t.x||0,o.y=t.y||0),t.rotation!==void 0&&(o.rotation=t.rotation),t.opacity!==void 0&&(o.alpha=t.opacity),t.scale!==void 0&&(o.scale={x:t.scale,y:t.scale})}secondsToFrames(o){return Math.round(o*this.fps)}framesToSeconds(o){return o/this.fps}framesToTime(o){const t=this.framesToSeconds(o),a=Math.floor(t/60),r=Math.floor(t%60),i=Math.floor(t%1*1e3);return`${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}.${i.toString().padStart(3,"0")}`}formatTime(o){const t=Math.floor(o/3600),a=Math.floor(o%3600/60),r=Math.floor(o%60);return`${t.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`}parseTime(o){const t=o.split(":");let a=0;if(t.length===2){const[r,i]=t;a=parseInt(r)*60+parseFloat(i)}else if(t.length===3){const[r,i,s]=t;a=parseInt(r)*3600+parseInt(i)*60+parseFloat(s)}else a=parseFloat(o);return a}timeToFrames(o){const t=o.split(":");let a=0;if(t.length===2){const[r,i]=t;a=parseInt(r)*60+parseFloat(i)}else if(t.length===3){const[r,i,s]=t;a=parseInt(r)*3600+parseInt(i)*60+parseFloat(s)}else a=parseFloat(o);return this.secondsToFrames(a)}}const l0={class:"time-markers"},c0=["aria-label","title"],d0={key:0,class:"timeline-scrollbar"},u0=e.defineComponent({__name:"VideoTimeline",props:{playhead:{},clips:{},duration:{},zoomLevel:{default:50},isMobile:{type:Boolean,default:!1},selectedClipId:{},fps:{default:30},useFrameMode:{type:Boolean,default:!1},sensitivity:{default:.25}},emits:["update:playhead","trim","split","clip-select","clip-move","toggle-frame-mode"],setup(n,{emit:o}){const t=n,a=e.computed(()=>t.isMobile===!0),r=o,i=e.ref(),s=e.ref(t.selectedClipId||null),l=e.ref(!1),c=e.ref(0),d=e.ref(),u=e.ref(0),p=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,U=>{U!==void 0&&(s.value=U)});const m=new Wl(t.fps),h=e.ref(!1),g=e.ref(null),v=e.ref(0),x=e.ref(0),B=e.ref(0),E=e.ref(0),y=e.ref(0),f=e.ref(!1),w=e.ref(0),$=e.ref(t.zoomLevel),C=e.computed(()=>t.zoomLevel);function b(U){const ne=t.clips.find(ee=>ee.id===U);if(!ne)return null;const K=t.clips.filter(ee=>ee.id!==U&&ee.timelineStart>=ne.timelineEnd-1e-9).map(ee=>ee.timelineStart);return K.length?Math.min(...K):null}function N(U){const ne=U.sourceMaxOut??t.duration,K=U.timelineStart+(ne-U.sourceIn),ee=b(U.id),be=ee!=null?Math.max(U.timelineStart,ee):1/0;return Math.min(K,be)}function P(U){const ne=U.sourceMinIn??0,ee=(U.sourceMaxOut??t.duration)-ne,be=U.sourceIn-ne;return{left:`${(U.timelineStart-be)*C.value-c.value}px`,width:`${ee*C.value}px`,top:"0px",height:"80px",opacity:p.value===U.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),T=e.computed(()=>m.secondsToFrames(t.duration)),F=e.computed(()=>t.useFrameMode?T.value*k.value:t.duration*C.value),D=e.computed(()=>{var U;return u.value||((U=i.value)==null?void 0:U.clientWidth)||800}),R=e.computed(()=>F.value>D.value),W=e.computed(()=>Math.max(0,F.value-D.value)),L=e.computed(()=>c.value>0),_=e.computed(()=>c.value<W.value),A=e.computed(()=>t.useFrameMode?m.secondsToFrames(t.playhead)*k.value-c.value:t.playhead*C.value-c.value),Z=e.computed(()=>{const U=Math.max(50,D.value/F.value*D.value),ne=c.value/W.value*(D.value-U);return{width:`${U}px`,left:`${ne}px`}}),H=e.computed(()=>{const U=[],ne=me();for(let K=0;K<=t.duration;K+=ne){const ee=K*C.value-c.value;ee>=-50&&ee<=D.value+50&&U.push({position:ee,label:Te(K),time:K})}return U});function me(){const ne=80/C.value;return ne<=1?1:ne<=5?5:ne<=10?10:ne<=30?30:ne<=60?60:Math.ceil(ne/60)*60}function Te(U){if(t.useFrameMode)return`F${m.secondsToFrames(U)}`;{const ne=Math.floor(U/60),K=Math.floor(U%60),ee=Math.floor(U%1*t.fps);return C.value>100?`${ne}:${K.toString().padStart(2,"0")}:${ee.toString().padStart(2,"0")}`:`${ne}:${K.toString().padStart(2,"0")}`}}function Be(U){const ne=i.value.getBoundingClientRect();let ee=(U.clientX-ne.left+c.value)/C.value;const be=t.clips.find(Y=>ee>=Y.timelineStart&&ee<=Y.timelineEnd);if(be)ee=Math.max(be.timelineStart,Math.min(be.timelineEnd,ee));else if(t.selectedClipId){const Y=t.clips.find(se=>se.id===t.selectedClipId);if(Y){const se=Math.abs(ee-Y.timelineStart),xe=Math.abs(ee-Y.timelineEnd);ee=se<xe?Y.timelineStart:Y.timelineEnd}}else ee=Math.max(0,Math.min(ee,t.duration));r("update:playhead",ee)}function ie(U){if(!R.value)return;const ne=Math.abs(U.deltaX)>Math.abs(U.deltaY)?U.deltaX:U.deltaY;ne!==0&&(U.preventDefault(),c.value=Math.max(0,Math.min(W.value,c.value+ne)))}function M(U){if(U.touches.length===2){f.value=!0;const ne=U.touches[0],K=U.touches[1];w.value=Math.hypot(K.clientX-ne.clientX,K.clientY-ne.clientY),$.value=t.zoomLevel}else U.touches.length===1&&(B.value=U.touches[0].clientX,E.value=U.touches[0].clientY,y.value=B.value)}function j(U){if(f.value&&U.touches.length===2){const ne=U.touches[0],K=U.touches[1],be=Math.hypot(K.clientX-ne.clientX,K.clientY-ne.clientY)/w.value;Math.max(10,Math.min(200,$.value*be)),r("update:playhead",t.playhead)}else if(U.touches.length===1&&!f.value){const ne=U.touches[0],K=y.value-ne.clientX;Math.abs(K)>Math.abs(ne.clientY-E.value)&&(U.preventDefault(),c.value=Math.max(0,Math.min(F.value-D.value,c.value+K)),y.value=ne.clientX)}}function te(){f.value=!1}function ae(U){const ne=U.target;if(ne.closest(".playhead-handle"))return;const K=U.button===1,ee=!!ne.closest(".video-track");(K||!ee&&R.value)&&re(U)}function re(U){h.value=!0,g.value="pan",v.value=U.clientX,x.value=c.value,document.addEventListener("mousemove",ve),document.addEventListener("mouseup",we)}function q(U){U.preventDefault(),U.stopPropagation(),h.value=!0,g.value="playhead";const ne="touches"in U?U.touches[0].clientX:U.clientX;v.value=ne,x.value=t.playhead,"touches"in U?(document.addEventListener("touchmove",ve),document.addEventListener("touchend",we)):(document.addEventListener("mousemove",ve),document.addEventListener("mouseup",we))}function ue(U){U.preventDefault(),U.stopPropagation(),h.value=!0,g.value="scrollbar";const ne="touches"in U?U.touches[0].clientX:U.clientX;v.value=ne,x.value=c.value,"touches"in U?(document.addEventListener("touchmove",ve),document.addEventListener("touchend",we)):(document.addEventListener("mousemove",ve),document.addEventListener("mouseup",we))}function ve(U){if(!h.value)return;const K=("touches"in U?U.touches[0].clientX:U.clientX)-v.value;if(g.value==="playhead"){const ee=K/C.value;let be=x.value+ee;if(t.selectedClipId){const Y=t.clips.find(se=>se.id===t.selectedClipId);Y?be=Math.max(Y.timelineStart,Math.min(Y.timelineEnd,be)):be=Math.max(0,Math.min(t.duration,be))}else{const Y=t.clips.find(se=>t.playhead>=se.timelineStart&&t.playhead<=se.timelineEnd);Y?be=Math.max(Y.timelineStart,Math.min(Y.timelineEnd,be)):be=Math.max(0,Math.min(t.duration,be))}r("update:playhead",be)}else if(g.value==="scrollbar"){const ee=K/D.value*F.value;c.value=Math.max(0,Math.min(W.value,x.value+ee))}else if(g.value==="pan"){const ee=x.value-K;c.value=Math.max(0,Math.min(W.value,ee))}}function we(){h.value=!1,g.value=null,document.removeEventListener("mousemove",ve),document.removeEventListener("mouseup",we),document.removeEventListener("touchmove",ve),document.removeEventListener("touchend",we)}function oe(U){s.value=s.value===U?null:U,r("clip-select",s.value)}function ye(U,ne){const K=t.clips.find(be=>be.id===U);if(!K||Math.abs(ne)<2)return;const ee=ne/C.value*t.sensitivity;if(t.useFrameMode){const be=m.secondsToFrames(K.sourceIn),Y=m.secondsToFrames(ee),se=Math.max(0,be+Y),xe=m.framesToSeconds(se);r("trim",U,"start",xe)}else{const be=Math.max(0,K.sourceIn+ee);r("trim",U,"start",be)}}function fe(U,ne){const K=t.clips.find(Ye=>Ye.id===U);if(!K||!i.value)return;const ee=i.value.getBoundingClientRect(),be=ne-ee.left,Y=80;if(be<Y)c.value=Math.max(0,c.value-8);else if(be>ee.width-Y){const Ye=Math.max(0,F.value-D.value);c.value=Math.min(Ye,c.value+8)}const se=be+c.value,xe=1/t.fps;let Ce=se/C.value;Ce=Math.max(0,Math.min(Ce,K.timelineEnd-xe));let Ue=K.sourceIn+(Ce-K.timelineStart);Ue=Math.round(Ue*t.fps)/t.fps,r("trim",U,"start",Ue)}function Ze(U,ne){const K=t.clips.find(nt=>nt.id===U);if(!K||!i.value)return;const ee=i.value.getBoundingClientRect(),be=ne-ee.left,Y=80;if(be<Y)c.value=Math.max(0,c.value-8);else if(be>ee.width-Y){const nt=Math.max(0,F.value-D.value);c.value=Math.min(nt,c.value+8)}const se=be+c.value,xe=1/t.fps,Ce=N(K);let Ue=se/C.value;Ue=Math.max(K.timelineStart+xe,Math.min(Ue,Ce));let Ye=K.sourceIn+(Ue-K.timelineStart);Ye=Math.round(Ye*t.fps)/t.fps,r("trim",U,"end",Ye)}function Ke(U,ne){const K=t.clips.find(Ce=>Ce.id===U);if(!K||!i.value)return;const ee=i.value.getBoundingClientRect(),Y=ne-ee.left+c.value,se=K.timelineEnd-K.timelineStart;let xe=Y/C.value;xe=Math.max(0,Math.min(xe,t.duration-se)),xe=Math.round(xe*t.fps)/t.fps,r("clip-move",U,xe)}function pe(U,ne){const K=t.clips.find(Y=>Y.id===U);if(!K||Math.abs(ne)<2)return;const ee=ne/C.value*t.sensitivity,be=Y=>Math.max(0,Math.round(Y*t.fps)/t.fps);if(t.useFrameMode){const Y=m.secondsToFrames(K.sourceOut),se=m.secondsToFrames(ee),xe=N(K),Ce=K.sourceIn+(xe-K.timelineStart),Ue=m.secondsToFrames(Ce),Ye=Math.min(Ue,Y+se),nt=m.framesToSeconds(Ye);r("trim",U,"end",nt)}else{const Y=N(K),se=K.sourceIn+(Y-K.timelineStart),xe=Math.min(se,K.sourceOut+ee),Ce=be(xe);r("trim",U,"end",Ce)}}function ke(U,ne){const K=t.clips.find(Y=>Y.id===U);if(!K||Math.abs(ne)<2)return;const ee=ne/C.value*t.sensitivity,be=Y=>Math.max(0,Math.round(Y*t.fps)/t.fps);if(t.useFrameMode){const Y=m.secondsToFrames(K.timelineStart),se=m.secondsToFrames(ee),xe=Math.max(0,Y+se),Ce=m.framesToSeconds(xe);r("clip-move",U,Ce)}else{const Y=Math.max(0,K.timelineStart+ee),se=be(Y);r("clip-move",U,se)}}return e.watch(()=>t.playhead,U=>{const ne=U*C.value;ne<c.value+50?c.value=Math.max(0,ne-50):ne>c.value+D.value-50&&(c.value=Math.min(W.value,ne-D.value+50))}),e.onMounted(()=>{const U=new ResizeObserver(ne=>{ne[0]&&(u.value=Math.round(ne[0].contentRect.width))});i.value&&U.observe(i.value),e.onUnmounted(()=>U.disconnect())}),e.onUnmounted(()=>{we()}),e.watch([F,D],()=>{c.value>W.value&&(c.value=W.value)}),(U,ne)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-timeline",{mobile:a.value}]),ref_key:"timelineRef",ref:i,onWheel:ie},[e.createElementVNode("div",{class:"timeline-ruler",onClick:Be},[e.createElementVNode("div",l0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,K=>(e.openBlock(),e.createElementBlock("span",{key:K.position,class:"time-marker",style:e.normalizeStyle({left:`${K.position}px`})},e.toDisplayString(K.label),5))),128))])]),e.createElementVNode("div",{class:e.normalizeClass(["timeline-content",{"is-pannable":R.value,"is-panning":h.value&&g.value==="pan","overflow-left":L.value,"overflow-right":_.value}]),onTouchstart:M,onTouchmove:j,onTouchend:te,onMousedown:ae},[e.createElementVNode("div",{class:"video-track",ref_key:"trackRef",ref:d},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.clips,K=>(e.openBlock(),e.createElementBlock("div",{key:`${K.id}-extent`,class:"clip-extent",style:e.normalizeStyle(P(K)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.clips,K=>(e.openBlock(),e.createBlock(s0,{key:K.id,clip:K,scale:C.value,"scroll-offset":c.value,selected:p.value===K.id,"is-mobile":a.value,onSelect:ee=>oe(K.id),onTrimStart:ee=>ye(K.id,ee),onTrimEnd:ee=>pe(K.id,ee),onDrag:ee=>ke(K.id,ee),onTrimStartAbs:ee=>fe(K.id,ee),onTrimEndAbs:ee=>Ze(K.id,ee),onDragAbs:ee=>Ke(K.id,ee)},null,8,["clip","scale","scroll-offset","selected","is-mobile","onSelect","onTrimStart","onTrimEnd","onDrag","onTrimStartAbs","onTrimEndAbs","onDragAbs"]))),128))],512),e.createElementVNode("div",{class:"playhead",style:e.normalizeStyle({left:`${A.value}px`}),onMousedown:q,onTouchstart:q},[...ne[1]||(ne[1]=[e.createElementVNode("div",{class:"playhead-handle"},[e.createElementVNode("div",{class:"playhead-line"})],-1)])],36),l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"split-indicator",style:e.normalizeStyle({left:`${A.value}px`})},null,4)):e.createCommentVNode("",!0),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"frame-mode-toggle",onClick:ne[0]||(ne[0]=K=>U.$emit("toggle-frame-mode")),"aria-label":U.useFrameMode?"Switch to time mode":"Switch to frame mode",title:U.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(U.useFrameMode?"F":"T"),9,c0))],34),R.value?(e.openBlock(),e.createElementBlock("div",d0,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(Z.value),onMousedown:ue,onTouchstart:ue},null,36)])):e.createCommentVNode("",!0)],34))}}),Es=_e(u0,[["__scopeId","data-v-d15e2d45"]]),m0={class:"control-group zoom-controls"},p0={class:"zoom-slider"},f0=["value"],h0={class:"control-group playback-controls"},v0=["aria-label"],g0={key:0,class:"control-group speed-control"},y0=["value"],b0=e.defineComponent({__name:"TimelineControls",props:{selectedClip:{},canSplit:{type:Boolean,default:!1},canDelete:{type:Boolean,default:!1},isPlaying:{type:Boolean,default:!1},zoomLevel:{default:50},playbackSpeed:{default:1},isMobile:{type:Boolean,default:!1}},emits:["split","delete","duplicate","zoom-in","zoom-out","zoom-change","fit-to-window","play-pause","frame-forward","frame-backward","skip-to-start","skip-to-end","speed-change"],setup(n,{emit:o}){const t=o;function a(u){const p=u.target;t("zoom-change",Number(p.value))}function r(){t("fit-to-window")}function i(){t("frame-forward")}function s(){t("frame-backward")}function l(){t("skip-to-start")}function c(){t("skip-to-end")}function d(u){const p=u.target;t("speed-change",Number(p.value))}return(u,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-controls",{mobile:u.isMobile}])},[e.createElementVNode("div",m0,[e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[0]||(p[0]=m=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Hu)},null,8,["icon"])]),e.createElementVNode("div",p0,[e.createElementVNode("input",{type:"range",value:u.zoomLevel,onInput:a,min:"10",max:"200",step:"5","aria-label":"Timeline zoom"},null,40,f0)]),e.createElementVNode("button",{class:"control-button zoom-button",onClick:p[1]||(p[1]=m=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(bu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:r,"aria-label":"Fit timeline to window"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Fu)},null,8,["icon"]),p[3]||(p[3]=e.createElementVNode("span",{class:"control-label"},"Fit",-1))])]),e.createElementVNode("div",h0,[e.createElementVNode("button",{class:"control-button",onClick:l,"aria-label":"Skip to start"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Yu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Lu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:p[2]||(p[2]=m=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:u.isPlaying?e.unref(Du):e.unref(Zu)},null,8,["icon"])],8,v0),e.createElementVNode("button",{class:"control-button",onClick:i,"aria-label":"Next frame"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Xu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:c,"aria-label":"Skip to end"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Gu)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",g0,[p[5]||(p[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...p[4]||(p[4]=[e.createStaticVNode('<option value="0.25" data-v-9a3abcf5>0.25x</option><option value="0.5" data-v-9a3abcf5>0.5x</option><option value="1" data-v-9a3abcf5>1x</option><option value="1.5" data-v-9a3abcf5>1.5x</option><option value="2" data-v-9a3abcf5>2x</option>',5)])],40,y0)]))],2))}}),w0=_e(b0,[["__scopeId","data-v-9a3abcf5"]]),k0={class:"video-filter-carousel-container"},x0={key:0,class:"category-section"},S0={class:"category-carousel-wrapper"},E0=["disabled"],C0=["onClick"],V0={class:"category-name"},N0=["disabled"],_0={class:"filter-section"},T0={class:"filter-carousel-wrapper"},M0=["disabled"],F0=["onClick"],I0=["onClick"],B0={class:"filter-preview"},R0={class:"filter-placeholder"},P0={class:"filter-name"},$0=["disabled"],z0={class:"carousel-pagination"},A0=["onClick"],D0={key:1,class:"filter-adjustments"},U0={class:"adjustment-header"},O0={class:"adjustment-actions"},L0={key:0},W0={class:"slider-control"},j0={class:"control-label"},X0={class:"slider-wrapper"},Z0={class:"slider-value"},Y0={key:1,class:"no-params"},G0=e.defineComponent({__name:"VideoFilterCarousel",props:{filters:{},activeFilters:{},thumbnailUrl:{},showCategories:{type:Boolean,default:!0}},emits:["apply-filter","remove-filter","update-param","preview-filter"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("all"),i=e.ref(null),s=e.ref(0),l=e.ref(0),c=e.ref(new Map),d=e.ref(),u=e.ref(),p={all:Gt,adjust:$n,color:Ht,blur:Fo,light:zn,effects:qa,stylize:Ln,advanced:Gt,distortion:Wn,transform:Wn};function m(_){return _.replace(/[-_]/g," ").replace(/\b\w/g,A=>A.toUpperCase())}function h(_){return p[_.toLowerCase()]??Gt}const g=e.computed(()=>{const _=Array.from(new Set(t.filters.map(A=>A.category).filter(A=>typeof A=="string"&&A.length>0))).sort((A,Z)=>A.localeCompare(Z));return[{id:"all",name:"All",icon:Gt},..._.map(A=>({id:A,name:m(A),icon:h(A)}))]}),v=e.computed(()=>r.value==="all"?t.filters:t.filters.filter(_=>_.category===r.value));e.watch(g,_=>{new Set(_.map(H=>H.id)).has(r.value)||(r.value="all");const Z=Math.max(0,_.length-3);s.value>Z&&(s.value=Z)},{immediate:!0});function x(_){var A;return((A=t.activeFilters)==null?void 0:A.has(_))||!1}function B(_){if(i.value=_,!x(_.id)&&(a("apply-filter",_),_.params&&_.params.length>0)){const A=new Map;_.params.forEach(Z=>{A.set(Z.id,Z.default)}),c.value.set(_.id,A)}a("preview-filter",_)}function E(_){var A;a("remove-filter",_),c.value.delete(_),((A=i.value)==null?void 0:A.id)===_&&(i.value=null)}function y(_){if(typeof _=="number"&&Number.isFinite(_))return _;if(typeof _=="string"){const A=Number(_);return Number.isFinite(A)?A:null}return null}function f(_,A){var ie;const Z=(ie=t.activeFilters)==null?void 0:ie.get(_);if(Z&&Z.params){const M=Z.params[A],j=y(M);if(j!==null)return j}const H=c.value.get(_);if(H){const M=y(H.get(A));if(M!==null)return M}const me=t.filters.find(M=>M.id===_),Te=me==null?void 0:me.params.find(M=>M.id===A);return y(Te==null?void 0:Te.default)??0}function w(_,A,Z){var me;const H=Number(Z.target.value);c.value.has(_)||c.value.set(_,new Map),(me=c.value.get(_))==null||me.set(A,H),a("update-param",_,A,H)}function $(_,A,Z){var me;const H=typeof Z=="number"?Z:Number(Z);c.value.has(_)||c.value.set(_,new Map),(me=c.value.get(_))==null||me.set(A,H),a("update-param",_,A,H)}function C(_){const A=y(_);return A===null?"0":Number.isInteger(A)?A.toString():A.toFixed(2)}function b(){if(i.value&&(a("apply-filter",i.value),i.value.params&&i.value.params.length>0)){const _=new Map;i.value.params.forEach(A=>{_.set(A.id,A.default)}),c.value.set(i.value.id,_)}}function N(_){const A=t.filters.find(Z=>Z.id===_);A&&A.params&&A.params.forEach(Z=>{w(_,Z.id,{target:{value:Z.default}})})}function P(_){return{basic:$n,color:Ht,blur:Fo,light:zn,effects:qa,stylize:Ln,adjustment:$n,"color-matrix":Ht,glow:Gt,distortion:Wn}[_]||Gt}function k(_){return{adjustment:$n,brightness:zn,contrast:$n,saturation:Ht,blur:Fo,"gaussian-blur":Fo,"color-matrix":Ht,grayscale:Ln,sepia:Ln,vignette:Wn,glow:Gt,glitch:qa,godray:zn,lightmap:zn}[_.id]||P(_.category)}function T(){s.value>0&&(s.value--,L(d.value,s.value))}function F(){s.value<g.value.length-3&&(s.value++,L(d.value,s.value))}function D(){l.value>0&&(l.value--,L(u.value,l.value))}function R(){l.value<v.value.length-4&&(l.value++,L(u.value,l.value))}function W(_){l.value=_*4,L(u.value,l.value)}function L(_,A){var Z;if(_){const H=((Z=_.querySelector(".category-chip, .filter-card"))==null?void 0:Z.clientWidth)||100;_.scrollTo({left:A*(H+8),behavior:"smooth"})}}return(_,A)=>{var Z;return e.openBlock(),e.createElementBlock("div",k0,[_.showCategories?(e.openBlock(),e.createElementBlock("div",x0,[e.createElementVNode("div",S0,[e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ji)},null,8,["icon"])],8,E0),e.createElementVNode("div",{ref_key:"categoryCarouselRef",ref:d,class:"category-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,H=>(e.openBlock(),e.createElementBlock("button",{key:H.id,onClick:me=>r.value=H.id,class:e.normalizeClass(["category-chip",{active:r.value===H.id}])},[e.createVNode(e.unref(I.IonIcon),{icon:H.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",V0,e.toDisplayString(H.name),1)],10,C0))),128))],512),e.createElementVNode("button",{onClick:F,class:"carousel-nav carousel-nav-right",disabled:s.value>=g.value.length-3,"aria-label":"Next categories"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qi)},null,8,["icon"])],8,N0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",_0,[e.createElementVNode("div",T0,[e.createElementVNode("button",{onClick:D,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ji)},null,8,["icon"])],8,M0),e.createElementVNode("div",{ref_key:"filterCarouselRef",ref:u,class:"filter-carousel"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,H=>{var me;return e.openBlock(),e.createElementBlock("div",{key:H.id,class:e.normalizeClass(["filter-card",{active:x(H.id),selected:((me=i.value)==null?void 0:me.id)===H.id}]),onClick:Te=>B(H)},[x(H.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(Te=>E(H.id),["stop"])},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(al)},null,8,["icon"])],8,I0)):e.createCommentVNode("",!0),e.createElementVNode("div",B0,[e.createElementVNode("div",R0,[e.createVNode(e.unref(I.IonIcon),{icon:k(H),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",P0,e.toDisplayString(H.name),1)],10,F0)}),128))],512),e.createElementVNode("button",{onClick:R,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,v.value.length-4),"aria-label":"Next filters"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qi)},null,8,["icon"])],8,$0)]),e.createElementVNode("div",z0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.ceil(v.value.length/4),(H,me)=>(e.openBlock(),e.createElementBlock("span",{key:me,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===me}]),onClick:Te=>W(me)},null,10,A0))),128))])]),i.value?(e.openBlock(),e.createElementBlock("div",D0,[e.createElementVNode("div",U0,[e.createElementVNode("h4",null,e.toDisplayString(i.value.name),1),e.createElementVNode("div",O0,[x(i.value.id)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,onClick:b,class:"apply-btn"}," Apply Filter ")),x(i.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:A[0]||(A[0]=H=>E(i.value.id)),class:"remove-btn"}," Remove Filter ")):e.createCommentVNode("",!0),x(i.value.id)&&((Z=i.value.params)==null?void 0:Z.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:A[1]||(A[1]=H=>N(i.value.id)),class:"reset-btn"}," Reset ")):e.createCommentVNode("",!0)])]),i.value.params&&i.value.params.length>0?(e.openBlock(),e.createElementBlock("div",L0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.params,H=>(e.openBlock(),e.createElementBlock("div",{key:H.id,class:"adjustment-control"},[e.createElementVNode("div",W0,[e.createElementVNode("label",j0,e.toDisplayString(H.label||H.id),1),e.createElementVNode("div",X0,[e.createVNode(e.unref(I.IonRange),{value:f(i.value.id,H.id),onIonChange:me=>$(i.value.id,H.id,me.detail.value),min:H.min,max:H.max,step:H.step||.01,color:"primary",class:"compact-slider",disabled:!x(i.value.id)},null,8,["value","onIonChange","min","max","step","disabled"]),e.createElementVNode("span",Z0,e.toDisplayString(C(f(i.value.id,H.id))),1)])])]))),128))])):(e.openBlock(),e.createElementBlock("div",Y0," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)])}}}),Cs=_e(G0,[["__scopeId","data-v-7cc27cd2"]]);class H0{constructor(o){this.pixiFilters=new Map,this.filterParams=new Map,this.filterTypes=new Map,this.filterIntensity=new Map,this.composition=o}setComposition(o){this.composition=o}mapMediablesToPIXI(o){switch(o.filterId){case"blur":return this.createBlurFilter(o.params);case"brightness":return this.createBrightnessFilter(o.params);case"contrast":return this.createContrastFilter(o.params);case"saturation":return this.createSaturationFilter(o.params);case"hue":return this.createHueFilter(o.params);case"vintage":return this.createVintageFilter(o.params);case"grayscale":return this.createGrayscaleFilter();case"sepia":return this.createSepiaFilter();default:return null}}createBlurFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.BlurFilter;if(!r)return null;const i=new r;return i.blur=o.intensity||5,i.quality=o.quality||4,i}catch{return null}}createBrightnessFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.brightness(o.value||1,!1),i}catch{return null}}createContrastFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.contrast(o.value||1,!1),i}catch{return null}}createSaturationFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.saturate(o.value||1,!1),i}catch{return null}}createHueFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.hue(o.rotation||0,!1),i}catch{return null}}createVintageFilter(o){var t,a;try{const r=(a=(t=window.PIXI)==null?void 0:t.filters)==null?void 0:a.ColorMatrixFilter;if(!r)return null;const i=new r;return i.vintage(!1),o.intensity&&(i.contrast(1.2,!1),i.saturate(.8,!1)),i}catch{return null}}createGrayscaleFilter(){var o,t;try{const a=(t=(o=window.PIXI)==null?void 0:o.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const r=new a;return r.desaturate(),r}catch{return null}}createSepiaFilter(){var o,t;try{const a=(t=(o=window.PIXI)==null?void 0:o.filters)==null?void 0:t.ColorMatrixFilter;if(!a)return null;const r=new a;return r.sepia(!1),r}catch{return null}}async applyFilters(o){if(this.composition){this.clearFilters();for(const t of o){const a=this.mapMediablesToPIXI(t);a&&(this.pixiFilters.set(t.id,a),this.filterParams.set(t.id,t.params),this.filterTypes.set(t.id,t.filterId),this.filterIntensity.set(t.id,t.intensity),await this.applyToComposition(t.id,a))}}}async applyToComposition(o,t){try{this.composition.applyFilter&&await this.composition.applyFilter(o,t)}catch{}}updateFilterParams(o,t){var r;const a=this.pixiFilters.get(o);a&&(this.filterParams.set(o,t),"blur"in a&&(a.blur=t.intensity||a.blur),"brightness"in a&&a.brightness(t.value||1,!1),"contrast"in a&&a.contrast(t.value||1,!1),"saturate"in a&&a.saturate(t.value||1,!1),"hue"in a&&a.hue(t.rotation||0,!1),(r=this.composition)!=null&&r.update&&this.composition.update())}getFilterParams(o){return this.filterParams.get(o)||{}}removeFilter(o){var t;this.pixiFilters.delete(o),this.filterParams.delete(o),this.filterTypes.delete(o),this.filterIntensity.delete(o),(t=this.composition)!=null&&t.removeFilter&&this.composition.removeFilter(o)}clearFilters(){var o;this.pixiFilters.clear(),this.filterParams.clear(),this.filterTypes.clear(),this.filterIntensity.clear(),(o=this.composition)!=null&&o.clearFilters&&this.composition.clearFilters()}getActiveFilters(){return Array.from(this.pixiFilters.values())}exportFilterConfig(){const o=[];return this.pixiFilters.forEach((t,a)=>{const r=this.filterParams.get(a)??{},i=this.filterTypes.get(a)??"unknown",s=this.filterIntensity.get(a)??1;o.push({id:a,filterId:i,params:r,intensity:s})}),o}async importFilterConfig(o){await this.applyFilters(o)}destroy(){this.clearFilters(),this.composition=null}}const J0={class:"video-filter-preview"},q0={class:"preview-title"},K0={class:"filter-controls"},Q0={class:"control-input"},ev=["value","onInput","min","max","step"],tv={class:"param-value"},nv={class:"preview-container"},ov={key:0,class:"filter-presets"},av=["onClick"],rv={class:"preview-actions"},iv=e.defineComponent({__name:"VideoFilterPreview",props:{filter:{},currentFrame:{},useVideoEngine:{type:Boolean,default:!1},composition:{}},emits:["update-params","apply"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),s=e.ref({});let l,c,d=null,u=null;const p=e.computed(()=>{var b;return((b=t.filter)==null?void 0:b.paramRanges)||{}}),m=e.computed(()=>h.value.length>0),h=e.computed(()=>t.filter?{brightness:[{name:"Subtle",params:{value:.1}},{name:"Medium",params:{value:.3}},{name:"Strong",params:{value:.5}}],contrast:[{name:"Low",params:{value:.8}},{name:"Normal",params:{value:1}},{name:"High",params:{value:1.5}}],"gaussian-blur":[{name:"Subtle",params:{value:1}},{name:"Medium",params:{value:3}},{name:"Strong",params:{value:5}}]}[t.filter.id]||[]:[]);async function g(){var b;if(r.value){t.useVideoEngine&&t.composition&&(u=new H0(t.composition));try{if(l=new Ae.Application,await l.init({width:r.value.clientWidth,height:r.value.clientHeight,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,canvas:r.value}),(b=t.currentFrame)!=null&&b.dataUrl){const N=await Ae.Assets.load(t.currentFrame.dataUrl);c=new Ae.Sprite(N);const P=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(P),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}v()}catch{}}}function v(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const b={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([b]).then(()=>{}).catch(N=>{}),d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}else d&&(d.destroy(),d=null),d=x(t.filter.id,s.value),d&&(c.filters=i.value?null:[d])}function x(b,N){switch(b){case"brightness":{const P=new Ae.ColorMatrixFilter,k=1+(N.value??0);return typeof P.brightness=="function"&&P.brightness(k,!1),P}case"contrast":{const P=new Ae.ColorMatrixFilter,k=N.value??1;return typeof P.contrast=="function"&&P.contrast(k,!1),P}case"saturation":{const P=new Ae.ColorMatrixFilter,k=N.value??1;return typeof P.saturate=="function"&&P.saturate(k,!1),P}case"hue":{const P=new Ae.ColorMatrixFilter,k=N.value??0;return typeof P.hue=="function"&&P.hue(k,!1),P}case"gaussian-blur":{const P=N.value??5;return new Ae.BlurFilter({strength:P,quality:4})}case"sepia":{const P=new Ae.ColorMatrixFilter;return typeof P.sepia=="function"&&P.sepia(!1),P}case"grayscale":{const P=new Ae.ColorMatrixFilter;return typeof P.desaturate=="function"&&P.desaturate(),P}default:return null}}function B(b,N){const P=N.target,k=Number.parseFloat(P.value),T=Number.isFinite(k)?k:0;s.value={...s.value,[b]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),v()}function E(b){return b.charAt(0).toUpperCase()+b.slice(1).replace(/_/g," ")}function y(b,N){var k;const P=typeof b=="number"?b:Number(b);return Number.isFinite(P)?N==="hue"||N==="angle"?`${P}°`:N==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+P)*100)}%`:Number.isInteger(P)?P.toString():P.toFixed(2):"0"}function f(){var b;s.value=((b=t.filter)==null?void 0:b.defaultParams)||{},a("update-params",s.value),v()}function w(b){s.value={...b.params},a("update-params",s.value),v()}function $(b){return JSON.stringify(b.params)===JSON.stringify(s.value)}function C(){a("apply")}return e.watch(()=>t.filter,b=>{b&&(s.value={...b.defaultParams},v())}),e.watch(()=>t.currentFrame,async b=>{if(b!=null&&b.dataUrl&&c){const N=await Ae.Assets.load(b.dataUrl);c.texture=N}}),e.watch(i,v),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),g()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(b,N)=>{var P;return e.openBlock(),e.createElementBlock("div",J0,[e.createElementVNode("h4",q0,e.toDisplayString((P=b.filter)==null?void 0:P.name)+" Settings",1),e.createElementVNode("div",K0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(k,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(E(T)),1),e.createElementVNode("div",Q0,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:F=>B(T,F),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,ev),e.createElementVNode("span",tv,e.toDisplayString(y(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",nv,[e.createElementVNode("canvas",{ref_key:"previewCanvas",ref:r,class:"preview-canvas"},null,512),e.createElementVNode("button",{class:"compare-button",onMousedown:N[0]||(N[0]=k=>i.value=!0),onMouseup:N[1]||(N[1]=k=>i.value=!1),onTouchstart:N[2]||(N[2]=k=>i.value=!0),onTouchend:N[3]||(N[3]=k=>i.value=!1)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Wn)},null,8,["icon"]),N[4]||(N[4]=e.createTextVNode(" Hold to compare ",-1))],32)]),m.value?(e.openBlock(),e.createElementBlock("div",ov,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,k=>(e.openBlock(),e.createElementBlock("button",{key:k.name,class:e.normalizeClass(["preset-button",{active:$(k)}]),onClick:T=>w(k)},e.toDisplayString(k.name),11,av))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",rv,[e.createElementVNode("button",{class:"action-button",onClick:f},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(co)},null,8,["icon"]),N[5]||(N[5]=e.createTextVNode(" Reset ",-1))]),e.createElementVNode("button",{class:"action-button primary",onClick:C},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),N[6]||(N[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Vs=_e(iv,[["__scopeId","data-v-3de3dd04"]]),sv={class:"export-settings"},lv={class:"setting-group"},cv={class:"setting-group"},dv={class:"estimated-size"},uv={key:0,class:"export-progress"},mv={class:"progress-header"},pv={class:"progress-percentage"},fv={class:"progress-time"},hv={class:"action-buttons"},vv=["disabled"],gv=["disabled"],yv=["disabled"],bv={class:"export-options"},wv=e.defineComponent({__name:"EditorControls",props:{canExport:{type:Boolean,default:!1},isExporting:{type:Boolean,default:!1},exportProgress:{default:0},isMobile:{type:Boolean,default:!1},duration:{default:0}},emits:["export","save-draft","reset","cancel-export"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("1080p"),i=e.ref("mp4"),s=e.ref(!0),l=e.ref(!1),c=e.ref(0),d=e.ref(0),u=e.ref(0);let p=null;const m=e.computed(()=>{const f=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[r.value]||8)*t.duration/8;return f<1e3?`~${Math.round(f)} MB`:`~${(f/1e3).toFixed(1)} GB`});function h(){t.isExporting?(a("cancel-export"),x()):g()}function g(){const E={quality:r.value,format:i.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",E),v()}function v(){c.value=Date.now(),d.value=0,p=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const E=d.value/t.exportProgress*100;u.value=Math.max(0,E-d.value)}},1e3)}function x(){p&&(clearInterval(p),p=null)}function B(E){const y=Math.floor(E/60),f=Math.floor(E%60);return`${y}:${f.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,E=>{E||x()}),e.onUnmounted(()=>{x()}),(E,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:E.isMobile}])},[e.createElementVNode("div",sv,[y[10]||(y[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",lv,[y[7]||(y[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[0]||(y[0]=f=>r.value=f),class:"setting-select"},[...y[6]||(y[6]=[e.createStaticVNode('<option value="360p" data-v-e1338d5e>360p (Low)</option><option value="480p" data-v-e1338d5e>480p (SD)</option><option value="720p" data-v-e1338d5e>720p (HD)</option><option value="1080p" data-v-e1338d5e>1080p (Full HD)</option><option value="1440p" data-v-e1338d5e>1440p (2K)</option><option value="2160p" data-v-e1338d5e>2160p (4K)</option>',6)])],512),[[e.vModelSelect,r.value]])]),e.createElementVNode("div",cv,[y[9]||(y[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":y[1]||(y[1]=f=>i.value=f),class:"setting-select"},[...y[8]||(y[8]=[e.createElementVNode("option",{value:"mp4"},"MP4 (Most Compatible)",-1),e.createElementVNode("option",{value:"webm"},"WebM (Web Optimized)",-1),e.createElementVNode("option",{value:"mov"},"MOV (Apple)",-1)])],512),[[e.vModelSelect,i.value]])]),e.createElementVNode("div",dv,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Pu)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(m.value),1)])]),E.isExporting?(e.openBlock(),e.createElementBlock("div",uv,[e.createElementVNode("div",mv,[y[11]||(y[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",pv,e.toDisplayString(E.exportProgress??0)+"%",1)]),e.createVNode(e.unref(I.IonProgressBar),{value:(E.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",fv,[e.createElementVNode("span",null,e.toDisplayString(B(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(B(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",hv,[e.createElementVNode("button",{class:"control-button secondary",onClick:y[2]||(y[2]=f=>E.$emit("save-draft")),disabled:!E.canExport||E.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cl)},null,8,["icon"]),y[12]||(y[12]=e.createTextVNode(" Save Draft ",-1))],8,vv),e.createElementVNode("button",{class:"control-button secondary",onClick:y[3]||(y[3]=f=>E.$emit("reset")),disabled:E.isExporting},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(co)},null,8,["icon"]),y[13]||(y[13]=e.createTextVNode(" Reset ",-1))],8,gv),e.createElementVNode("button",{class:"control-button primary",onClick:h,disabled:!E.canExport&&!E.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(I.IonIcon),{icon:E.isExporting?e.unref(ao):e.unref(pa)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(E.isExporting?"Cancel":"Export Video"),1)],8,yv)]),e.createElementVNode("div",bv,[e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":y[4]||(y[4]=f=>s.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...y[14]||(y[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(I.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":y[5]||(y[5]=f=>l.value=f)},null,8,["modelValue"]),e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...y[15]||(y[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Ns=_e(wv,[["__scopeId","data-v-e1338d5e"]]),kv={class:"thumbnail-picker"},xv={class:"thumbnail-grid"},Sv=["onClick"],Ev=["src","alt"],Cv={key:1,class:"thumbnail-placeholder"},Vv={class:"thumbnail-time"},Nv={class:"custom-selector"},_v={class:"time-input-group"},Tv=["max"],Mv={class:"time-value"},Fv=["disabled"],Iv={class:"picker-actions"},Bv=["disabled"],Rv=e.defineComponent({__name:"ThumbnailPicker",props:{mediaUuid:{},duration:{},currentTime:{default:0}},emits:["select","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref([]),i=e.ref(-1),s=e.ref(t.currentTime),l=e.ref(!1);function c(){const B=[];if(t.duration<=10)for(let y=0;y<Math.min(9,t.duration);y++)B.push(y);else{const y=t.duration/10;for(let f=1;f<=9;f++)B.push(y*f)}return B}async function d(B){try{const E=document.createElement("video");return E.crossOrigin="anonymous",E.src=await u(),new Promise(y=>{E.addEventListener("loadedmetadata",()=>{E.currentTime=B}),E.addEventListener("seeked",()=>{const f=document.createElement("canvas");f.width=E.videoWidth,f.height=E.videoHeight;const w=f.getContext("2d");w?(w.drawImage(E,0,0),y(f.toDataURL("image/jpeg",.8))):y(null),E.remove()}),E.addEventListener("error",()=>{y(null),E.remove()})})}catch{return null}}async function u(){try{return(await(await fetch(`/api/media/${t.mediaUuid}/playback`)).json()).playback_url}catch{return`/media/${t.mediaUuid}/video`}}async function p(){const B=c();r.value=B.map(y=>({time:y,loading:!0}));const E=3;for(let y=0;y<r.value.length;y+=E){const f=r.value.slice(y,y+E);await Promise.all(f.map(async w=>{const $=await d(w.time);$&&(w.dataUrl=$),w.loading=!1}))}}function m(B){i.value=B,s.value=r.value[B].time}function h(){i.value=-1}async function g(){l.value=!0;try{const B=await d(s.value);if(B){const E=r.value.findIndex(y=>Math.abs(y.time-s.value)<.1);E>=0?(r.value[E].dataUrl=B,i.value=E):(r.value.push({time:s.value,dataUrl:B}),i.value=r.value.length-1,r.value.sort((y,f)=>y.time-f.time),i.value=r.value.findIndex(y=>y.time===s.value))}}finally{l.value=!1}}function v(){const B=i.value>=0?r.value[i.value].time:s.value;a("select",B)}function x(B){const E=Math.floor(B/60),y=Math.floor(B%60),f=Math.floor(B%1*100);return E>0?`${E}:${y.toString().padStart(2,"0")}.${f.toString().padStart(2,"0")}`:`${y}.${f.toString().padStart(2,"0")}s`}return e.onMounted(()=>{p()}),(B,E)=>(e.openBlock(),e.createElementBlock("div",kv,[E[5]||(E[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",xv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(y,f)=>(e.openBlock(),e.createElementBlock("div",{key:f,class:e.normalizeClass(["thumbnail-item",{selected:i.value===f}]),onClick:w=>m(f)},[y.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:y.dataUrl,alt:`Frame at ${x(y.time)}`},null,8,Ev)):(e.openBlock(),e.createElementBlock("div",Cv,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",Vv,e.toDisplayString(x(y.time)),1)],10,Sv))),128))]),e.createElementVNode("div",Nv,[E[3]||(E[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",_v,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":E[0]||(E[0]=y=>s.value=y),min:0,max:B.duration,step:.1,onInput:h,class:"time-slider"},null,40,Tv),[[e.vModelText,s.value]]),e.createElementVNode("span",Mv,e.toDisplayString(x(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:g,disabled:l.value},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Su)},null,8,["icon"]),E[2]||(E[2]=e.createTextVNode(" Capture Frame ",-1))],8,Fv)]),e.createElementVNode("div",Iv,[e.createElementVNode("button",{class:"action-button",onClick:E[1]||(E[1]=y=>B.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:v,disabled:i.value===-1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),E[4]||(E[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,Bv)])]))}}),Pv=_e(Rv,[["__scopeId","data-v-336c322c"]]),$v={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},zv={class:"mb-4"},Av={class:"space-y-2 max-h-64 overflow-y-auto"},Dv={class:"flex items-center justify-between"},Uv={class:"flex-1"},Ov={class:"font-medium text-gray-900 dark:text-white"},Lv={class:"text-sm text-gray-500 dark:text-gray-400"},Wv={class:"flex items-center space-x-2"},jv=["onClick"],Xv=["onClick"],Zv={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Yv={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Gv={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Hv={class:"space-y-4"},Jv={class:"grid grid-cols-2 gap-4"},qv={class:"grid grid-cols-2 gap-4"},Kv={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Qv={class:"grid grid-cols-2 gap-3"},eg={class:"flex justify-end space-x-3 mt-6"},tg=e.defineComponent({__name:"TextOverlayPanel",props:{overlays:{}},emits:["add-overlay","update-overlay","remove-overlay"],setup(n,{emit:o}){const t=o,a=e.ref(!1),r=e.ref(null),i=()=>({id:"",text:"",fontSize:24,color:"#ffffff",position:"center",startTime:0,duration:5,animationType:"",animationDuration:1,animationEasing:"linear"}),s=e.reactive(i());function l(m){Object.assign(s,m),r.value=m}function c(){a.value=!1,r.value=null,Object.assign(s,i())}function d(){const m={text:s.text,fontSize:s.fontSize,color:s.color,position:s.position,startTime:s.startTime,duration:s.duration};if(s.animationType&&(m.animation={type:s.animationType},s.animationDuration!==void 0&&(m.animation.duration=s.animationDuration),s.animationEasing&&(m.animation.easing=s.animationEasing),m.animation))switch(s.animationType){case"rotate":m.animation.rotation={from:0,to:360};break;case"scale":m.animation.scale={from:.5,to:1};break;case"slide":m.animation.translate={fromX:-100,toX:0,fromY:0,toY:0};break}r.value?t("update-overlay",r.value.id,m):t("add-overlay",m),c()}function u(m){confirm("Are you sure you want to remove this text overlay?")&&t("remove-overlay",m)}function p(m){const h=Math.floor(m/60),g=Math.floor(m%60);return`${h}:${g.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",$v,[e.createElementVNode("div",zv,[h[11]||(h[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Text Overlays ",-1)),e.createElementVNode("button",{onClick:h[0]||(h[0]=g=>a.value=!0),class:"w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},[...h[10]||(h[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Text Overlay ",-1)])])]),e.createElementVNode("div",Av,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.overlays,g=>(e.openBlock(),e.createElementBlock("div",{key:g.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors"},[e.createElementVNode("div",Dv,[e.createElementVNode("div",Uv,[e.createElementVNode("div",Ov,e.toDisplayString(g.text.substring(0,30))+e.toDisplayString(g.text.length>30?"...":""),1),e.createElementVNode("div",Lv,e.toDisplayString(p(g.startTime??0))+" - "+e.toDisplayString(p((g.startTime||0)+(g.duration||5))),1)]),e.createElementVNode("div",Wv,[e.createElementVNode("button",{onClick:v=>l(g),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Edit"},[...h[12]||(h[12]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1)])],8,jv),e.createElementVNode("button",{onClick:v=>u(g.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...h[13]||(h[13]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,Xv)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",Zv," No text overlays added yet ")):e.createCommentVNode("",!0)]),a.value||r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(c,["self"])},[e.createElementVNode("div",Yv,[e.createElementVNode("h4",Gv,e.toDisplayString(r.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",Hv,[e.createElementVNode("div",null,[h[14]||(h[14]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Text ",-1)),e.withDirectives(e.createElementVNode("textarea",{"onUpdate:modelValue":h[1]||(h[1]=g=>s.text=g),rows:"3",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter your text..."},null,512),[[e.vModelText,s.text]])]),e.createElementVNode("div",Jv,[e.createElementVNode("div",null,[h[15]||(h[15]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Font Size ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[2]||(h[2]=g=>s.fontSize=g),type:"number",min:"10",max:"200",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[16]||(h[16]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Color ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[3]||(h[3]=g=>s.color=g),type:"color",class:"w-full h-10 border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer"},null,512),[[e.vModelText,s.color]])])]),e.createElementVNode("div",null,[h[18]||(h[18]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Position ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[4]||(h[4]=g=>s.position=g),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[17]||(h[17]=[e.createStaticVNode('<option value="center" data-v-f86e688c>Center</option><option value="top" data-v-f86e688c>Top</option><option value="bottom" data-v-f86e688c>Bottom</option><option value="left" data-v-f86e688c>Left</option><option value="right" data-v-f86e688c>Right</option>',5)])],512),[[e.vModelSelect,s.position]])]),e.createElementVNode("div",qv,[e.createElementVNode("div",null,[h[19]||(h[19]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[5]||(h[5]=g=>s.startTime=g),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[20]||(h[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[6]||(h[6]=g=>s.duration=g),type:"number",min:"0.1",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,s.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[h[22]||(h[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Animation ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[7]||(h[7]=g=>s.animationType=g),class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},[...h[21]||(h[21]=[e.createStaticVNode('<option value="" data-v-f86e688c>None</option><option value="fade-in" data-v-f86e688c>Fade In</option><option value="fade-out" data-v-f86e688c>Fade Out</option><option value="slide" data-v-f86e688c>Slide</option><option value="scale" data-v-f86e688c>Scale</option><option value="rotate" data-v-f86e688c>Rotate</option><option value="typewriter" data-v-f86e688c>Typewriter</option>',7)])],512),[[e.vModelSelect,s.animationType]])]),s.animationType?(e.openBlock(),e.createElementBlock("div",Kv,[h[26]||(h[26]=e.createElementVNode("div",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Animation Settings ",-1)),e.createElementVNode("div",Qv,[e.createElementVNode("div",null,[h[23]||(h[23]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (s) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[8]||(h[8]=g=>s.animationDuration=g),type:"number",min:"0.1",step:"0.1",class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.animationDuration,void 0,{number:!0}]])]),e.createElementVNode("div",null,[h[25]||(h[25]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":h[9]||(h[9]=g=>s.animationEasing=g),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...h[24]||(h[24]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,s.animationEasing]])])])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",eg,[e.createElementVNode("button",{onClick:c,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:d,class:"px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"},e.toDisplayString(r.value?"Save":"Add"),1)])])])):e.createCommentVNode("",!0)]))}}),_s=_e(tg,[["__scopeId","data-v-f86e688c"]]),to=class to{constructor(o){this.transitions=new Map,this.nextId=0,this.composition=o}async applyTransition(o,t,a){const r=`transition-${this.nextId++}`,i=Math.round(a.duration*30),s=a.easing||"linear",l=this.findTrackForClip(o),c=this.findTrackForClip(t);if(!l||!c)throw new Error("Clips must be added to composition before applying transitions");const d=o.stop.frames-i,u=o.stop.frames;switch(a.type){case"fade":await this.applyFadeTransition(o,t,d,u,s);break;case"dissolve":case"cross-fade":await this.applyCrossFadeTransition(o,t,d,u,s);break;case"wipe-left":case"wipe-right":case"wipe-up":case"wipe-down":await this.applyWipeTransition(o,t,a.type,d,u,s);break;case"slide-left":case"slide-right":case"slide-up":case"slide-down":await this.applySlideTransition(o,t,a.type,d,u,s);break;case"zoom-in":case"zoom-out":await this.applyZoomTransition(o,t,a.type,d,u,s);break;case"dip-to-black":case"dip-to-white":await this.applyDipTransition(o,t,a.type,d,u,s);break}return this.transitions.set(r,a),r}async applyFadeTransition(o,t,a,r,i){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Fade transitions require VideoClip instances");o.alpha=new Se([a,r],[1,0],{easing:i}),t.alpha=new Se([a,r],[0,1],{easing:i}),t.start=de.fromFrames(a)}async applyCrossFadeTransition(o,t,a,r,i){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Cross-fade transitions require VideoClip instances");o.alpha=new Se([a,r],[1,0],{easing:i}),t.alpha=new Se([a,r],[0,1],{easing:i}),t.start=de.fromFrames(a)}async applyWipeTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Wipe transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(a){case"wipe-left":l.x=new Se([r,i],[0,-1920],{easing:s}),c.x=new Se([r,i],[1920,0],{easing:s});break;case"wipe-right":l.x=new Se([r,i],[0,1920],{easing:s}),c.x=new Se([r,i],[-1920,0],{easing:s});break;case"wipe-up":l.y=new Se([r,i],[0,-1080],{easing:s}),c.y=new Se([r,i],[1080,0],{easing:s});break;case"wipe-down":l.y=new Se([r,i],[0,1080],{easing:s}),c.y=new Se([r,i],[-1080,0],{easing:s});break}o.translate=l,t.translate=c,t.start=de.fromFrames(r)}async applySlideTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Slide transitions require VideoClip instances");const l={x:0,y:0},c={x:0,y:0};switch(a){case"slide-left":l.x=new Se([r,i],[0,-1920],{easing:s}),c.x=new Se([r,i],[1920,0],{easing:s});break;case"slide-right":l.x=new Se([r,i],[0,1920],{easing:s}),c.x=new Se([r,i],[-1920,0],{easing:s});break;case"slide-up":l.y=new Se([r,i],[0,-1080],{easing:s}),c.y=new Se([r,i],[1080,0],{easing:s});break;case"slide-down":l.y=new Se([r,i],[0,1080],{easing:s}),c.y=new Se([r,i],[-1080,0],{easing:s});break}o.translate=l,t.translate=c,t.start=de.fromFrames(r)}async applyZoomTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Zoom transitions require VideoClip instances");a==="zoom-in"?(o.scale=new Se([r,i],[1,2],{easing:s}),o.alpha=new Se([r,i],[1,0],{easing:s}),t.scale=new Se([r,i],[.5,1],{easing:s}),t.alpha=new Se([r,i],[0,1],{easing:s})):(o.scale=new Se([r,i],[1,.5],{easing:s}),o.alpha=new Se([r,i],[1,0],{easing:s}),t.scale=new Se([r,i],[2,1],{easing:s}),t.alpha=new Se([r,i],[0,1],{easing:s})),t.start=de.fromFrames(r)}async applyDipTransition(o,t,a,r,i,s){if(!this.isVideoClip(o)||!this.isVideoClip(t))throw new Error("Dip transitions require VideoClip instances");const l=Math.round((r+i)/2),c=a==="dip-to-black"?"#000000":"#ffffff",d=await aa.fromColor(c),u=new xr(d,{start:de.fromFrames(r),stop:de.fromFrames(i)});o.alpha=new Se([r,l],[1,0],{easing:s}),u.alpha=new Se([r,l,i],[0,1,0],{easing:s}),t.alpha=new Se([l,i],[0,1],{easing:s}),await this.composition.add(u),t.start=de.fromFrames(l)}findTrackForClip(o){for(const t of this.composition.tracks)if(t.clips.includes(o))return t}removeTransition(o){this.transitions.delete(o)}getTransitions(){return new Map(this.transitions)}static getAvailableTransitions(){return[...to.TRANSITIONS]}static previewTransition(o){return to.TRANSITIONS.find(t=>t.type===o)}isVideoClip(o){return"alpha"in o&&"scale"in o&&"translate"in o}};to.TRANSITIONS=[{type:"fade",name:"Fade",description:"Simple fade transition"},{type:"dissolve",name:"Dissolve",description:"Cross-dissolve between clips"},{type:"wipe-left",name:"Wipe Left",description:"Wipe from right to left"},{type:"wipe-right",name:"Wipe Right",description:"Wipe from left to right"},{type:"wipe-up",name:"Wipe Up",description:"Wipe from bottom to top"},{type:"wipe-down",name:"Wipe Down",description:"Wipe from top to bottom"},{type:"slide-left",name:"Slide Left",description:"Slide out to the left"},{type:"slide-right",name:"Slide Right",description:"Slide out to the right"},{type:"slide-up",name:"Slide Up",description:"Slide out upward"},{type:"slide-down",name:"Slide Down",description:"Slide out downward"},{type:"zoom-in",name:"Zoom In",description:"Zoom into the next clip"},{type:"zoom-out",name:"Zoom Out",description:"Zoom out to the next clip"},{type:"cross-fade",name:"Cross Fade",description:"Cross-fade between clips"},{type:"dip-to-black",name:"Dip to Black",description:"Fade through black"},{type:"dip-to-white",name:"Dip to White",description:"Fade through white"}];let la=to;const ng={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},og={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},ag=["onClick"],rg={class:"w-full h-16 bg-gradient-to-r from-gray-300 to-gray-400 dark:from-gray-600 dark:to-gray-700 rounded mb-2 flex items-center justify-center"},ig={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},sg={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},lg={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},cg={key:2,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"},dg={key:3,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"},ug={key:4,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 5a1 1 0 011-1h14a1 1 0 011 1v14a1 1 0 01-1 1H5a1 1 0 01-1-1V5z"},mg={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},pg={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},fg={class:"space-y-3"},hg={class:"flex items-center space-x-2"},vg=["disabled"],gg=["disabled"],yg={key:1,class:"mt-4"},bg={class:"space-y-2 max-h-32 overflow-y-auto"},wg={class:"text-sm text-gray-700 dark:text-gray-300"},kg=["onClick"],xg=e.defineComponent({__name:"TransitionSelector",props:{selectedClips:{},appliedTransitions:{}},emits:["apply-transition","remove-transition","preview-transition"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(la.getAvailableTransitions()),i=e.ref(null),s=e.ref(.5),l=e.ref("linear"),c=e.computed(()=>i.value&&t.selectedClips&&t.selectedClips.length>=2);function d(g){i.value=g}function u(){if(!i.value||!c.value)return;const g={type:i.value.type,duration:s.value,easing:l.value};a("apply-transition",g),i.value=null}function p(){if(!i.value)return;const g={type:i.value.type,duration:s.value,easing:l.value};a("preview-transition",g)}function m(g){a("remove-transition",g)}function h(g){return["fade","wipe","slide","zoom"].some(v=>g.includes(v))}return(g,v)=>(e.openBlock(),e.createElementBlock("div",ng,[v[9]||(v[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",og,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,x=>{var B;return e.openBlock(),e.createElementBlock("div",{key:x.type,onClick:E=>d(x),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((B=i.value)==null?void 0:B.type)===x.type?"border-blue-500 bg-blue-50 dark:bg-blue-900":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"])},[e.createElementVNode("div",rg,[h(x.type)?(e.openBlock(),e.createElementBlock("svg",ig,[x.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",sg)):x.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",lg)):x.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",cg)):x.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",dg)):(e.openBlock(),e.createElementBlock("path",ug))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",mg,e.toDisplayString(x.name),1)],10,ag)}),128))]),i.value?(e.openBlock(),e.createElementBlock("div",pg,[v[6]||(v[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",fg,[e.createElementVNode("div",null,[v[3]||(v[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",hg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[0]||(v[0]=x=>s.value=x),type:"range",min:"0.1",max:"3",step:"0.1",class:"flex-1"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":v[1]||(v[1]=x=>s.value=x),type:"number",min:"0.1",max:"3",step:"0.1",class:"w-16 px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]])])]),e.createElementVNode("div",null,[v[5]||(v[5]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Easing ",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":v[2]||(v[2]=x=>l.value=x),class:"w-full px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 dark:bg-gray-600 dark:text-white"},[...v[4]||(v[4]=[e.createElementVNode("option",{value:"linear"},"Linear",-1),e.createElementVNode("option",{value:"easeIn"},"Ease In",-1),e.createElementVNode("option",{value:"easeOut"},"Ease Out",-1),e.createElementVNode("option",{value:"easeInOut"},"Ease In Out",-1)])],512),[[e.vModelSelect,l.value]])]),e.createElementVNode("button",{onClick:u,disabled:!c.value,class:e.normalizeClass(["w-full px-3 py-2 rounded-lg font-medium transition-colors",c.value?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])}," Apply Transition ",10,vg),e.createElementVNode("button",{onClick:p,disabled:!i.value,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors"}," Preview ",8,gg)])])):e.createCommentVNode("",!0),g.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",yg,[v[8]||(v[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",bg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.appliedTransitions,(x,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",wg,e.toDisplayString(x.name)+" ("+e.toDisplayString(x.duration)+"s) ",1),e.createElementVNode("button",{onClick:E=>m(B),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...v[7]||(v[7]=[e.createElementVNode("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,kg)]))),128))])])):e.createCommentVNode("",!0),v[10]||(v[10]=e.createElementVNode("div",{class:"mt-4 text-xs text-gray-500 dark:text-gray-400"},[e.createElementVNode("p",null,"Select clips in the timeline, then choose a transition to apply between them.")],-1))]))}}),Ts=_e(xg,[["__scopeId","data-v-5ef1b100"]]),Sg={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Eg={class:"mb-4"},Cg={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Vg={class:"flex items-center justify-between mb-2"},Ng={class:"text-sm text-gray-600 dark:text-gray-400"},_g={class:"flex items-center space-x-2"},Tg={class:"space-y-3 max-h-64 overflow-y-auto"},Mg={class:"flex items-center justify-between mb-2"},Fg={class:"font-medium text-gray-900 dark:text-white"},Ig={class:"flex items-center space-x-2"},Bg=["onClick","title"],Rg={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Pg={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},$g=["onClick"],zg=["onClick"],Ag={class:"flex items-center space-x-2"},Dg={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},Ug=["value","onInput","disabled"],Og={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Lg={key:0,class:"ml-2"},Wg={key:1,class:"ml-2"},jg={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},Xg={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},Zg={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},Yg={class:"space-y-4"},Gg={class:"space-y-2"},Hg={class:"flex items-center"},Jg={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},qg={class:"grid grid-cols-2 gap-4"},Kg={class:"grid grid-cols-2 gap-4"},Qg={class:"flex items-center"},e1={class:"flex justify-end space-x-3 mt-6"},t1=["disabled"],n1=e.defineComponent({__name:"AudioTrackManager",props:{audioLayers:{},masterVolume:{}},emits:["add-track","update-track","remove-track","update-volume","toggle-mute","update-master-volume"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.ref(null),s=e.ref(t.masterVolume),l=()=>({id:"",source:"",sourceUrl:"",name:"Background Music",volume:.7,startTime:0,fadeIn:0,fadeOut:0,loop:!1}),c=e.reactive(l()),d=e.computed(()=>c.sourceUrl||c.sourceFile);function u(y){const f=y.target;f.files&&f.files[0]&&(c.sourceFile=f.files[0],c.name=c.name||f.files[0].name.replace(/\.[^/.]+$/,""))}function p(y){Object.assign(c,y),i.value=y}function m(){r.value=!1,i.value=null,Object.assign(c,l())}function h(){if(!d.value)return;const y={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(y.duration=c.duration),c.fadeIn>0&&(y.fadeIn=c.fadeIn),c.fadeOut>0&&(y.fadeOut=c.fadeOut),i.value?a("update-track",i.value.id,y):a("add-track",y),m()}function g(y){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",y)}function v(y,f){const w=f.target,$=parseFloat(w.value);a("update-volume",y.id,$)}function x(y){a("toggle-mute",y.id,!y.muted)}function B(){a("update-master-volume",s.value)}function E(y){const f=Math.floor(y/60),w=Math.floor(y%60);return`${f}:${w.toString().padStart(2,"0")}`}return(y,f)=>(e.openBlock(),e.createElementBlock("div",Sg,[e.createElementVNode("div",Eg,[f[11]||(f[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:f[0]||(f[0]=w=>r.value=!0),class:"w-full px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"},[...f[10]||(f[10]=[e.createElementVNode("svg",{class:"w-5 h-5 inline-block mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})],-1),e.createTextVNode(" Add Audio Track ",-1)])])]),e.createElementVNode("div",Cg,[e.createElementVNode("div",Vg,[f[12]||(f[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",Ng,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",_g,[f[13]||(f[13]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[1]||(f[1]=w=>s.value=w),onInput:B,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),f[14]||(f[14]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1))])]),e.createElementVNode("div",Tg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.audioLayers,w=>(e.openBlock(),e.createElementBlock("div",{key:w.id,class:"p-3 border border-gray-200 dark:border-gray-700 rounded-lg"},[e.createElementVNode("div",Mg,[e.createElementVNode("div",Fg,e.toDisplayString(w.name),1),e.createElementVNode("div",Ig,[e.createElementVNode("button",{onClick:$=>x(w),class:e.normalizeClass(["p-1 rounded",w.muted?"text-red-600 bg-red-50 dark:bg-red-900":"text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700"]),title:w.muted?"Unmute":"Mute"},[w.muted?(e.openBlock(),e.createElementBlock("svg",Pg,[...f[16]||(f[16]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM12.293 7.293a1 1 0 011.414 0L15 8.586l1.293-1.293a1 1 0 111.414 1.414L16.414 10l1.293 1.293a1 1 0 01-1.414 1.414L15 11.414l-1.293 1.293a1 1 0 01-1.414-1.414L13.586 10l-1.293-1.293a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",Rg,[...f[15]||(f[15]=[e.createElementVNode("path",{"fill-rule":"evenodd",d:"M9.383 3.076A1 1 0 0110 4v12a1 1 0 01-1.707.707L4.586 13H2a1 1 0 01-1-1V8a1 1 0 011-1h2.586l3.707-3.707a1 1 0 011.09-.217zM14.657 2.929a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L16.586 7l-1.929-1.929a1 1 0 010-1.414z","clip-rule":"evenodd"},null,-1)])]))],10,Bg),e.createElementVNode("button",{onClick:$=>p(w),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...f[17]||(f[17]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])],8,$g),e.createElementVNode("button",{onClick:$=>g(w.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...f[18]||(f[18]=[e.createElementVNode("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})],-1)])],8,zg)])]),e.createElementVNode("div",Ag,[e.createElementVNode("span",Dg,e.toDisplayString(Math.round((w.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:w.volume||1,onInput:$=>v(w,$),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:w.muted},null,40,Ug)]),e.createElementVNode("div",Og,[e.createTextVNode(e.toDisplayString(E(w.startTime||0))+" - "+e.toDisplayString(E((w.startTime||0)+(w.duration||0)))+" ",1),w.fadeIn?(e.openBlock(),e.createElementBlock("span",Lg,"Fade In: "+e.toDisplayString(w.fadeIn)+"s",1)):e.createCommentVNode("",!0),w.fadeOut?(e.openBlock(),e.createElementBlock("span",Wg,"Fade Out: "+e.toDisplayString(w.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),y.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",jg," No audio tracks added yet ")):e.createCommentVNode("",!0)]),r.value||i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",onClick:e.withModifiers(m,["self"])},[e.createElementVNode("div",Xg,[e.createElementVNode("h4",Zg,e.toDisplayString(i.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",Yg,[e.createElementVNode("div",null,[f[20]||(f[20]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Audio Source ",-1)),e.createElementVNode("div",Gg,[e.createElementVNode("input",{type:"file",accept:"audio/*",onChange:u,class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,32),e.createElementVNode("div",Hg,[f[19]||(f[19]=e.createElementVNode("span",{class:"text-sm text-gray-500 dark:text-gray-400 mr-2"},"or URL:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[2]||(f[2]=w=>c.sourceUrl=w),type:"url",placeholder:"https://example.com/audio.mp3",class:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.sourceUrl]])])])]),e.createElementVNode("div",null,[f[21]||(f[21]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Track Name ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[3]||(f[3]=w=>c.name=w),type:"text",placeholder:"Background Music",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.name]])]),e.createElementVNode("div",null,[e.createElementVNode("label",Jg," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[4]||(f[4]=w=>c.volume=w),type:"range",min:"0",max:"1",step:"0.01",class:"w-full"},null,512),[[e.vModelText,c.volume,void 0,{number:!0}]])]),e.createElementVNode("div",qg,[e.createElementVNode("div",null,[f[22]||(f[22]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Start Time (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[5]||(f[5]=w=>c.startTime=w),type:"number",min:"0",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.startTime,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[23]||(f[23]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Duration (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[6]||(f[6]=w=>c.duration=w),type:"number",min:"0.1",step:"0.1",placeholder:"Auto",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.duration,void 0,{number:!0}]])])]),e.createElementVNode("div",Kg,[e.createElementVNode("div",null,[f[24]||(f[24]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade In (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[7]||(f[7]=w=>c.fadeIn=w),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeIn,void 0,{number:!0}]])]),e.createElementVNode("div",null,[f[25]||(f[25]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"}," Fade Out (seconds) ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[8]||(f[8]=w=>c.fadeOut=w),type:"number",min:"0",max:"10",step:"0.1",class:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white"},null,512),[[e.vModelText,c.fadeOut,void 0,{number:!0}]])])]),e.createElementVNode("div",Qg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":f[9]||(f[9]=w=>c.loop=w),type:"checkbox",id:"loop-checkbox",class:"mr-2 rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"},null,512),[[e.vModelCheckbox,c.loop]]),f[26]||(f[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",e1,[e.createElementVNode("button",{onClick:m,class:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"}," Cancel "),e.createElementVNode("button",{onClick:h,disabled:!d.value,class:e.normalizeClass(["px-4 py-2 rounded-lg transition-colors",d.value?"bg-green-600 text-white hover:bg-green-700":"bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"])},e.toDisplayString(i.value?"Save":"Add"),11,t1)])])])):e.createCommentVNode("",!0)]))}}),Ms=_e(n1,[["__scopeId","data-v-593719ac"]]);function Fs(n){var s,l;o1(n);const o=a1(n.clips),t=[],a=r1(n),r=i1(n),i={version:"1.0",source:{media_uuid:n.mediaUuid,duration:n.originalDuration,original_width:((s=n.media)==null?void 0:s.width)||1920,original_height:((l=n.media)==null?void 0:l.height)||1080},timeline:o,filters:t,audio:a,output:r,metadata:{created_at:new Date().toISOString(),editor_version:"2.0.0"}};return n.textOverlays&&(i.textOverlays=n.textOverlays),n.audioTracks&&(i.audioTracks=n.audioTracks.filter(c=>typeof c.source=="string")),i}function o1(n){if(!n.mediaUuid)throw new Error("Media UUID is required");if(!n.clips||n.clips.length===0)throw new Error("At least one clip is required");const o=[...n.clips].sort((t,a)=>t.timelineStart-a.timelineStart);for(let t=1;t<o.length;t++)if(o[t].timelineStart<o[t-1].timelineEnd)throw new Error(`Clips ${o[t-1].id} and ${o[t].id} overlap on timeline`)}function a1(n){return n.map(o=>{const t=o.speed||1,a=typeof o.sourceIn=="number"&&!Number.isNaN(o.sourceIn),r=typeof o.sourceOut=="number"&&!Number.isNaN(o.sourceOut),i=Math.max(0,o.timelineEnd-o.timelineStart),s=o.sourceOffset??o.trimStart??0;let l=Number(a?o.sourceIn:s),c=r?Number(o.sourceOut):Number(s)+i/t;return c>l||(c=l+Math.max(.033,i/Math.max(1e-6,t))),{id:o.id,type:"clip",timelineStart:o.timelineStart,timelineEnd:o.timelineEnd,sourceIn:l,sourceOut:c,speed:t,filters:o.filters?[...o.filters]:[]}})}function r1(n){const o={volume:n.audioVolume,muted:n.audioVolume===0};return n.audioFadeIn>0&&(o.fadeIn=n.audioFadeIn),n.audioFadeOut>0&&(o.fadeOut=n.audioFadeOut),o}function i1(n){var i;const o={"360p":{bitrate:1e6},"480p":{bitrate:25e5},"720p":{bitrate:5e6},"1080p":{bitrate:8e6},"1440p":{bitrate:16e6},"2160p":{bitrate:35e6}},t=o[n.exportQuality]||o["1080p"],a=(i=n.media)==null?void 0:i.frame_rate,r=a&&Number.isFinite(a)&&a>0?a:30;return{format:n.exportFormat||"mp4",codec:"h264",quality:n.exportQuality||"1080p",fps:r,bitrate:t.bitrate}}function s1(n,o,t){var ee,be;const a=typeof n=="string"&&n.trim()!==""?n.trim():`temp-${Date.now()}`,r=e.reactive({mediaUuid:a,clips:[],playheadPosition:0,totalDuration:0,originalDuration:0,filters:[],audioVolume:1,audioFadeIn:0,audioFadeOut:0,exportQuality:"1080p",exportFormat:"mp4",hasChanges:!1,isPlaying:!1,zoomLevel:100}),i=e.ref(null),s=e.ref([]),l=e.ref([]),c=e.ref(void 0),d=e.ref(!1),u=e.shallowRef(null),p=new Wl(30),m=e.ref(30),h=e.ref(!1),g=e.ref(!1);o&&o.timeline&&o.timeline.length>0?(y(o),(ee=o.output)!=null&&ee.fps&&(m.value=o.output.fps,p.setFps(m.value))):(E(),o&&((be=o.output)!=null&&be.fps&&(m.value=o.output.fps,p.setFps(m.value)),o.audio&&(r.audioVolume=o.audio.volume||1,r.audioFadeIn=o.audio.fadeIn||0,r.audioFadeOut=o.audio.fadeOut||0),o.output&&(r.exportFormat=o.output.format||"mp4",r.exportQuality=o.output.quality||"1080p")));const v=e.computed(()=>r.selectedClipId?r.clips.find(Y=>Y.id===r.selectedClipId)??null:null),x=e.computed(()=>s.value.length>0),B=e.computed(()=>l.value.length>0);function E(){const Y=typeof(t==null?void 0:t.duration)=="number"&&t.duration>0?t.duration:10;t&&(r.media=t),r.originalDuration=Y,r.totalDuration=Y;const se=Be(),xe={id:se,type:"clip",timelineStart:0,timelineEnd:Y,sourceIn:0,sourceOut:Y,sourceMinIn:0,sourceMaxOut:Y,speed:1};r.clips=[xe],r.selectedClipId=se,c.value=se,!(t||a.startsWith("temp-"))&&(async()=>{try{const Ce=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!Ce.ok)throw new Error(`Failed to fetch media: ${Ce.status}`);const Ue=await Ce.json(),Ye=typeof Ue=="object"&&Ue!==null&&"data"in Ue?Ue.data:Ue;if(!Ye||typeof Ye!="object")throw new Error("Failed to parse media payload");const nt=Ye;r.media=nt;const At=typeof nt.duration=="number"&&nt.duration>0?nt.duration:Y;if(r.hasChanges||r.clips.length!==1||r.clips[0].id!==se)return;r.originalDuration=At,r.totalDuration=At;const ut=r.clips[0];ut.timelineStart=0,ut.timelineEnd=At,ut.sourceIn=0,ut.sourceOut=At,ut.sourceMinIn=0,ut.sourceMaxOut=At,F()}catch{}})()}function y(Y){r.clips=Y.timeline.map(se=>({...se,sourceMinIn:se.sourceMinIn??0,sourceMaxOut:se.sourceMaxOut??Y.source.duration})),r.filters=[],r.audioVolume=Y.audio.volume,r.audioFadeIn=Y.audio.fadeIn||0,r.audioFadeOut=Y.audio.fadeOut||0,r.exportFormat=Y.output.format,r.exportQuality=Y.output.quality,r.originalDuration=Y.source.duration,r.clips.length>0?(r.selectedClipId=r.clips[0].id,c.value=r.selectedClipId):(delete r.selectedClipId,c.value=void 0),F()}function f(){s.value.push(JSON.parse(JSON.stringify(r))),l.value=[],r.hasChanges=!0}function w(){if(!x.value)return;const Y=s.value.pop();l.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,Y)}function $(){if(!B.value)return;const Y=l.value.pop();s.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,Y)}function C(Y,se,xe){f();const Ce=r.clips.find(ut=>ut.id===Y);if(!Ce)return;const Ye=1/30,nt=Ce.sourceMinIn??0,At=Ce.sourceMaxOut??r.originalDuration;if(se==="start"){const ut=Ce.sourceIn,fn=Math.max(nt,Math.min(xe,Ce.sourceOut-Ye));Ce.sourceIn=fn;const Da=fn-ut;Ce.timelineStart+=Da}else{const ut=Math.max(Ce.sourceIn+Ye,Math.min(xe,At));Ce.sourceOut=ut;const fn=Ce.sourceOut-Ce.sourceIn;Ce.timelineEnd=Ce.timelineStart+fn}F(),u.value&&u.value.trimClip(Y,Ce.sourceIn,Ce.sourceOut)}function b(Y){f();const se=r.clips.find(nt=>Y>nt.timelineStart&&Y<nt.timelineEnd);if(!se)return;const xe=Y-se.timelineStart,Ce=se.sourceIn+xe,Ue={id:Be(),type:"clip",timelineStart:Y,timelineEnd:se.timelineEnd,sourceIn:Ce,sourceOut:se.sourceOut,speed:se.speed??1,sourceMinIn:se.sourceMinIn??0,sourceMaxOut:se.sourceMaxOut??r.originalDuration,filters:[...se.filters||[]]};se.timelineEnd=Y,se.sourceOut=Ce;const Ye=r.clips.indexOf(se);r.clips.splice(Ye+1,0,Ue),r.selectedClipId=Ue.id}function N(){b(r.playheadPosition)}function P(Y){var xe;const se=Y??r.selectedClipId??c.value??((xe=r.clips[0])==null?void 0:xe.id);se&&(r.selectedClipId=se,c.value=se)}function k(){if(!r.selectedClipId||r.clips.length<=1)return;f();const Y=r.clips.findIndex(se=>se.id===r.selectedClipId);if(Y!==-1){r.clips.splice(Y,1);const se=Math.min(Y,r.clips.length-1);r.selectedClipId=r.clips[se].id,c.value=r.selectedClipId,F()}}function T(Y,se){f();const xe=r.clips.find(Ue=>Ue.id===Y);if(!xe)return;const Ce=se-xe.timelineStart;xe.timelineStart=se,xe.timelineEnd+=Ce,F(),u.value&&u.value.moveClip(Y,se)}function F(){if(r.clips.length===0){r.totalDuration=0;return}const Y=r.clips.reduce((se,xe)=>xe.timelineEnd>se.timelineEnd?xe:se);r.totalDuration=Y.timelineEnd}function D(){r.zoomLevel=Math.min(200,r.zoomLevel*1.2)}function R(){r.zoomLevel=Math.max(10,r.zoomLevel/1.2)}function W(Y){r.zoomLevel=Math.max(10,Math.min(600,Math.round(Y)))}function L(){r.isPlaying=!r.isPlaying}function _(Y){r.isPlaying=Y}function A(Y){r.playheadPosition=Math.max(0,Math.min(Y,r.totalDuration))}function Z(){const Y=Fs(r);return localStorage.setItem(`video-draft-${a}`,JSON.stringify(Y)),Y}function H(){r.hasChanges=!1}function me(){return confirm("Are you sure you want to reset all changes?")?(f(),E(),r.hasChanges=!1,!0):!1}function Te(){return Fs(r)}function Be(){return`clip-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}async function ie(Y=1920,se=1080){if(d.value)try{u.value=new Ll(Y,se,m.value),await M()}catch{u.value=null}}async function M(){if(!(!u.value||g.value)){g.value=!0;try{const Y=Te();await u.value.loadFromRecipe(Y);const se=p.secondsToFrames(r.playheadPosition);u.value.seek(se)}catch{}finally{g.value=!1}}}function j(Y){}function te(Y){return p.secondsToFrames(Y)}function ae(Y){return p.framesToSeconds(Y)}function re(Y){const se=ae(Y);A(se),u.value&&u.value.seek(Y)}function q(){h.value=!h.value}function ue(){M()}function ve(Y){d.value=!1,u.value=null}e.watch(()=>r.clips,()=>{r.hasChanges=!0,d.value&&u.value&&M()},{deep:!0}),e.watch(()=>r.filters,()=>{r.hasChanges=!0,d.value&&u.value&&M()},{deep:!0}),e.watch(()=>r.clips.map(Y=>Y.id),()=>{var se;if(!r.clips.length){delete r.selectedClipId,c.value=void 0;return}if(!r.clips.some(xe=>xe.id===r.selectedClipId)){const xe=c.value&&((se=r.clips.find(Ce=>Ce.id===c.value))==null?void 0:se.id);r.selectedClipId=xe??r.clips[0].id,c.value=r.selectedClipId}},{deep:!0});function we(Y){const se=r.selectedClipId?r.clips.find(xe=>xe.id===r.selectedClipId):r.clips[0];se&&(se.filters=[...Y],r.hasChanges=!0)}function oe(Y){r.textOverlays=[...Y]}function ye(Y){r.audioTracks=[...Y]}e.watch(d,Y=>{Y?ie():u.value&&(u.value.destroy(),u.value=null)}),e.watch(h,()=>{}),e.watch(m,Y=>{p.setFps(Y)});const fe=e.ref(1);function Ze(){if(!r.selectedClipId)return;f();const Y=r.clips.find(Ce=>Ce.id===r.selectedClipId);if(!Y)return;const se={...Y,id:Be(),timelineStart:Y.timelineEnd,timelineEnd:Y.timelineEnd+(Y.timelineEnd-Y.timelineStart),filters:[...Y.filters||[]]},xe=r.clips.indexOf(Y);r.clips.splice(xe+1,0,se),r.selectedClipId=se.id,r.hasChanges=!0}function Ke(){r.zoomLevel=50}function pe(){const Y=1/m.value;A(Math.min(r.playheadPosition+Y,r.totalDuration))}function ke(){const Y=1/m.value;A(Math.max(r.playheadPosition-Y,0))}function U(){A(0)}function ne(){A(r.totalDuration)}function K(Y){fe.value=Y}return{currentFrame:i,playheadPosition:e.computed(()=>r.playheadPosition),timelineClips:e.computed(()=>r.clips),totalDuration:e.computed(()=>r.totalDuration),hasChanges:e.computed(()=>r.hasChanges),isPlaying:e.computed(()=>r.isPlaying),selectedClip:v,zoomLevel:e.computed(()=>r.zoomLevel),playbackSpeed:fe,useVideoEngine:d,compositionAdapter:e.computed(()=>u.value),fps:m,useFrameMode:h,handleTrim:C,handleSplit:b,handleClipSelect:P,splitAtPlayhead:N,deleteSelectedClip:k,duplicateSelectedClip:Ze,setFilters:we,setTextOverlays:oe,setAudioTracks:ye,moveClip:T,saveDraft:Z,clearHasChanges:H,resetChanges:me,generateRecipe:Te,zoomIn:D,zoomOut:R,setZoomLevel:W,fitToWindow:Ke,togglePlayback:L,setPlaying:_,seekTo:A,frameForward:pe,frameBackward:ke,skipToStart:U,skipToEnd:ne,setPlaybackSpeed:K,undo:w,redo:$,canUndo:x,canRedo:B,initializeComposition:ie,syncCompositionWithState:M,syncWithComposition:j,convertToFrames:te,convertToSeconds:ae,seekToFrame:re,toggleFrameMode:q,onCompositionReady:ue,onCompositionError:ve}}const l1=[{id:"brightness",name:"Brightness",category:"color",ffmpeg:"eq=brightness={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:0},paramRanges:{value:{min:-1,max:1,step:.05}}},{id:"contrast",name:"Contrast",category:"color",ffmpeg:"eq=contrast={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:1},paramRanges:{value:{min:.5,max:2,step:.05}}},{id:"saturation",name:"Saturation",category:"color",ffmpeg:"eq=saturation={value}",pixiFilter:"AdjustmentFilter",defaultParams:{value:1},paramRanges:{value:{min:0,max:2,step:.05}}},{id:"hue",name:"Hue Shift",category:"color",ffmpeg:"hue=h={value}",pixiFilter:"HueRotateFilter",defaultParams:{value:0},paramRanges:{value:{min:-180,max:180,step:5}}},{id:"gaussian-blur",name:"Gaussian Blur",category:"blur",ffmpeg:"gblur=sigma={value}",pixiFilter:"BlurFilter",defaultParams:{value:2},paramRanges:{value:{min:0,max:10,step:.5}}},{id:"motion-blur",name:"Motion Blur",category:"blur",ffmpeg:"minterpolate=fps=60:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:me=epzs:vsbmc=1",pixiFilter:"MotionBlurFilter",defaultParams:{velocity:5,angle:0},paramRanges:{velocity:{min:0,max:20,step:1},angle:{min:0,max:360,step:15}}},{id:"vintage",name:"Vintage",category:"stylize",ffmpeg:"curves=preset=vintage",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"vintage"},paramRanges:{}},{id:"sepia",name:"Sepia",category:"stylize",ffmpeg:"colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"sepia"},paramRanges:{}},{id:"grayscale",name:"Black & White",category:"stylize",ffmpeg:"colorchannelmixer=0.3:0.59:0.11:0:0.3:0.59:0.11:0:0.3:0.59:0.11",pixiFilter:"ColorMatrixFilter",defaultParams:{preset:"grayscale"},paramRanges:{}},{id:"vignette",name:"Vignette",category:"effects",ffmpeg:"vignette=a={value}",pixiFilter:"VignetteFilter",defaultParams:{value:.3},paramRanges:{value:{min:0,max:1,step:.05}}},{id:"sharpen",name:"Sharpen",category:"effects",ffmpeg:"unsharp=5:5:{value}:5:5:0",pixiFilter:"SharpenFilter",defaultParams:{value:1},paramRanges:{value:{min:0,max:5,step:.25}}},{id:"denoise",name:"Noise Reduction",category:"effects",ffmpeg:"nlmeans=s={value}",pixiFilter:"NoiseFilter",defaultParams:{value:1},paramRanges:{value:{min:.1,max:5,step:.1}}},{id:"motion-blur",name:"Motion Blur",category:"effects",ffmpeg:"minterpolate=fps=30:mi_mode=blend",pixiFilter:"MotionBlurFilter",defaultParams:{velocity:[0,0],kernelSize:5},paramRanges:{velocityX:{min:-100,max:100,step:1},velocityY:{min:-100,max:100,step:1},kernelSize:{min:3,max:15,step:2}}},{id:"radial-blur",name:"Radial Blur",category:"effects",ffmpeg:"boxblur={radius}:{radius}",pixiFilter:"RadialBlurFilter",defaultParams:{radius:.1,angle:0,kernelSize:5},paramRanges:{radius:{min:0,max:1,step:.01},angle:{min:-180,max:180,step:1},kernelSize:{min:3,max:15,step:2}}},{id:"kawase-blur",name:"Kawase Blur",category:"effects",ffmpeg:"gblur=sigma={blur}:steps={quality}",pixiFilter:"KawaseBlurFilter",defaultParams:{blur:4,quality:3},paramRanges:{blur:{min:0,max:20,step:.5},quality:{min:1,max:10,step:1}}},{id:"flip-horizontal",name:"Flip Horizontal",category:"transform",ffmpeg:"hflip",pixiFilter:"FlipFilter",defaultParams:{horizontal:!0},paramRanges:{}},{id:"flip-vertical",name:"Flip Vertical",category:"transform",ffmpeg:"vflip",pixiFilter:"FlipFilter",defaultParams:{vertical:!0},paramRanges:{}},{id:"rotate",name:"Rotate",category:"transform",ffmpeg:"rotate={value}*PI/180",pixiFilter:"RotateFilter",defaultParams:{value:0},paramRanges:{value:{min:-180,max:180,step:15}}}],c1={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function _a(n){return typeof n=="object"&&n!==null}function d1(n,o){if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const t=Number(n);if(Number.isFinite(t))return t}return o}function Ta(n){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean")return n}function u1(n){const o={id:n.id,type:n.type,label:n.label};n.property!==void 0&&(o.property=n.property),n.min!==void 0&&(o.min=n.min),n.max!==void 0&&(o.max=n.max),n.step!==void 0&&(o.step=n.step);const t=Ta(n.default);return t!==void 0&&(o.default=t),o}function jl(n,o,t){const a=no.getFilter(n),r={},i=(a==null?void 0:a.defaultParams)??t;if(i&&_a(i))for(const[s,l]of Object.entries(i))r[s]=Ta(l)??null;for(const s of o){const l=s.property??s.id;r[l]===void 0&&s.default!==void 0&&(r[l]=s.default)}return r}function Xl(n){const o={};for(const t of n){if(t.type!=="slider")continue;const a=t.property??t.id;o[a]={min:t.min??0,max:t.max??100,step:t.step??1}}return o}function m1(n,o,t,a){const r=a.map(u1);return{id:n,name:o,category:t,controls:r,params:r,defaultParams:jl(n,r),paramRanges:Xl(r)}}function p1(n){const o=n.paramRanges??{},t=Object.entries(o).map(([a,r])=>{var l;const i={id:a,type:"slider",label:a.replace(/[-_]/g," ").replace(/\b\w/g,c=>c.toUpperCase()),property:a,min:r.min,max:r.max,step:r.step},s=Ta((l=n.defaultParams)==null?void 0:l[a]);return s!==void 0&&(i.default=s),i});return{id:n.id,name:n.name,category:n.category,controls:t,params:t,defaultParams:jl(n.id,t,n.defaultParams),paramRanges:Xl(t)}}function f1(n,o){return o.toLowerCase()!=="unlisted"}function ir(n){return c1[n]??n}function Zn(n){const o=d1(n,1);return Math.max(0,Math.min(1,o))}function Yn(n){if(!_a(n))return{};const o={};for(const[t,a]of Object.entries(n))o[t]=Ta(a)??null;return o}function h1(n){return!_a(n)||typeof n.filterId!="string"?null:{filterId:n.filterId,params:Yn(n.params),intensity:Zn(n.intensity)}}function v1(n){if(!_a(n)||typeof n.id!="string"||typeof n.name!="string")return null;const t=(Array.isArray(n.filters)?n.filters:[]).map(r=>h1(r)).filter(r=>r!==null),a=typeof n.created_at=="string"?n.created_at:new Date().toISOString();return{id:n.id,name:n.name,filters:t,created_at:a}}function g1(){no.initializeFilterRegistry();const n=e.ref([]),o=e.ref(null),t=e.ref(null),a=e.ref([]),r=e.ref(null),i=e.reactive({}),s=e.computed(()=>{const F=new Map,D=no.getRegisteredFilters();for(const R of D)f1(R.id,R.category)&&F.set(R.id,m1(R.id,R.name,R.category,R.controls));for(const R of l1)F.has(R.id)||F.set(R.id,p1(R));return Array.from(F.values())}),l=e.computed(()=>{const F=new Map;for(const D of s.value)F.set(D.id,D);return F}),c=e.computed(()=>n.value.length>0),d=e.computed(()=>{const F={};for(const D of s.value)F[D.category]||(F[D.category]=[]),F[D.category].push(D);return F});function u(F){const D=l.value.get(F);if(D)return D;const R=ir(F);return l.value.get(R)??null}function p(F){const D=l.value.get(F);if(D)return D.id;const R=ir(F),W=l.value.get(R);return W?W.id:null}function m(F){const D=F?u(F):o.value;if(!D)return;const R=D.defaultParams||{},W={id:N(),filterId:D.id,params:{...R},intensity:1};return n.value.push(W),r.value=W.id,o.value=D,Object.keys(i).forEach(L=>delete i[L]),Object.assign(i,W.params),t.value=null,W}function h(F){const D=u(F);if(!D)return;o.value=D;const R=D.defaultParams||k(F);Object.assign(i,R),t.value={id:"preview",filterId:D.id,params:{...R},intensity:1}}function g(F){if(Object.assign(i,F),t.value&&(t.value.params={...i}),r.value){const D=n.value.find(R=>R.id===r.value);D&&(D.params={...i})}}function v(F){const D=n.value.findIndex(R=>R.id===F);D!==-1&&n.value.splice(D,1)}function x(F,D){if(F<0||F>=n.value.length||D<0||D>=n.value.length)return;const[R]=n.value.splice(F,1);n.value.splice(D,0,R)}function B(F,D){const R=n.value.find(W=>W.id===F);R&&(R.intensity=Math.max(0,Math.min(1,D)))}function E(F){const D=n.value.find(R=>R.id===F);D&&(D.intensity=D.intensity>0?0:1)}function y(){n.value=[],t.value=null,o.value=null,r.value=null,Object.keys(i).forEach(F=>delete i[F])}function f(F){const D={id:P(),name:F,filters:n.value.map(W=>({filterId:W.filterId,params:Yn(W.params),intensity:Zn(W.intensity)})),created_at:new Date().toISOString()};a.value.push(D);const R=a.value.map(W=>({...W}));return localStorage.setItem("video-filter-presets",JSON.stringify(R)),D}function w(F){const D=a.value.find(R=>R.id===F);if(D){y();for(const R of D.filters){const W=u(R.filterId);W&&n.value.push({id:N(),filterId:W.id,params:{...R.params},intensity:Zn(R.intensity)})}}}function $(F){const D=a.value.findIndex(R=>R.id===F);D!==-1&&(a.value.splice(D,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function C(){try{const F=localStorage.getItem("video-filter-presets");if(!F)return;const D=JSON.parse(F);if(!Array.isArray(D))return;a.value=D.map(R=>v1(R)).filter(R=>R!==null)}catch{}}function b(){if(n.value.length===0)return"No filters applied";const F=n.value.map(D=>{const R=T(D.filterId);return(R==null?void 0:R.name)||D.filterId});return F.length===1?F[0]:F.length===2?`${F[0]} + ${F[1]}`:`${F[0]} + ${F.length-1} more`}function N(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function P(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(F){const D=u(F);return D?D.defaultParams||{}:{}}function T(F){return u(F)}return C(),{videoCompatibleFilters:s,activeFilters:n,selectedFilter:o,previewFilter:t,filterPresets:a,filterParams:i,hasActiveFilters:c,filtersByCategory:d,applyFilter:m,previewFilterEffect:h,updateFilterParams:g,removeFilter:v,reorderFilters:x,updateFilterIntensity:B,toggleFilter:E,clearAllFilters:y,saveFilterPreset:f,loadFilterPreset:w,deleteFilterPreset:$,getFilterSummary:b,setActiveFilters(F){var R;const D=[];for(const W of F){const L=p(W.filterId);if(!L){const _=ir(W.filterId);D.push({...W,filterId:_,params:Yn(W.params),intensity:Zn(W.intensity)});continue}D.push({...W,filterId:L,params:Yn(W.params),intensity:Zn(W.intensity)})}n.value=D,r.value=((R=n.value[0])==null?void 0:R.id)??null,Object.keys(i).forEach(W=>delete i[W]),n.value[0]&&Object.assign(i,Yn(n.value[0].params))}}}class y1{constructor(o){this.textClips=new Map,this.fonts=new Map,this.nextId=0,this.composition=o,this.initializeDefaultFonts()}initializeDefaultFonts(){try{this.fonts.set("default",new st({source:"https://fonts.googleapis.com/css2?family=Inter:wght@400",family:"Inter",weight:"400"})),this.fonts.set("bold",new st({source:"https://fonts.googleapis.com/css2?family=Inter:wght@700",family:"Inter",weight:"700"})),this.fonts.set("serif",new st({source:"https://fonts.googleapis.com/css2?family=Merriweather:wght@400",family:"Merriweather",weight:"400"}))}catch{}}async loadWebFont(o,t,a,r="400"){const i=new st({source:t,family:a,weight:r});this.fonts.set(o,i)}loadLocalFont(o,t,a="400"){const r=new st({source:`local('${t}')`,family:t,weight:a});this.fonts.set(o,r)}async addTextOverlay(o){const t=`text-overlay-${this.nextId++}`,a={text:o.text,fontSize:o.fontSize||24,fillStyle:o.color||"#ffffff",textAlign:o.textAlign||"center",textBaseline:o.textBaseline||"middle"},r=o.fontFamily||"default",i=this.fonts.get(r)||this.fonts.get("default");if(a.font=i,o.position)if(typeof o.position=="string")switch(o.position){case"center":a.position="center";break;case"top":a.x="50%",a.y="10%";break;case"bottom":a.x="50%",a.y="90%";break;case"left":a.x="10%",a.y="50%";break;case"right":a.x="90%",a.y="50%";break}else a.x=o.position.x,a.y=o.position.y;else a.position="center";if(o.startTime!==void 0&&(a.start=de.fromSeconds(o.startTime)),o.duration!==void 0){const l=o.startTime||0;a.stop=de.fromSeconds(l+o.duration)}o.animation&&this.applyAnimation(a,o.animation,o);const s=new Tn(a);return await this.composition.add(s),this.textClips.set(t,s),t}applyAnimation(o,t,a){if(!t)return;const r=a.startTime?Math.round(a.startTime*30):0,i=t.duration||1,s=Math.round(i*30),l=r+s,c=t.easing||"linear";switch(t.type){case"fade-in":o.alpha=new Se([r,l],[0,1],{easing:c});break;case"fade-out":o.alpha=new Se([r,l],[1,0],{easing:c});break;case"rotate":t.rotation&&(o.rotation=new Se([r,l],[t.rotation.from,t.rotation.to],{easing:c}));break;case"scale":t.scale&&(o.scale=new Se([r,l],[t.scale.from,t.scale.to],{easing:c}));break;case"slide":t.translate&&(o.translate={x:new Se([r,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([r,l],[t.translate.fromY,t.translate.toY],{easing:c})});break;case"typewriter":o.alpha=new Se([r,l],[0,1],{easing:"linear"});break;case"custom":t.rotation&&(o.rotation=new Se([r,l],[t.rotation.from,t.rotation.to],{easing:c})),t.scale&&(o.scale=new Se([r,l],[t.scale.from,t.scale.to],{easing:c})),t.translate&&(o.translate={x:new Se([r,l],[t.translate.fromX,t.translate.toX],{easing:c}),y:new Se([r,l],[t.translate.fromY,t.translate.toY],{easing:c})});break}}async updateTextOverlay(o,t){if(!this.textClips.get(o))throw new Error(`Text overlay with id ${o} not found`);await this.removeTextOverlay(o);const r={...t};await this.addTextOverlay(r)}async removeTextOverlay(o){const t=this.textClips.get(o);if(!t)throw new Error(`Text overlay with id ${o} not found`);const a=this.composition.tracks;for(const r of a){const i=r.clips.indexOf(t);if(i!==-1){r.clips.splice(i,1);break}}this.textClips.delete(o)}getTextOverlays(){return new Map(this.textClips)}async clearAllTextOverlays(){const o=Array.from(this.textClips.keys());for(const t of o)await this.removeTextOverlay(t)}getOverlays(){const o=[];return this.textClips.forEach((t,a)=>{const r={text:t.text||"",fontSize:t.fontSize,color:t.fillStyle,fontFamily:"default",position:"center"};o.push({id:a,config:r})}),o}async addCaptions(o,t="classic",a){var c,d;const i={classic:vo,cascade:Sa,guinea:xa,solar:Ea,spotlight:go,whisper:yo}[t],s=await this.composition.createTrack("caption"),l=new va({transcript:o});if(await s.add(l),await((c=s.generate)==null?void 0:c.call(s,i)),a&&s.clips.length>0){const u=s.clips[0];(d=u.set)==null||d.call(u,a)}}}class b1{constructor(o){this.audioLayers=new Map,this.audioSources=new Map,this.nextId=0,this.masterVolume=1,this.composition=o}async loadAudioSource(o,t){try{const a=await Jt.from(o),r=t||`audio-source-${this.nextId++}`;return this.audioSources.set(r,a),a}catch(a){throw a instanceof Error?a:new Error("Failed to load audio source")}}async addBackgroundMusic(o){return this.addAudioTrack({...o,name:o.name||"Background Music"})}async addAudioTrack(o){const t=`audio-track-${this.nextId++}`;let a;try{if(typeof o.source=="object"&&o.source instanceof Jt)a=o.source;else if(typeof o.source=="string")a=await Jt.from(o.source);else if(typeof o.source=="object"&&o.source instanceof File)a=await Jt.from(URL.createObjectURL(o.source));else throw new Error("Invalid audio source")}catch(c){throw c instanceof Error?c:new Error("Failed to create audio source")}const r={source:a,volume:(o.volume??1)*this.masterVolume};if(o.startTime!==void 0&&(r.start=de.fromSeconds(o.startTime)),o.duration!==void 0){const c=o.startTime||0;r.stop=de.fromSeconds(c+o.duration)}(o.fadeIn||o.fadeOut)&&(r.volume=this.createVolumeKeyframes(o));const i=new sa(r);let s=this.composition.tracks.find(c=>c.kind==="audio");s||(s=await this.composition.createTrack("audio")),await s.add(i);const l={id:t,name:o.name||`Audio Track ${this.audioLayers.size+1}`,clip:i,track:s,config:o};return this.audioLayers.set(t,l),t}createVolumeKeyframes(o){const t=(o.volume??1)*this.masterVolume,a=o.startTime?Math.round(o.startTime*30):0,r=o.duration,i=[],s=[];if(o.fadeIn){const l=Math.round(o.fadeIn*30);i.push(a,a+l),s.push(0,t)}else i.push(a),s.push(t);if(o.fadeOut&&r){const l=a+Math.round(r*30),c=Math.round(o.fadeOut*30);o.fadeIn||(i.push(l-c),s.push(t)),i.push(l),s.push(0)}return new Se(i,s,{easing:"linear"})}async updateVolume(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);const r=Math.max(0,Math.min(1,t));a.clip.volume=r*this.masterVolume,a.config.volume=r}async applyFadeIn(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);a.config.fadeIn=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async applyFadeOut(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);a.config.fadeOut=t,a.clip.set({volume:this.createVolumeKeyframes(a.config)})}async removeAudioTrack(o){const t=this.audioLayers.get(o);if(!t)throw new Error(`Audio track with id ${o} not found`);const a=t.track.clips.indexOf(t.clip);a!==-1&&t.track.clips.splice(a,1),this.audioLayers.delete(o)}async muteTrack(o,t){const a=this.audioLayers.get(o);if(!a)throw new Error(`Audio track with id ${o} not found`);t?a.clip.volume=0:a.clip.volume=(a.config.volume??1)*this.masterVolume}setMasterVolume(o){this.masterVolume=Math.max(0,Math.min(1,o));for(const t of this.audioLayers.values())t.clip.volume=(t.config.volume??1)*this.masterVolume}getMasterVolume(){return this.masterVolume}getAudioLayers(){return Array.from(this.audioLayers.values())}getAudioLayer(o){return this.audioLayers.get(o)}async clearAllAudioTracks(){const o=Array.from(this.audioLayers.keys());for(const t of o)await this.removeAudioTrack(t)}async syncWithVideo(o,t){for(const a of this.audioLayers.values()){const r=a.config.startTime||0,i=a.config.duration||t-o;if(r+i>t){a.config.duration=t-r;const s=new sa({source:a.clip.source,start:de.fromSeconds(r),stop:de.fromSeconds(t),volume:a.clip.volume}),l=a.track.clips.indexOf(a.clip);l!==-1&&(a.track.clips[l]=s,a.clip=s)}}}exportConfiguration(){return Array.from(this.audioLayers.values()).map(o=>({id:o.id,name:o.name,config:{...o.config,source:o.config.source&&typeof o.config.source=="object"&&"type"in o.config.source?"[AudioSource]":o.config.source}}))}async importConfiguration(o){for(const{name:t,config:a}of o)await this.addAudioTrack({...a,name:t})}}function Zl(n,o){return function(){return n.apply(o,arguments)}}const{toString:w1}=Object.prototype,{getPrototypeOf:Jr}=Object,{iterator:Ma,toStringTag:Yl}=Symbol,Fa=(n=>o=>{const t=w1.call(o);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ct=n=>(n=n.toLowerCase(),o=>Fa(o)===n),Ia=n=>o=>typeof o===n,{isArray:In}=Array,lo=Ia("undefined");function bo(n){return n!==null&&!lo(n)&&n.constructor!==null&&!lo(n.constructor)&&mt(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Gl=Ct("ArrayBuffer");function k1(n){let o;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?o=ArrayBuffer.isView(n):o=n&&n.buffer&&Gl(n.buffer),o}const x1=Ia("string"),mt=Ia("function"),Hl=Ia("number"),wo=n=>n!==null&&typeof n=="object",S1=n=>n===!0||n===!1,Yo=n=>{if(Fa(n)!=="object")return!1;const o=Jr(n);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(Yl in n)&&!(Ma in n)},E1=n=>{if(!wo(n)||bo(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},C1=Ct("Date"),V1=Ct("File"),N1=Ct("Blob"),_1=Ct("FileList"),T1=n=>wo(n)&&mt(n.pipe),M1=n=>{let o;return n&&(typeof FormData=="function"&&n instanceof FormData||mt(n.append)&&((o=Fa(n))==="formdata"||o==="object"&&mt(n.toString)&&n.toString()==="[object FormData]"))},F1=Ct("URLSearchParams"),[I1,B1,R1,P1]=["ReadableStream","Request","Response","Headers"].map(Ct),$1=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ko(n,o,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let a,r;if(typeof n!="object"&&(n=[n]),In(n))for(a=0,r=n.length;a<r;a++)o.call(null,n[a],a,n);else{if(bo(n))return;const i=t?Object.getOwnPropertyNames(n):Object.keys(n),s=i.length;let l;for(a=0;a<s;a++)l=i[a],o.call(null,n[l],l,n)}}function Jl(n,o){if(bo(n))return null;o=o.toLowerCase();const t=Object.keys(n);let a=t.length,r;for(;a-- >0;)if(r=t[a],o===r.toLowerCase())return r;return null}const rn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ql=n=>!lo(n)&&n!==rn;function Cr(){const{caseless:n}=ql(this)&&this||{},o={},t=(a,r)=>{const i=n&&Jl(o,r)||r;Yo(o[i])&&Yo(a)?o[i]=Cr(o[i],a):Yo(a)?o[i]=Cr({},a):In(a)?o[i]=a.slice():o[i]=a};for(let a=0,r=arguments.length;a<r;a++)arguments[a]&&ko(arguments[a],t);return o}const z1=(n,o,t,{allOwnKeys:a}={})=>(ko(o,(r,i)=>{t&&mt(r)?n[i]=Zl(r,t):n[i]=r},{allOwnKeys:a}),n),A1=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),D1=(n,o,t,a)=>{n.prototype=Object.create(o.prototype,a),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:o.prototype}),t&&Object.assign(n.prototype,t)},U1=(n,o,t,a)=>{let r,i,s;const l={};if(o=o||{},n==null)return o;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)s=r[i],(!a||a(s,n,o))&&!l[s]&&(o[s]=n[s],l[s]=!0);n=t!==!1&&Jr(n)}while(n&&(!t||t(n,o))&&n!==Object.prototype);return o},O1=(n,o,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=o.length;const a=n.indexOf(o,t);return a!==-1&&a===t},L1=n=>{if(!n)return null;if(In(n))return n;let o=n.length;if(!Hl(o))return null;const t=new Array(o);for(;o-- >0;)t[o]=n[o];return t},W1=(n=>o=>n&&o instanceof n)(typeof Uint8Array<"u"&&Jr(Uint8Array)),j1=(n,o)=>{const a=(n&&n[Ma]).call(n);let r;for(;(r=a.next())&&!r.done;){const i=r.value;o.call(n,i[0],i[1])}},X1=(n,o)=>{let t;const a=[];for(;(t=n.exec(o))!==null;)a.push(t);return a},Z1=Ct("HTMLFormElement"),Y1=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,a,r){return a.toUpperCase()+r}),Is=(({hasOwnProperty:n})=>(o,t)=>n.call(o,t))(Object.prototype),G1=Ct("RegExp"),Kl=(n,o)=>{const t=Object.getOwnPropertyDescriptors(n),a={};ko(t,(r,i)=>{let s;(s=o(r,i,n))!==!1&&(a[i]=s||r)}),Object.defineProperties(n,a)},H1=n=>{Kl(n,(o,t)=>{if(mt(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const a=n[t];if(mt(a)){if(o.enumerable=!1,"writable"in o){o.writable=!1;return}o.set||(o.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},J1=(n,o)=>{const t={},a=r=>{r.forEach(i=>{t[i]=!0})};return In(n)?a(n):a(String(n).split(o)),t},q1=()=>{},K1=(n,o)=>n!=null&&Number.isFinite(n=+n)?n:o;function Q1(n){return!!(n&&mt(n.append)&&n[Yl]==="FormData"&&n[Ma])}const ey=n=>{const o=new Array(10),t=(a,r)=>{if(wo(a)){if(o.indexOf(a)>=0)return;if(bo(a))return a;if(!("toJSON"in a)){o[r]=a;const i=In(a)?[]:{};return ko(a,(s,l)=>{const c=t(s,r+1);!lo(c)&&(i[l]=c)}),o[r]=void 0,i}}return a};return t(n,0)},ty=Ct("AsyncFunction"),ny=n=>n&&(wo(n)||mt(n))&&mt(n.then)&&mt(n.catch),Ql=((n,o)=>n?setImmediate:o?((t,a)=>(rn.addEventListener("message",({source:r,data:i})=>{r===rn&&i===t&&a.length&&a.shift()()},!1),r=>{a.push(r),rn.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",mt(rn.postMessage)),oy=typeof queueMicrotask<"u"?queueMicrotask.bind(rn):typeof process<"u"&&process.nextTick||Ql,ay=n=>n!=null&&mt(n[Ma]),G={isArray:In,isArrayBuffer:Gl,isBuffer:bo,isFormData:M1,isArrayBufferView:k1,isString:x1,isNumber:Hl,isBoolean:S1,isObject:wo,isPlainObject:Yo,isEmptyObject:E1,isReadableStream:I1,isRequest:B1,isResponse:R1,isHeaders:P1,isUndefined:lo,isDate:C1,isFile:V1,isBlob:N1,isRegExp:G1,isFunction:mt,isStream:T1,isURLSearchParams:F1,isTypedArray:W1,isFileList:_1,forEach:ko,merge:Cr,extend:z1,trim:$1,stripBOM:A1,inherits:D1,toFlatObject:U1,kindOf:Fa,kindOfTest:Ct,endsWith:O1,toArray:L1,forEachEntry:j1,matchAll:X1,isHTMLForm:Z1,hasOwnProperty:Is,hasOwnProp:Is,reduceDescriptors:Kl,freezeMethods:H1,toObjectSet:J1,toCamelCase:Y1,noop:q1,toFiniteNumber:K1,findKey:Jl,global:rn,isContextDefined:ql,isSpecCompliantForm:Q1,toJSONObject:ey,isAsyncFn:ty,isThenable:ny,setImmediate:Ql,asap:oy,isIterable:ay};function Me(n,o,t,a,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",o&&(this.code=o),t&&(this.config=t),a&&(this.request=a),r&&(this.response=r,this.status=r.status?r.status:null)}G.inherits(Me,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:G.toJSONObject(this.config),code:this.code,status:this.status}}});const ec=Me.prototype,tc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{tc[n]={value:n}});Object.defineProperties(Me,tc);Object.defineProperty(ec,"isAxiosError",{value:!0});Me.from=(n,o,t,a,r,i)=>{const s=Object.create(ec);return G.toFlatObject(n,s,function(c){return c!==Error.prototype},l=>l!=="isAxiosError"),Me.call(s,n.message,o,t,a,r),s.cause=n,s.name=n.name,i&&Object.assign(s,i),s};const ry=null;function Vr(n){return G.isPlainObject(n)||G.isArray(n)}function nc(n){return G.endsWith(n,"[]")?n.slice(0,-2):n}function Bs(n,o,t){return n?n.concat(o).map(function(r,i){return r=nc(r),!t&&i?"["+r+"]":r}).join(t?".":""):o}function iy(n){return G.isArray(n)&&!n.some(Vr)}const sy=G.toFlatObject(G,{},null,function(o){return/^is[A-Z]/.test(o)});function Ba(n,o,t){if(!G.isObject(n))throw new TypeError("target must be an object");o=o||new FormData,t=G.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,x){return!G.isUndefined(x[v])});const a=t.metaTokens,r=t.visitor||u,i=t.dots,s=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(o);if(!G.isFunction(r))throw new TypeError("visitor must be a function");function d(g){if(g===null)return"";if(G.isDate(g))return g.toISOString();if(G.isBoolean(g))return g.toString();if(!c&&G.isBlob(g))throw new Me("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(g)||G.isTypedArray(g)?c&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,v,x){let B=g;if(g&&!x&&typeof g=="object"){if(G.endsWith(v,"{}"))v=a?v:v.slice(0,-2),g=JSON.stringify(g);else if(G.isArray(g)&&iy(g)||(G.isFileList(g)||G.endsWith(v,"[]"))&&(B=G.toArray(g)))return v=nc(v),B.forEach(function(y,f){!(G.isUndefined(y)||y===null)&&o.append(s===!0?Bs([v],f,i):s===null?v:v+"[]",d(y))}),!1}return Vr(g)?!0:(o.append(Bs(x,v,i),d(g)),!1)}const p=[],m=Object.assign(sy,{defaultVisitor:u,convertValue:d,isVisitable:Vr});function h(g,v){if(!G.isUndefined(g)){if(p.indexOf(g)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(g),G.forEach(g,function(B,E){(!(G.isUndefined(B)||B===null)&&r.call(o,B,G.isString(E)?E.trim():E,v,m))===!0&&h(B,v?v.concat(E):[E])}),p.pop()}}if(!G.isObject(n))throw new TypeError("data must be an object");return h(n),o}function Rs(n){const o={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(a){return o[a]})}function qr(n,o){this._pairs=[],n&&Ba(n,this,o)}const oc=qr.prototype;oc.append=function(o,t){this._pairs.push([o,t])};oc.toString=function(o){const t=o?function(a){return o.call(this,a,Rs)}:Rs;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function ly(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ac(n,o,t){if(!o)return n;const a=t&&t.encode||ly;G.isFunction(t)&&(t={serialize:t});const r=t&&t.serialize;let i;if(r?i=r(o,t):i=G.isURLSearchParams(o)?o.toString():new qr(o,t).toString(a),i){const s=n.indexOf("#");s!==-1&&(n=n.slice(0,s)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Ps{constructor(){this.handlers=[]}use(o,t,a){return this.handlers.push({fulfilled:o,rejected:t,synchronous:a?a.synchronous:!1,runWhen:a?a.runWhen:null}),this.handlers.length-1}eject(o){this.handlers[o]&&(this.handlers[o]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(o){G.forEach(this.handlers,function(a){a!==null&&o(a)})}}const rc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cy=typeof URLSearchParams<"u"?URLSearchParams:qr,dy=typeof FormData<"u"?FormData:null,uy=typeof Blob<"u"?Blob:null,my={isBrowser:!0,classes:{URLSearchParams:cy,FormData:dy,Blob:uy},protocols:["http","https","file","blob","url","data"]},Kr=typeof window<"u"&&typeof document<"u",Nr=typeof navigator=="object"&&navigator||void 0,py=Kr&&(!Nr||["ReactNative","NativeScript","NS"].indexOf(Nr.product)<0),fy=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",hy=Kr&&window.location.href||"http://localhost",vy=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Kr,hasStandardBrowserEnv:py,hasStandardBrowserWebWorkerEnv:fy,navigator:Nr,origin:hy},Symbol.toStringTag,{value:"Module"})),lt={...vy,...my};function gy(n,o){return Ba(n,new lt.classes.URLSearchParams,{visitor:function(t,a,r,i){return lt.isNode&&G.isBuffer(t)?(this.append(a,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...o})}function yy(n){return G.matchAll(/\w+|\[(\w*)]/g,n).map(o=>o[0]==="[]"?"":o[1]||o[0])}function by(n){const o={},t=Object.keys(n);let a;const r=t.length;let i;for(a=0;a<r;a++)i=t[a],o[i]=n[i];return o}function ic(n){function o(t,a,r,i){let s=t[i++];if(s==="__proto__")return!0;const l=Number.isFinite(+s),c=i>=t.length;return s=!s&&G.isArray(r)?r.length:s,c?(G.hasOwnProp(r,s)?r[s]=[r[s],a]:r[s]=a,!l):((!r[s]||!G.isObject(r[s]))&&(r[s]=[]),o(t,a,r[s],i)&&G.isArray(r[s])&&(r[s]=by(r[s])),!l)}if(G.isFormData(n)&&G.isFunction(n.entries)){const t={};return G.forEachEntry(n,(a,r)=>{o(yy(a),r,t,0)}),t}return null}function wy(n,o,t){if(G.isString(n))try{return(o||JSON.parse)(n),G.trim(n)}catch(a){if(a.name!=="SyntaxError")throw a}return(t||JSON.stringify)(n)}const xo={transitional:rc,adapter:["xhr","http","fetch"],transformRequest:[function(o,t){const a=t.getContentType()||"",r=a.indexOf("application/json")>-1,i=G.isObject(o);if(i&&G.isHTMLForm(o)&&(o=new FormData(o)),G.isFormData(o))return r?JSON.stringify(ic(o)):o;if(G.isArrayBuffer(o)||G.isBuffer(o)||G.isStream(o)||G.isFile(o)||G.isBlob(o)||G.isReadableStream(o))return o;if(G.isArrayBufferView(o))return o.buffer;if(G.isURLSearchParams(o))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),o.toString();let l;if(i){if(a.indexOf("application/x-www-form-urlencoded")>-1)return gy(o,this.formSerializer).toString();if((l=G.isFileList(o))||a.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Ba(l?{"files[]":o}:o,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),wy(o)):o}],transformResponse:[function(o){const t=this.transitional||xo.transitional,a=t&&t.forcedJSONParsing,r=this.responseType==="json";if(G.isResponse(o)||G.isReadableStream(o))return o;if(o&&G.isString(o)&&(a&&!this.responseType||r)){const s=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(o)}catch(l){if(s)throw l.name==="SyntaxError"?Me.from(l,Me.ERR_BAD_RESPONSE,this,null,this.response):l}}return o}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:lt.classes.FormData,Blob:lt.classes.Blob},validateStatus:function(o){return o>=200&&o<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],n=>{xo.headers[n]={}});const ky=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),xy=n=>{const o={};let t,a,r;return n&&n.split(`
|
|
71
|
-
`).forEach(function(s){r=s.indexOf(":"),t=s.substring(0,r).trim().toLowerCase(),a=s.substring(r+1).trim(),!(!t||o[t]&&ky[t])&&(t==="set-cookie"?o[t]?o[t].push(a):o[t]=[a]:o[t]=o[t]?o[t]+", "+a:a)}),o},$s=Symbol("internals");function Dn(n){return n&&String(n).trim().toLowerCase()}function Go(n){return n===!1||n==null?n:G.isArray(n)?n.map(Go):String(n)}function Sy(n){const o=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let a;for(;a=t.exec(n);)o[a[1]]=a[2];return o}const Ey=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function sr(n,o,t,a,r){if(G.isFunction(a))return a.call(this,o,t);if(r&&(o=t),!!G.isString(o)){if(G.isString(a))return o.indexOf(a)!==-1;if(G.isRegExp(a))return a.test(o)}}function Cy(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(o,t,a)=>t.toUpperCase()+a)}function Vy(n,o){const t=G.toCamelCase(" "+o);["get","set","has"].forEach(a=>{Object.defineProperty(n,a+t,{value:function(r,i,s){return this[a].call(this,o,r,i,s)},configurable:!0})})}let pt=class{constructor(o){o&&this.set(o)}set(o,t,a){const r=this;function i(l,c,d){const u=Dn(c);if(!u)throw new Error("header name must be a non-empty string");const p=G.findKey(r,u);(!p||r[p]===void 0||d===!0||d===void 0&&r[p]!==!1)&&(r[p||c]=Go(l))}const s=(l,c)=>G.forEach(l,(d,u)=>i(d,u,c));if(G.isPlainObject(o)||o instanceof this.constructor)s(o,t);else if(G.isString(o)&&(o=o.trim())&&!Ey(o))s(xy(o),t);else if(G.isObject(o)&&G.isIterable(o)){let l={},c,d;for(const u of o){if(!G.isArray(u))throw TypeError("Object iterator must return a key-value pair");l[d=u[0]]=(c=l[d])?G.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}s(l,t)}else o!=null&&i(t,o,a);return this}get(o,t){if(o=Dn(o),o){const a=G.findKey(this,o);if(a){const r=this[a];if(!t)return r;if(t===!0)return Sy(r);if(G.isFunction(t))return t.call(this,r,a);if(G.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(o,t){if(o=Dn(o),o){const a=G.findKey(this,o);return!!(a&&this[a]!==void 0&&(!t||sr(this,this[a],a,t)))}return!1}delete(o,t){const a=this;let r=!1;function i(s){if(s=Dn(s),s){const l=G.findKey(a,s);l&&(!t||sr(a,a[l],l,t))&&(delete a[l],r=!0)}}return G.isArray(o)?o.forEach(i):i(o),r}clear(o){const t=Object.keys(this);let a=t.length,r=!1;for(;a--;){const i=t[a];(!o||sr(this,this[i],i,o,!0))&&(delete this[i],r=!0)}return r}normalize(o){const t=this,a={};return G.forEach(this,(r,i)=>{const s=G.findKey(a,i);if(s){t[s]=Go(r),delete t[i];return}const l=o?Cy(i):String(i).trim();l!==i&&delete t[i],t[l]=Go(r),a[l]=!0}),this}concat(...o){return this.constructor.concat(this,...o)}toJSON(o){const t=Object.create(null);return G.forEach(this,(a,r)=>{a!=null&&a!==!1&&(t[r]=o&&G.isArray(a)?a.join(", "):a)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([o,t])=>o+": "+t).join(`
|
|
72
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(o){return o instanceof this?o:new this(o)}static concat(o,...t){const a=new this(o);return t.forEach(r=>a.set(r)),a}static accessor(o){const a=(this[$s]=this[$s]={accessors:{}}).accessors,r=this.prototype;function i(s){const l=Dn(s);a[l]||(Vy(r,s),a[l]=!0)}return G.isArray(o)?o.forEach(i):i(o),this}};pt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);G.reduceDescriptors(pt.prototype,({value:n},o)=>{let t=o[0].toUpperCase()+o.slice(1);return{get:()=>n,set(a){this[t]=a}}});G.freezeMethods(pt);function lr(n,o){const t=this||xo,a=o||t,r=pt.from(a.headers);let i=a.data;return G.forEach(n,function(l){i=l.call(t,i,r.normalize(),o?o.status:void 0)}),r.normalize(),i}function sc(n){return!!(n&&n.__CANCEL__)}function Bn(n,o,t){Me.call(this,n??"canceled",Me.ERR_CANCELED,o,t),this.name="CanceledError"}G.inherits(Bn,Me,{__CANCEL__:!0});function lc(n,o,t){const a=t.config.validateStatus;!t.status||!a||a(t.status)?n(t):o(new Me("Request failed with status code "+t.status,[Me.ERR_BAD_REQUEST,Me.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Ny(n){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return o&&o[1]||""}function _y(n,o){n=n||10;const t=new Array(n),a=new Array(n);let r=0,i=0,s;return o=o!==void 0?o:1e3,function(c){const d=Date.now(),u=a[i];s||(s=d),t[r]=c,a[r]=d;let p=i,m=0;for(;p!==r;)m+=t[p++],p=p%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),d-s<o)return;const h=u&&d-u;return h?Math.round(m*1e3/h):void 0}}function Ty(n,o){let t=0,a=1e3/o,r,i;const s=(d,u=Date.now())=>{t=u,r=null,i&&(clearTimeout(i),i=null),n(...d)};return[(...d)=>{const u=Date.now(),p=u-t;p>=a?s(d,u):(r=d,i||(i=setTimeout(()=>{i=null,s(r)},a-p)))},()=>r&&s(r)]}const ca=(n,o,t=3)=>{let a=0;const r=_y(50,250);return Ty(i=>{const s=i.loaded,l=i.lengthComputable?i.total:void 0,c=s-a,d=r(c),u=s<=l;a=s;const p={loaded:s,total:l,progress:l?s/l:void 0,bytes:c,rate:d||void 0,estimated:d&&l&&u?(l-s)/d:void 0,event:i,lengthComputable:l!=null,[o?"download":"upload"]:!0};n(p)},t)},zs=(n,o)=>{const t=n!=null;return[a=>o[0]({lengthComputable:t,total:n,loaded:a}),o[1]]},As=n=>(...o)=>G.asap(()=>n(...o)),My=lt.hasStandardBrowserEnv?((n,o)=>t=>(t=new URL(t,lt.origin),n.protocol===t.protocol&&n.host===t.host&&(o||n.port===t.port)))(new URL(lt.origin),lt.navigator&&/(msie|trident)/i.test(lt.navigator.userAgent)):()=>!0,Fy=lt.hasStandardBrowserEnv?{write(n,o,t,a,r,i){const s=[n+"="+encodeURIComponent(o)];G.isNumber(t)&&s.push("expires="+new Date(t).toGMTString()),G.isString(a)&&s.push("path="+a),G.isString(r)&&s.push("domain="+r),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read(n){const o=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Iy(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function By(n,o){return o?n.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):n}function cc(n,o,t){let a=!Iy(o);return n&&(a||t==!1)?By(n,o):o}const Ds=n=>n instanceof pt?{...n}:n;function dn(n,o){o=o||{};const t={};function a(d,u,p,m){return G.isPlainObject(d)&&G.isPlainObject(u)?G.merge.call({caseless:m},d,u):G.isPlainObject(u)?G.merge({},u):G.isArray(u)?u.slice():u}function r(d,u,p,m){if(G.isUndefined(u)){if(!G.isUndefined(d))return a(void 0,d,p,m)}else return a(d,u,p,m)}function i(d,u){if(!G.isUndefined(u))return a(void 0,u)}function s(d,u){if(G.isUndefined(u)){if(!G.isUndefined(d))return a(void 0,d)}else return a(void 0,u)}function l(d,u,p){if(p in o)return a(d,u);if(p in n)return a(void 0,d)}const c={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(d,u,p)=>r(Ds(d),Ds(u),p,!0)};return G.forEach(Object.keys({...n,...o}),function(u){const p=c[u]||r,m=p(n[u],o[u],u);G.isUndefined(m)&&p!==l||(t[u]=m)}),t}const dc=n=>{const o=dn({},n);let{data:t,withXSRFToken:a,xsrfHeaderName:r,xsrfCookieName:i,headers:s,auth:l}=o;o.headers=s=pt.from(s),o.url=ac(cc(o.baseURL,o.url,o.allowAbsoluteUrls),n.params,n.paramsSerializer),l&&s.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let c;if(G.isFormData(t)){if(lt.hasStandardBrowserEnv||lt.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[d,...u]=c?c.split(";").map(p=>p.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(lt.hasStandardBrowserEnv&&(a&&G.isFunction(a)&&(a=a(o)),a||a!==!1&&My(o.url))){const d=r&&i&&Fy.read(i);d&&s.set(r,d)}return o},Ry=typeof XMLHttpRequest<"u",Py=Ry&&function(n){return new Promise(function(t,a){const r=dc(n);let i=r.data;const s=pt.from(r.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=r,u,p,m,h,g;function v(){h&&h(),g&&g(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(r.method.toUpperCase(),r.url,!0),x.timeout=r.timeout;function B(){if(!x)return;const y=pt.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),w={data:!l||l==="text"||l==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:y,config:n,request:x};lc(function(C){t(C),v()},function(C){a(C),v()},w),x=null}"onloadend"in x?x.onloadend=B:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(B)},x.onabort=function(){x&&(a(new Me("Request aborted",Me.ECONNABORTED,n,x)),x=null)},x.onerror=function(){a(new Me("Network Error",Me.ERR_NETWORK,n,x)),x=null},x.ontimeout=function(){let f=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const w=r.transitional||rc;r.timeoutErrorMessage&&(f=r.timeoutErrorMessage),a(new Me(f,w.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,n,x)),x=null},i===void 0&&s.setContentType(null),"setRequestHeader"in x&&G.forEach(s.toJSON(),function(f,w){x.setRequestHeader(w,f)}),G.isUndefined(r.withCredentials)||(x.withCredentials=!!r.withCredentials),l&&l!=="json"&&(x.responseType=r.responseType),d&&([m,g]=ca(d,!0),x.addEventListener("progress",m)),c&&x.upload&&([p,h]=ca(c),x.upload.addEventListener("progress",p),x.upload.addEventListener("loadend",h)),(r.cancelToken||r.signal)&&(u=y=>{x&&(a(!y||y.type?new Bn(null,n,x):y),x.abort(),x=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const E=Ny(r.url);if(E&<.protocols.indexOf(E)===-1){a(new Me("Unsupported protocol "+E+":",Me.ERR_BAD_REQUEST,n));return}x.send(i||null)})},$y=(n,o)=>{const{length:t}=n=n?n.filter(Boolean):[];if(o||t){let a=new AbortController,r;const i=function(d){if(!r){r=!0,l();const u=d instanceof Error?d:this.reason;a.abort(u instanceof Me?u:new Bn(u instanceof Error?u.message:u))}};let s=o&&setTimeout(()=>{s=null,i(new Me(`timeout ${o} of ms exceeded`,Me.ETIMEDOUT))},o);const l=()=>{n&&(s&&clearTimeout(s),s=null,n.forEach(d=>{d.unsubscribe?d.unsubscribe(i):d.removeEventListener("abort",i)}),n=null)};n.forEach(d=>d.addEventListener("abort",i));const{signal:c}=a;return c.unsubscribe=()=>G.asap(l),c}},zy=function*(n,o){let t=n.byteLength;if(t<o){yield n;return}let a=0,r;for(;a<t;)r=a+o,yield n.slice(a,r),a=r},Ay=async function*(n,o){for await(const t of Dy(n))yield*zy(t,o)},Dy=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const o=n.getReader();try{for(;;){const{done:t,value:a}=await o.read();if(t)break;yield a}}finally{await o.cancel()}},Us=(n,o,t,a)=>{const r=Ay(n,o);let i=0,s,l=c=>{s||(s=!0,a&&a(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await r.next();if(d){l(),c.close();return}let p=u.byteLength;if(t){let m=i+=p;t(m)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),r.return()}},{highWaterMark:2})},Ra=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",uc=Ra&&typeof ReadableStream=="function",Uy=Ra&&(typeof TextEncoder=="function"?(n=>o=>n.encode(o))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),mc=(n,...o)=>{try{return!!n(...o)}catch{return!1}},Oy=uc&&mc(()=>{let n=!1;const o=new Request(lt.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!o}),Os=64*1024,_r=uc&&mc(()=>G.isReadableStream(new Response("").body)),da={stream:_r&&(n=>n.body)};Ra&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(o=>{!da[o]&&(da[o]=G.isFunction(n[o])?t=>t[o]():(t,a)=>{throw new Me(`Response type '${o}' is not supported`,Me.ERR_NOT_SUPPORT,a)})})})(new Response);const Ly=async n=>{if(n==null)return 0;if(G.isBlob(n))return n.size;if(G.isSpecCompliantForm(n))return(await new Request(lt.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(G.isArrayBufferView(n)||G.isArrayBuffer(n))return n.byteLength;if(G.isURLSearchParams(n)&&(n=n+""),G.isString(n))return(await Uy(n)).byteLength},Wy=async(n,o)=>{const t=G.toFiniteNumber(n.getContentLength());return t??Ly(o)},jy=Ra&&(async n=>{let{url:o,method:t,data:a,signal:r,cancelToken:i,timeout:s,onDownloadProgress:l,onUploadProgress:c,responseType:d,headers:u,withCredentials:p="same-origin",fetchOptions:m}=dc(n);d=d?(d+"").toLowerCase():"text";let h=$y([r,i&&i.toAbortSignal()],s),g;const v=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let x;try{if(c&&Oy&&t!=="get"&&t!=="head"&&(x=await Wy(u,a))!==0){let w=new Request(o,{method:"POST",body:a,duplex:"half"}),$;if(G.isFormData(a)&&($=w.headers.get("content-type"))&&u.setContentType($),w.body){const[C,b]=zs(x,ca(As(c)));a=Us(w.body,Os,C,b)}}G.isString(p)||(p=p?"include":"omit");const B="credentials"in Request.prototype;g=new Request(o,{...m,signal:h,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:B?p:void 0});let E=await fetch(g,m);const y=_r&&(d==="stream"||d==="response");if(_r&&(l||y&&v)){const w={};["status","statusText","headers"].forEach(N=>{w[N]=E[N]});const $=G.toFiniteNumber(E.headers.get("content-length")),[C,b]=l&&zs($,ca(As(l),!0))||[];E=new Response(Us(E.body,Os,C,()=>{b&&b(),v&&v()}),w)}d=d||"text";let f=await da[G.findKey(da,d)||"text"](E,n);return!y&&v&&v(),await new Promise((w,$)=>{lc(w,$,{data:f,headers:pt.from(E.headers),status:E.status,statusText:E.statusText,config:n,request:g})})}catch(B){throw v&&v(),B&&B.name==="TypeError"&&/Load failed|fetch/i.test(B.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,n,g),{cause:B.cause||B}):Me.from(B,B&&B.code,n,g)}}),Tr={http:ry,xhr:Py,fetch:jy};G.forEach(Tr,(n,o)=>{if(n){try{Object.defineProperty(n,"name",{value:o})}catch{}Object.defineProperty(n,"adapterName",{value:o})}});const Ls=n=>`- ${n}`,Xy=n=>G.isFunction(n)||n===null||n===!1,pc={getAdapter:n=>{n=G.isArray(n)?n:[n];const{length:o}=n;let t,a;const r={};for(let i=0;i<o;i++){t=n[i];let s;if(a=t,!Xy(t)&&(a=Tr[(s=String(t)).toLowerCase()],a===void 0))throw new Me(`Unknown adapter '${s}'`);if(a)break;r[s||"#"+i]=a}if(!a){const i=Object.entries(r).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=o?i.length>1?`since :
|
|
73
|
-
`+i.map(Ls).join(`
|
|
74
|
-
`):" "+Ls(i[0]):"as no adapter specified";throw new Me("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return a},adapters:Tr};function cr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Bn(null,n)}function Ws(n){return cr(n),n.headers=pt.from(n.headers),n.data=lr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),pc.getAdapter(n.adapter||xo.adapter)(n).then(function(a){return cr(n),a.data=lr.call(n,n.transformResponse,a),a.headers=pt.from(a.headers),a},function(a){return sc(a)||(cr(n),a&&a.response&&(a.response.data=lr.call(n,n.transformResponse,a.response),a.response.headers=pt.from(a.response.headers))),Promise.reject(a)})}const fc="1.11.0",Pa={};["object","boolean","number","function","string","symbol"].forEach((n,o)=>{Pa[n]=function(a){return typeof a===n||"a"+(o<1?"n ":" ")+n}});const js={};Pa.transitional=function(o,t,a){function r(i,s){return"[Axios v"+fc+"] Transitional option '"+i+"'"+s+(a?". "+a:"")}return(i,s,l)=>{if(o===!1)throw new Me(r(s," has been removed"+(t?" in "+t:"")),Me.ERR_DEPRECATED);return t&&!js[s]&&(js[s]=!0),o?o(i,s,l):!0}};Pa.spelling=function(o){return(t,a)=>!0};function Zy(n,o,t){if(typeof n!="object")throw new Me("options must be an object",Me.ERR_BAD_OPTION_VALUE);const a=Object.keys(n);let r=a.length;for(;r-- >0;){const i=a[r],s=o[i];if(s){const l=n[i],c=l===void 0||s(l,i,n);if(c!==!0)throw new Me("option "+i+" must be "+c,Me.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Me("Unknown option "+i,Me.ERR_BAD_OPTION)}}const Ho={assertOptions:Zy,validators:Pa},Ft=Ho.validators;let ln=class{constructor(o){this.defaults=o||{},this.interceptors={request:new Ps,response:new Ps}}async request(o,t){try{return await this._request(o,t)}catch(a){if(a instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const i=r.stack?r.stack.replace(/^.+\n/,""):"";try{a.stack?i&&!String(a.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(a.stack+=`
|
|
75
|
-
`+i):a.stack=i}catch{}}throw a}}_request(o,t){typeof o=="string"?(t=t||{},t.url=o):t=o||{},t=dn(this.defaults,t);const{transitional:a,paramsSerializer:r,headers:i}=t;a!==void 0&&Ho.assertOptions(a,{silentJSONParsing:Ft.transitional(Ft.boolean),forcedJSONParsing:Ft.transitional(Ft.boolean),clarifyTimeoutError:Ft.transitional(Ft.boolean)},!1),r!=null&&(G.isFunction(r)?t.paramsSerializer={serialize:r}:Ho.assertOptions(r,{encode:Ft.function,serialize:Ft.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Ho.assertOptions(t,{baseUrl:Ft.spelling("baseURL"),withXsrfToken:Ft.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=i&&G.merge(i.common,i[t.method]);i&&G.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),t.headers=pt.concat(s,i);const l=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(c=c&&v.synchronous,l.unshift(v.fulfilled,v.rejected))});const d=[];this.interceptors.response.forEach(function(v){d.push(v.fulfilled,v.rejected)});let u,p=0,m;if(!c){const g=[Ws.bind(this),void 0];for(g.unshift(...l),g.push(...d),m=g.length,u=Promise.resolve(t);p<m;)u=u.then(g[p++],g[p++]);return u}m=l.length;let h=t;for(p=0;p<m;){const g=l[p++],v=l[p++];try{h=g(h)}catch(x){v.call(this,x);break}}try{u=Ws.call(this,h)}catch(g){return Promise.reject(g)}for(p=0,m=d.length;p<m;)u=u.then(d[p++],d[p++]);return u}getUri(o){o=dn(this.defaults,o);const t=cc(o.baseURL,o.url,o.allowAbsoluteUrls);return ac(t,o.params,o.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(o){ln.prototype[o]=function(t,a){return this.request(dn(a||{},{method:o,url:t,data:(a||{}).data}))}});G.forEach(["post","put","patch"],function(o){function t(a){return function(i,s,l){return this.request(dn(l||{},{method:o,headers:a?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}ln.prototype[o]=t(),ln.prototype[o+"Form"]=t(!0)});let Yy=class hc{constructor(o){if(typeof o!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const a=this;this.promise.then(r=>{if(!a._listeners)return;let i=a._listeners.length;for(;i-- >0;)a._listeners[i](r);a._listeners=null}),this.promise.then=r=>{let i;const s=new Promise(l=>{a.subscribe(l),i=l}).then(r);return s.cancel=function(){a.unsubscribe(i)},s},o(function(i,s,l){a.reason||(a.reason=new Bn(i,s,l),t(a.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(o){if(this.reason){o(this.reason);return}this._listeners?this._listeners.push(o):this._listeners=[o]}unsubscribe(o){if(!this._listeners)return;const t=this._listeners.indexOf(o);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const o=new AbortController,t=a=>{o.abort(a)};return this.subscribe(t),o.signal.unsubscribe=()=>this.unsubscribe(t),o.signal}static source(){let o;return{token:new hc(function(r){o=r}),cancel:o}}};function Gy(n){return function(t){return n.apply(null,t)}}function Hy(n){return G.isObject(n)&&n.isAxiosError===!0}const Mr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Mr).forEach(([n,o])=>{Mr[o]=n});function vc(n){const o=new ln(n),t=Zl(ln.prototype.request,o);return G.extend(t,ln.prototype,o,{allOwnKeys:!0}),G.extend(t,o,null,{allOwnKeys:!0}),t.create=function(r){return vc(dn(n,r))},t}const Xe=vc(xo);Xe.Axios=ln;Xe.CanceledError=Bn;Xe.CancelToken=Yy;Xe.isCancel=sc;Xe.VERSION=fc;Xe.toFormData=Ba;Xe.AxiosError=Me;Xe.Cancel=Xe.CanceledError;Xe.all=function(o){return Promise.all(o)};Xe.spread=Gy;Xe.isAxiosError=Hy;Xe.mergeConfig=dn;Xe.AxiosHeaders=pt;Xe.formToJSON=n=>ic(G.isHTMLForm(n)?new FormData(n):n);Xe.getAdapter=pc.getAdapter;Xe.HttpStatusCode=Mr;Xe.default=Xe;const{Axios:d4,AxiosError:u4,CanceledError:m4,isCancel:p4,CancelToken:f4,VERSION:h4,all:v4,Cancel:g4,isAxiosError:y4,spread:b4,toFormData:w4,AxiosHeaders:k4,HttpStatusCode:x4,formToJSON:S4,getAdapter:E4,mergeConfig:C4}=Xe;class Qr{constructor(o="/api/v1"){this.eventSource=null,this.progressCallbacks=new Map,this.api=Xe.create({baseURL:o,headers:{"Content-Type":"application/json",Accept:"application/json"}}),this.api.interceptors.request.use(t=>{const a=this.getAuthToken();return a&&(t.headers.Authorization=`Bearer ${a}`),t}),this.api.interceptors.response.use(t=>t,t=>{var a;return(a=t.response)==null||a.status,Promise.reject(t)})}async createJob(o){try{return(await this.api.post("/video/jobs",o)).data.data}catch(t){throw t}}async createRenderJob(o){try{return(await this.api.post("/video/jobs/render",o)).data.data}catch(t){throw t}}async pollRenderJob(o,t,a=3e3,r=6e5){const i=Date.now();return new Promise((s,l)=>{const c=setInterval(async()=>{try{const d=await this.getJob(o);t==null||t(d.progress,d.status),d.status==="completed"?(clearInterval(c),s(d)):d.status==="failed"?(clearInterval(c),l(new Error(d.errorMessage??"Render job failed"))):Date.now()-i>r&&(clearInterval(c),l(new Error("Render job timed out")))}catch(d){clearInterval(c),l(d)}},a)})}async getJob(o){try{return(await this.api.get(`/video/jobs/${o}`)).data.data}catch(t){throw t}}async listJobs(o){try{return(await this.api.get("/video/jobs",{params:o})).data}catch(t){throw t}}async cancelJob(o){try{await this.api.delete(`/video/jobs/${o}`),this.unsubscribeFromProgress(o)}catch(t){throw t}}async retryJob(o){try{return(await this.api.post(`/video/jobs/${o}/retry`)).data.data}catch(t){throw t}}subscribeToProgress(o,t){this.progressCallbacks.set(o,t),this.eventSource||this.initializeEventSource(),this.eventSource||this.pollProgress(o)}unsubscribeFromProgress(o){this.progressCallbacks.delete(o),this.progressCallbacks.size===0&&this.eventSource&&(this.eventSource.close(),this.eventSource=null)}initializeEventSource(){try{const o=this.getAuthToken(),t=`/api/v1/video/jobs/events${o?`?token=${o}`:""}`;this.eventSource=new EventSource(t),this.eventSource.addEventListener("progress",a=>{const r=JSON.parse(a.data),i=this.progressCallbacks.get(r.jobId);i&&i(r.progress)}),this.eventSource.addEventListener("complete",a=>{const r=JSON.parse(a.data),i=this.progressCallbacks.get(r.jobId);i&&(i(100),this.unsubscribeFromProgress(r.jobId))}),this.eventSource.addEventListener("error",a=>{this.progressCallbacks.forEach((r,i)=>{this.pollProgress(i)})})}catch{}}async pollProgress(o){const t=setInterval(async()=>{try{const a=await this.getJob(o),r=this.progressCallbacks.get(o);r&&r(a.progress),(a.status==="completed"||a.status==="failed")&&(clearInterval(t),this.unsubscribeFromProgress(o))}catch{clearInterval(t)}},2e3)}getAuthToken(){const o=localStorage.getItem("auth_token");if(o)return o;const t=document.cookie.split(";");for(const a of t){const[r,i]=a.trim().split("=");if(r==="auth_token")return decodeURIComponent(i)}return null}async downloadVideo(o){try{return(await this.api.get(`/video/jobs/${o}/download`,{responseType:"blob"})).data}catch(t){throw t}}async getThumbnail(o,t=0){try{const a=await this.api.get(`/video/jobs/${o}/thumbnail`,{params:{time:t},responseType:"blob"});return URL.createObjectURL(a.data)}catch(a){throw a}}}new Qr;const Jy={key:0,class:"mobile-layout"},qy={class:"preview-section"},Ky={class:"timeline-section"},Qy={class:"controls-section"},eb={class:"tab-nav"},tb=["onClick"],nb={class:"tab-content"},ob={class:"filters-panel"},ab={class:"adjustments-panel"},rb={class:"text-panel"},ib={class:"transitions-panel"},sb={class:"audio-panel"},lb={class:"export-panel"},cb={key:0,"data-testid":"video-export-status-completed"},db={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},ub={key:1,class:"desktop-layout"},mb={class:"desktop-main-row"},pb={class:"preview-panel"},fb={class:"fit-toggle"},hb={class:"editor-content"},vb={class:"editor-tabs"},gb={class:"tab-header"},yb=["onClick"],bb={class:"tab-content-area"},wb={class:"filter-controls"},kb={class:"text-controls"},xb={class:"transition-controls"},Sb={class:"audio-controls"},Eb={class:"adjustments-controls"},Cb={key:1,class:"no-filter-selected"},Vb={class:"export-controls"},Nb={key:0,"data-testid":"video-export-status-completed"},_b={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Tb={class:"desktop-timeline-row"},Mb={class:"timeline-container"},Fb={class:"timeline-zoom"},Ib=["value"],Bb={class:"zoom-readout"},Rb={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Pb={class:"dev-editor-row"},$b={class:"dev-editor-field"},zb={class:"dev-editor-field"},Ab=["disabled"],Db=["disabled"],Ub=["disabled"],Ob={class:"dev-editor-row"},Lb={class:"dev-editor-field dev-editor-field--wide"},Wb=["value"],jb=["disabled"],Xb=["disabled"],Zb=["disabled"],Yb=["disabled"],Gb=e.defineComponent({__name:"VideoEditor",props:{mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},workflowMode:{default:"full"},featureFlags:{},clientExportThreshold:{default:20},maxDuration:{default:300},serverRenderEndpoint:{default:void 0}},emits:["recipe-generated","export-started","draft-saved","video-exported","thumbnail-selected","server-render-started","server-render-progress","server-render-completed","server-render-failed"],setup(n,{expose:o,emit:t}){const a=n,r=t,i=e.computed(()=>{if(!a.media||typeof a.media!="object")return;const S=a.media.uuid??a.media.id;return typeof S=="string"&&S.trim()!==""?S.trim():void 0}),s=e.computed(()=>{const S=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return S!==""?S:i.value??`temp-${Date.now()}`}),l=e.ref(typeof window<"u"?window.innerWidth<768:!1),c=e.ref("filters"),d=e.ref("filters"),u=e.computed(()=>{const S=a.workflowMode==="uploader"?{filters:!0,adjustments:!0,text:!1,transitions:!1,audio:!1,export:!1}:{filters:!0,adjustments:!0,text:!0,transitions:!0,audio:!0,export:!0},V=a.featureFlags;return V?{filters:typeof V.filters=="boolean"?V.filters:S.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:S.adjustments,text:typeof V.text=="boolean"?V.text:S.text,transitions:typeof V.transitions=="boolean"?V.transitions:S.transitions,audio:typeof V.audio=="boolean"?V.audio:S.audio,export:typeof V.export=="boolean"?V.export:S.export}:S}),p=e.computed(()=>l.value?c.value:d.value),m=e.computed(()=>p.value==="filters"||x.value),h=e.computed(()=>p.value!=="filters"&&!x.value),g=e.ref(null),v=e.ref(null),x=e.ref(!1),B=e.computed(()=>l.value?g.value:v.value),E=e.shallowRef(null),y=e.ref(null),f=e.ref("cover"),w=e.ref(null),$=e.ref(null),C=e.ref(null),b=e.ref(!1),N=new Map,P=e.ref([]),k=e.ref([]),T=e.ref([]),F=e.ref([]),D=e.ref(1),R=()=>{l.value=window.innerWidth<768},W=[{id:"filters",label:"Filters",icon:Ht},{id:"adjustments",label:"Adjust",icon:$u},{id:"text",label:"Text",icon:"text-outline"},{id:"transitions",label:"Transitions",icon:"swap-horizontal-outline"},{id:"audio",label:"Audio",icon:"musical-notes-outline"},{id:"export",label:"Export",icon:pa}],L=[{id:"filters",label:"Filters"},{id:"adjustments",label:"Adjustments"},{id:"text",label:"Text"},{id:"transitions",label:"Transitions"},{id:"audio",label:"Audio"},{id:"export",label:"Export"}],_=e.computed(()=>W.filter(S=>u.value[S.id])),A=e.computed(()=>L.filter(S=>u.value[S.id])),Z=e.computed(()=>{var S,V;return((S=A.value[0])==null?void 0:S.id)??((V=_.value[0])==null?void 0:V.id)??"filters"});e.watch(u,S=>{S[c.value]||(c.value=Z.value),S[d.value]||(d.value=Z.value)},{immediate:!0,deep:!0}),e.watch(Z,S=>{u.value[c.value]||(c.value=S),u.value[d.value]||(d.value=S)},{immediate:!0}),e.watch(u,S=>{S.export||(c.value==="export"&&(c.value=Z.value),d.value==="export"&&(d.value=Z.value))},{immediate:!0,deep:!0});const H=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:me,playheadPosition:Te,timelineClips:Be,totalDuration:ie,hasChanges:M,isPlaying:j,selectedClip:te,zoomLevel:ae,playbackSpeed:re,handleTrim:q,handleSplit:ue,handleClipSelect:ve,splitAtPlayhead:we,deleteSelectedClip:oe,duplicateSelectedClip:ye,setZoomLevel:fe,moveClip:Ze,setFilters:Ke,setTextOverlays:pe,setAudioTracks:ke,saveDraft:U,clearHasChanges:ne,resetChanges:K,generateRecipe:ee,zoomIn:be,zoomOut:Y,fitToWindow:se,togglePlayback:xe,setPlaying:Ce,seekTo:Ue,frameForward:Ye,frameBackward:nt,skipToStart:At,skipToEnd:ut,setPlaybackSpeed:fn}=s1(s.value,a.initialRecipe,a.media),{videoCompatibleFilters:Da,activeFilters:Je,selectedFilter:So,previewFilter:Eo,previewFilterEffect:Mc,applyFilter:li,updateFilterParams:Fc,removeFilter:Ic,clearAllFilters:ci,setActiveFilters:Bc}=g1();function Rn(S){var X,J;const V=((X=te.value)==null?void 0:X.id)??((J=Be.value[0])==null?void 0:J.id);V&&(b.value=!0,typeof S=="object"&&S.id?li(S.id):typeof S=="string"&&li(S),Ke(Je.value),E.value?E.value.setClipFilters(V,Je.value):N.set(V,[...Je.value]),ve(V),b.value=!1,Nt())}function Rc(){var V,X;const S=((V=te.value)==null?void 0:V.id)??((X=Be.value[0])==null?void 0:X.id);S&&ve(S)}function di(S){const V=Je.value.find(X=>X.filterId===S);V&&Ic(V.id)}const Co=e.computed(()=>Da.value.map(V=>{var J;const X=[];if(V.controls&&V.controls.length>0)for(const le of V.controls)le.type==="slider"&&X.push({id:le.property||le.id,label:le.label||le.id,min:le.min??0,max:le.max??1,step:le.step??.01,default:typeof le.default=="number"?le.default:1});else if(V.paramRanges){const le=Object.entries(V.paramRanges);for(const[Q,ce]of le){const Re=Q.replace(/[-_]/g," ").replace(/\b\w/g,_t=>_t.toUpperCase()),ct=(J=V.defaultParams)==null?void 0:J[Q],Ut=(ce.min+ce.max)/2;X.push({id:Q,label:Re,min:ce.min,max:ce.max,step:ce.step??.01,default:typeof ct=="number"?ct:Ut})}}return{id:V.id,name:V.name,category:V.category,params:X}})),hn=e.ref("0.00"),vn=e.ref("0.00"),Xt=e.ref("");e.watch(Co,S=>{if(S.length===0){Xt.value="";return}S.some(X=>X.id===Xt.value)||(Xt.value=S[0].id)},{immediate:!0});const ot=e.ref(!1),We=e.ref(0),St=e.ref(!1),Oe=e.ref(null),Et=e.ref(null);let Vo=null,wt=!1,Dt=null;const ui=e.computed(()=>{const S=new Map;return Je.value.forEach(V=>S.set(V.filterId,V)),S}),mi=e.computed(()=>{var S,V;return me.value?me.value:((S=a.media)==null?void 0:S.thumbnail_url)||((V=a.media)==null?void 0:V.url)}),Vt=e.ref("");e.watch(()=>{var S,V;return{file:(S=a.media)==null?void 0:S.file,url:(V=a.media)==null?void 0:V.url}},(S,V,X)=>{var le,Q;const J=Vt.value;X(()=>{J&&J.startsWith("blob:")&&URL.revokeObjectURL(J)}),(le=a.media)!=null&&le.file?Vt.value=URL.createObjectURL(a.media.file):(Q=a.media)!=null&&Q.url?Vt.value=a.media.url:Vt.value=""},{immediate:!0}),e.onUnmounted(()=>{Vt.value&&Vt.value.startsWith("blob:")&&URL.revokeObjectURL(Vt.value)});const Ua=e.computed(()=>Vt.value),pi=e.computed(()=>{if(!a.media)return null;const{file:S,...V}=a.media;return{...V,url:Vt.value}}),fi=e.computed(()=>{var V;const S=(V=a.media)==null?void 0:V.url;return!!(S&&/^https?:/i.test(S))}),hi=e.computed(()=>Je.value),vi=e.computed(()=>Te.value),Pc=e.computed(()=>!!te.value&&Te.value>0),$c=e.computed(()=>!!te.value&&Be.value.length>1),Oa=e.ref(0),gn=e.computed(()=>{try{const S=ie.value??ie;return S&&typeof S=="number"&&S>0?S:Oa.value}catch{return Oa.value}});function yn(S){return Number.isFinite(S)?S.toFixed(2):"0.00"}function gi(S){const V=Number(S);return Number.isFinite(V)?V:null}function zc(S){S&&(hn.value=yn(S.sourceIn),vn.value=yn(S.sourceOut))}e.watch(()=>{var S,V,X;return[(S=te.value)==null?void 0:S.id,(V=te.value)==null?void 0:V.sourceIn,(X=te.value)==null?void 0:X.sourceOut]},()=>{zc(te.value)},{immediate:!0});function yi(S){const V=te.value;if(!V)return;const X=1/30,J=V.sourceMinIn??0,le=V.sourceMaxOut??gn.value,Q=V.sourceIn+(Te.value-V.timelineStart);if(S==="start"){const Re=Math.max(J,Math.min(Q,V.sourceOut-X));hn.value=yn(Re);return}const ce=Math.max(V.sourceIn+X,Math.min(Q,le));vn.value=yn(ce)}function Ac(){const S=te.value;if(!S)return;const V=gi(hn.value),X=gi(vn.value);if(V===null||X===null)return;const J=1/30,le=S.sourceMinIn??0,Q=S.sourceMaxOut??gn.value,ce=Math.max(le,Math.min(V,Q-J)),Re=Math.max(ce+J,Math.min(X,Q));q(S.id,"start",ce),q(S.id,"end",Re),hn.value=yn(ce),vn.value=yn(Re),te.value&&Ue(te.value.timelineStart)}function Dc(){Xt.value.trim()!==""&&Rn(Xt.value)}function Uc(){var S;ci(),Ke(Je.value),(S=te.value)!=null&&S.id&&(E.value?E.value.setClipFilters(te.value.id,Je.value):N.set(te.value.id,[...Je.value])),Nt()}function bi(S,V,X){var le,Q;const J=Je.value.find(ce=>ce.filterId===S);J?(J.params={...J.params,[V]:X},Ke(Je.value),E.value&&((le=te.value)!=null&&le.id)?E.value.setClipFilters(te.value.id,Je.value):(Q=te.value)!=null&&Q.id&&N.set(te.value.id,[...Je.value]),Nt(),Rc()):Eo.value&&Eo.value.filterId===S&&(Eo.value.params={...Eo.value.params||{},[V]:X})}function wi(S){Ue(S)}function ki(S){Ce(S)}function No(S){Oa.value=S}function Oc(S){const V=S.target,X=Number(V.value);fe(X)}function xi(S){var V;E.value=S,(V=E.value)!=null&&V.composition&&(w.value=new y1(E.value.composition),$.value=new la(E.value.composition),C.value=new b1(E.value.composition));try{N.size&&(N.forEach((X,J)=>{E.value.setClipFilters(J,X)}),N.clear(),E.value.composition.computeFrame())}catch{}}function Si(S){S!=null&&S.id&&Mc(S.id)}function Ei(S){Fc(S),Nt()}async function Ci(S){if(!w.value)return;const V=await w.value.addTextOverlay(S);P.value.push({id:V,...S})}async function Vi(S,V){if(!w.value)return;await w.value.updateTextOverlay(S,V);const X=P.value.findIndex(J=>J.id===S);X!==-1&&(P.value[X]={...P.value[X],...V})}async function Ni(S){w.value&&(await w.value.removeTextOverlay(S),P.value=P.value.filter(V=>V.id!==S))}async function _i(S){if(!$.value||F.value.length<2)return;const[V,X]=F.value,J=await $.value.applyTransition(V,X,S);k.value.push({id:J,...S,name:S.type})}function Ti(S){if(!$.value)return;const V=k.value[S];V&&($.value.removeTransition(V.id),k.value.splice(S,1))}function Mi(S){}async function Fi(S){if(!C.value)return;const V=await C.value.addAudioTrack(S);T.value.push({id:V,...S})}async function Ii(S,V){if(!C.value)return;const X=T.value.findIndex(J=>J.id===S);X!==-1&&(T.value[X]={...T.value[X],...V})}async function Bi(S){C.value&&(await C.value.removeAudioTrack(S),T.value=T.value.filter(V=>V.id!==S))}async function Ri(S,V){if(!C.value)return;await C.value.updateVolume(S,V);const X=T.value.find(J=>J.id===S);X&&(X.volume=V)}async function Pi(S,V){if(!C.value)return;await C.value.muteTrack(S,V);const X=T.value.find(J=>J.id===S);X&&(X.muted=V)}function $i(S){C.value&&(C.value.setMasterVolume(S),D.value=S)}function Lc(S){r("thumbnail-selected",S)}function Zt(){Vo!==null&&(clearInterval(Vo),Vo=null)}function Wc(S,V){return V?{...S,output:{...S.output,format:V.format,quality:V.quality}}:S}function je(S,V,X){return Math.min(X,Math.max(V,S))}function La(S,V){if(typeof S=="number"&&Number.isFinite(S))return S;if(typeof S=="string"){const X=Number(S);if(Number.isFinite(X))return X}return V}function rt(S,V,X){for(const J of V)if(J in S)return La(S[J],X);return X}function jc(S){const V=typeof S.params=="object"&&S.params!==null?S.params:{};switch(S.filterId.trim().toLowerCase()){case"brightness":return[{type:"brightness",value:je(rt(V,["value","brightness"],0),-1,1)}];case"contrast":return[{type:"contrast",value:je(rt(V,["value","contrast"],1),.1,3)}];case"saturation":return[{type:"saturation",value:je(rt(V,["value","saturation"],1),0,3)}];case"blur":case"gaussian-blur":case"kawase-blur":case"radial-blur":return[{type:"blur",value:je(rt(V,["value","blur","radius"],0),0,25)}];case"sharpen":return[{type:"sharpen",value:je(rt(V,["value","amount"],1),0,5)}];case"sepia":return[{type:"sepia",value:1}];case"grayscale":return[{type:"grayscale",value:1}];case"adjustment":{const J=je(rt(V,["brightness"],1)-1,-1,1),le=je(rt(V,["contrast"],1),.1,3),Q=je(rt(V,["saturation"],1),0,3);return[{type:"brightness",value:J},{type:"contrast",value:le},{type:"saturation",value:Q}]}default:return[]}}function Xc(S){const V=S.timeline[0],X=Array.isArray(V==null?void 0:V.filters)?V.filters:[],J=[];for(const Q of X)if(J.push(...jc(Q)),J.length>=12)break;const le={...S,filters:J.slice(0,12)};if(S.timeline.length===1&&V){const Q=Math.max(0,La(V.sourceIn,0)),ce=La(V.sourceOut,Q);ce>Q&&(le.trim={start:Q,end:ce})}return le}function Zc(S){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[S??""]??[1920,1080]}function Yc(S){if(!S||typeof S!="object")return null;const V=S.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const X=V.value;if(typeof X=="number"&&Number.isFinite(X)&&X>0)return X}return null}async function zi(S,V,X){var Ut,_t,Tt,Mt;const J=S.timeline[0],le=J?Math.max(0,J.sourceIn):0,Q=J?J.sourceOut:void 0,[ce,Re]=Zc((V==null?void 0:V.quality)??((Ut=S.output)==null?void 0:Ut.quality)),ct=((_t=S.output)==null?void 0:_t.fps)||30;Ce(!1),x.value=!0,await e.nextTick();try{const Qe=[200,500,1e3];let it=!1;for(const Ha of Qe){await new Promise(md=>setTimeout(md,Ha));const To=B.value;if(!(!To||typeof To.captureFrameAt!="function")&&typeof To.ensureReadyForCapture=="function"&&(it=await To.ensureReadyForCapture(),it))break}const ht=B.value;if(!ht||typeof ht.captureFrameAt!="function")throw new Error("PIXI preview not available for export. Ensure the preview is mounted.");if(!it)throw new Error("PIXI preview not ready for frame capture after retries. The video may still be loading.");const{exportWithPixiFrames:_o,isWebCodecsSupported:Pn}=await Promise.resolve().then(()=>require("./PixiFrameExporter-BTU38EVl.cjs"));if(!Pn())throw new Error("WebCodecs is not supported in this browser. Export requires Chrome 94+ or equivalent.");Dt=new AbortController;const bn={width:ce,height:Re,fps:ct,trimStart:le,signal:Dt.signal};Q!==void 0&&(bn.trimEnd=Q),X&&(bn.onProgress=X);const Zi=Vt.value;Zi!==""&&(bn.sourceUrl=Zi);const sd=typeof ht.duration=="number"&&ht.duration>0?ht.duration:((Tt=S.source)==null?void 0:Tt.duration)??Q??0,ld=await _o({captureFrameAt:Ha=>ht.captureFrameAt(Ha),duration:{value:sd}},bn),Ga=new File([ld],`edited-video-${Date.now()}.mp4`,{type:"video/mp4"}),cd=Yc(ht),dd=((Mt=S.source)==null?void 0:Mt.duration)??0,ud=Math.max(0,(Q??cd??dd)-le);return{file:Ga,recipe:S,meta:{duration:ud,width:ce,height:Re,format:"mp4",sizeBytes:Ga.size,size_bytes:Ga.size}}}finally{x.value=!1,Dt=null}}async function Gc(S,V){var Mt;Zt(),wt=!1,Dt=null,Et.value=null,Oe.value=null,St.value=!1,We.value=0;const X=S??ee(),J=ji(X),le=Array.isArray(J.filters)&&J.filters.length>0,Q=Xa(J);if(!(M.value||le||Q))return ne(),r("video-exported",null),null;const Re=J.timeline[0],ct=Re?Math.max(0,Re.sourceIn):0,_t=((Re==null?void 0:Re.sourceOut)??((Mt=J.source)==null?void 0:Mt.duration)??gn.value)-ct,Tt=a.serverRenderEndpoint!=null&&a.clientExportThreshold>0&&_t>a.clientExportThreshold;if(Tt){ot.value=!0;try{return await Hc(J),null}catch(Qe){const it=Qe instanceof Error?Qe.message:"Server render failed";throw Oe.value=it,r("server-render-failed",it),Qe}finally{ot.value=!1}}if(a.maxDuration>0&&_t>a.maxDuration&&!Tt){const Qe=`This video is too long for in-browser export (${Math.round(_t)}s). Server rendering is not available. Try a shorter clip.`;return Oe.value=Qe,r("video-exported",null),null}ot.value=!0;try{const Qe=await zi(J,V,it=>{wt||(We.value=it)});return wt?(Oe.value="Export canceled.",We.value=0,r("video-exported",null),null):(ne(),r("recipe-generated",J),r("video-exported",Qe),We.value=100,St.value=!0,Qe)}catch(Qe){if(wt)return Oe.value="Export canceled.",We.value=0,r("video-exported",null),null;const it=Qe instanceof Error?Qe.message:"Local WebGL export failed.";throw Oe.value=it,new Error(`Video export failed: ${it}`)}finally{ot.value=!1}}async function Hc(S){const V=new Qr(a.serverRenderEndpoint??"/api/v1");Oe.value="Starting server render...",We.value=0;const X=await V.createRenderJob({source_media_uuid:s.value,recipe:S});Et.value=X.id,r("server-render-started",X.id),r("export-started",X.id),Oe.value="Rendering on server...";const J=await V.pollRenderJob(X.id,(le,Q)=>{We.value=le,Q==="processing"&&(Oe.value=`Server rendering: ${le}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);We.value=100,St.value=!0,Oe.value="Server render complete!",ne(),r("recipe-generated",S),r("server-render-completed",{id:J.id,outputMediaId:J.outputMediaId})}async function Ai(){if(!ot.value)return;wt=!0,x.value=!1,Dt&&(Dt.abort(),Dt=null),Zt();const S=Et.value;if(S)try{const V=await fetch(`/api/v1/video/jobs/${S}`,{method:"DELETE"});if(!V.ok)throw new Error(`Cancel failed: ${V.status} ${V.statusText}`)}catch(V){const X=V instanceof Error?V.message:"Failed to cancel export";Oe.value=X,ot.value=!1,Et.value=null;return}ot.value=!1,We.value=0,St.value=!1,Et.value=null,Oe.value="Export canceled."}async function Di(S){Zt(),wt=!1,Dt=null,Et.value=null,Oe.value=null,St.value=!1,ot.value=!0,We.value=0;try{const V=Wc(ee(),S);r("recipe-generated",V);const X=s.value.startsWith("temp-"),J=V.timeline[0],le=Array.isArray(J==null?void 0:J.filters)?J.filters:[],Q=!0,ce=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(Q)try{const ht=await zi(V,S,bn=>{wt||(We.value=bn)});if(wt){Oe.value="Export canceled.",ot.value=!1,We.value=0;return}r("video-exported",ht);const _o=URL.createObjectURL(ht.file),Pn=document.createElement("a");Pn.href=_o,Pn.download=`edited-video-${Date.now()}.mp4`,Pn.click(),setTimeout(()=>URL.revokeObjectURL(_o),100),ot.value=!1,We.value=100,St.value=!0;return}catch(ht){if(wt){Oe.value="Export canceled.",ot.value=!1,We.value=0;return}if(X||!ce)throw ht;We.value=0,Oe.value="Local filter export failed, falling back to server render."}const Re={"360p":"low","480p":"low","720p":"medium","1080p":"high","1440p":"ultra","2160p":"ultra"},ct=(S==null?void 0:S.quality)??V.output.quality,Ut=Re[ct]??"high",_t={...Xc(V),export:{format:(S==null?void 0:S.format)??V.output.format,quality:Ut,resolution:ct,framerate:V.output.fps}},Tt=await fetch("/api/v1/video/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_media_id:s.value,recipe:_t})});if(!Tt.ok)throw new Error(`Export failed: ${Tt.status} ${Tt.statusText}`);const Mt=await Tt.json(),Qe=(Mt==null?void 0:Mt.data)??Mt,it=typeof(Qe==null?void 0:Qe.id)=="string"?Qe.id:null;if(!it)throw new Error("Export failed: missing job id");Et.value=it,r("export-started",it),id(it)}catch(V){if(x.value=!1,Dt=null,wt){Oe.value="Export canceled.",ot.value=!1,We.value=0,Et.value=null;return}try{const X=ee(),J=new Blob([JSON.stringify(X,null,2)],{type:"application/json"}),le=URL.createObjectURL(J),Q=document.createElement("a");Q.href=le,Q.download=`video-recipe-${Date.now()}.json`,Q.click(),setTimeout(()=>URL.revokeObjectURL(le),100)}finally{ot.value=!1,We.value=0,Et.value=null,Oe.value=V instanceof Error?V.message:"Export failed"}}}const Wa=async S=>{await new Promise(V=>{window.setTimeout(V,S)})},ja=S=>{if(!S||S.width<=0||S.height<=0)return null;try{return S.toDataURL("image/jpeg",.85)}catch{return null}},Jc=S=>{if(!S||typeof S!="object")return null;const X=S.pixiCanvas;if(X&&typeof X=="object"&&"value"in X){const J=X.value;return J instanceof HTMLCanvasElement?J:null}return X instanceof HTMLCanvasElement?X:null},qc=S=>{if(!S||typeof S!="object")return null;const V=S.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const X=V.value;if(typeof X=="number"&&Number.isFinite(X))return X}return null},Kc=S=>{if(!S||typeof S!="object")return null;const X=S.videoElement;if(X&&typeof X=="object"&&"value"in X){const J=X.value;return J instanceof HTMLVideoElement?J:null}return X instanceof HTMLVideoElement?X:null},Ui=S=>typeof S.params=="object"&&S.params!==null?S.params:{},Qc=S=>{const V=[];for(const X of S){const J=Ui(X),le=X.filterId.trim().toLowerCase();if(le==="brightness"){const ce=(je(rt(J,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${ce.toFixed(2)}%)`);continue}if(le==="contrast"){const Q=je(rt(J,["value","contrast"],1),.1,4);V.push(`contrast(${(Q*100).toFixed(2)}%)`);continue}if(le==="saturation"||le==="saturate"){const Q=je(rt(J,["value","saturation"],1),0,4);V.push(`saturate(${(Q*100).toFixed(2)}%)`);continue}if(le==="grayscale"){V.push("grayscale(100%)");continue}if(le==="sepia"){V.push("sepia(100%)");continue}if(le==="blur"||le==="gaussian-blur"||le==="kawase-blur"){const Q=je(rt(J,["value","blur","radius"],0),0,30);Q>.01&&V.push(`blur(${Q.toFixed(2)}px)`);continue}if(le==="adjustment"){const Q=rt(J,["brightness"],1),ce=rt(J,["contrast"],1),Re=rt(J,["saturation"],1);Math.abs(Q-1)>.01&&V.push(`brightness(${(je(Q,0,5)*100).toFixed(2)}%)`),Math.abs(ce-1)>.01&&V.push(`contrast(${(je(ce,.1,5)*100).toFixed(2)}%)`),Math.abs(Re-1)>.01&&V.push(`saturate(${(je(Re,0,5)*100).toFixed(2)}%)`);continue}if(le==="cinematic"){V.push("contrast(120%) brightness(95%) saturate(85%)");continue}if(le==="dramatic"){V.push("contrast(140%) brightness(90%) saturate(110%) sepia(10%)");continue}if(le==="dreamy"){V.push("blur(0.5px) brightness(105%) saturate(90%) contrast(95%)");continue}}return V.join(" ")},ed=S=>{const V=S.find(le=>le.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const X=Ui(V),J=rt(X,["noise","value","amount","intensity"],.2);return J<=1?je(J,0,1):je(J/100,0,1)},td=(S,V,X,J)=>{if(J<=0)return;const le=S.getImageData(0,0,V,X),Q=255*J;for(let ce=0;ce<le.data.length;ce+=4){const Re=(Math.random()*2-1)*Q;le.data[ce]=je(le.data[ce]+Re,0,255),le.data[ce+1]=je(le.data[ce+1]+Re,0,255),le.data[ce+2]=je(le.data[ce+2]+Re,0,255)}S.putImageData(le,0,0)},Oi=async S=>{S.readyState>=2&&S.videoWidth>0&&S.videoHeight>0||await new Promise(V=>{let X=!1,J=0;const le=()=>{X||(X=!0,S.removeEventListener("loadedmetadata",Q),S.removeEventListener("loadeddata",Q),S.removeEventListener("canplay",Q),window.clearTimeout(J),V())},Q=()=>{le()};S.addEventListener("loadedmetadata",Q),S.addEventListener("loadeddata",Q),S.addEventListener("canplay",Q),J=window.setTimeout(()=>le(),800),S.play().catch(()=>{})})},nd=async(S,V)=>{await new Promise(X=>{let J=!1,le=0;const Q=()=>{J||(J=!0,S.removeEventListener("seeked",ce),window.clearTimeout(le),X())},ce=()=>{Q()};if(Math.abs(S.currentTime-V)<.016){requestAnimationFrame(()=>Q());return}S.addEventListener("seeked",ce),le=window.setTimeout(()=>Q(),700),S.currentTime=V})},Li=async(S,V)=>{await Oi(S);const X=Math.floor(S.videoWidth),J=Math.floor(S.videoHeight);if(X<=0||J<=0)return null;const le=Number.isFinite(S.duration)&&S.duration>0?S.duration:0,Q=le>0?je(V,0,le):0;await nd(S,Q);const ce=document.createElement("canvas");ce.width=X,ce.height=J;const Re=ce.getContext("2d");if(!Re)return null;const ct=Qc(Je.value);ct!==""&&(Re.filter=ct);try{Re.drawImage(S,0,0,X,J)}catch{return null}const Ut=ed(Je.value);return td(Re,X,J,Ut),ja(ce)},od=async(S,V)=>{const X=document.createElement("video");X.src=S,X.muted=!0,X.playsInline=!0,X.preload="auto",S.startsWith("blob:")||(X.crossOrigin="anonymous");try{return await Oi(X),await Li(X,V)}catch{return null}finally{X.pause(),X.removeAttribute("src"),X.load()}},ad=async S=>{const V=B.value,X=ja(Jc(V));if(X)return X;if(V!=null&&V.captureFrameAt)for(let Q=0;Q<4;Q+=1){const ce=qc(V);if(ce!==null&&ce<=0&&Q<2){await Wa(80);continue}const Re=await Promise.race([V.captureFrameAt(S),Wa(450).then(()=>null)]),ct=ja(Re);if(ct)return ct;await Wa(80)}const J=Kc(V);if(J){const Q=await Li(J,S);if(Q)return Q}const le=Ua.value.trim();if(le!==""){const Q=await od(le,S);if(Q)return Q}return null},Wi=S=>S.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function ji(S){const V=Wi(Je.value);if(!Xa(S)&&V.length>0&&Array.isArray(S.timeline)&&S.timeline.length>0){const J=S.timeline[0];J&&(S.timeline=[{...J,filters:V},...S.timeline.slice(1)])}return S}const Xa=S=>Array.isArray(S.timeline)?S.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,rd=S=>{if(!S||typeof S!="object")return null;const V=S.posterFrame;if(typeof V!="string")return null;const X=V.trim();return X!==""?X:null};async function Za(){const S=ji(U()),V=Wi(Je.value),X=Xa(S)||V.length>0,J=rd(a.initialRecipe);if(X){const le=Te.value>0?Te.value:.1;try{const Q=await ad(le);Q?S.posterFrame=Q:J&&(S.posterFrame=J)}catch{J&&(S.posterFrame=J)}}else delete S.posterFrame;return ne(),r("draft-saved",S),S}function Xi(){K()&&(ci(),Nt())}async function id(S){Zt(),Vo=window.setInterval(async()=>{var V,X;try{if(wt){Zt();return}const J=await fetch(`/api/v1/video/jobs/${S}`);if(!J.ok)throw new Error(`Status poll failed: ${J.status} ${J.statusText}`);const le=await J.json(),Q=(le==null?void 0:le.data)??le,ce=Number((Q==null?void 0:Q.progress)??0);if(We.value=Number.isFinite(ce)?ce:0,Q.status==="completed"||Q.status==="failed"||Q.status==="cancelled")if(Zt(),ot.value=!1,Et.value=null,Q.status==="completed"){const Re=((V=Q==null?void 0:Q.output_media)==null?void 0:V.url)??(Q==null?void 0:Q.output_url);We.value=100,St.value=!0,Oe.value=null}else{const Re=!!((X=Q==null?void 0:Q.meta)!=null&&X.is_cancelled)||Q.status==="cancelled"||typeof(Q==null?void 0:Q.error_message)=="string"&&/cancel/i.test(Q.error_message);Oe.value=Re?"Export canceled.":typeof(Q==null?void 0:Q.error_message)=="string"&&Q.error_message.trim()!==""?Q.error_message:"Export failed"}}catch(J){Zt(),ot.value=!1,Et.value=null,Oe.value=J instanceof Error?J.message:"Failed to check export progress"}},2e3)}function Ya(){var V,X;const S=ee();((V=a.media)!=null&&V.url||(X=a.media)!=null&&X.file)&&(S.metadata||(S.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),a.media.url&&/^https?:/i.test(a.media.url)?S.metadata.source_url=a.media.url:delete S.metadata.source_url);try{const J=S.timeline??[]}catch{}y.value=S}let qt=null;function Nt(){qt&&clearTimeout(qt),qt=setTimeout(()=>{Ya(),qt=null},200)}return e.watch(()=>Be.value,Nt,{deep:!0}),e.watch(()=>te.value,S=>{if(b.value||!S)return;const V=(S==null?void 0:S.filters)??[];Bc(V)},{immediate:!0}),e.watch(()=>Je.value,S=>{Ke(S),Nt()},{deep:!0}),e.watch(()=>P.value,S=>{pe(S),Nt()},{deep:!0}),e.watch(()=>T.value,S=>{const V=S.map(X=>({...X,source:typeof X.source=="string"?X.source:void 0}));ke(V),Nt()},{deep:!0}),e.watch(()=>Te.value,Nt),o({saveDraft:Za,exportForUpload:Gc}),Ya(),e.onUnmounted(()=>{Zt(),wt=!0,qt&&(clearTimeout(qt),qt=null),E.value&&(E.value.destroy(),E.value=null),w.value=null,$.value=null,C.value=null}),e.onMounted(()=>{window.addEventListener("resize",R),a.media&&Ya(),e.nextTick(()=>{const S=document.querySelector(".video-editor");S&&S.getBoundingClientRect();const V=document.querySelector(".mobile-layout");V&&V.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",R)}),(S,V)=>{var X,J,le,Q;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",Jy,[e.createElementVNode("div",qy,[e.withDirectives(e.createVNode(as,{ref_key:"pixiPreviewMobileRef",ref:g,"aria-hidden":!m.value,class:"preview-host-child",source:Ua.value,filters:hi.value,playhead:vi.value,"is-playing":e.unref(j),"fit-mode":f.value,active:m.value,onPlayPause:e.unref(xe),onDurationChange:No},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(Ss,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:y.value,media:pi.value,"enable-engine":h.value&&fi.value,"fit-mode":f.value,onTimeUpdate:wi,onPlayStateChange:ki,onDurationChange:No,onEngineReady:xi},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]])]),e.createElementVNode("div",Ky,[e.createVNode(Es,{playhead:e.unref(Te),clips:e.unref(Be),"selected-clip-id":((X=e.unref(te))==null?void 0:X.id)??((J=e.unref(Be)[0])==null?void 0:J.id)??null,duration:gn.value,"zoom-level":e.unref(ae),sensitivity:.25,"is-mobile":!0,"onUpdate:playhead":e.unref(Ue),onTrim:e.unref(q),onSplit:e.unref(ue),onClipSelect:e.unref(ve),onClipMove:e.unref(Ze)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])]),e.createElementVNode("div",Qy,[e.createElementVNode("div",eb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,ce=>(e.openBlock(),e.createElementBlock("button",{key:ce.id,class:e.normalizeClass(["tab-button",{active:c.value===ce.id}]),onClick:Re=>c.value=ce.id},[e.createVNode(e.unref(I.IonIcon),{icon:ce.icon},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(ce.label),1)],10,tb))),128))]),e.createElementVNode("div",nb,[e.withDirectives(e.createElementVNode("div",ob,[e.createVNode(Cs,{filters:Co.value,"active-filters":ui.value,"thumbnail-url":mi.value,onApplyFilter:Rn,onRemoveFilter:di,onUpdateParam:bi,onPreviewFilter:Si},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,c.value==="filters"]]),e.withDirectives(e.createElementVNode("div",ab,[e.unref(So)?(e.openBlock(),e.createBlock(Vs,{key:0,filter:e.unref(So),"current-frame":e.unref(me),onUpdateParams:Ei},null,8,["filter","current-frame"])):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",rb,[e.createVNode(_s,{overlays:P.value,onAddOverlay:Ci,onUpdateOverlay:Vi,onRemoveOverlay:Ni},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",ib,[e.createVNode(Ts,{"selected-clips":F.value,"applied-transitions":k.value,onApplyTransition:_i,onRemoveTransition:Ti,onPreviewTransition:Mi},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,c.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",sb,[e.createVNode(Ms,{"audio-layers":T.value,"master-volume":D.value,onAddTrack:Fi,onUpdateTrack:Ii,onRemoveTrack:Bi,onUpdateVolume:Ri,onToggleMute:Pi,onUpdateMasterVolume:$i},null,8,["audio-layers","master-volume"])],512),[[e.vShow,c.value==="audio"]]),e.withDirectives(e.createElementVNode("div",lb,[e.createVNode(Ns,{"can-export":e.unref(M),"is-exporting":ot.value,"export-progress":We.value,onExport:Di,onCancelExport:Ai,onSaveDraft:Za,onReset:Xi},null,8,["can-export","is-exporting","export-progress"]),St.value?(e.openBlock(),e.createElementBlock("div",cb," Export complete ")):e.createCommentVNode("",!0),Oe.value&&!St.value?(e.openBlock(),e.createElementBlock("div",db,e.toDisplayString(Oe.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])):(e.openBlock(),e.createElementBlock("div",ub,[e.createElementVNode("div",mb,[e.createElementVNode("div",pb,[e.createElementVNode("div",fb,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[0]||(V[0]=ce=>f.value=ce),"aria-label":"Fit mode","data-testid":"select-video-fit-mode"},[...V[9]||(V[9]=[e.createElementVNode("option",{value:"contain"},"Contain",-1),e.createElementVNode("option",{value:"cover"},"Cover",-1),e.createElementVNode("option",{value:"none"},"None",-1)])],512),[[e.vModelSelect,f.value]])])]),e.withDirectives(e.createVNode(as,{ref_key:"pixiPreviewDesktopRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:Ua.value,filters:hi.value,playhead:vi.value,"is-playing":e.unref(j),"fit-mode":f.value,active:m.value,onPlayPause:e.unref(xe),onDurationChange:No},null,8,["aria-hidden","source","filters","playhead","is-playing","fit-mode","active","onPlayPause"]),[[e.vShow,m.value]]),e.withDirectives(e.createVNode(Ss,{"aria-hidden":!h.value,class:"preview-host-child","media-uuid":s.value,recipe:y.value,media:pi.value,"enable-engine":h.value&&fi.value,"fit-mode":f.value,onTimeUpdate:wi,onPlayStateChange:ki,onDurationChange:No,onEngineReady:xi},null,8,["aria-hidden","media-uuid","recipe","media","enable-engine","fit-mode"]),[[e.vShow,h.value]]),S.showThumbnailPicker?(e.openBlock(),e.createBlock(Pv,{key:0,"media-uuid":s.value,duration:gn.value,onSelect:Lc},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",hb,[e.createElementVNode("div",vb,[e.createElementVNode("div",gb,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(A.value,ce=>(e.openBlock(),e.createElementBlock("button",{key:ce.id,class:e.normalizeClass(["tab-btn",{active:d.value===ce.id}]),onClick:Re=>d.value=ce.id},e.toDisplayString(ce.label),11,yb))),128))]),e.createElementVNode("div",bb,[e.withDirectives(e.createElementVNode("div",wb,[e.createVNode(Cs,{filters:Co.value,"active-filters":ui.value,"thumbnail-url":mi.value,onApplyFilter:Rn,onRemoveFilter:di,onUpdateParam:bi,onPreviewFilter:Si},null,8,["filters","active-filters","thumbnail-url"])],512),[[e.vShow,d.value==="filters"]]),e.withDirectives(e.createElementVNode("div",kb,[e.createVNode(_s,{overlays:P.value,onAddOverlay:Ci,onUpdateOverlay:Vi,onRemoveOverlay:Ni},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",xb,[e.createVNode(Ts,{"selected-clips":F.value,"applied-transitions":k.value,onApplyTransition:_i,onRemoveTransition:Ti,onPreviewTransition:Mi},null,8,["selected-clips","applied-transitions"])],512),[[e.vShow,d.value==="transitions"]]),e.withDirectives(e.createElementVNode("div",Sb,[e.createVNode(Ms,{"audio-layers":T.value,"master-volume":D.value,onAddTrack:Fi,onUpdateTrack:Ii,onRemoveTrack:Bi,onUpdateVolume:Ri,onToggleMute:Pi,onUpdateMasterVolume:$i},null,8,["audio-layers","master-volume"])],512),[[e.vShow,d.value==="audio"]]),e.withDirectives(e.createElementVNode("div",Eb,[e.unref(So)?(e.openBlock(),e.createBlock(Vs,{key:0,filter:e.unref(So),"current-frame":e.unref(me),onUpdateParams:Ei},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",Cb,[...V[10]||(V[10]=[e.createElementVNode("p",null,"Select a filter from the Filters tab to adjust its parameters",-1)])]))],512),[[e.vShow,d.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",Vb,[e.createVNode(Ns,{"can-export":e.unref(M),"is-exporting":ot.value,"export-progress":We.value,onExport:Di,onCancelExport:Ai,onSaveDraft:Za,onReset:Xi},null,8,["can-export","is-exporting","export-progress"]),St.value?(e.openBlock(),e.createElementBlock("div",Nb," Export complete ")):e.createCommentVNode("",!0),Oe.value&&!St.value?(e.openBlock(),e.createElementBlock("div",_b,e.toDisplayString(Oe.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,d.value==="export"]])])])])]),e.createElementVNode("div",Tb,[e.createElementVNode("div",Mb,[e.createElementVNode("div",Fb,[e.createElementVNode("label",null,[V[11]||(V[11]=e.createTextVNode(" Zoom ",-1)),e.createElementVNode("input",{type:"range",min:"10",max:"600",value:e.unref(ae),onInput:V[1]||(V[1]=ce=>Oc(ce))},null,40,Ib)]),e.createElementVNode("span",Bb,e.toDisplayString(Math.round(e.unref(ae)))+" px/s",1)]),e.createVNode(Es,{playhead:e.unref(Te),clips:e.unref(Be),"selected-clip-id":((le=e.unref(te))==null?void 0:le.id)??((Q=e.unref(Be)[0])==null?void 0:Q.id)??null,duration:gn.value,"zoom-level":e.unref(ae),sensitivity:.25,"onUpdate:playhead":e.unref(Ue),onTrim:e.unref(q),onSplit:e.unref(ue),onClipSelect:e.unref(ve),onClipMove:e.unref(Ze)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"]),e.createVNode(w0,{"selected-clip":e.unref(te),"can-split":Pc.value,"can-delete":$c.value,"is-playing":e.unref(j),"zoom-level":e.unref(ae),"playback-speed":e.unref(re),onSplit:e.unref(we),onDelete:e.unref(oe),onDuplicate:e.unref(ye),onZoomIn:e.unref(be),onZoomOut:e.unref(Y),onZoomChange:e.unref(fe),onFitToWindow:e.unref(se),onPlayPause:e.unref(xe),onFrameForward:e.unref(Ye),onFrameBackward:e.unref(nt),onSkipToStart:e.unref(At),onSkipToEnd:e.unref(ut),onSpeedChange:e.unref(fn)},null,8,["selected-clip","can-split","can-delete","is-playing","zoom-level","playback-speed","onSplit","onDelete","onDuplicate","onZoomIn","onZoomOut","onZoomChange","onFitToWindow","onPlayPause","onFrameForward","onFrameBackward","onSkipToStart","onSkipToEnd","onSpeedChange"]),H.value?(e.openBlock(),e.createElementBlock("div",Rb,[e.createElementVNode("div",Pb,[e.createElementVNode("label",$b,[V[12]||(V[12]=e.createElementVNode("span",null,"Trim start (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[2]||(V[2]=ce=>hn.value=ce),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-start"},null,512),[[e.vModelText,hn.value]])]),e.createElementVNode("label",zb,[V[13]||(V[13]=e.createElementVNode("span",null,"Trim end (s)",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":V[3]||(V[3]=ce=>vn.value=ce),type:"number",step:"0.01",min:"0",inputmode:"decimal","data-testid":"video-dev-trim-end"},null,512),[[e.vModelText,vn.value]])]),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-start-playhead",disabled:!e.unref(te),onClick:V[4]||(V[4]=ce=>yi("start"))}," Start = Playhead ",8,Ab),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-trim-end-playhead",disabled:!e.unref(te),onClick:V[5]||(V[5]=ce=>yi("end"))}," End = Playhead ",8,Db),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-trim",disabled:!e.unref(te),onClick:Ac}," Apply Trim ",8,Ub)]),e.createElementVNode("div",Ob,[e.createElementVNode("label",Lb,[V[14]||(V[14]=e.createElementVNode("span",null,"Quick filter",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[6]||(V[6]=ce=>Xt.value=ce),"data-testid":"video-dev-filter-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Co.value,ce=>(e.openBlock(),e.createElementBlock("option",{key:ce.id,value:ce.id},e.toDisplayString(ce.name),9,Wb))),128))],512),[[e.vModelSelect,Xt.value]])]),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"video-dev-apply-filter",disabled:!e.unref(te)||Xt.value==="",onClick:Dc}," Apply Filter ",8,jb),e.createElementVNode("button",{class:"dev-editor-button",type:"button","data-testid":"video-dev-clear-filters",disabled:e.unref(Je).length===0,onClick:Uc}," Clear Filters ",8,Xb),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"btn-apply-noise-filter","aria-label":"Apply noise filter for QA testing",disabled:!e.unref(te),onClick:V[7]||(V[7]=ce=>Rn("noise"))}," QA: Noise ",8,Zb),e.createElementVNode("button",{class:"dev-editor-button dev-editor-button--primary",type:"button","data-testid":"btn-apply-grayscale-filter","aria-label":"Apply grayscale filter for QA testing",disabled:!e.unref(te),onClick:V[8]||(V[8]=ce=>Rn("grayscale"))}," QA: Grayscale ",8,Yb)])])):e.createCommentVNode("",!0)])])]))],2)}}}),gc=_e(Gb,[["__scopeId","data-v-43d94aba"]]),Hb=["aria-label"],Jb={class:"ve-header"},qb={class:"ve-title"},Kb={class:"ve-body"},Qb={class:"ve-footer"},e2=e.defineComponent({__name:"VideoEditorDialog",props:{open:{type:Boolean},mediaUuid:{},initialRecipe:{},media:{},showThumbnailPicker:{type:Boolean,default:!1},title:{default:"Edit Video"}},emits:["update:open","close","recipe-generated","export-started","draft-saved","thumbnail-selected"],setup(n,{emit:o}){const t=n,a=o,r=e.computed(()=>t.open??!0),i=e.computed(()=>{var l;return t.mediaUuid||((l=t.media)==null?void 0:l.id)||`temp-${Date.now()}`});function s(){a("close"),a("update:open",!1)}return(l,c)=>r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"ve-overlay",onClick:e.withModifiers(s,["self"])},[e.createElementVNode("div",{class:"ve-dialog",role:"dialog","aria-label":l.title,"aria-modal":"true"},[e.createElementVNode("header",Jb,[e.createElementVNode("h2",qb,e.toDisplayString(l.title),1),e.createElementVNode("button",{class:"ve-close",onClick:s,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",Kb,[e.createVNode(gc,e.mergeProps({"media-uuid":i.value},{...l.initialRecipe?{initialRecipe:l.initialRecipe}:{},...l.media?{media:l.media}:{}},{"show-thumbnail-picker":l.showThumbnailPicker??!1,onRecipeGenerated:c[0]||(c[0]=d=>l.$emit("recipe-generated",d)),onExportStarted:c[1]||(c[1]=d=>l.$emit("export-started",d)),onDraftSaved:c[2]||(c[2]=d=>l.$emit("draft-saved",d)),onThumbnailSelected:c[3]||(c[3]=d=>l.$emit("thumbnail-selected",d))}),null,16,["media-uuid","show-thumbnail-picker"])]),e.createElementVNode("footer",Qb,[e.renderSlot(l.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:s},"Cancel")],!0)])],8,Hb)])):e.createCommentVNode("",!0)}}),t2=_e(e2,[["__scopeId","data-v-710e8e26"]]),n2={class:"video-editor-modal"},o2={class:"video-preview-container"},a2=["src"],r2={class:"video-overlay-controls"},i2=["aria-label"],s2={class:"time-display"},l2={class:"timeline-container"},c2={class:"clip-name"},d2={class:"timeline-time-labels"},u2={class:"tool-tabs"},m2=["onClick"],p2={class:"tool-panel"},f2={key:0,class:"trim-panel"},h2={class:"trim-controls"},v2={key:1,class:"filters-panel"},g2={class:"filter-grid"},y2=["onClick"],b2={key:2,class:"text-panel"},w2={key:3,class:"transitions-panel"},k2={class:"transition-grid"},x2=["onClick"],S2={class:"action-buttons"},E2=e.defineComponent({__name:"VideoEditorSimple",props:{media:{}},emits:["save","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(""),s=e.ref(!1),l=e.ref(0),c=e.ref(0),d=e.ref("video-1"),u=e.ref(0),p=e.ref(0),m=e.ref(null),h=e.ref("trim"),g=e.ref(null),v=e.ref(""),x=[{id:"trim",label:"Trim",icon:il},{id:"filters",label:"Filters",icon:Vu},{id:"text",label:"Text",icon:dl},{id:"transitions",label:"Transitions",icon:Ru}],B=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],E=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],y=e.ref();e.onMounted(()=>{var _,A;(_=t.media)!=null&&_.url?i.value=t.media.url:(A=t.media)!=null&&A.file&&(i.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var _;(_=t.media)!=null&&_.file&&i.value&&URL.revokeObjectURL(i.value)});function f(){r.value&&(c.value=r.value.duration,p.value=c.value)}function w(){r.value&&(l.value=r.value.currentTime)}function $(){s.value=!1}function C(){r.value&&(s.value?(r.value.pause(),s.value=!1):(r.value.play(),s.value=!0))}function b(_){if(!_||isNaN(_))return"00:00";const A=Math.floor(_/60),Z=Math.floor(_%60);return`${A.toString().padStart(2,"0")}:${Z.toString().padStart(2,"0")}`}function N(_){if(!r.value||!y.value)return;const A=y.value.getBoundingClientRect(),me=(_.clientX-A.left)/A.width*c.value;r.value.currentTime=Math.max(0,Math.min(me,c.value))}function P(){u.value=l.value}function k(){p.value=l.value}function T(){u.value=0,p.value=c.value}function F(_){m.value=_;const A=H=>{if(!m.value||!y.value)return;const me=y.value.getBoundingClientRect(),ie=(H.clientX-me.left)/me.width*c.value;m.value==="start"?u.value=Math.max(0,Math.min(ie,p.value-1)):p.value=Math.max(u.value+1,Math.min(ie,c.value))},Z=()=>{m.value=null,document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",Z)}function D(_){if(g.value=_,!r.value)return;const A={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};r.value.style.filter=A[_]||"none"}function R(){}function W(_){}function L(){const _={timeline:[{id:d.value,url:i.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:p.value,track:0}],filters:g.value?[{type:g.value}]:[],textOverlays:v.value?[{content:v.value}]:[],duration:p.value-u.value};a("save",_)}return(_,A)=>(e.openBlock(),e.createElementBlock("div",n2,[e.createElementVNode("div",o2,[e.createElementVNode("video",{ref_key:"videoElement",ref:r,class:"video-preview",src:i.value,onLoadedmetadata:f,onTimeupdate:w,onEnded:$,controls:""},null,40,a2),e.createElementVNode("div",r2,[e.createElementVNode("button",{class:"play-pause-btn",onClick:C,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:s.value?e.unref(Au):e.unref(Wu)},null,8,["icon"])],8,i2),e.createElementVNode("div",s2,e.toDisplayString(b(l.value))+" / "+e.toDisplayString(b(c.value)),1)])]),e.createElementVNode("div",l2,[e.createElementVNode("div",{class:"timeline-track",onClick:N,ref_key:"timelineTrack",ref:y},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-p.value/c.value*100}%`})},[e.createElementVNode("span",c2,e.toDisplayString(d.value),1)],4),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:`${l.value/c.value*100}%`})},null,4),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:0,class:"trim-handle trim-start",style:e.normalizeStyle({left:`${u.value/c.value*100}%`}),onMousedown:A[0]||(A[0]=Z=>F("start"))},null,36)):e.createCommentVNode("",!0),h.value==="trim"?(e.openBlock(),e.createElementBlock("div",{key:1,class:"trim-handle trim-end",style:e.normalizeStyle({left:`${p.value/c.value*100}%`}),onMousedown:A[1]||(A[1]=Z=>F("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",d2,[e.createElementVNode("span",null,e.toDisplayString(b(0)),1),e.createElementVNode("span",null,e.toDisplayString(b(c.value)),1)])]),e.createElementVNode("div",u2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(x,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["tool-tab",{active:h.value===Z.id}]),onClick:H=>h.value=Z.id},[e.createVNode(e.unref(I.IonIcon),{icon:Z.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(Z.label),1)],10,m2)),64))]),e.createElementVNode("div",p2,[h.value==="trim"?(e.openBlock(),e.createElementBlock("div",f2,[A[7]||(A[7]=e.createElementVNode("h3",null,"Trim Video",-1)),A[8]||(A[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",h2,[e.createElementVNode("button",{class:"btn-trim",onClick:P},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),A[4]||(A[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),A[5]||(A[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:T},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ao)},null,8,["icon"]),A[6]||(A[6]=e.createTextVNode(" Clear ",-1))])])])):h.value==="filters"?(e.openBlock(),e.createElementBlock("div",v2,[A[9]||(A[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",g2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(B,Z=>e.createElementVNode("button",{key:Z.id,class:e.normalizeClass(["filter-option",{active:g.value===Z.id}]),onClick:H=>D(Z.id)},e.toDisplayString(Z.name),11,y2)),64))])])):h.value==="text"?(e.openBlock(),e.createElementBlock("div",b2,[A[10]||(A[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[2]||(A[2]=Z=>v.value=Z),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,v.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:R},"Add Text")])):h.value==="transitions"?(e.openBlock(),e.createElementBlock("div",w2,[A[11]||(A[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",k2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(E,Z=>e.createElementVNode("button",{key:Z.id,class:"transition-option",onClick:H=>(Z.id,void 0)},e.toDisplayString(Z.name),9,x2)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",S2,[e.createElementVNode("button",{class:"btn-cancel",onClick:A[3]||(A[3]=Z=>_.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:L},"SAVE")])]))}}),C2=_e(E2,[["__scopeId","data-v-b933f33b"]]),V2={class:"time-label"},N2=e.defineComponent({__name:"TimeRuler",props:{duration:{},zoom:{}},setup(n){const o=n,t=e.computed(()=>({width:`${o.duration*o.zoom*100}px`})),a=e.computed(()=>{const s=[],l=r(o.duration,o.zoom);for(let c=0;c<=o.duration;c+=l){const d=`${c/o.duration*100}%`,u=i(c),p=c%(l*5)===0;s.push({time:c,position:d,label:u,major:p})}return s});function r(s,l){const c=s/(10*l);return c<=1?1:c<=5?5:c<=10?10:c<=30?30:c<=60?60:Math.ceil(c/60)*60}function i(s){const l=Math.floor(s/60),c=Math.floor(s%60);return l===0?`${c}s`:c===0?`${l}m`:`${l}:${c.toString().padStart(2,"0")}`}return(s,l)=>(e.openBlock(),e.createElementBlock("div",{class:"time-ruler",style:e.normalizeStyle(t.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,c=>(e.openBlock(),e.createElementBlock("div",{key:c.time,class:"time-mark",style:e.normalizeStyle({left:c.position})},[e.createElementVNode("span",V2,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),_2=_e(N2,[["__scopeId","data-v-0ef9c910"]]),T2=["data-track-index"],M2={class:"track-header"},F2={class:"track-label"},I2={class:"track-controls"},B2=["data-testid","aria-label"],R2=["data-testid","onMousedown","onClick"],P2={class:"clip-content"},$2={class:"clip-name"},z2={key:0,class:"clip-thumbnail"},A2=["src","alt"],D2=["onMousedown","aria-label"],U2=["onMousedown","aria-label"],O2=e.defineComponent({__name:"VideoTrack",props:{clips:{},trackIndex:{},zoom:{},duration:{}},emits:["clip-move","clip-trim","clip-select"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null),i=e.ref(!1),s=e.ref(!1),l=e.ref(null),c=e.computed(()=>({width:`${t.duration*t.zoom*100}px`}));function d(x){const B=x.timelineEnd-x.timelineStart,E=x.timelineStart/t.duration*100,y=B/t.duration*100;return{left:`${E}%`,width:`${y}%`,backgroundColor:u(x)}}function u(x){const B=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],E=parseInt(x.id.replace(/\D/g,""))%B.length;return B[E]}function p(x){return x.label?x.label:x.url?(x.url.split("/").pop()||"Clip").split(".")[0]:`Clip ${x.id.slice(-4)}`}function m(x){r.value=x.id,a("clip-select",x.id)}function h(){i.value=!i.value}function g(x,B){if(l.value)return;s.value=!0;const E=B.clientX,y=x.timelineStart,f=$=>{if(!s.value)return;const C=$.clientX-E,b=parseFloat(c.value.width),N=C/(t.zoom*100)*(t.duration/b),P=Math.max(0,y+N);a("clip-move",x.id,P)},w=()=>{s.value=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",w)}function v(x,B,E){l.value=B;const y=E.clientX,f=x.sourceIn,w=x.sourceOut,$=b=>{if(!l.value)return;const N=b.clientX-y,P=parseFloat(c.value.width),k=N/(t.zoom*100)*(t.duration/P);if(l.value==="start"){const T=Math.max(0,f+k);a("clip-trim",x.id,T,w)}else{const T=Math.max(f+1,w+k);a("clip-trim",x.id,f,T)}},C=()=>{l.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",C)}return(x,B)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":x.trackIndex},[e.createElementVNode("div",M2,[e.createElementVNode("span",F2,"Track "+e.toDisplayString(x.trackIndex+1),1),e.createElementVNode("div",I2,[x.clips.length>0?(e.openBlock(),e.createElementBlock("button",{key:0,class:"track-btn","data-testid":`btn-mute-track-${x.trackIndex}`,"aria-label":`${i.value?"Unmute":"Mute"} track ${x.trackIndex+1}`,onClick:h},[e.createVNode(e.unref(I.IonIcon),{icon:i.value?e.unref(rm):e.unref(om)},null,8,["icon"])],8,B2)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",{class:"track-timeline",style:e.normalizeStyle(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.clips,E=>(e.openBlock(),e.createElementBlock("div",{key:E.id,class:e.normalizeClass(["timeline-clip",{selected:E.id===r.value}]),style:e.normalizeStyle(d(E)),"data-testid":`clip-${E.id}`,onMousedown:y=>g(E,y),onClick:y=>m(E)},[e.createElementVNode("div",P2,[e.createElementVNode("span",$2,e.toDisplayString(p(E)),1),E.thumbnail?(e.openBlock(),e.createElementBlock("div",z2,[e.createElementVNode("img",{src:E.thumbnail,alt:p(E)},null,8,A2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(y=>v(E,"start",y),["stop"]),"aria-label":`Trim start of ${p(E)}`},null,40,D2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(y=>v(E,"end",y),["stop"]),"aria-label":`Trim end of ${p(E)}`},null,40,U2)],46,R2))),128))],4)],8,T2))}}),L2=_e(O2,[["__scopeId","data-v-48e480d2"]]),W2={class:"video-timeline"},j2={class:"timeline-tracks"},X2=["aria-label","aria-valuenow","aria-valuemax"],Z2={class:"timeline-controls"},Y2={class:"zoom-level"},G2=e.defineComponent({__name:"VideoTimeline",props:{clips:{},duration:{},currentTime:{}},emits:["update:clips","seek","clip-move","clip-trim"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(1),i=e.ref(null),s=e.ref(!1),l=e.ref(),c=e.computed(()=>{const y=Math.max(0,...t.clips.map(f=>f.track||0));return Array(y+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(y){return t.clips.filter(f=>(f.track||0)===y)}function p(y){const f=Math.floor(y/60),w=Math.floor(y%60);return`${f}:${w.toString().padStart(2,"0")}`}function m(y,f){a("clip-move",y,f)}function h(y,f,w){a("clip-trim",y,f,w)}function g(y){i.value=y}function v(){r.value=Math.min(r.value*1.2,5)}function x(){r.value=Math.max(r.value/1.2,.5)}function B(){s.value=!0;const y=w=>{if(!s.value||!l.value)return;const $=l.value.getBoundingClientRect(),N=Math.max(0,Math.min(w.clientX-$.left,$.width))/$.width*t.duration;a("seek",N)},f=()=>{s.value=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f)};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}function E(y){let f=t.currentTime;switch(y.key){case"ArrowLeft":f=Math.max(0,t.currentTime-1);break;case"ArrowRight":f=Math.min(t.duration,t.currentTime+1);break;case"Home":f=0;break;case"End":f=t.duration;break;default:return}y.preventDefault(),a("seek",f)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(y,f)=>(e.openBlock(),e.createElementBlock("div",W2,[e.createVNode(_2,{duration:y.duration,zoom:r.value},null,8,["duration","zoom"]),e.createElementVNode("div",j2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(w,$)=>(e.openBlock(),e.createBlock(L2,{key:`track-${$}`,"data-testid":`track-${$}`,clips:u($),"track-index":$,zoom:r.value,duration:y.duration,onClipMove:m,onClipTrim:h,onClipSelect:g},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:B,"data-testid":"playhead","aria-label":`Playhead at ${p(y.currentTime)}`,role:"slider","aria-valuenow":y.currentTime,"aria-valuemax":y.duration,tabindex:"0",onKeydown:E},null,44,X2),e.createElementVNode("div",Z2,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:v},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ir)},null,8,["icon"])]),e.createElementVNode("span",Y2,e.toDisplayString(Math.round(r.value*100))+"%",1),e.createElementVNode("button",{"data-testid":"btn-zoom-out","aria-label":"Zoom out",onClick:x},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ju)},null,8,["icon"])])])]))}}),H2=_e(G2,[["__scopeId","data-v-001df415"]]),J2={class:"video-filters-panel"},q2={class:"filter-controls"},K2=["for"],Q2={class:"filter-slider-group"},ew=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],tw={class:"filter-value"},nw={class:"filter-actions"},ow={key:0,class:"filter-presets"},aw={class:"preset-list"},rw=["data-testid","aria-label","onClick"],iw=e.defineComponent({__name:"VideoFiltersPanel",emits:["filter-change"],setup(n,{emit:o}){const t=o,a=[{type:"brightness",label:"Brightness",min:0,max:200,step:1,default:100},{type:"contrast",label:"Contrast",min:0,max:200,step:1,default:100},{type:"saturation",label:"Saturation",min:0,max:200,step:1,default:100},{type:"hue",label:"Hue",min:-180,max:180,step:1,default:0},{type:"blur",label:"Blur",min:0,max:10,step:.5,default:0},{type:"sharpen",label:"Sharpen",min:0,max:10,step:.5,default:0},{type:"sepia",label:"Sepia",min:0,max:100,step:1,default:0},{type:"grayscale",label:"Grayscale",min:0,max:100,step:1,default:0}],r=e.reactive(a.reduce((m,h)=>(m[h.type]=h.default,m),{})),i=e.ref([{id:"vintage",name:"Vintage",values:{brightness:110,contrast:120,saturation:80,sepia:30}},{id:"noir",name:"Film Noir",values:{brightness:90,contrast:130,grayscale:100}},{id:"vibrant",name:"Vibrant",values:{brightness:110,contrast:110,saturation:140}},{id:"dreamy",name:"Dreamy",values:{brightness:120,blur:2,saturation:90}}]);function s(m,h){switch(m){case"brightness":case"contrast":case"saturation":case"sepia":case"grayscale":return`${h}%`;case"hue":return`${h}°`;case"blur":case"sharpen":return h.toFixed(1);default:return h.toString()}}function l(m){return["brightness","contrast","saturation","hue","blur","sharpen","sepia","grayscale"].includes(m)}function c(m){if(!l(m))return;const h={id:`filter-${m}`,filterId:m,params:{value:r[m]},intensity:1};t("filter-change",h)}function d(){a.forEach(m=>{r[m.type]=m.default,c(m.type)})}function u(){const m=prompt("Enter preset name:");if(!m)return;const h={id:`custom-${Date.now()}`,name:m,values:{...r}};i.value.push(h)}function p(m){Object.entries(m.values).forEach(([h,g])=>{r[h]=g,c(h)})}return(m,h)=>(e.openBlock(),e.createElementBlock("div",J2,[h[3]||(h[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",q2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,g=>e.createElementVNode("div",{key:g.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${g.type}`},e.toDisplayString(g.label),9,K2),e.createElementVNode("div",Q2,[e.withDirectives(e.createElementVNode("input",{id:`filter-${g.type}`,"onUpdate:modelValue":v=>r[g.type]=v,type:"range",min:g.min,max:g.max,step:g.step,class:"filter-slider","data-testid":`filter-${g.type}`,"aria-label":`${g.label} filter`,"aria-valuenow":r[g.type],"aria-valuemin":g.min,"aria-valuemax":g.max,onInput:v=>c(g.type)},null,40,ew),[[e.vModelText,r[g.type],void 0,{number:!0}]]),e.createElementVNode("span",tw,e.toDisplayString(s(g.type,r[g.type])),1)])])),64))]),e.createElementVNode("div",nw,[e.createElementVNode("button",{class:"reset-filters-btn","data-testid":"btn-reset-filters","aria-label":"Reset all filters to default",onClick:d},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(co)},null,8,["icon"]),h[0]||(h[0]=e.createTextVNode(" Reset All Filters ",-1))]),e.createElementVNode("button",{class:"save-preset-btn","data-testid":"btn-save-preset","aria-label":"Save current filter settings as preset",onClick:u},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(cl)},null,8,["icon"]),h[1]||(h[1]=e.createTextVNode(" Save as Preset ",-1))])]),i.value.length>0?(e.openBlock(),e.createElementBlock("div",ow,[h[2]||(h[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",aw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,g=>(e.openBlock(),e.createElementBlock("button",{key:g.id,class:"preset-btn","data-testid":`preset-${g.id}`,"aria-label":`Apply ${g.name} preset`,onClick:v=>p(g)},e.toDisplayString(g.name),9,rw))),128))])])):e.createCommentVNode("",!0)]))}}),sw=_e(iw,[["__scopeId","data-v-5ad2ac63"]]),lw={class:"video-text-panel"},cw={class:"text-input-group"},dw={class:"text-options"},uw={class:"option-row"},mw={class:"option-row"},pw={class:"option-row"},fw={class:"option-row"},hw={class:"checkbox-label"},vw={class:"option-row"},gw={class:"text-overlay-list"},yw={key:0,class:"empty-state"},bw=["data-testid"],ww={class:"overlay-preview"},kw={class:"overlay-controls"},xw=["data-testid","aria-label","onClick"],Sw=["data-testid","aria-label","onClick"],Ew=["data-testid","aria-label","onClick"],Cw=e.defineComponent({__name:"VideoTextPanel",emits:["text-add","text-remove","text-update"],setup(n,{emit:o}){const t=o,a=e.ref([]),r=e.reactive({text:"",fontFamily:"Arial",fontSize:32,color:"#FFFFFF",backgroundColor:"#000000",hasBackground:!0,animation:"fade-in"});function i(){if(!r.text.trim())return;const d={id:`text-${Date.now()}`,text:r.text,x:50,y:50,fontSize:r.fontSize,fontFamily:r.fontFamily,color:r.color,startTime:0,opacity:1};r.hasBackground&&(d.backgroundColor=r.backgroundColor),r.animation!=="none"&&(d.animation=r.animation),a.value.push(d),t("text-add",d),r.text=""}function s(d){const u=a.value.findIndex(p=>p.id===d);u!==-1&&(a.value.splice(u,1),t("text-remove",d))}function l(d){r.text=d.text,r.fontFamily=d.fontFamily||"Arial",r.fontSize=d.fontSize,r.color=d.color,r.backgroundColor=d.backgroundColor||"#000000",r.hasBackground=!!d.backgroundColor,r.animation=d.animation||"none",s(d.id)}function c(d){const u={...d,id:`text-${Date.now()}`,x:d.x+10,y:d.y+10};a.value.push(u),t("text-add",u)}return(d,u)=>(e.openBlock(),e.createElementBlock("div",lw,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",cw,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=p=>r.text=p),type:"text",placeholder:"Enter text...",class:"text-input","data-testid":"input-text","aria-label":"Text overlay content",onKeyup:e.withKeys(i,["enter"])},null,544),[[e.vModelText,r.text]]),e.createElementVNode("button",{class:"add-text-btn","data-testid":"btn-add-text","aria-label":"Add text overlay",onClick:i},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ir)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",dw,[e.createElementVNode("div",uw,[u[9]||(u[9]=e.createElementVNode("label",{for:"font-family"},"Font:",-1)),e.withDirectives(e.createElementVNode("select",{id:"font-family","onUpdate:modelValue":u[1]||(u[1]=p=>r.fontFamily=p),"data-testid":"select-font"},[...u[8]||(u[8]=[e.createStaticVNode('<option value="Arial" data-v-4d240e1e>Arial</option><option value="Helvetica" data-v-4d240e1e>Helvetica</option><option value="Times New Roman" data-v-4d240e1e>Times New Roman</option><option value="Georgia" data-v-4d240e1e>Georgia</option><option value="Courier New" data-v-4d240e1e>Courier New</option><option value="Impact" data-v-4d240e1e>Impact</option><option value="Comic Sans MS" data-v-4d240e1e>Comic Sans MS</option>',7)])],512),[[e.vModelSelect,r.fontFamily]])]),e.createElementVNode("div",mw,[u[10]||(u[10]=e.createElementVNode("label",{for:"font-size"},"Size:",-1)),e.withDirectives(e.createElementVNode("input",{id:"font-size","onUpdate:modelValue":u[2]||(u[2]=p=>r.fontSize=p),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,r.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",pw,[u[11]||(u[11]=e.createElementVNode("label",{for:"text-color"},"Color:",-1)),e.withDirectives(e.createElementVNode("input",{id:"text-color","onUpdate:modelValue":u[3]||(u[3]=p=>r.color=p),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,r.color]])]),e.createElementVNode("div",fw,[u[13]||(u[13]=e.createElementVNode("label",{for:"bg-color"},"Background:",-1)),e.withDirectives(e.createElementVNode("input",{id:"bg-color","onUpdate:modelValue":u[4]||(u[4]=p=>r.backgroundColor=p),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,r.backgroundColor]]),e.createElementVNode("label",hw,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=p=>r.hasBackground=p),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,r.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",vw,[u[15]||(u[15]=e.createElementVNode("label",{for:"text-animation"},"Animation:",-1)),e.withDirectives(e.createElementVNode("select",{id:"text-animation","onUpdate:modelValue":u[6]||(u[6]=p=>r.animation=p),"data-testid":"select-animation"},[...u[14]||(u[14]=[e.createStaticVNode('<option value="none" data-v-4d240e1e>None</option><option value="fade-in" data-v-4d240e1e>Fade In</option><option value="slide-left" data-v-4d240e1e>Slide from Left</option><option value="slide-right" data-v-4d240e1e>Slide from Right</option><option value="slide-up" data-v-4d240e1e>Slide from Bottom</option><option value="slide-down" data-v-4d240e1e>Slide from Top</option><option value="typewriter" data-v-4d240e1e>Typewriter</option><option value="bounce" data-v-4d240e1e>Bounce</option>',8)])],512),[[e.vModelSelect,r.animation]])])]),e.createElementVNode("div",gw,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",yw," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(p,m)=>(e.openBlock(),e.createElementBlock("div",{key:p.id,class:"text-overlay-item","data-testid":`overlay-${m}`},[e.createElementVNode("div",ww,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:p.fontFamily,fontSize:`${Math.min(p.fontSize/4,16)}px`,color:p.color})},e.toDisplayString(p.text),5)]),e.createElementVNode("div",kw,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${p.text}`,onClick:h=>l(p)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Tu)},null,8,["icon"])],8,xw),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${p.text}`,onClick:h=>c(p)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(_u)},null,8,["icon"])],8,Sw),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${p.text}`,onClick:h=>s(p.id)},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Qu)},null,8,["icon"])],8,Ew)])],8,bw))),128))])]))}}),Vw=_e(Cw,[["__scopeId","data-v-4d240e1e"]]),Nw={class:"video-tools-panel"},_w={class:"tool-tabs"},Tw=["data-testid","aria-label","aria-selected","onClick"],Mw={class:"tool-content"},Fw={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},Iw={class:"trim-actions"},Bw={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Rw={class:"transition-types"},Pw=["data-testid","aria-label","onClick"],$w={class:"transition-preview"},zw=e.defineComponent({__name:"VideoToolsPanel",props:{activeTool:{}},emits:["tool-change","filter-change","text-add","transition-add","trim-set-start","trim-set-end","trim-clear"],setup(n){const o=[{id:"trim",name:"Trim",icon:il},{id:"filters",name:"Filters",icon:Ht},{id:"text",name:"Text",icon:dl},{id:"transitions",name:"Transitions",icon:ns}],t=[{id:"fade",name:"Fade",icon:Qa},{id:"slide-left",name:"Slide Left",icon:ku},{id:"slide-right",name:"Slide Right",icon:xu},{id:"dissolve",name:"Dissolve",icon:Qa},{id:"wipe",name:"Wipe",icon:ns},{id:"zoom",name:"Zoom",icon:Qa}];return(a,r)=>(e.openBlock(),e.createElementBlock("div",Nw,[e.createElementVNode("div",_w,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,i=>e.createElementVNode("button",{key:i.id,class:e.normalizeClass(["tool-tab",{active:a.activeTool===i.id}]),"data-testid":`tab-${i.id}`,"aria-label":`${i.name} tool`,"aria-selected":a.activeTool===i.id,role:"tab",onClick:s=>a.$emit("tool-change",i.id)},[e.createVNode(e.unref(I.IonIcon),{icon:i.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(i.name),1)],10,Tw)),64))]),e.createElementVNode("div",Mw,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",Fw,[r[8]||(r[8]=e.createElementVNode("h3",null,"Trim Video",-1)),r[9]||(r[9]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",Iw,[e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-start","aria-label":"Set trim start at current position",onClick:r[0]||(r[0]=i=>a.$emit("trim-set-start"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(es)},null,8,["icon"]),r[5]||(r[5]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-set-end","aria-label":"Set trim end at current position",onClick:r[1]||(r[1]=i=>a.$emit("trim-set-end"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(es)},null,8,["icon"]),r[6]||(r[6]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"action-btn","data-testid":"btn-clear-trim","aria-label":"Clear trim points",onClick:r[2]||(r[2]=i=>a.$emit("trim-clear"))},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ao)},null,8,["icon"]),r[7]||(r[7]=e.createTextVNode(" Clear ",-1))])])])):e.createCommentVNode("",!0),a.activeTool==="filters"?(e.openBlock(),e.createBlock(sw,{key:1,onFilterChange:r[3]||(r[3]=i=>a.$emit("filter-change",i))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(Vw,{key:2,onTextAdd:r[4]||(r[4]=i=>a.$emit("text-add",i))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",Bw,[r[10]||(r[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Rw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(t,i=>e.createElementVNode("button",{key:i.id,class:"transition-btn","data-testid":`transition-${i.id}`,"aria-label":`Add ${i.name} transition`,onClick:s=>a.$emit("transition-add",i.id)},[e.createElementVNode("div",$w,[e.createVNode(e.unref(I.IonIcon),{icon:i.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(i.name),1)],8,Pw)),64))])])):e.createCommentVNode("",!0)])]))}}),Aw=_e(zw,[["__scopeId","data-v-fc135306"]]),Dw={class:"video-export-panel"},Uw={class:"export-presets"},Ow=["value"],Lw={key:0,class:"preset-details"},Ww={class:"detail-row"},jw={class:"detail-row"},Xw={class:"detail-row"},Zw={class:"advanced-options"},Yw={class:"options-content"},Gw={class:"option-group"},Hw={class:"option-group"},Jw={class:"option-group"},qw=["disabled"],Kw={key:1,class:"export-progress"},Qw={class:"progress-message"},ek={class:"progress-bar"},tk=["aria-valuenow"],nk={class:"progress-percentage"},ok=e.defineComponent({__name:"VideoExportPanel",props:{presets:{},isExporting:{type:Boolean},exportProgress:{}},emits:["export"],setup(n,{emit:o}){const t=n,a=o,r=e.ref("instagram-reel"),i=e.reactive({quality:"medium",bitrate:5,includeAudio:!0}),s=e.computed(()=>t.presets.find(d=>d.id===r.value)),l=e.computed(()=>t.exportProgress<10?"Initializing export...":t.exportProgress<30?"Processing video tracks...":t.exportProgress<50?"Applying filters and effects...":t.exportProgress<70?"Rendering frames...":t.exportProgress<90?"Encoding video...":t.exportProgress<100?"Finalizing export...":"Export complete!");function c(){s.value&&a("export",{...s.value,options:{...i}})}return(d,u)=>(e.openBlock(),e.createElementBlock("div",Dw,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",Uw,[u[4]||(u[4]=e.createElementVNode("label",{for:"preset-select"},"Export Preset:",-1)),e.withDirectives(e.createElementVNode("select",{id:"preset-select","onUpdate:modelValue":u[0]||(u[0]=p=>r.value=p),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,p=>(e.openBlock(),e.createElementBlock("option",{key:p.id,value:p.id},e.toDisplayString(p.name),9,Ow))),128))],512),[[e.vModelSelect,r.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Lw,[e.createElementVNode("div",Ww,[u[5]||(u[5]=e.createElementVNode("span",null,"Resolution:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.width)+"x"+e.toDisplayString(s.value.height),1)]),e.createElementVNode("div",jw,[u[6]||(u[6]=e.createElementVNode("span",null,"Frame Rate:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.fps)+" fps",1)]),e.createElementVNode("div",Xw,[u[7]||(u[7]=e.createElementVNode("span",null,"Format:",-1)),e.createElementVNode("span",null,e.toDisplayString(s.value.format.toUpperCase()),1)])])):e.createCommentVNode("",!0),e.createElementVNode("details",Zw,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",Yw,[e.createElementVNode("div",Gw,[u[9]||(u[9]=e.createElementVNode("label",{for:"quality-select"},"Quality:",-1)),e.withDirectives(e.createElementVNode("select",{id:"quality-select","onUpdate:modelValue":u[1]||(u[1]=p=>i.quality=p),"data-testid":"quality-select"},[...u[8]||(u[8]=[e.createElementVNode("option",{value:"low"},"Low (smaller file)",-1),e.createElementVNode("option",{value:"medium"},"Medium (balanced)",-1),e.createElementVNode("option",{value:"high"},"High (best quality)",-1)])],512),[[e.vModelSelect,i.quality]])]),e.createElementVNode("div",Hw,[u[10]||(u[10]=e.createElementVNode("label",{for:"bitrate-input"},"Bitrate (Mbps):",-1)),e.withDirectives(e.createElementVNode("input",{id:"bitrate-input","onUpdate:modelValue":u[2]||(u[2]=p=>i.bitrate=p),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,i.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",Jw,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=p=>i.includeAudio=p),type:"checkbox","data-testid":"include-audio"},null,512),[[e.vModelCheckbox,i.includeAudio]]),u[11]||(u[11]=e.createTextVNode(" Include Audio ",-1))])])])]),e.createElementVNode("button",{class:"btn-export",disabled:d.isExporting||!s.value,"data-testid":"btn-start-export","aria-label":"Start video export",onClick:c},[d.isExporting?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(pa)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,qw),d.isExporting?(e.openBlock(),e.createElementBlock("div",Kw,[e.createElementVNode("div",Qw,e.toDisplayString(l.value),1),e.createElementVNode("div",ek,[e.createElementVNode("div",{class:"progress-fill",style:e.normalizeStyle({width:`${d.exportProgress}%`}),role:"progressbar","aria-valuenow":d.exportProgress,"aria-valuemin":"0","aria-valuemax":"100"},null,12,tk)]),e.createElementVNode("div",nk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),ak=_e(ok,[["__scopeId","data-v-5caf8fe6"]]),rk={class:"progress-header"},ik={class:"file-info"},sk={class:"file-details"},lk={class:"file-name"},ck={class:"file-meta"},dk={class:"file-size"},uk={key:0,class:"separator"},mk={key:1,class:"upload-speed"},pk={key:2,class:"separator"},fk={key:3,class:"time-remaining"},hk={class:"progress-actions"},vk={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},gk={key:1,class:"status-icon error"},yk={key:2,class:"status-icon processing"},bk={key:0,class:"progress-bar-container"},wk={class:"progress-bar"},kk={class:"progress-percent"},xk={key:1,class:"error-message","data-testid":"video-upload-error"},Sk={key:2,class:"thumbnail-preview"},Ek=["src","alt"],Ck={key:0,class:"video-duration"},Vk=e.defineComponent({__name:"VideoUploadProgress",props:{upload:{}},emits:["cancel","retry","remove"],setup(n){const o=n,t=e.computed(()=>({"is-uploading":o.upload.status==="uploading","is-processing":o.upload.status==="processing","is-completed":o.upload.status==="completed","is-error":o.upload.status==="error","is-pending":o.upload.status==="pending"})),a=e.computed(()=>ul),r=e.computed(()=>["uploading","processing"].includes(o.upload.status)),i=e.computed(()=>(o.upload.status==="processing",o.upload.progress||0)),s=e.computed(()=>{if(!o.upload.timeRemaining||o.upload.status!=="uploading")return null;const m=o.upload.timeRemaining;if(m<60)return`${Math.round(m)}s`;const h=Math.floor(m/60);return h<60?`${h}m ${Math.round(m%60)}s`:`${Math.floor(h/60)}h ${h%60}m`}),l=e.computed(()=>{var m;return o.upload.status==="completed"&&((m=o.upload.media)!=null&&m.thumbnail_url)?o.upload.media.thumbnail_url:null}),c=e.computed(()=>{var m;return(m=o.upload.media)==null?void 0:m.duration});function d(m){if(m===0)return"0 B";const h=["B","KB","MB","GB","TB"],g=1024,v=Math.floor(Math.log(m)/Math.log(g));return`${(m/Math.pow(g,v)).toFixed(1)} ${h[v]}`}function u(m){if(m===0)return"0 B/s";const h=["B/s","KB/s","MB/s","GB/s"],g=1024,v=Math.floor(Math.log(m)/Math.log(g));return`${(m/Math.pow(g,v)).toFixed(1)} ${h[v]}`}function p(m){const h=Math.floor(m/3600),g=Math.floor(m%3600/60),v=Math.floor(m%60);return h>0?`${h}:${g.toString().padStart(2,"0")}:${v.toString().padStart(2,"0")}`:`${g}:${v.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value])},[e.createElementVNode("div",rk,[e.createElementVNode("div",ik,[e.createVNode(e.unref(I.IonIcon),{icon:a.value,class:"file-icon"},null,8,["icon"]),e.createElementVNode("div",sk,[e.createElementVNode("h4",lk,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",ck,[e.createElementVNode("span",dk,e.toDisplayString(d(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",uk,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",mk,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",pk,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",fk,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",hk,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",vk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(al)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",gk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(wu)},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",yk,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:3,fill:"clear",size:"small",onClick:h[0]||(h[0]=g=>m.$emit("cancel")),"aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ao),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:4,fill:"clear",size:"small",onClick:h[1]||(h[1]=g=>m.$emit("retry")),"aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(co),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:5,fill:"clear",size:"small",onClick:h[2]||(h[2]=g=>m.$emit("remove")),"aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ao),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),r.value?(e.openBlock(),e.createElementBlock("div",bk,[e.createElementVNode("div",wk,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:i.value+"%"})},null,6)]),e.createElementVNode("span",kk,e.toDisplayString(Math.round(i.value))+"%",1)])):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",xk,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(im)},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(m.upload.error),1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",Sk,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,Ek),c.value?(e.openBlock(),e.createElementBlock("div",Ck,e.toDisplayString(p(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],2))}}),Nk=_e(Vk,[["__scopeId","data-v-efdca40e"]]);function $a(n){return typeof n=="object"&&n!==null}function Xs(n){return $a(n)?typeof n.upload_url=="string"&&typeof n.upload_id=="string"&&typeof n.media_uuid=="string"&&typeof n.expires_at=="string":!1}function _k(n){if(Xs(n))return n;if($a(n)&&Xs(n.data))return n.data;throw new Error("Invalid upload response from backend")}function Zs(n){return $a(n)?typeof n.uuid=="string"&&typeof n.processing_status=="string":!1}function Tk(n){if(Zs(n))return n;if($a(n)&&Zs(n.data))return n.data;throw new Error("Invalid media response from backend")}function Po(n){return n?{...n}:{}}function Ys(n,o="PUT"){return typeof n.method=="string"&&n.method.trim()!==""?n.method.trim().toUpperCase():o}function Mk(n){return n.resumable===!0?!0:/tusupload/i.test(n.upload_url)}function Fk(n){if(typeof btoa=="function")try{return btoa(unescape(encodeURIComponent(n)))}catch{return btoa(n)}throw new Error("Base64 encoder is unavailable for TUS metadata")}function Ik(n,o){return[["filename",n.filename],["filetype",n.file.type||"application/octet-stream"],["uploadid",o.upload_id],["mediauuid",o.media_uuid]].map(([a,r])=>`${a} ${Fk(r)}`).join(",")}function $o(n,o){const t=Math.max(n.bytesTotal,1);n.bytesUploaded=o,n.progress=Math.min(100,o/t*100);const a=Math.max((Date.now()-n.startedAt.getTime())/1e3,.001);n.uploadSpeed=o/a;const r=Math.max(t-o,0);n.timeRemaining=r/Math.max(n.uploadSpeed,1)}function Bk(n,o){return n instanceof Error?n:new Error(o)}function Rk(n={}){const o=e.ref(new Map),t=e.ref(new Set),a=e.ref(null),r=new Map,i=new Map,s=e.computed(()=>t.value.size>0),l=e.computed(()=>Array.from(o.value.values())),c=e.computed(()=>{const k=Array.from(o.value.values());return k.length===0?0:k.reduce((F,D)=>F+D.progress,0)/k.length});function d(k){a.value=k}function u(){}async function p(k){var F;const T=k.filter(D=>m(D));if(T.length!==0&&((F=n.onFilesSelected)==null||F.call(n,T),n.autoUpload!==!1))for(const D of T)await h(D)}function m(k){return!(n.maxFileSize&&k.size>n.maxFileSize||n.allowedFormats&&n.allowedFormats.length>0&&!n.allowedFormats.includes(k.type))}async function h(k){var D,R,W;const T=P(k);if(o.value.has(T)){const L=o.value.get(T);if((L==null?void 0:L.status)==="uploading")return}const F={id:T,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};o.value.set(F.id,F),t.value.add(F.id);try{F.status="uploading",(D=n.onUploadStart)==null||D.call(n,F);const L=await g(k);n.resumable===!0||L.resumable===!0?await x(F,L):await v(F,L),F.status="processing",F.progress=100;const A=await w(L.media_uuid);F.status="completed",F.media=A,(R=n.onUploadComplete)==null||R.call(n,A)}catch(L){if(F.status!=="cancelled"){const _=Bk(L,"Upload failed");F.status="error",F.error=_.message,(W=n.onUploadError)==null||W.call(n,_,F)}}finally{t.value.delete(F.id),r.delete(F.id),i.delete(F.id)}}async function g(k){if(!a.value)throw new Error("API client not configured");const T={collection:n.collection||"videos",filename:k.name,size:k.size,mime_type:k.type,...n.ownerUuid!==void 0?{ownerUuid:n.ownerUuid}:{},...n.ownerType!==void 0?{ownerType:n.ownerType}:{}},F=await a.value.post("/api/v1/video/upload",T);return _k(F)}async function v(k,T){const F=new XMLHttpRequest,D=Ys(T),R=Po(T.headers);return new Promise((W,L)=>{F.upload.addEventListener("progress",_=>{var A;_.lengthComputable&&($o(k,_.loaded),(A=n.onUploadProgress)==null||A.call(n,k))}),F.addEventListener("load",()=>{r.delete(k.id),F.status>=200&&F.status<300?W():L(new Error(`Upload failed with status ${F.status}`))}),F.addEventListener("error",()=>{r.delete(k.id),L(new Error("Upload failed"))}),F.addEventListener("abort",()=>{r.delete(k.id),L(new Error("Upload cancelled"))}),F.open(D,T.upload_url),Object.entries(R).forEach(([_,A])=>{F.setRequestHeader(_,A)}),!Object.keys(R).some(_=>_.toLowerCase()==="content-type")&&k.file.type&&F.setRequestHeader("Content-Type",k.file.type),r.set(k.id,F),F.send(k.file)})}async function x(k,T){var L;if(Mk(T)){await B(k,T);return}const F=n.chunkSize||5*1024*1024,D=E(k.file,F),R=new AbortController;i.set(k.id,R);const W=await f(T.upload_id);W&&(D.forEach(_=>{_.end<=W.bytesUploaded&&(_.uploaded=!0)}),$o(k,W.bytesUploaded));for(const _ of D)_.uploaded||(await y(k,T,_,R),$o(k,_.end),(L=n.onUploadProgress)==null||L.call(n,k))}async function B(k,T){var Z;const F=new AbortController;i.set(k.id,F);const D={...Po(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":Ik(k,T)},R=await fetch(T.upload_url,{method:"POST",headers:D,signal:F.signal});if(!R.ok)throw new Error(`Failed to initialize resumable upload: ${R.status}`);const W=R.headers.get("Location");if(!W)throw new Error("Resumable upload endpoint did not return upload location");const L=new URL(W,T.upload_url).toString(),_=n.chunkSize||5*1024*1024;let A=0;for(;A<k.file.size;){const H=Math.min(A+_,k.file.size),me=k.file.slice(A,H),Te={...Po(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(A),"Content-Type":"application/offset+octet-stream"},Be=await fetch(L,{method:"PATCH",headers:Te,body:me,signal:F.signal});if(Be.status===409){const M=Number(Be.headers.get("Upload-Offset")??"-1");if(Number.isFinite(M)&&M>=0){A=M;continue}}if(!Be.ok)throw new Error(`Resumable chunk upload failed: ${Be.status}`);const ie=Number(Be.headers.get("Upload-Offset")??String(H));A=Number.isFinite(ie)&&ie>A?ie:H,$o(k,A),(Z=n.onUploadProgress)==null||Z.call(n,k)}}function E(k,T){const F=[];let D=0,R=0;for(;D<k.size;){const W=Math.min(D+T,k.size);F.push({start:D,end:W,blob:k.slice(D,W),index:R,uploaded:!1}),D=W,R++}return F}async function y(k,T,F,D){const R={...Po(T.headers),"Content-Range":`bytes ${F.start}-${F.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},W=await fetch(T.upload_url,{method:Ys(T),headers:R,body:F.blob,signal:D.signal});if(!W.ok)throw new Error(`Chunk upload failed: ${W.status}`);F.uploaded=!0}async function f(k){return null}async function w(k){if(!a.value)throw new Error("API client not configured");const T=60;let F=0;for(;F<T;){const D=await a.value.get(`/api/v1/video/${k}`),R=Tk(D),W=String(R.processing_status);if(W==="ready")return R;if(W==="failed"||W==="error")throw new Error("Video processing failed");await new Promise(L=>{window.setTimeout(L,5e3)}),F++}throw new Error("Video processing timeout")}function $(k){const T=o.value.get(k);if(!T)return;const F=r.get(k);F&&(F.abort(),r.delete(k));const D=i.get(k);D&&(D.abort(),i.delete(k)),T.status="cancelled",T.error="Upload cancelled",t.value.delete(k)}async function C(k){const T=o.value.get(k);T&&(T.status="pending",T.error="",T.progress=0,T.bytesUploaded=0,await h(T.file))}function b(k){o.value.delete(k),t.value.delete(k),r.delete(k),i.delete(k)}function N(){Array.from(o.value.entries()).forEach(([k,T])=>{T.status==="completed"&&o.value.delete(k)})}function P(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:p,validateFile:m,startUpload:h,cancelUpload:$,retryUpload:C,removeUpload:b,clearCompleted:N,setApiClient:d}}const Pk=["accept","multiple"],$k={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},zk={key:1,class:"upload-list","data-testid":"video-upload-list"},Ak={class:"drag-content"},Dk=e.defineComponent({__name:"VideoUploader",props:{collection:{default:"videos"},multiple:{type:Boolean,default:!1},maxFileSize:{default:5*1024*1024*1024},maxDuration:{},allowedFormats:{default:()=>["video/mp4","video/webm","video/quicktime","video/x-msvideo"]},autoUpload:{type:Boolean,default:!0},resumable:{type:Boolean,default:!0},label:{default:"Upload Video"},description:{default:"Click to select or drag and drop"},ownerUuid:{},ownerType:{},apiClient:{}},emits:["upload-start","upload-progress","upload-complete","upload-error","files-selected"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(),i=e.ref(!1),{uploads:s,isUploading:l,handleFileSelect:c,cancelUpload:d,retryUpload:u,removeUpload:p,setApiClient:m}=Rk({collection:t.collection,...t.ownerUuid!==void 0?{ownerUuid:t.ownerUuid}:{},...t.ownerType!==void 0?{ownerType:t.ownerType}:{},maxFileSize:t.maxFileSize,...t.maxDuration!==void 0?{maxDuration:t.maxDuration}:{},allowedFormats:t.allowedFormats,autoUpload:t.autoUpload,resumable:t.resumable,onUploadStart:f=>a("upload-start",f),onUploadProgress:f=>a("upload-progress",f),onUploadComplete:f=>a("upload-complete",f),onUploadError:(f,w)=>a("upload-error",f,w),onFilesSelected:f=>a("files-selected",f)});t.apiClient&&m(t.apiClient);const h=e.computed(()=>t.allowedFormats.join(",")),g=e.computed(()=>t.multiple||s.value.length===0);function v(){r.value&&r.value.click()}function x(f){const w=f.target,$=Array.from(w.files||[]);$.length>0&&(c($),w.value="")}function B(f){var C;f.preventDefault(),i.value=!1;const $=Array.from(((C=f.dataTransfer)==null?void 0:C.files)||[]).filter(b=>b.type.startsWith("video/"));$.length>0&&c($)}function E(f){var w;f.preventDefault(),(w=f.dataTransfer)!=null&&w.types.includes("Files")&&(i.value=!0)}function y(f){f.target.closest(".video-uploader")||(i.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",E),document.addEventListener("dragleave",y),document.addEventListener("drop",f=>f.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",E),document.removeEventListener("dragleave",y),document.removeEventListener("drop",f=>f.preventDefault())}),(f,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-uploader",{"is-uploading":e.unref(l)}]),"data-testid":"video-uploader"},[e.createElementVNode("input",{ref_key:"fileInputEl",ref:r,type:"file",accept:h.value,multiple:f.multiple,onChange:x,"data-testid":"video-uploader-input",hidden:""},null,40,Pk),!e.unref(l)||g.value?(e.openBlock(),e.createElementBlock("div",$k,[e.renderSlot(f.$slots,"trigger",{open:v},()=>[e.createElementVNode("div",{class:"default-upload-area",onClick:v},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ul),class:"upload-icon"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(f.label),1),e.createElementVNode("p",null,e.toDisplayString(f.description),1),e.createVNode(e.unref(I.IonButton),{size:"small"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ir),slot:"start"},null,8,["icon"]),w[2]||(w[2]=e.createTextVNode(" Select Video ",-1))]),_:1})])],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",zk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),$=>(e.openBlock(),e.createBlock(Nk,{key:$.id,upload:$,onCancel:C=>e.unref(d)($.id),onRetry:C=>e.unref(u)($.id),onRemove:C=>e.unref(p)($.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay",onDrop:B,onDragover:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:w[1]||(w[1]=$=>i.value=!1)},[e.createElementVNode("div",Ak,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(pa)},null,8,["icon"]),w[3]||(w[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Uk=_e(Dk,[["__scopeId","data-v-f74e356b"]]),Ok={class:"progress-bar"},Lk={class:"time-display"},Wk={class:"current-time"},jk={class:"duration"},Xk={class:"control-buttons"},Zk={class:"controls-left"},Yk=["aria-label"],Gk={class:"controls-center"},Hk={key:0,class:"volume-controls"},Jk=["aria-label"],qk=["value"],Kk={class:"controls-right"},Qk={key:0,class:"quality-selector"},ex={class:"quality-label"},tx={key:0,class:"quality-menu"},nx=["onClick"],ox=["aria-label"],ax=e.defineComponent({__name:"VideoControls",props:{playing:{type:Boolean},currentTime:{},duration:{},buffered:{},volume:{default:100},muted:{type:Boolean,default:!1},fullscreen:{type:Boolean,default:!1},isLive:{type:Boolean,default:!1},qualityLevels:{default:()=>[]},currentQuality:{default:"Auto"}},emits:["play-pause","play","pause","seek","skip-forward","skip-backward","toggleMute","setVolume","toggleFullscreen","togglePiP","selectQuality"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!0),i=e.ref(!1),s=e.ref(),l=I.isPlatform("mobile"),c="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),p=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let f=0;f<t.buffered.length;f++){const w=t.buffered.start(f),$=t.buffered.end(f);if(t.currentTime>=w&&t.currentTime<=$)return{width:`${$/t.duration*100}%`}}return t.buffered.length>0?{width:`${t.buffered.end(0)/t.duration*100}%`}:{width:"0%"}}),m=e.computed(()=>t.muted||t.volume===0?am:t.volume<33?tm:t.volume<66?nm:em);let h=null;function g(){r.value=!0,v()}function v(){h&&clearTimeout(h),t.playing&&!l&&(h=setTimeout(()=>{r.value=!1},3e3))}function x(f){if(!s.value||t.isLive)return;const w=s.value.getBoundingClientRect(),C=(f.clientX-w.left)/w.width*t.duration;a("seek",Math.max(0,Math.min(C,t.duration)))}function B(f){const w=f.target;a("setVolume",parseInt(w.value))}function E(f){a("selectQuality",f),i.value=!1}function y(f){if(!isFinite(f))return"0:00";const w=Math.floor(f/3600),$=Math.floor(f%3600/60),C=Math.floor(f%60);return w>0?`${w}:${$.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`:`${$}:${C.toString().padStart(2,"0")}`}return e.onMounted(()=>{document.addEventListener("mousemove",g),v()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",g),h&&clearTimeout(h)}),(f,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":r.value}])},[e.createElementVNode("div",{class:"progress-container",onClick:x},[e.createElementVNode("div",Ok,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(p.value)},null,4),e.createElementVNode("div",{class:"progress-played",style:e.normalizeStyle(d.value)},null,4),e.createElementVNode("div",{class:"progress-thumb",style:e.normalizeStyle(u.value)},null,4)]),e.createElementVNode("div",Lk,[e.createElementVNode("span",Wk,e.toDisplayString(y(f.currentTime)),1),w[7]||(w[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",jk,e.toDisplayString(f.isLive?"LIVE":y(f.duration)),1)])]),e.createElementVNode("div",Xk,[e.createElementVNode("div",Zk,[e.createElementVNode("button",{class:"control-btn play-pause",onClick:w[0]||(w[0]=$=>f.$emit("play-pause")),"aria-label":f.playing?"Pause":"Play"},[e.createVNode(e.unref(I.IonIcon),{icon:f.playing?e.unref(zu):e.unref(Uu)},null,8,["icon"])],8,Yk),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward",onClick:w[1]||(w[1]=$=>f.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ou)},null,8,["icon"]),w[8]||(w[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),f.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward",onClick:w[2]||(w[2]=$=>f.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(ju)},null,8,["icon"]),w[9]||(w[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",Gk,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Hk,[e.createElementVNode("button",{class:"control-btn mute-btn",onClick:w[3]||(w[3]=$=>f.$emit("toggleMute")),"aria-label":f.muted?"Unmute":"Mute"},[e.createVNode(e.unref(I.IonIcon),{icon:m.value},null,8,["icon"])],8,Jk),e.createElementVNode("input",{type:"range",class:"volume-slider",min:"0",max:"100",value:f.muted?0:f.volume,onInput:B,"aria-label":"Volume"},null,40,qk)]))]),e.createElementVNode("div",Kk,[f.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",Qk,[e.createElementVNode("button",{class:"control-btn quality-btn",onClick:w[4]||(w[4]=$=>i.value=!i.value),"aria-label":"Quality settings"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(qu)},null,8,["icon"]),e.createElementVNode("span",ex,e.toDisplayString(f.currentQuality),1)]),i.value?(e.openBlock(),e.createElementBlock("div",tx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.qualityLevels,$=>(e.openBlock(),e.createElementBlock("button",{key:$.label,class:e.normalizeClass(["quality-option",{active:$.label===f.currentQuality}]),onClick:C=>E($)},e.toDisplayString($.label),11,nx))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&c?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn",onClick:w[5]||(w[5]=$=>f.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Ku)},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn",onClick:w[6]||(w[6]=$=>f.$emit("toggleFullscreen")),"aria-label":f.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(I.IonIcon),{icon:f.fullscreen?e.unref(Nu):e.unref(Mu)},null,8,["icon"])],8,ox)])])],2))}}),rx=_e(ax,[["__scopeId","data-v-2b2ef5f6"]]);function ix(n={}){var me,Te,Be;const o=e.ref(),t=e.ref(),a=e.ref(!1),r=e.ref(0),i=e.ref(0),s=e.ref(100),l=e.ref(n.muted||!1),c=e.ref(!1),d=e.ref(),u=e.ref(1),p=e.ref(!1),m=e.ref(null),h=e.ref("idle"),g=e.ref(n.playbackUrl||((me=n.media)==null?void 0:me.playback_url)||((Te=n.media)==null?void 0:Te.url)||""),v=e.ref(null),x=e.ref(n.isLive||!1),B=e.ref(null),E=e.ref(null);function y(ie){E.value=ie}if((Be=n.media)!=null&&Be.token_expires_at){const ie=new Date(n.media.token_expires_at);v.value=Number.isNaN(ie.getTime())?null:ie}async function f(){var M;const ie=x.value?t.value:o.value;if(ie)try{await ie.play(),a.value=!0,h.value=x.value?"live":"playing",(M=n.onPlay)==null||M.call(n)}catch{m.value="Failed to play video",h.value="error"}}function w(){var M;const ie=x.value?t.value:o.value;ie&&(ie.pause(),a.value=!1,h.value="paused",(M=n.onPause)==null||M.call(n))}function $(){a.value?w():f()}function C(ie){const M=x.value?t.value:o.value;if(!M||x.value)return;const j=Number.isFinite(M.duration)?M.duration:ie;M.currentTime=Math.max(0,Math.min(ie,j)),r.value=M.currentTime}function b(ie=10){const M=o.value;!M||x.value||C(M.currentTime+ie)}function N(ie=10){const M=o.value;!M||x.value||C(M.currentTime-ie)}function P(){const ie=x.value?t.value:o.value;ie&&(ie.muted=!ie.muted,l.value=ie.muted)}function k(ie){const M=x.value?t.value:o.value;if(!M)return;const j=Math.max(0,Math.min(100,ie));M.volume=j/100,s.value=j,j>0&&M.muted&&(M.muted=!1,l.value=!1)}function T(ie){const M=o.value;!M||x.value||(M.playbackRate=ie,u.value=ie)}async function F(){const ie=document.querySelector(".video-player-container");if(ie)try{document.fullscreenElement?(await document.exitFullscreen(),c.value=!1):(await ie.requestFullscreen(),c.value=!0)}catch{}}async function D(){const ie=x.value?t.value:o.value;if(ie)try{document.pictureInPictureElement?await document.exitPictureInPicture():document.pictureInPictureEnabled&&await ie.requestPictureInPicture()}catch{}}async function R(){var M;m.value=null,h.value="loading",(M=n.media)!=null&&M.provider&&n.media.provider!=="local"&&await W();const ie=x.value?t.value:o.value;ie&&(ie.load(),await f())}async function W(){if(!(!E.value||!n.media))try{p.value=!0;const ie=await E.value.get(`/api/v1/video/${n.media.uuid}/playback`);g.value=ie.playback_url,v.value=new Date(ie.token_expires_at);const M=x.value?t.value:o.value;if(M&&M.src!==g.value){const j=!M.paused,te=M.currentTime;M.src=g.value,x.value||(M.currentTime=te),j&&await f()}}catch{m.value="Failed to refresh playback token",h.value="error"}finally{p.value=!1}}async function L(ie){if(t.value){if(t.value.canPlayType("application/vnd.apple.mpegurl")){t.value.src=ie;return}try{t.value.src=ie}catch{m.value="Live streaming not supported in this browser",h.value="error"}}}function _(){B.value&&(B.value.destroy(),B.value=null)}function A(){var M;const ie=x.value?t.value:o.value;ie&&(r.value=ie.currentTime,i.value=ie.duration,(M=n.onTimeUpdate)==null||M.call(n,ie.currentTime))}const Z=e.computed(()=>{if(!d.value||d.value.length===0||!i.value)return 0;for(let ie=0;ie<d.value.length;ie++){const M=d.value.start(ie),j=d.value.end(ie);if(r.value>=M&&r.value<=j)return j/i.value*100}return 0});function H(){if(!v.value)return!1;const ie=new Date;return v.value.getTime()-ie.getTime()<5*60*1e3}return e.watch([o,t],([ie,M])=>{const j=x.value?M:ie;j&&(j.addEventListener("timeupdate",A),j.addEventListener("loadedmetadata",()=>{i.value=j.duration,h.value="ready"}),j.addEventListener("progress",()=>{d.value=j.buffered}),j.addEventListener("ended",()=>{var te;a.value=!1,h.value="ended",(te=n.onEnded)==null||te.call(n)}),j.addEventListener("error",te=>{var ae;h.value="error",(ae=n.onError)==null||ae.call(n,"Video playback error")}),j.volume=s.value/100,j.muted=l.value)}),e.onUnmounted(()=>{_();const ie=x.value?t.value:o.value;ie&&ie.removeEventListener("timeupdate",A)}),{videoEl:o,liveVideoEl:t,playing:a,currentTime:r,duration:i,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:Z,playbackRate:u,isLoading:p,error:m,status:h,currentPlaybackUrl:g,tokenExpiresAt:v,play:f,pause:w,togglePlayPause:$,seek:C,skipForward:b,skipBackward:N,toggleMute:P,setVolume:k,setPlaybackRate:T,toggleFullscreen:F,togglePiP:D,retry:R,refreshToken:W,setupLiveStream:L,setApiClient:y,shouldRefreshToken:H}}const sx=["src","poster","controls","autoplay","muted","loop","preload"],lx={key:1,ref:"livePlayerEl",class:"live-player"},cx=["controls","muted"],dx={key:0,class:"live-indicator"},ux={key:2,class:"video-loading"},mx={key:3,class:"video-error"},px={key:5,class:"gesture-zones"},fx=e.defineComponent({__name:"VideoPlayer",props:{media:{},playbackUrl:{},apiClient:{},isLive:{type:Boolean,default:!1},controls:{type:Boolean,default:!0},autoplay:{type:Boolean,default:!1},muted:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},poster:{},preload:{default:"metadata"},showCustomControls:{type:Boolean,default:!1},enableGestures:{type:Boolean,default:!0},className:{},crossorigin:{}},emits:["play","pause","ended","error","timeupdate","loadedmetadata","progress"],setup(n,{emit:o}){const t=n,a=o,{videoEl:r,liveVideoEl:i,playing:s,currentTime:l,duration:c,volume:d,muted:u,isFullscreen:p,bufferedRanges:m,isLoading:h,error:g,status:v,currentPlaybackUrl:x,tokenExpiresAt:B,play:E,pause:y,seek:f,toggleMute:w,setVolume:$,toggleFullscreen:C,togglePlayPause:b,skipForward:N,skipBackward:P,retry:k,refreshToken:T,setApiClient:F,shouldRefreshToken:D,setupLiveStream:R}=ix({...t.media!==void 0?{media:t.media}:{},...t.playbackUrl!==void 0?{playbackUrl:t.playbackUrl}:{},isLive:t.isLive??!1,autoplay:t.autoplay??!1,muted:t.muted??!1});async function W(){await T()}const L=e.computed(()=>{const ae=["video-player-container"];return t.className&&ae.push(t.className),p.value&&ae.push("fullscreen"),t.isLive&&ae.push("is-live"),s.value&&ae.push("is-playing"),h.value&&ae.push("is-loading"),ae}),_=e.computed(()=>{var ae,re;if(t.poster)return t.poster;if((ae=t.media)!=null&&ae.poster_url)return t.media.poster_url;if((re=t.media)!=null&&re.thumbnail_url)return t.media.thumbnail_url});function A(ae){const re=ae.target;a("loadedmetadata",{duration:re.duration,width:re.videoWidth,height:re.videoHeight})}function Z(ae){const re=ae.target;l.value=re.currentTime,a("timeupdate",re.currentTime)}function H(){s.value=!0,a("play")}function me(){s.value=!1,a("pause")}function Te(){s.value=!1,a("ended")}function Be(ae){const re=ae.target;let q="Failed to load video";if(re.error)switch(re.error.code){case re.error.MEDIA_ERR_ABORTED:q="Video playback aborted";break;case re.error.MEDIA_ERR_NETWORK:q="Network error while loading video";break;case re.error.MEDIA_ERR_DECODE:q="Video decoding error";break;case re.error.MEDIA_ERR_SRC_NOT_SUPPORTED:q="Video format not supported";break}g.value=q,a("error",q)}function ie(ae){const re=ae.target;m.value=re.buffered,a("progress",re.buffered)}function M(){h.value=!0}function j(){h.value=!1}e.watch(()=>t.apiClient,ae=>{ae&&F(ae)},{immediate:!0}),e.watch(()=>t.playbackUrl,ae=>{typeof ae=="string"&&ae.length>0&&(x.value=ae)},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.token_expires_at},ae=>{if(!ae){B.value=null;return}const re=new Date(ae);B.value=Number.isNaN(re.getTime())?null:re},{immediate:!0}),e.watch(()=>{var ae;return(ae=t.media)==null?void 0:ae.playback_url},async(ae,re)=>{if(t.playbackUrl||!ae||ae===re)return;const q=r.value;if(!q||t.isLive){x.value=ae;return}const ue=!q.paused,ve=q.currentTime;x.value=ae,await e.nextTick();try{q.currentTime=ve}catch{}ue&&await E()},{immediate:!0});let te=null;return e.watch(()=>t.isLive,async ae=>{var q;if(!ae)return;const re=t.playbackUrl||((q=t.media)==null?void 0:q.playback_url)||"";re&&await R(re)},{immediate:!0}),e.onMounted(()=>{var ae;(ae=t.media)!=null&&ae.provider&&t.media.provider!=="local"&&(te=setInterval(()=>{D()&&W()},3e4)),I.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{te&&clearInterval(te)}),(ae,re)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",L.value]),"data-testid":"video-player"},[ae.isLive?(e.openBlock(),e.createElementBlock("div",lx,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:i,controls:ae.controls&&!ae.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:H,onPause:me,onError:Be,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,cx),e.unref(v)==="live"?(e.openBlock(),e.createElementBlock("div",dx,[...re[3]||(re[3]=[e.createElementVNode("span",{class:"live-dot"},null,-1),e.createElementVNode("span",{class:"live-text"},"LIVE",-1)])])):e.createCommentVNode("",!0)],512)):(e.openBlock(),e.createElementBlock("video",{key:0,ref_key:"videoEl",ref:r,src:e.unref(x),poster:_.value,controls:ae.controls&&!ae.showCustomControls,autoplay:ae.autoplay,muted:e.unref(u),loop:ae.loop,preload:ae.preload,onLoadedmetadata:A,onTimeupdate:Z,onPlay:H,onPause:me,onEnded:Te,onError:Be,onProgress:ie,onWaiting:M,onCanplay:j,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,sx)),e.unref(h)?(e.openBlock(),e.createElementBlock("div",ux,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("div",mx,[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(g)),1),e.createVNode(e.unref(I.IonButton),{size:"small",onClick:e.unref(k)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{icon:e.unref(co),slot:"start"},null,8,["icon"]),re[4]||(re[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ae.showCustomControls&&!e.unref(g)?(e.openBlock(),e.createBlock(rx,{key:4,playing:e.unref(s),currentTime:e.unref(l),duration:e.unref(c),buffered:e.unref(m),volume:e.unref(d),muted:e.unref(u),fullscreen:e.unref(p),isLive:ae.isLive,onPlay:e.unref(E),onPause:e.unref(y),onSeek:e.unref(f),onToggleMute:e.unref(w),onSetVolume:e.unref($),onToggleFullscreen:e.unref(C),class:"custom-controls"},null,8,["playing","currentTime","duration","buffered","volume","muted","fullscreen","isLive","onPlay","onPause","onSeek","onToggleMute","onSetVolume","onToggleFullscreen"])):e.createCommentVNode("",!0),ae.enableGestures&&!e.unref(g)?(e.openBlock(),e.createElementBlock("div",px,[e.createElementVNode("div",{class:"gesture-left",onDblclick:re[0]||(re[0]=(...q)=>e.unref(P)&&e.unref(P)(...q))},null,32),e.createElementVNode("div",{class:"gesture-center",onClick:re[1]||(re[1]=(...q)=>e.unref(b)&&e.unref(b)(...q))}),e.createElementVNode("div",{class:"gesture-right",onDblclick:re[2]||(re[2]=(...q)=>e.unref(N)&&e.unref(N)(...q))},null,32)])):e.createCommentVNode("",!0)],2))}}),yc=_e(fx,[["__scopeId","data-v-110956e0"]]),hx=ma.defineStore("video",()=>{const n=e.ref(new Map),o=e.ref(new Map),t=e.ref(new Map),a=e.ref(null),r=e.ref(!1),i=e.computed(()=>Array.from(n.value.values())),s=e.computed(()=>Array.from(o.value.values())),l=e.computed(()=>s.value.filter(R=>R.status==="live")),c=e.computed(()=>i.value.filter(R=>R.processing_status==="processing"));function d(R){n.value.set(R.uuid,R)}function u(R,W){const L=n.value.get(R);L&&n.value.set(R,{...L,...W})}function p(R){n.value.delete(R)}function m(R){return n.value.get(R)}function h(R){o.value.set(R.id,R)}function g(R,W){const L=o.value.get(R);L&&o.value.set(R,{...L,...W})}function v(R,W){const L=o.value.get(R);L&&o.value.set(R,{...L,status:W.status,viewer_count:W.viewer_count,peak_viewers:W.peak_viewers})}function x(R){o.value.delete(R)}function B(R){return o.value.get(R)}function E(R){return s.value.find(W=>W.media_uuid===R)}function y(R){t.value.set(R.id,R)}function f(R,W){const L=t.value.get(R);L&&t.value.set(R,{...L,...W})}function w(R){t.value.delete(R)}function $(R){return t.value.get(R)}function C(R){return Array.from(t.value.values()).filter(W=>W.media_uuid===R)}function b(R){a.value=R}function N(R){a.value&&(a.value={...a.value,...R})}function P(){a.value=null}function k(R){r.value=R}function T(){n.value.clear(),o.value.clear(),t.value.clear(),a.value=null,r.value=!1}function F(R){n.value.clear(),R.forEach(W=>{n.value.set(W.uuid,W)})}function D(R){o.value.clear(),R.forEach(W=>{o.value.set(W.id,W)})}return{videos:n,liveStreams:o,exportJobs:t,currentEditorState:a,isProcessing:r,allVideos:i,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:p,getVideo:m,setLiveStream:h,updateLiveStream:g,updateLiveStreamStats:v,removeLiveStream:x,getLiveStream:B,getLiveStreamByMedia:E,addExportJob:y,updateExportJob:f,removeExportJob:w,getExportJob:$,getExportJobsByMedia:C,setEditorState:b,updateEditorState:N,clearEditorState:P,setProcessing:k,clearAll:T,loadVideos:F,loadLiveStreams:D}});let on=null;function vx(n){on=n}const zo={post:async(n,o)=>{if(!on)throw new Error("HTTP client not configured");return await on(`/api/v1/video${n}`,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}})},get:async n=>{if(!on)throw new Error("HTTP client not configured");return await on(`/api/v1/video${n}`)},delete:async n=>{if(!on)throw new Error("HTTP client not configured");return await on(`/api/v1/video${n}`,{method:"DELETE"})}};function Ao(n,o=null){const t=typeof n.id=="string"&&n.id!==""?n.id:typeof n.stream_id=="string"&&n.stream_id!==""?n.stream_id:o==null?void 0:o.id;if(!t)throw new Error("Invalid live stream response: missing stream id");const a={id:t,media_uuid:n.media_uuid??(o==null?void 0:o.media_uuid)??"",stream_key:n.stream_key??(o==null?void 0:o.stream_key)??"",rtmp_url:n.rtmp_url??(o==null?void 0:o.rtmp_url)??"",status:n.status??(o==null?void 0:o.status)??"idle",viewer_count:n.viewer_count??(o==null?void 0:o.viewer_count)??0,peak_viewers:n.peak_viewers??(o==null?void 0:o.peak_viewers)??0,auto_record:n.auto_record??(o==null?void 0:o.auto_record)??!0,low_latency:n.low_latency??(o==null?void 0:o.low_latency)??!1},r=n.playback_url??(o==null?void 0:o.playback_url);r!==void 0&&(a.playback_url=r);const i=n.started_at??(o==null?void 0:o.started_at);i!==void 0&&(a.started_at=i);const s=n.ended_at??(o==null?void 0:o.ended_at);return s!==void 0&&(a.ended_at=s),(o==null?void 0:o.metadata)!==void 0&&(a.metadata=o.metadata),(o==null?void 0:o.vod_media_uuid)!==void 0&&(a.vod_media_uuid=o.vod_media_uuid),a}function dr(n,o){return n instanceof Error&&n.message?n.message:o}function gx(n){const o=hx(),t=e.ref(null),a=e.ref(!1),r=e.ref(!0),i=e.ref(""),s=e.ref(!1),l=e.ref(!1),c=e.ref(null),d=e.ref(null),u=e.ref(0),p=e.ref(0);let m;const h=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),g=e.computed(()=>{var P;if(!((P=t.value)!=null&&P.playback_url))return null;const N=new URL(t.value.playback_url);return N.searchParams.set("live","true"),a.value&&N.searchParams.set("latency","low"),N.toString()}),v=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="live"}),x=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="idle"}),B=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="ended"});async function E(N={}){s.value=!0,c.value=null;try{const P=await zo.post("/live",{title:i.value||N.title||"Live Stream",low_latency:N.low_latency??a.value,auto_record:N.auto_record??r.value,...N}),k=Ao(P);return t.value=k,o.setLiveStream(k),$(),k}catch(P){throw c.value=dr(P,"Failed to create stream"),P instanceof Error?P:new Error(c.value)}finally{s.value=!1}}async function y(){if(!t.value)throw new Error("No active stream");l.value=!0,c.value=null;try{const N=await zo.post(`/live/${t.value.id}/end`),P=Ao(N,t.value);return t.value=P,o.setLiveStream(P),C(),P}catch(N){throw c.value=dr(N,"Failed to end stream"),N instanceof Error?N:new Error(c.value)}finally{l.value=!1}}async function f(){if(t.value)try{const N=await zo.get(`/live/${t.value.id}`),P=Ao(N,t.value);u.value=P.viewer_count,p.value=P.peak_viewers,t.value=P;const k={status:P.status,viewer_count:P.viewer_count,peak_viewers:P.peak_viewers};P.started_at&&(k.started_at=P.started_at),P.ended_at&&(k.ended_at=P.ended_at),o.updateLiveStreamStats(P.id,k),P.status==="live"&&!d.value&&P.started_at&&(d.value=new Date(P.started_at)),P.status==="ended"&&C()}catch{}}async function w(N){try{const P=await zo.get(`/live/${N}`),k=Ao(P,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(P){throw c.value=dr(P,"Failed to get stream credentials"),P instanceof Error?P:new Error(c.value)}}function $(N=5e3){C(),m=window.setInterval(()=>{f()},N)}function C(){m!==void 0&&(clearInterval(m),m=void 0)}async function b(){if(!n)return;const N=o.getLiveStreamByMedia(n);N&&(t.value=N,u.value=N.viewer_count,p.value=N.peak_viewers,N.status==="live"&&($(),N.started_at&&(d.value=new Date(N.started_at))))}return n&&b(),e.onUnmounted(()=>{C()}),{stream:t,lowLatency:a,autoRecord:r,streamTitle:i,isCreating:s,isEnding:l,error:c,streamDuration:h,viewerCount:u,peakViewers:p,playbackUrl:g,isLive:v,isIdle:x,hasEnded:B,createStream:E,endStream:y,refreshStreamStatus:f,getStreamCredentials:w,startStatusPolling:$,stopStatusPolling:C}}const yx={class:"stream-status"},bx={class:"flex items-center justify-between"},wx={class:"flex items-center gap-3"},kx={key:0,class:"flex items-center"},xx={key:2,class:"text-sm text-gray-600"},Sx={key:0,class:"flex items-center gap-2"},Ex={class:"text-sm font-medium text-gray-700"},Cx={key:0,class:"text-xs text-gray-500"},Vx=e.defineComponent({__name:"StreamStatus",props:{status:{},viewers:{},peakViewers:{},duration:{}},setup(n){const o=n,t=e.computed(()=>({idle:"Ready to Stream",live:"Live",ended:"Stream Ended",error:"Error"})[o.status]||o.status),a=e.computed(()=>{const i="px-3 py-1 rounded-full text-xs font-semibold uppercase",s={idle:"bg-gray-100 text-gray-700",live:"bg-red-100 text-red-700",ended:"bg-blue-100 text-blue-700",error:"bg-yellow-100 text-yellow-700"};return`${i} ${s[o.status]||s.idle}`}),r=e.computed(()=>{if(!o.duration)return null;const i=Math.floor(o.duration/3600),s=Math.floor(o.duration%3600/60),l=o.duration%60;return i>0?`${i}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`:`${s}:${l.toString().padStart(2,"0")}`});return(i,s)=>(e.openBlock(),e.createElementBlock("div",yx,[e.createElementVNode("div",bx,[e.createElementVNode("div",wx,[i.status==="live"?(e.openBlock(),e.createElementBlock("div",kx,[...s[0]||(s[0]=[e.createElementVNode("span",{class:"relative flex h-3 w-3"},[e.createElementVNode("span",{class:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.createElementVNode("span",{class:"relative inline-flex rounded-full h-3 w-3 bg-red-500"})],-1),e.createElementVNode("span",{class:"ml-2 text-sm font-semibold text-red-600 uppercase"},"Live",-1)])])):(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(a.value)},e.toDisplayString(t.value),3)),r.value?(e.openBlock(),e.createElementBlock("div",xx,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)]),i.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",Sx,[s[1]||(s[1]=e.createElementVNode("svg",{class:"w-4 h-4 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20"},[e.createElementVNode("path",{d:"M10 12a2 2 0 100-4 2 2 0 000 4z"}),e.createElementVNode("path",{"fill-rule":"evenodd",d:"M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z","clip-rule":"evenodd"})],-1)),e.createElementVNode("span",Ex,e.toDisplayString(i.viewers)+" "+e.toDisplayString(i.viewers===1?"viewer":"viewers"),1),i.peakViewers>i.viewers?(e.openBlock(),e.createElementBlock("span",Cx," (Peak: "+e.toDisplayString(i.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),Nx=_e(Vx,[["__scopeId","data-v-1d09c19f"]]),_x={class:"stream-credentials"},Tx={class:"space-y-3"},Mx={class:"credential-field"},Fx={class:"flex gap-2"},Ix=["value"],Bx={class:"credential-field"},Rx={class:"flex gap-2"},Px=["value","type"],$x=["aria-label"],zx={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ax={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Dx={key:0,class:"mt-2 text-sm text-green-600"},Ux=e.defineComponent({__name:"StreamCredentials",props:{rtmpUrl:{},streamKey:{}},emits:["copy"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.ref(""),s=e.computed(()=>{if(r.value)return t.streamKey;if(t.streamKey.length>8){const d=t.streamKey.slice(0,4),u=t.streamKey.slice(-4);return`${d}${"•".repeat(16)}${u}`}return"•".repeat(t.streamKey.length)});function l(){r.value=!r.value}async function c(d,u){try{await navigator.clipboard.writeText(d),i.value=u,a("copy",d,u),setTimeout(()=>{i.value=""},2e3)}catch{}}return(d,u)=>(e.openBlock(),e.createElementBlock("div",_x,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",Tx,[e.createElementVNode("div",Mx,[u[3]||(u[3]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"RTMP Server URL",-1)),e.createElementVNode("div",Fx,[e.createElementVNode("input",{value:d.rtmpUrl,readonly:"",type:"text",class:"flex-1 px-3 py-2 bg-gray-50 border border-gray-200 rounded-md text-sm font-mono text-gray-700","aria-label":"RTMP server URL"},null,8,Ix),e.createElementVNode("button",{onClick:u[0]||(u[0]=p=>c(d.rtmpUrl,"RTMP URL")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy RTMP URL"},[...u[2]||(u[2]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])]),e.createElementVNode("div",Bx,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",Rx,[e.createElementVNode("input",{value:s.value,readonly:"",type:r.value?"text":"password",class:"flex-1 px-3 py-2 bg-gray-50 border border-gray-200 rounded-md text-sm font-mono text-gray-700","aria-label":"Stream key"},null,8,Px),e.createElementVNode("button",{onClick:l,class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":r.value?"Hide stream key":"Show stream key"},[r.value?(e.openBlock(),e.createElementBlock("svg",Ax,[...u[5]||(u[5]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",zx,[...u[4]||(u[4]=[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},null,-1),e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"},null,-1)])]))],8,$x),e.createElementVNode("button",{onClick:u[1]||(u[1]=p=>c(d.streamKey,"Stream Key")),class:"px-3 py-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors","aria-label":"Copy stream key"},[...u[6]||(u[6]=[e.createElementVNode("svg",{class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})],-1)])])])])]),u[9]||(u[9]=e.createElementVNode("details",{class:"mt-4"},[e.createElementVNode("summary",{class:"cursor-pointer text-sm text-blue-600 hover:text-blue-700"}," How to connect with OBS Studio "),e.createElementVNode("div",{class:"mt-2 p-3 bg-blue-50 rounded-md text-sm text-gray-700"},[e.createElementVNode("ol",{class:"list-decimal list-inside space-y-1"},[e.createElementVNode("li",null,"Open OBS Studio"),e.createElementVNode("li",null,"Go to Settings → Stream"),e.createElementVNode("li",null,'Set Service to "Custom"'),e.createElementVNode("li",null,'Paste the RTMP URL in "Server"'),e.createElementVNode("li",null,'Paste the Stream Key in "Stream Key"'),e.createElementVNode("li",null,'Click OK and then "Start Streaming"')])])],-1)),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createElementBlock("div",Dx,e.toDisplayString(i.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),Ox=_e(Ux,[["__scopeId","data-v-306d92f6"]]),Lx={class:"live-stream-manager","data-testid":"live-stream-manager"},Wx={key:0,class:"stream-setup"},jx={class:"space-y-4"},Xx={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},Zx={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},Yx=["disabled"],Gx={key:0},Hx={key:1,class:"flex items-center justify-center"},Jx={key:1,class:"stream-active space-y-6"},qx={key:1,class:"video-preview"},Kx={key:2,class:"analytics-panel"},Qx={class:"grid grid-cols-2 gap-4"},eS={class:"bg-gray-50 p-3 rounded"},tS={class:"text-2xl font-bold text-gray-900"},nS={class:"bg-gray-50 p-3 rounded"},oS={class:"text-2xl font-bold text-gray-900"},aS={class:"stream-controls flex gap-3"},rS=["disabled"],iS={key:0},sS={key:1},lS={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},cS={class:"text-red-600 text-sm"},dS=e.defineComponent({__name:"LiveStreamManager",props:{mediaUuid:{},onStreamCreated:{type:Function},onStreamEnded:{type:Function},httpClient:{type:Function}},emits:["stream-created","stream-ended","error"],setup(n,{emit:o}){const t=n,a=o;t.httpClient&&vx(t.httpClient);const{stream:r,lowLatency:i,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:p,endStream:m,streamDuration:h,playbackUrl:g,refreshStreamStatus:v}=gx(t.mediaUuid),x=e.ref(!1);async function B(){var $;try{const C=await p({title:l.value,low_latency:i.value,auto_record:s.value});a("stream-created",C),($=t.onStreamCreated)==null||$.call(t,C)}catch(C){a("error",C)}}async function E(){var $;try{const C=await m();a("stream-ended",C),($=t.onStreamEnded)==null||$.call(t,C)}catch(C){a("error",C)}}function y(){r.value=null,l.value="",x.value=!1,u.value=null}async function f($,C){try{await navigator.clipboard.writeText($)}catch{}}let w;return e.onMounted(()=>{var $;(($=r.value)==null?void 0:$.status)==="live"&&(w=window.setInterval(()=>{v()},5e3))}),e.onUnmounted(()=>{w&&clearInterval(w)}),($,C)=>(e.openBlock(),e.createElementBlock("div",Lx,[e.unref(r)?(e.openBlock(),e.createElementBlock("div",Jx,[e.createVNode(Nx,{status:e.unref(r).status,viewers:e.unref(r).viewer_count,duration:e.unref(h),"peak-viewers":e.unref(r).peak_viewers},null,8,["status","viewers","duration","peak-viewers"]),e.unref(r).status==="idle"?(e.openBlock(),e.createBlock(Ox,{key:0,"rtmp-url":e.unref(r).rtmp_url,"stream-key":e.unref(r).stream_key,onCopy:f},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("div",qx,[C[9]||(C[9]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-2"},"Live Preview",-1)),e.createVNode(yc,{"playback-url":e.unref(g),"is-live":!0,muted:!0,controls:!1,class:"w-full rounded-lg overflow-hidden"},null,8,["playback-url"])])):e.createCommentVNode("",!0),e.unref(r).status==="live"?(e.openBlock(),e.createElementBlock("div",Kx,[C[12]||(C[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",Qx,[e.createElementVNode("div",eS,[e.createElementVNode("div",tS,e.toDisplayString(e.unref(r).viewer_count),1),C[10]||(C[10]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Current Viewers",-1))]),e.createElementVNode("div",nS,[e.createElementVNode("div",oS,e.toDisplayString(e.unref(r).peak_viewers),1),C[11]||(C[11]=e.createElementVNode("div",{class:"text-xs text-gray-500"},"Peak Viewers",-1))])])])):e.createCommentVNode("",!0),e.createElementVNode("div",aS,[e.unref(r).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C[3]||(C[3]=b=>x.value=!x.value),class:"flex-1 py-2 px-4 bg-gray-200 text-gray-700 font-medium rounded-lg hover:bg-gray-300 transition-colors"},e.toDisplayString(x.value?"Hide":"Show")+" Credentials ",1)):e.createCommentVNode("",!0),e.unref(r).status==="live"?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:E,disabled:e.unref(d),class:"flex-1 py-2 px-4 bg-red-600 text-white font-medium rounded-lg hover:bg-red-700 disabled:opacity-50 transition-colors","aria-label":"End live stream"},[e.unref(d)?(e.openBlock(),e.createElementBlock("span",sS,"Ending...")):(e.openBlock(),e.createElementBlock("span",iS,"End Stream"))],8,rS)):e.createCommentVNode("",!0),e.unref(r).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:y,class:"flex-1 py-2 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 transition-colors"}," Start New Stream ")):e.createCommentVNode("",!0)])])):(e.openBlock(),e.createElementBlock("div",Wx,[C[8]||(C[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",jx,[e.createElementVNode("div",Xx,[C[4]||(C[4]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Low Latency Mode"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," 5-7 second delay (vs 15-20s standard) ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[0]||(C[0]=b=>e.isRef(i)?i.value=b:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable low latency mode"},null,512),[[e.vModelCheckbox,e.unref(i)]])]),e.createElementVNode("div",Zx,[C[5]||(C[5]=e.createElementVNode("div",{class:"flex-1"},[e.createElementVNode("label",{class:"font-medium text-gray-900"},"Auto-Record Stream"),e.createElementVNode("p",{class:"text-sm text-gray-500 mt-1"}," Save stream as VOD for later viewing ")],-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[1]||(C[1]=b=>e.isRef(s)?s.value=b:null),type:"checkbox",class:"h-5 w-5 text-blue-600 rounded focus:ring-blue-500","aria-label":"Enable auto-recording"},null,512),[[e.vModelCheckbox,e.unref(s)]])]),e.createElementVNode("div",null,[C[6]||(C[6]=e.createElementVNode("label",{for:"stream-title",class:"block text-sm font-medium text-gray-700 mb-2"}," Stream Title (optional) ",-1)),e.withDirectives(e.createElementVNode("input",{id:"stream-title","onUpdate:modelValue":C[2]||(C[2]=b=>e.isRef(l)?l.value=b:null),type:"text",class:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"My Live Stream"},null,512),[[e.vModelText,e.unref(l)]])]),e.createElementVNode("button",{onClick:B,disabled:e.unref(c),class:"w-full py-3 px-4 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"create-stream-button","aria-label":"Create live stream"},[e.unref(c)?(e.openBlock(),e.createElementBlock("span",Hx,[...C[7]||(C[7]=[e.createElementVNode("svg",{class:"animate-spin h-5 w-5 mr-2",viewBox:"0 0 24 24"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4",fill:"none"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})],-1),e.createTextVNode(" Creating... ",-1)])])):(e.openBlock(),e.createElementBlock("span",Gx,"Create Stream"))],8,Yx)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",lS,[e.createElementVNode("p",cS,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),uS=_e(dS,[["__scopeId","data-v-26291f6f"]]),mS={class:"album-tree-node"},pS=["data-album-id","draggable","aria-selected","aria-expanded"],fS={key:1,class:"album-node__chevron-placeholder"},hS={key:2,"data-testid":"media-count",class:"album-node__count"},vS={key:0,class:"album-tree-node__children",role:"group"},gS=16,yS=e.defineComponent({__name:"AlbumTreeNode",props:{album:{},depth:{},selectedId:{},expandedIds:{},focusedId:{},draggable:{type:Boolean},showMediaCount:{type:Boolean},compact:{type:Boolean},dragState:{}},emits:["select","toggle-expand","drag-start","drag-over","drag-leave","drop"],setup(n,{emit:o}){const t=n,a=o,r=e.computed(()=>t.expandedIds.has(t.album.id)),i=e.computed(()=>t.selectedId===t.album.id),s=e.computed(()=>t.focusedId===t.album.id),l=e.computed(()=>t.album.children_count>0),c=e.computed(()=>`${t.depth*gS}px`),d=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var y;return((y=t.dragState)==null?void 0:y.dropTargetId)===t.album.id}),p=e.computed(()=>{var y;return(y=t.dragState)!=null&&y.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const y=["album-node"];return i.value&&y.push("album-node--selected"),s.value&&y.push("album-node--focused"),t.compact&&y.push("album-node--compact"),d.value&&y.push("album-node--dragging"),u.value&&y.push("album-node--drop-target"),p.value&&y.push("album-node--invalid-drop"),y});function h(){a("select",t.album)}function g(y){y.stopPropagation(),a("toggle-expand",t.album.id)}function v(y){t.draggable&&(y.dataTransfer&&(y.dataTransfer.setData("text/plain",t.album.id),y.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function x(y){t.draggable&&(y.preventDefault(),y.dataTransfer&&(y.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function B(){a("drag-leave",t.album.id)}function E(y){t.draggable&&(y.preventDefault(),a("drop",t.album.id))}return(y,f)=>{var $;const w=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",mS,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":y.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:y.draggable,role:"treeitem","aria-selected":i.value,"aria-expanded":l.value?r.value:void 0,onDragstart:v,onDragover:x,onDragleave:B,onDrop:E},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:g},[e.createVNode(e.unref(I.IonIcon),{icon:r.value?e.unref(Eu):e.unref(Cu)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",fS)),e.createVNode(e.unref(I.IonIcon),{icon:e.unref(Bu),class:"album-node__icon"},null,8,["icon"]),e.createElementVNode("span",{"data-testid":"album-name",class:"album-node__name",onClick:h},e.toDisplayString(y.album.name),1),y.showMediaCount?(e.openBlock(),e.createElementBlock("span",hS,e.toDisplayString(y.album.media_count),1)):e.createCommentVNode("",!0)],46,pS),r.value&&(($=y.album.children)!=null&&$.length)?(e.openBlock(),e.createElementBlock("div",vS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.album.children,C=>(e.openBlock(),e.createBlock(w,{key:C.id,album:C,depth:y.depth+1,"selected-id":y.selectedId,"expanded-ids":y.expandedIds,"focused-id":y.focusedId,draggable:y.draggable,"show-media-count":y.showMediaCount,compact:y.compact,onSelect:f[0]||(f[0]=b=>a("select",b)),onToggleExpand:f[1]||(f[1]=b=>a("toggle-expand",b))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),bS=_e(yS,[["__scopeId","data-v-76be65a6"]]),za=ma.defineStore("albums",()=>{const n=e.ref([]),o=e.ref(new Map),t=e.ref(!1),a=e.ref(null),r=e.ref(new Set),i=e.computed(()=>{const f=new Map;return n.value.forEach(w=>f.set(w.id,w)),f}),s=e.computed(()=>n.value.filter(f=>f.parent_id===null));async function l(f){t.value=!0,a.value=null;try{const w=(f==null?void 0:f.parent_id)??null,$=w?`/api/v1/albums?parent_id=${w}`:"/api/v1/albums?parent_id=null",C=await fetch($);if(!C.ok)throw new Error("Failed to fetch albums");((await C.json()).data||[]).forEach(P=>{const k=n.value.findIndex(T=>T.id===P.id);k>=0?n.value[k]=P:n.value.push(P)}),w!==null&&r.value.add(w)}catch(w){a.value=w instanceof Error?w.message:"Unknown error"}finally{t.value=!1}}async function c(f){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${f}`);if(!w.ok)throw new Error("Failed to fetch album");const C=(await w.json()).data,b=n.value.findIndex(N=>N.id===C.id);return b>=0?n.value[b]=C:n.value.push(C),C}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function d(f){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${f}/media`);if(!w.ok)throw new Error("Failed to fetch album media");const C=(await w.json()).data||[];return o.value.set(f,C),C}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function u(f,w){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}/media/reorder`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({media_ids:w})})).ok)throw new Error("Failed to reorder album media");const C=o.value.get(f)||[],b=w.map(N=>C.find(P=>P.uuid===N)).filter(N=>N!==void 0);o.value.set(f,b)}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function p(f){t.value=!0,a.value=null;try{const w=await fetch("/api/v1/albums",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(f)});if(!w.ok)throw new Error("Failed to create album");const C=(await w.json()).data;return n.value.push(C),C}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function m(f,w){t.value=!0,a.value=null;try{const $=await fetch(`/api/v1/albums/${f}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(w)});if(!$.ok)throw new Error("Failed to update album");const b=(await $.json()).data,N=n.value.findIndex(P=>P.id===b.id);return N>=0&&(n.value[N]=b),b}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function h(f){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${f}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const $=n.value.findIndex(C=>C.id===f);$>=0&&n.value.splice($,1),o.value.delete(f)}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}function g(f){return n.value.filter(w=>w.parent_id===f)}function v(f){return r.value.has(f)}function x(f){return o.value.get(f)||[]}async function B(f,w){const $=n.value.findIndex(b=>b.id===f);if($<0)return;const C=n.value[$];n.value[$]={...C,parent_id:w};try{if(!(await fetch(`/api/v1/albums/${f}/move`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({parent_id:w})})).ok)throw new Error("Failed to move album")}catch(b){throw n.value[$]=C,a.value=b instanceof Error?b.message:"Unknown error",b instanceof Error?b:new Error("Failed to move album")}}function E(f){n.value=f}function y(){n.value=[],o.value.clear(),t.value=!1,a.value=null,r.value.clear()}return{albums:n,albumMedia:o,loading:t,error:a,childrenLoadedById:r,albumsById:i,rootAlbums:s,fetchAlbums:l,fetchAlbum:c,fetchAlbumMedia:d,reorderAlbumMedia:u,createAlbum:p,updateAlbum:m,deleteAlbum:h,getChildrenOf:g,childrenLoaded:v,getAlbumMedia:x,moveAlbum:B,setAlbums:E,reset:y}});function bc(){const n=za(),{albums:o,albumsById:t,rootAlbums:a,loading:r,error:i}=ma.storeToRefs(n);async function s(u){await n.fetchAlbums(u)}function l(u){return n.getChildrenOf(u)}function c(u){return n.childrenLoaded(u)}async function d(u,p){await n.moveAlbum(u,p)}return{albums:o,albumsById:t,rootAlbums:a,loading:r,error:i,fetchAlbums:s,getChildrenOf:l,childrenLoaded:c,moveAlbum:d}}function wc(n){const{childrenByParentId:o,onMove:t}=n,a=e.ref({isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null});function r(p,m){if(p===m)return!0;const h=new Set,g=[p];for(;g.length>0;){const v=g.shift();if(!v||h.has(v))continue;h.add(v);const x=o.get(v)||[];for(const B of x){if(B===m)return!0;g.push(B)}}return!1}function i(p,m){return p===m?!1:m===null?!0:!r(p,m)}function s(p){a.value={isDragging:!0,draggedAlbumId:p,dropTargetId:null,dropPosition:null}}function l(){a.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(p){a.value.dropTargetId=p}function d(){a.value.dropTargetId=null,a.value.dropPosition=null}async function u(){const{draggedAlbumId:p,dropTargetId:m}=a.value;if(!p){l();return}if(!i(p,m)){l();return}try{await t(p,m)}finally{l()}}return{dragState:a,isDescendant:r,canDropOn:i,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const wS={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},kS={key:1,"data-testid":"error-state",class:"album-tree__error"},xS={key:2,"data-testid":"empty-state",class:"album-tree__empty"},SS={key:3,class:"album-tree__content",role:"group"},ES=e.defineComponent({__name:"AlbumTree",props:{modelValue:{default:null},expandedIds:{default:()=>[]},draggable:{type:Boolean,default:!0},showMediaCount:{type:Boolean,default:!0},compact:{type:Boolean,default:!1}},emits:["update:modelValue","album-selected","album-moved","album-expanded","album-collapsed"],setup(n,{expose:o,emit:t}){const a=n,r=t,i=e.computed(()=>a.draggable===!0),s=e.computed(()=>a.showMediaCount===!0),l=e.computed(()=>a.compact===!0),{albums:c,rootAlbums:d,loading:u,error:p,fetchAlbums:m,getChildrenOf:h,childrenLoaded:g,moveAlbum:v}=bc(),x=e.shallowRef(new Set(a.expandedIds)),B=e.ref(a.modelValue??null),E=e.ref(null),y=new Map,f=new Map;function w(M){y.clear(),f.clear();for(const j of M){y.set(j.id,j);const te=j.parent_id??null,ae=f.get(te)??[];ae.push(j.id),f.set(te,ae)}}e.watch(c,M=>{w(M)},{immediate:!0});const{dragState:$,canDropOn:C,startDrag:b,endDrag:N,setDropTarget:P,clearDropTarget:k,executeDrop:T}=wc({childrenByParentId:f,onMove:async(M,j)=>{await v(M,j),r("album-moved",{albumId:M,newParentId:j})}});e.watch(()=>a.modelValue,M=>{B.value=M??null}),e.watch(()=>a.expandedIds,M=>{x.value=new Set(M)}),e.onMounted(async()=>{await m({parent_id:null})});const F=e.computed(()=>d.value.map(M=>D(M)));function D(M){if(!x.value.has(M.id))return M;const j=h(M.id);return{...M,children:j.map(te=>D(te))}}const R=e.computed(()=>{const M=[];function j(te){var ae;for(const re of te)M.push(re),x.value.has(re.id)&&((ae=re.children)!=null&&ae.length)&&j(re.children)}return j(F.value),M});function W(M){var ae;if(!R.value.length)return;const j=E.value?R.value.findIndex(re=>re.id===E.value):-1,te=j>=0?R.value[j]:null;switch(M.key){case"ArrowDown":M.preventDefault(),j<R.value.length-1?E.value=R.value[j+1].id:j===-1&&R.value.length>0&&(E.value=R.value[0].id);break;case"ArrowUp":M.preventDefault(),j>0&&(E.value=R.value[j-1].id);break;case"ArrowRight":M.preventDefault(),te&&(te.children_count>0&&!x.value.has(te.id)?L(te.id):x.value.has(te.id)&&((ae=te.children)!=null&&ae.length)&&(E.value=te.children[0].id));break;case"ArrowLeft":M.preventDefault(),te&&(x.value.has(te.id)&&te.children_count>0?L(te.id):te.parent_id&&(E.value=te.parent_id));break;case"Enter":case" ":M.preventDefault(),te&&_(te);break;case"Home":M.preventDefault(),R.value.length>0&&(E.value=R.value[0].id);break;case"End":M.preventDefault(),R.value.length>0&&(E.value=R.value[R.value.length-1].id);break}}async function L(M){x.value.has(M)?(x.value.delete(M),r("album-collapsed",M)):(g(M)||await m({parent_id:M}),x.value.add(M),r("album-expanded",M))}function _(M){B.value=M.id,r("update:modelValue",M.id),r("album-selected",M)}function A(M){a.draggable&&b(M)}function Z(M){var te;if(!a.draggable)return;const j=(te=$.value)==null?void 0:te.draggedAlbumId;j&&(P(M),C(j,M))}function H(){a.draggable&&k()}async function me(M){a.draggable&&(P(M),await T())}function Te(M){a.draggable&&(M.preventDefault(),P(null))}async function Be(M){a.draggable&&(M.preventDefault(),P(null),await T())}function ie(){N()}return o({focusedId:E}),(M,j)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:W,onDragover:Te,onDrop:Be,onDragend:ie},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",wS,[e.createVNode(e.unref(I.IonSpinner),{name:"crescent"})])):e.unref(p)?(e.openBlock(),e.createElementBlock("div",kS,[e.createElementVNode("p",null,e.toDisplayString(e.unref(p)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",SS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(F.value,te=>(e.openBlock(),e.createBlock(bS,{key:te.id,album:te,depth:0,"selected-id":B.value,"expanded-ids":x.value,"focused-id":E.value,draggable:i.value,"drag-state":i.value?e.unref($):null,"show-media-count":s.value,compact:l.value,onSelect:_,onToggleExpand:L,onDragStart:A,onDragOver:Z,onDragLeave:H,onDrop:me},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",xS,[j[0]||(j[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(M.$slots,"empty-action",{},void 0,!0)]))],32))}}),kc=_e(ES,[["__scopeId","data-v-ae3dea7a"]]),CS=300,VS=e.defineComponent({__name:"AlbumBrowser",props:{isOpen:{type:Boolean},selectedAlbumId:{default:null},title:{default:"Select Album"},confirmText:{default:"Select"}},emits:["close","confirm"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(t.selectedAlbumId??null),i=e.ref(null),s=e.ref(0),l=e.ref(null);e.watch(()=>t.selectedAlbumId,h=>{r.value=h??null});const c=e.computed(()=>i.value!==null);function d(h){const g=Date.now();if(l.value===h.id&&g-s.value<CS){a("confirm",h);return}s.value=g,l.value=h.id,r.value=h.id,i.value=h}function u(){i.value&&a("confirm",i.value)}function p(){a("close")}function m(){a("close")}return(h,g)=>(e.openBlock(),e.createBlock(e.unref(I.IonModal),{"is-open":h.isOpen,class:"album-browser-modal",onDidDismiss:m},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.title),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-button",onClick:p},{default:e.withCtx(()=>[...g[1]||(g[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(kc,{modelValue:r.value,"onUpdate:modelValue":g[0]||(g[0]=v=>r.value=v),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{fill:"clear",onClick:p},{default:e.withCtx(()=>[...g[2]||(g[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(I.IonButton),{"data-testid":"confirm-button",fill:"solid",color:"primary",disabled:!c.value,onClick:u},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.confirmText),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"]))}}),xc=_e(VS,[["__scopeId","data-v-21676ec1"]]),NS={class:"ion-padding-start text-sm"},_S={class:"ion-padding-start text-sm"},TS={key:1},MS={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},FS={class:"flex items-center justify-between gap-3 pb-3"},IS={class:"text-base font-semibold text-gray-900"},BS={class:"ion-padding-start text-sm"},RS={class:"ion-padding-start text-sm"},PS={class:"flex justify-between pt-2"},$S={key:1},Un=255,On=1e3,zS=e.defineComponent({__name:"AlbumManager",props:{albumId:{default:null},parentId:{default:null},mode:{default:"inline"},isOpen:{type:Boolean,default:!1}},emits:["close","created","updated","deleted","error"],setup(n,{emit:o}){const t=n,a=o,r=za(),i=e.computed(()=>t.albumId!==null&&t.albumId!==void 0),s=e.computed(()=>i.value?"Edit Album":"Create Album"),l=e.computed(()=>i.value?"Save":"Create"),c=e.ref({name:"",description:"",parent_id:t.parentId}),d=e.ref({name:!1,description:!1}),u=e.ref(null),p=e.ref(!1),m=e.ref(null),h=e.ref(!1),g=e.ref(!1),v=e.computed(()=>d.value.name?c.value.name.trim()?c.value.name.length>Un?`Name must be ${Un} characters or less`:null:"Name is required":null),x=e.computed(()=>d.value.description&&c.value.description.length>On?`Description must be ${On} characters or less`:null),B=e.computed(()=>{const W=c.value.name.trim().length>0,L=c.value.name.length<=Un,_=c.value.description.length<=On;return W&&L&&_&&!h.value}),E=e.computed(()=>{var W;return((W=u.value)==null?void 0:W.name)??"None (Root)"}),y=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),f=e.computed(()=>m.value?m.value.children_count>0?"Cannot delete album with child albums. Move or delete children first.":m.value.media_count>0?"Cannot delete album with media. Remove media first.":`Are you sure you want to delete "${m.value.name}"? This action cannot be undone.`:"");e.onMounted(async()=>{t.albumId&&await w()});async function w(){if(t.albumId)try{const W=await r.fetchAlbum(t.albumId);m.value=W,c.value={name:W.name,description:W.description??"",parent_id:W.parent_id},W.parent_id&&(u.value={id:W.parent_id,name:"Parent Album"})}catch(W){a("error",W)}}function $(){d.value.name=!0}function C(){d.value.description=!0}function b(){p.value=!0}function N(W){u.value={id:W.id,name:W.name},c.value.parent_id=W.id,p.value=!1}function P(){p.value=!1}function k(){a("close")}function T(){a("close")}async function F(){if(d.value.name=!0,d.value.description=!0,!(!B.value||h.value)){h.value=!0;try{const W={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(i.value&&t.albumId){const L=await r.updateAlbum(t.albumId,W);a("updated",L)}else{const L=await r.createAlbum(W);a("created",L)}a("close")}catch(W){a("error",W)}finally{h.value=!1}}}function D(){y.value&&(g.value=!0)}async function R(W){var _;if((((_=W.detail)==null?void 0:_.role)??"")!=="confirm"){g.value=!1;return}if(t.albumId){h.value=!0;try{await r.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch(A){a("error",A)}finally{h.value=!1,g.value=!1}}}return(W,L)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[W.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(I.IonModal),{key:0,"is-open":W.isOpen,class:"album-manager-modal",onDidDismiss:T},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...L[4]||(L[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(I.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[5]||(L[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[0]||(L[0]=_=>c.value.name=_),"data-testid":"name-input",maxlength:Un,onIonBlur:$},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",NS,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[6]||(L[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[1]||(L[1]=_=>c.value.description=_),"data-testid":"description-input",maxlength:On,onIonBlur:C},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",_S,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:b},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...L[7]||(L[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(E.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(I.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButtons),{slot:"start"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!y.value,title:y.value?void 0:f.value,onClick:D},{default:e.withCtx(()=>[...L[8]||(L[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(I.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!B.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",TS,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",MS,[e.createElementVNode("div",FS,[e.createElementVNode("h2",IS,e.toDisplayString(s.value),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...L[9]||(L[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(F,["prevent"])},[e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[10]||(L[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(I.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":L[2]||(L[2]=_=>c.value.name=_),"data-testid":"name-input",maxlength:Un,onIonBlur:$},null,8,["modelValue"])]),_:1}),v.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",BS,e.toDisplayString(v.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...L[11]||(L[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(I.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":L[3]||(L[3]=_=>c.value.description=_),"data-testid":"description-input",maxlength:On,onIonBlur:C},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(I.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",RS,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonItem),{button:"","data-testid":"parent-selector",onClick:b},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonLabel),null,{default:e.withCtx(()=>[...L[12]||(L[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(I.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(E.value),1)]),_:1})]),_:1}),e.createElementVNode("div",PS,[e.createElementVNode("div",null,[i.value?(e.openBlock(),e.createBlock(e.unref(I.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!y.value,title:y.value?void 0:f.value,onClick:D},{default:e.withCtx(()=>[...L[13]||(L[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(I.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!B.value,onClick:F},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(I.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",$S,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(xc,{"is-open":p.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:P,onConfirm:N},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(I.IonAlert),{"is-open":g.value,header:"Delete Album?",message:f.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:R},null,8,["is-open","message"])],64))}}),AS=_e(zS,[["__scopeId","data-v-22083f3a"]]),DS={class:"album-media-grid"},US={class:"aspect-square"},OS={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},LS={class:"text-gray-500"},WS=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],jS={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},XS={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},ZS={class:"aspect-square relative"},YS=["src","alt"],GS={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},HS=e.defineComponent({__name:"AlbumMediaGrid",props:{albumId:{},selectionMode:{type:Boolean,default:!1},selectedItems:{default:()=>[]},reorderable:{type:Boolean,default:!1},showActions:{type:Boolean,default:!0},columns:{default:()=>({mobile:2,sm:3,md:4,lg:5,xl:6})},isLoading:{type:Boolean,default:!1},emptyText:{default:"No media in this album"}},emits:["toggle-select","preview","edit","detach","reorder","add","selection-change"],setup(n,{emit:o}){const t=n,a=o,r=za(),i=e.ref([]),s=e.ref(!1),l=e.ref(null),c=e.ref(null),d=e.ref(null),u=e.computed(()=>t.isLoading||s.value),p=e.computed(()=>!u.value&&i.value.length===0),m=e.computed(()=>{const T=t.columns;return["grid","gap-4",`grid-cols-${T.mobile??2}`,`sm:grid-cols-${T.sm??3}`,`md:grid-cols-${T.md??4}`,`lg:grid-cols-${T.lg??5}`,`xl:grid-cols-${T.xl??6}`]}),h=e.computed(()=>(t.columns.md??4)*2);e.onMounted(async()=>{await g()}),e.watch(()=>t.albumId,async()=>{await g()});async function g(){s.value=!0;try{const T=await r.fetchAlbumMedia(t.albumId);i.value=T}catch{i.value=[]}finally{s.value=!1}}function v(T){return t.selectedItems.includes(T)}function x(T){a("toggle-select",T);const F=v(T.uuid)?t.selectedItems.filter(D=>D!==T.uuid):[...t.selectedItems,T.uuid];a("selection-change",F)}function B(T){if(T.conversions&&typeof T.conversions=="object"){const F=T.conversions.thumb;if(typeof F=="string")return F}return T.original_url}function E(T){l.value=T}function y(){l.value=null}function f(T){a("preview",T)}function w(T){a("edit",T)}function $(T){a("detach",T.uuid)}function C(){a("add")}function b(T,F){t.reorderable&&(c.value=F,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(F))))}function N(T,F){!t.reorderable||c.value===null||(T.preventDefault(),d.value=F)}function P(T,F){if(!t.reorderable||c.value===null)return;T.preventDefault();const D=c.value;if(D!==F){const R=[...i.value],[W]=R.splice(D,1);R.splice(F,0,W),i.value=R;const L=R.map(_=>_.uuid);a("reorder",L),r.reorderAlbumMedia(t.albumId,L).catch(()=>{g()})}c.value=null,d.value=null}function k(){c.value=null,d.value=null}return(T,F)=>(e.openBlock(),e.createElementBlock("div",DS,[u.value?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"loading-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,D=>(e.openBlock(),e.createBlock(e.unref(I.IonCard),{key:D,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",US,[e.createVNode(e.unref(I.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):p.value?(e.openBlock(),e.createElementBlock("div",OS,[e.createVNode(e.unref(I.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",LS,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(I.IonButton),{"data-testid":"add-media-btn",onClick:C},{default:e.withCtx(()=>[...F[0]||(F[0]=[e.createTextVNode(" Add Media ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("div",{key:2,"data-testid":"media-grid",class:e.normalizeClass(m.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(D,R)=>(e.openBlock(),e.createElementBlock("div",{key:D.uuid,"data-media-id":D.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===R,"ring-2 ring-primary":d.value===R&&c.value!==R}]),draggable:T.reorderable,onDragstart:W=>b(W,R),onDragover:W=>N(W,R),onDrop:W=>P(W,R),onDragend:k,onMouseenter:W=>E(D.uuid),onMouseleave:y},[d.value===R&&c.value!==R&&T.reorderable?(e.openBlock(),e.createElementBlock("div",jS)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",XS,[e.createVNode(e.unref(I.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),T.selectionMode?(e.openBlock(),e.createBlock(e.unref(I.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:v(D.uuid),class:"absolute top-2 left-2 z-20",onIonChange:W=>x(D)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(I.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",ZS,[e.createElementVNode("img",{src:B(D),alt:D.file_name,class:"w-full h-full object-cover"},null,8,YS),T.showActions&&l.value===D.uuid?(e.openBlock(),e.createElementBlock("div",GS,[e.createVNode(e.unref(I.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:W=>f(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:W=>w(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(I.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:W=>$(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(I.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,WS))),128)),e.createElementVNode("div",{class:"aspect-square border-2 border-dashed border-gray-300 rounded-lg flex flex-col items-center justify-center gap-2 cursor-pointer hover:border-primary hover:bg-gray-50 transition-colors","data-testid":"add-more-card",onClick:C},[e.createVNode(e.unref(I.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),F[1]||(F[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),JS=_e(HS,[["__scopeId","data-v-d84b796a"]]);function ei(n){return n.filter(o=>o.media&&!o.markedForRemoval).map((o,t)=>{const a={uuid:o.media.uuid,name:o.name,order:t};return o.customProperties&&(a.custom_properties=o.customProperties),a})}function Fr(n){return n.map((o,t)=>{const a={media:o,clientId:o.uuid,name:o.name||o.file_name,order:t};return o.custom_properties&&(a.customProperties=o.custom_properties),a})}function ti(n){if(n){const t={};n.apiBaseUrl!==void 0&&(t.apiBaseUrl=n.apiBaseUrl),n.isAdmin!==void 0&&(t.isAdmin=n.isAdmin),Cn(t)}return{name:"mediables",async upload(t,a){const i=await vt().uploadFile(t,{collection:(a==null?void 0:a.collection)||"default",customProperties:a==null?void 0:a.customProperties});if(!i)throw new Error("Upload failed: No media returned");return{media:i,uuid:i.uuid}},async attach(t,a){await vt().attachMedia(a.modelType,String(a.modelId),[t],a.collection||"images")},async attachMany(t,a){await vt().attachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async detach(t,a){await vt().detachMedia(a.modelType,String(a.modelId),t,a.collection||"images")},async reorder(t,a){await vt().reorderMedia(t.modelType,String(t.modelId),a,t.collection||"images")},async fetchModelMedia(t){return await vt().fetchModelMedia(t.modelType,String(t.modelId),t.collection||"images")},getUrl(t,a){return vt().getMediaUrl(t,a)},getThumbnailUrl(t){var a,r;return(a=t.conversion_urls)!=null&&a.thumb?t.conversion_urls.thumb:(r=t.conversion_urls)!=null&&r.thumbnail?t.conversion_urls.thumbnail:t.thumbnail_url?t.thumbnail_url:t.original_url||t.url||""},async delete(t){await vt().deleteMedia(t)},async update(t,a){const i=await vt().updateMedia(t,a);if(!i)throw new Error("Update failed: No media returned");return i},configure(t){const a={};t.apiBaseUrl!==void 0&&(a.apiBaseUrl=t.apiBaseUrl),t.isAdmin!==void 0&&(a.isAdmin=t.isAdmin),Cn(a)}}}let Jo=null;function qS(){return Jo||(Jo=ti()),Jo}function KS(){Jo=null}const QS={apiBaseUrl:"/media-library-pro"};function Do(){var n;return typeof document>"u"?null:((n=document.querySelector('meta[name="csrf-token"]'))==null?void 0:n.getAttribute("content"))||null}function ur(n){const o={uuid:n.uuid,file_name:n.fileName||n.name,mime_type:`application/${n.extension}`,size:n.size,disk:"public",original_url:n.original_url||"",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return n.name&&(o.name=n.name),n.original_url&&(o.url=n.original_url),n.preview_url&&(o.thumbnail_url=n.preview_url,o.preview_url=n.preview_url),n.custom_properties&&(o.custom_properties=n.custom_properties),o}function ni(n){const o={...QS,...n};return{name:"spatie",async upload(a,r){const i=new FormData;i.append("file",a),r!=null&&r.collection&&i.append("collection",r.collection),r!=null&&r.customProperties&&i.append("custom_properties",JSON.stringify(r.customProperties));const s={Accept:"application/json",...o.headers},l=o.csrfToken||Do();l&&(s["X-CSRF-TOKEN"]=l);const c={method:"POST",headers:s,body:i,credentials:"include"};r!=null&&r.signal&&(c.signal=r.signal);const d=await fetch(`${o.apiBaseUrl}/uploads`,c);if(!d.ok){const m=await d.json().catch(()=>({message:"Upload failed"}));throw new Error(m.message||`HTTP ${d.status}`)}const u=await d.json(),p=ur(u);return r!=null&&r.onProgress&&r.onProgress(100),{media:p,uuid:u.uuid}},async attach(a,r){},async attachMany(a,r){},async detach(a,r){},async reorder(a,r){},async fetchModelMedia(a){const r={Accept:"application/json",...o.headers},i=o.csrfToken||Do();i&&(r["X-CSRF-TOKEN"]=i);const s=new URLSearchParams;s.append("model_type",a.modelType),s.append("model_id",String(a.modelId)),a.collection&&s.append("collection",a.collection);try{const l=await fetch(`${o.apiBaseUrl}/media?${s}`,{method:"GET",headers:r,credentials:"include"});if(!l.ok)throw new Error(`HTTP ${l.status}`);return(await l.json()).map(ur)}catch{return[]}},getUrl(a,r){var i;if(r){const s=(i=a.conversion_urls)==null?void 0:i[r];if(s)return s}return a.original_url||a.url||""},getThumbnailUrl(a){var r,i;return a.preview_url?a.preview_url:(r=a.conversion_urls)!=null&&r.preview?a.conversion_urls.preview:a.thumbnail_url?a.thumbnail_url:(i=a.conversion_urls)!=null&&i.thumb?a.conversion_urls.thumb:a.original_url||a.url||""},async delete(a){const r={Accept:"application/json",...o.headers},i=o.csrfToken||Do();i&&(r["X-CSRF-TOKEN"]=i);const s=await fetch(`${o.apiBaseUrl}/uploads/${a}`,{method:"DELETE",headers:r,credentials:"include"});if(!s.ok){const l=await s.json().catch(()=>({message:"Delete failed"}));throw new Error(l.message||`HTTP ${s.status}`)}},async update(a,r){const i={Accept:"application/json","Content-Type":"application/json",...o.headers},s=o.csrfToken||Do();s&&(i["X-CSRF-TOKEN"]=s);const l=await fetch(`${o.apiBaseUrl}/uploads/${a}`,{method:"PATCH",headers:i,body:JSON.stringify(r),credentials:"include"});if(!l.ok){const d=await l.json().catch(()=>({message:"Update failed"}));throw new Error(d.message||`HTTP ${l.status}`)}const c=await l.json();return ur(c)},configure(a){Object.assign(o,a)}}}let qo=null;function eE(){return qo||(qo=ni()),qo}function tE(){qo=null}function Sc(n,o){switch(n){case"mediables":return ti(o);case"spatie":return ni(o);default:throw new Error(`Unknown adapter: ${n}`)}}function ua(n){if(n===0)return"0 Bytes";const o=1024,t=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(n)/Math.log(o));return parseFloat((n/Math.pow(o,a)).toFixed(2))+" "+t[a]}function Ec(n){var t;const o=n.split(".");return o.length>1?`.${(t=o.pop())==null?void 0:t.toLowerCase()}`:""}function oi(n){return n.type.startsWith("image/")}async function Cc(n){return oi(n)?new Promise(o=>{const t=new Image,a=URL.createObjectURL(n);t.onload=()=>{URL.revokeObjectURL(a),o({width:t.naturalWidth,height:t.naturalHeight})},t.onerror=()=>{URL.revokeObjectURL(a),o(null)},t.src=a}):null}async function Vc(n,o){const t=[];if(o.maxFileSize&&n.size>o.maxFileSize&&t.push({field:"size",message:`File exceeds maximum size of ${ua(o.maxFileSize)}`,code:"MAX_FILE_SIZE"}),o.minFileSize&&n.size<o.minFileSize&&t.push({field:"size",message:`File is smaller than minimum size of ${ua(o.minFileSize)}`,code:"MIN_FILE_SIZE"}),o.acceptedMimeTypes&&o.acceptedMimeTypes.length>0&&(o.acceptedMimeTypes.some(r=>r.endsWith("/*")?n.type.startsWith(r.slice(0,-1)):n.type===r)||t.push({field:"type",message:`File type "${n.type}" is not allowed`,code:"INVALID_MIME_TYPE"})),o.acceptedExtensions&&o.acceptedExtensions.length>0){const a=Ec(n.name);o.acceptedExtensions.some(i=>i.toLowerCase()===a.toLowerCase())||t.push({field:"extension",message:`File extension "${a}" is not allowed`,code:"INVALID_EXTENSION"})}if(oi(n)&&(o.maxDimensions||o.minDimensions)){const a=await Cc(n);a&&(o.maxDimensions&&(a.width>o.maxDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) exceeds maximum (${o.maxDimensions.width}px)`,code:"MAX_WIDTH"}),a.height>o.maxDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) exceeds maximum (${o.maxDimensions.height}px)`,code:"MAX_HEIGHT"})),o.minDimensions&&(a.width<o.minDimensions.width&&t.push({field:"dimensions",message:`Image width (${a.width}px) is smaller than minimum (${o.minDimensions.width}px)`,code:"MIN_WIDTH"}),a.height<o.minDimensions.height&&t.push({field:"dimensions",message:`Image height (${a.height}px) is smaller than minimum (${o.minDimensions.height}px)`,code:"MIN_HEIGHT"})))}if(o.customValidator){const a=await o.customValidator(n);t.push(...a)}return{valid:t.length===0,errors:t}}function ai(n={}){const o=e.ref(n.rules||{});function t(c){o.value=c}async function a(c){return Vc(c,o.value)}async function r(c){const d=new Map;return await Promise.all(c.map(async u=>{const p=await a(u);d.set(u,p)})),d}function i(c,d){return o.value.maxItems?d+c<=o.value.maxItems:!0}const s=e.computed(()=>{const c=[];return o.value.acceptedMimeTypes&&c.push(...o.value.acceptedMimeTypes),o.value.acceptedExtensions&&c.push(...o.value.acceptedExtensions),c.join(",")});function l(c){return!o.value.acceptedMimeTypes||o.value.acceptedMimeTypes.length===0?!0:o.value.acceptedMimeTypes.some(d=>d.endsWith("/*")?c.startsWith(d.slice(0,-1)):c===d)}return{rules:o,setRules:t,validateFile:a,validateFiles:r,canAddFiles:i,acceptString:s,isMimeTypeAllowed:l}}function nE(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function oE(n){if(n.type.startsWith("image/"))return URL.createObjectURL(n)}function Nc(n){const{adapter:o,maxConcurrent:t=3,rules:a,collection:r,onUploadStart:i,onUploadProgress:s,onUploadComplete:l,onUploadError:c,onQueueComplete:d}=n,u=e.ref(new Map),p=e.ref(new Set),m=a?{rules:a}:{},{validateFile:h}=ai(m);async function g(){if(p.value.size>=t)return;const k=Array.from(u.value.entries()).find(([D,R])=>R.status==="pending"&&!p.value.has(D));if(!k){Array.from(u.value.values()).every(R=>R.status==="completed"||R.status==="error")&&u.value.size>0&&(d==null||d());return}const[T,F]=k;await v(T,F)}async function v(k,T){p.value.add(k),T.status="uploading",T.abortController=new AbortController,u.value.set(k,{...T}),i==null||i(T);try{const F={onProgress:R=>{T.progress=R,u.value.set(k,{...T}),s==null||s(T)},signal:T.abortController.signal};r&&(F.collection=r);const D=await o.upload(T.file,F);T.status="completed",T.progress=100,T.media=D.media,u.value.set(k,{...T}),l==null||l(T,D.media)}catch(F){F.name==="AbortError"?u.value.delete(k):(T.status="error",T.error=F.message,u.value.set(k,{...T}),c==null||c(T,F))}finally{p.value.delete(k),delete T.abortController,g()}}async function x(k){var D;const T=Array.from(k),F=[];for(const R of T){const W=await h(R),L=nE(),_=oE(R),A={id:L,file:R,progress:0,status:W.valid?"pending":"error"};!W.valid&&((D=W.errors[0])!=null&&D.message)&&(A.error=W.errors[0].message),_&&(A.previewUrl=_),u.value.set(L,A);const Z={media:null,clientId:L,name:R.name,order:0,upload:A,errors:W.errors};F.push(Z)}for(let R=0;R<t;R++)g();return F}function B(k){const T=u.value.get(k);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k),p.value.delete(k),g())}async function E(k){const T=u.value.get(k);!T||T.status!=="error"||(T.status="pending",T.progress=0,delete T.error,u.value.set(k,{...T}),g())}function y(){for(const[k,T]of u.value.entries())(T.status==="completed"||T.status==="error")&&(T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k))}function f(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),p.value.clear()}function w(k){return u.value.get(k)}const $=e.computed(()=>p.value.size>0),C=e.computed(()=>p.value.size),b=e.computed(()=>Array.from(u.value.values()).filter(k=>k.status==="pending").length),N=e.computed(()=>u.value.size===0?!0:Array.from(u.value.values()).every(k=>k.status==="completed"||k.status==="error")),P=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:$,activeCount:C,pendingCount:b,isComplete:N,addFiles:x,cancelUpload:B,retryUpload:E,clearCompleted:y,clearAll:f,getUpload:w,uploadsArray:P}}function _c(n={}){const{enabled:o=!0,onReorder:t,onDragStart:a,onDragEnd:r,draggingClass:i="is-dragging",dropTargetClass:s="is-drop-target"}=n,l=e.ref({isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null}),c=e.ref(!1);let d=null;function u(E,y,f){o&&("dataTransfer"in E&&E.dataTransfer&&(E.dataTransfer.effectAllowed="move",E.dataTransfer.setData("text/plain",String(f))),d=E.target,d&&d.classList.add(i),l.value={isDragging:!0,dragIndex:f,dropIndex:f,draggedItem:y},c.value=!0,a==null||a(y,f))}function p(E,y){var f;if(!(!o||!l.value.isDragging)&&(E.preventDefault(),l.value.dropIndex!==y)){const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s);const $=(f=E.target)==null?void 0:f.closest("[data-index]");$==null||$.classList.add(s),l.value.dropIndex=y}}function m(){if(!l.value.isDragging)return;const{dragIndex:E,dropIndex:y,draggedItem:f}=l.value;d&&d.classList.remove(i);const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s),E!==null&&y!==null&&E!==y&&f&&(t==null||t({fromIndex:E,toIndex:y,item:f})),g(),r==null||r()}function h(){d&&d.classList.remove(i);const E=document.querySelector(`.${s}`);E==null||E.classList.remove(s),g(),r==null||r()}function g(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function v(E,y,f){const w=[...E],[$]=w.splice(y,1);return w.splice(f,0,$),w.map((C,b)=>({...C,order:b}))}function x(E,y){return{draggable:o,"data-index":y,onDragstart:f=>u(f,E,y),onDragover:f=>p(f,y),onDragend:()=>m(),onDrop:f=>{f.preventDefault(),m()}}}function B(E){E.key==="Escape"&&l.value.isDragging&&h()}return e.onMounted(()=>{document.addEventListener("keydown",B)}),e.onUnmounted(()=>{document.removeEventListener("keydown",B),h()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:p,endDrag:m,cancelDrag:h,reorderItems:v,getDragProps:x}}function Aa(n={}){const{initialItems:o=[],modelType:t,modelId:a,collection:r="images",maxItems:i,maxFileSize:s,acceptedMimeTypes:l,sortable:c=!0,disabled:d=!1,rules:u={},adapterType:p="mediables",adapter:m,maxConcurrentUploads:h=3,onChange:g,onUpload:v,onUploadComplete:x,onUploadError:B,onRemove:E,onReorder:y,onError:f,onReadyToSubmitChange:w}=n,$={maxItems:i,maxFileSize:s,acceptedMimeTypes:l,...u},C=m||Sc(p),b=e.ref([]),N=e.ref(!1),P=e.ref([]);function k(oe){if(oe.length===0)return[];const ye=oe[0];return"media"in ye&&"clientId"in ye?oe:Fr(oe)}b.value=k(o);const{acceptString:T,canAddFiles:F}=ai({rules:$}),D=Nc({adapter:C,maxConcurrent:h,rules:$,collection:r,onUploadStart:oe=>{v==null||v(oe)},onUploadComplete:(oe,ye)=>{const fe=b.value.findIndex(Ze=>Ze.clientId===oe.id);fe!==-1&&(b.value[fe]={...b.value[fe],media:ye,name:ye.name||ye.file_name,upload:{...oe,status:"completed"}}),x==null||x(ye)},onUploadError:(oe,ye)=>{const fe=b.value.findIndex(Ze=>Ze.clientId===oe.id);fe!==-1&&(b.value[fe]={...b.value[fe],upload:{...oe,status:"error",error:ye.message},errors:[{field:"upload",message:ye.message,code:"UPLOAD_ERROR"}]}),B==null||B({file:oe.file,message:ye.message})},onQueueComplete:()=>{g==null||g(b.value)}}),{dragState:R,getDragProps:W,reorderItems:L}=_c({enabled:c&&!d,onReorder:oe=>{b.value=L(b.value,oe.fromIndex,oe.toIndex),y==null||y(b.value),g==null||g(b.value)}}),_=e.computed(()=>D.isUploading.value),A=e.computed(()=>!D.isUploading.value&&D.pendingCount.value===0),Z=e.computed(()=>i?b.value.length>=i:!1),H=e.computed(()=>ei(b.value)),me=e.computed(()=>b.value.length),Te=e.computed(()=>i?Math.max(0,i-b.value.length):1/0);e.watch(A,oe=>{w==null||w(oe)});function Be(oe){b.value=k(oe),g==null||g(b.value)}async function ie(oe){if(d)return;const ye=Array.from(oe);if(!F(ye.length,b.value.length)){const pe={field:"count",message:`Maximum ${i} files allowed`,code:"MAX_ITEMS"};P.value=[pe],f==null||f([pe]);return}const fe=await D.addFiles(ye),Ze=b.value.length,Ke=fe.map((pe,ke)=>({...pe,order:Ze+ke}));b.value=[...b.value,...Ke],g==null||g(b.value)}function M(oe){d||(oe.upload&&(oe.upload.status==="uploading"||oe.upload.status==="pending")&&D.cancelUpload(oe.clientId),b.value=b.value.filter(ye=>ye.clientId!==oe.clientId),b.value=b.value.map((ye,fe)=>({...ye,order:fe})),E==null||E(oe),g==null||g(b.value))}function j(oe){const ye=b.value.find(fe=>fe.clientId===oe);ye&&M(ye)}function te(){d||(D.clearAll(),b.value=[],g==null||g(b.value))}function ae(oe,ye){d||!c||(b.value=L(b.value,oe,ye),y==null||y(b.value),g==null||g(b.value))}function re(oe,ye){if(d)return;const fe=b.value.findIndex(Ze=>Ze.clientId===oe);fe!==-1&&(b.value[fe]={...b.value[fe],...ye},g==null||g(b.value))}function q(oe){D.cancelUpload(oe),j(oe)}async function ue(oe){await D.retryUpload(oe)}async function ve(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const oe={modelType:t,modelId:a,collection:r},ye=b.value.filter(fe=>fe.media&&!fe.markedForRemoval).map(fe=>fe.media.uuid);N.value=!0;try{await C.attachMany(ye,oe),await C.reorder(oe,ye)}finally{N.value=!1}}async function we(){if(!t||!a)throw new Error("modelType and modelId are required for load()");const oe={modelType:t,modelId:a,collection:r};N.value=!0;try{const ye=await C.fetchModelMedia(oe);b.value=Fr(ye),g==null||g(b.value)}finally{N.value=!1}}return e.onMounted(()=>{t&&a&&o.length===0&&we().catch(console.error)}),e.onUnmounted(()=>{D.clearAll()}),{items:b,setItems:Be,addFiles:ie,removeItem:M,removeItemById:j,clearAll:te,reorderItems:ae,updateItem:re,cancelUpload:q,retryUpload:ue,save:ve,load:we,isLoading:N,isUploading:_,isReadyToSubmit:A,isAtMaxItems:Z,errors:P,dragState:R,getDragProps:W,adapter:C,formValues:H,acceptString:T,count:me,remainingSlots:Te}}const aE=["aria-disabled"],rE=["accept","multiple","disabled"],iE={class:"media-dropzone__content"},sE={class:"media-dropzone__title"},lE={class:"media-dropzone__subtitle"},cE=["disabled"],dE={key:0,class:"media-dropzone__helper"},uE=e.defineComponent({__name:"MediaCollectionDropzone",props:{accept:{default:"*"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxFileSize:{},maxItems:{},title:{default:"Drop files here"},subtitle:{default:"or click to browse"},buttonText:{default:"Select files"}},emits:["files"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.ref(null),s=e.computed(()=>({"media-dropzone":!0,"media-dropzone--drag-over":r.value,"media-dropzone--disabled":t.disabled})),l=e.computed(()=>{const v=[];return t.maxFileSize&&v.push(`Max size: ${ua(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&v.push(`Max files: ${t.maxItems}`),v.join(" • ")});function c(v){v.preventDefault(),!t.disabled&&(r.value=!0)}function d(v){v.preventDefault(),r.value=!1}function u(v){v.preventDefault()}function p(v){var B;if(v.preventDefault(),r.value=!1,t.disabled)return;const x=(B=v.dataTransfer)==null?void 0:B.files;x&&x.length>0&&a("files",x)}function m(){var v;t.disabled||(v=i.value)==null||v.click()}function h(v){const x=v.target,B=x.files;B&&B.length>0&&a("files",B),x.value=""}function g(v){(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m())}return(v,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":v.disabled,"aria-label":"Upload files",onClick:m,onKeydown:g,onDragenter:c,onDragleave:d,onDragover:u,onDrop:p},[e.createElementVNode("input",{ref_key:"fileInput",ref:i,type:"file",accept:v.accept,multiple:v.multiple,disabled:v.disabled,class:"media-dropzone__input",onChange:h},null,40,rE),e.createElementVNode("div",iE,[e.renderSlot(v.$slots,"icon",{},()=>[x[0]||(x[0]=e.createElementVNode("svg",{class:"media-dropzone__icon",xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1))],!0),e.createElementVNode("p",sE,[e.renderSlot(v.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(v.title),1)],!0)]),e.createElementVNode("p",lE,[e.renderSlot(v.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(v.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:v.disabled,onClick:e.withModifiers(m,["stop"])},[e.renderSlot(v.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(v.buttonText),1)],!0)],8,cE),l.value?(e.openBlock(),e.createElementBlock("p",dE,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,aE))}}),ri=_e(uE,[["__scopeId","data-v-b1366c1e"]]),mE=["data-index"],pE={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},fE={class:"media-item__thumbnail"},hE=["src","alt"],vE={key:1,class:"media-item__file-icon"},gE={key:2,class:"media-item__progress-overlay"},yE={class:"media-item__progress-text"},bE={key:3,class:"media-item__processing-overlay"},wE={key:4,class:"media-item__error-overlay"},kE={class:"media-item__info"},xE=["title"],SE={key:0,class:"media-item__size"},EE={key:1,class:"media-item__error-message"},CE={class:"media-item__actions"},VE=["disabled"],NE=["disabled"],_E=["disabled"],TE=["disabled"],ME=e.defineComponent({__name:"MediaCollectionItem",props:{item:{},adapter:{},disabled:{type:Boolean,default:!1},sortable:{type:Boolean,default:!1},showRemove:{type:Boolean,default:!0},showEdit:{type:Boolean,default:!1},index:{default:0}},emits:["remove","edit","retry","cancel"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(!1),i=e.computed(()=>{var y;return(y=t.item.upload)!=null&&y.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var y,f,w;return((y=t.item.upload)==null?void 0:y.status)==="uploading"||((f=t.item.upload)==null?void 0:f.status)==="pending"||((w=t.item.upload)==null?void 0:w.status)==="queued"}),l=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="processing"}),c=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var y;return(y=t.item.upload)!=null&&y.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var y;return((y=t.item.upload)==null?void 0:y.progress)||0}),p=e.computed(()=>{var y;return t.item.name||((y=t.item.media)==null?void 0:y.file_name)||"Unknown file"}),m=e.computed(()=>{var C,b;const y=((C=t.item.media)==null?void 0:C.size)||((b=t.item.upload)==null?void 0:b.file.size);if(!y)return"";const f=1024,w=["Bytes","KB","MB","GB"],$=Math.floor(Math.log(y)/Math.log(f));return parseFloat((y/Math.pow(f,$)).toFixed(2))+" "+w[$]}),h=e.computed(()=>{var f,w;const y=((f=t.item.media)==null?void 0:f.mime_type)||((w=t.item.upload)==null?void 0:w.file.type);return y==null?void 0:y.startsWith("image/")}),g=e.computed(()=>({"media-item":!0,"media-item--uploading":s.value,"media-item--processing":l.value,"media-item--error":c.value,"media-item--disabled":t.disabled,"media-item--sortable":t.sortable}));function v(){t.disabled||a("remove",t.item)}function x(){t.disabled||a("edit",t.item)}function B(){t.disabled||a("retry",t.item)}function E(){t.disabled||a("cancel",t.item)}return(y,f)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(g.value),"data-index":y.index,onMouseenter:f[0]||(f[0]=w=>r.value=!0),onMouseleave:f[1]||(f[1]=w=>r.value=!1)},[y.sortable&&!y.disabled?(e.openBlock(),e.createElementBlock("div",pE,[...f[2]||(f[2]=[e.createStaticVNode('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-v-ff81c9ec><circle cx="9" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="9" cy="19" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="5" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="12" r="1" data-v-ff81c9ec></circle><circle cx="15" cy="19" r="1" data-v-ff81c9ec></circle></svg>',1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",fE,[i.value&&h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,alt:p.value,class:"media-item__image"},null,8,hE)):(e.openBlock(),e.createElementBlock("div",vE,[...f[3]||(f[3]=[e.createElementVNode("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","aria-hidden":"true"},[e.createElementVNode("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.createElementVNode("polyline",{points:"14 2 14 8 20 8"})],-1)])])),s.value?(e.openBlock(),e.createElementBlock("div",gE,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",yE,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",bE,[...f[4]||(f[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",wE,[...f[5]||(f[5]=[e.createElementVNode("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","aria-hidden":"true"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElementVNode("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})],-1)])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",kE,[e.createElementVNode("span",{class:"media-item__name",title:p.value},e.toDisplayString(p.value),9,xE),m.value?(e.openBlock(),e.createElementBlock("span",SE,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",EE,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",CE,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:y.disabled,"aria-label":"Cancel upload",onClick:E},[...f[6]||(f[6]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElementVNode("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])],8,VE)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:y.disabled,"aria-label":"Retry upload",onClick:B},[...f[7]||(f[7]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"23 4 23 10 17 10"}),e.createElementVNode("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})],-1)])],8,NE)):e.createCommentVNode("",!0),y.showEdit&&y.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:y.disabled,"aria-label":"Edit",onClick:x},[...f[8]||(f[8]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})],-1)])],8,_E)):e.createCommentVNode("",!0),y.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:y.disabled,"aria-label":"Remove",onClick:v},[...f[9]||(f[9]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("polyline",{points:"3 6 5 6 21 6"}),e.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])],8,TE)):e.createCommentVNode("",!0)])],42,mE))}}),ii=_e(ME,[["__scopeId","data-v-ff81c9ec"]]),FE=["aria-label"],IE=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],BE={key:0,class:"media-collection__footer"},RE={class:"media-collection__count"},PE={key:0},$E={key:0,class:"media-collection__uploading"},zE=["name","value"],AE=["name","value"],DE=["name","value"],UE=["name","value"],OE={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},LE=e.defineComponent({__name:"MediaCollection",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(n,{emit:o}){const t=n,a=o,r={initialItems:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxItems:t.maxItems,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,sortable:t.sortable,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:_=>{a("update:modelValue",_),a("change",_)},onUpload:_=>{a("upload",_)},onUploadComplete:_=>{a("upload-complete",_)},onUploadError:_=>{a("upload-error",_)},onRemove:_=>{a("remove",_)},onReorder:_=>{a("reorder",_)},onError:_=>{a("validation-error",_)},onReadyToSubmitChange:_=>{a("is-ready-to-submit-change",_)}},{items:i,setItems:s,addFiles:l,removeItem:c,reorderItems:d,cancelUpload:u,retryUpload:p,isLoading:m,isUploading:h,isAtMaxItems:g,errors:v,dragState:x,getDragProps:B,adapter:E,formValues:y,acceptString:f,count:w,remainingSlots:$}=Aa(r);e.provide("mediaAdapter",E),e.provide("mediaCollection",{items:i,addFiles:l,removeItem:c,reorderItems:d}),e.watch(()=>t.modelValue,_=>{_!==i.value&&s(_)},{deep:!0});const C=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!g.value),b=e.computed(()=>({"media-collection":!0,"media-collection--disabled":t.disabled,"media-collection--readonly":t.readonly,"media-collection--loading":m.value,"media-collection--has-items":i.value.length>0,"media-collection--dragging":x.value.isDragging}));function N(_){l(_)}function P(_){c(_)}function k(_){p(_.clientId)}function T(_){u(_.clientId)}function F(_){}function D(_,A,Z){if(!t.sortable||t.disabled)return;const H=B(A,Z);H.onDragstart&&H.onDragstart(_)}function R(_,A){if(!t.sortable||t.disabled)return;_.preventDefault();const Z=i.value[A],H=B(Z,A);H.onDragover&&H.onDragover(_)}function W(_,A){const Z=B(_,A);Z.onDragend&&Z.onDragend()}function L(_,A){_.preventDefault();const Z=i.value[A],H=B(Z,A);H.onDrop&&H.onDrop(_)}return(_,A)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(b.value)},[e.renderSlot(_.$slots,"dropzone",{addFiles:e.unref(l)},()=>[C.value?(e.openBlock(),e.createBlock(ri,{key:0,accept:e.unref(f),multiple:_.maxItems!==1,disabled:_.disabled,"max-file-size":_.maxFileSize,"max-items":e.unref($),onFiles:N},null,8,["accept","multiple","disabled","max-file-size","max-items"])):e.createCommentVNode("",!0)],!0),e.unref(i).length>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"media-collection__list",role:"list","aria-label":`${e.unref(w)} media items`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),(Z,H)=>e.renderSlot(_.$slots,"item",{key:Z.clientId,item:Z,index:H,remove:()=>P(Z)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(x).dropIndex===H}]),draggable:_.sortable&&!_.disabled,"data-index":H,onDragstart:me=>D(me,Z,H),onDragover:me=>R(me,H),onDragend:me=>W(Z,H),onDrop:me=>L(me,H)},[e.createVNode(ii,{item:Z,adapter:e.unref(E),disabled:_.disabled,sortable:_.sortable,"show-remove":!_.readonly,"show-edit":!1,index:H,onRemove:P,onRetry:k,onCancel:T,onEdit:F},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,IE)],!0)),128))],8,FE)):C.value?e.createCommentVNode("",!0):e.renderSlot(_.$slots,"empty",{key:1},()=>[A[0]||(A[0]=e.createElementVNode("div",{class:"media-collection__empty"},[e.createElementVNode("p",null,"No files uploaded")],-1))],!0),e.renderSlot(_.$slots,"footer",{count:e.unref(w),isUploading:e.unref(h)},()=>[e.unref(i).length>0?(e.openBlock(),e.createElementBlock("div",BE,[e.createElementVNode("span",RE,[e.createTextVNode(e.toDisplayString(e.unref(w))+" "+e.toDisplayString(e.unref(w)===1?"file":"files")+" ",1),_.maxItems?(e.openBlock(),e.createElementBlock("span",PE," / "+e.toDisplayString(_.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(h)?(e.openBlock(),e.createElementBlock("span",$E," Uploading... ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],!0),_.generateFormFields?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(Z,H)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${Z.uuid}`,type:"hidden",name:`${_.name}[${H}][uuid]`,value:Z.uuid},null,8,zE))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(Z,H)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${Z.uuid}-name`,type:"hidden",name:`${_.name}[${H}][name]`,value:Z.name},null,8,AE))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(Z,H)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${Z.uuid}-order`,type:"hidden",name:`${_.name}[${H}][order]`,value:Z.order},null,8,DE))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(Z,H)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${_.name}-${Z.uuid}-props`},[Z.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${_.name}[${H}][custom_properties]`,value:JSON.stringify(Z.custom_properties)},null,8,UE)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",OE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),Z=>(e.openBlock(),e.createElementBlock("p",{key:Z.code||Z.message,class:"media-collection__error"},e.toDisplayString(Z.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),WE=_e(LE,[["__scopeId","data-v-10a5bfff"]]);function si(n={}){const{initialItem:o,onChange:t,onReplace:a,onUpload:r,onUploadComplete:i,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d,...u}=n,m={...u,initialItems:o?[o]:[],maxItems:1,sortable:!1,onChange:C=>{t==null||t(C[0]||null)},onUpload:r,onUploadComplete:i,onUploadError:s,onRemove:l,onError:c,onReadyToSubmitChange:d},h=Aa(m),g=e.computed(()=>h.items.value[0]||null),v=e.computed(()=>g.value!==null),x=e.computed(()=>h.formValues.value[0]||null);function B(C){C===null?h.clearAll():h.setItems([C])}async function E(C){const b=g.value;b&&h.removeItem(b),await h.addFiles([C])}function y(){g.value&&h.removeItem(g.value)}async function f(C){const b=g.value;b&&h.removeItem(b),await h.addFiles([C]);const N=h.items.value[0];N&&(a==null||a(b,N))}function w(){var C;(C=g.value)!=null&&C.upload&&h.cancelUpload(g.value.clientId)}async function $(){var C,b;((b=(C=g.value)==null?void 0:C.upload)==null?void 0:b.status)==="error"&&await h.retryUpload(g.value.clientId)}return{item:g,setItem:B,addFile:E,removeItem:y,replaceItem:f,cancelUpload:w,retryUpload:$,save:h.save,load:h.load,isLoading:h.isLoading,isUploading:h.isUploading,isReadyToSubmit:h.isReadyToSubmit,hasItem:v,errors:h.errors,adapter:h.adapter,formValue:x,acceptString:h.acceptString}}const jE=["accept","disabled"],XE={class:"media-attachment__preview"},ZE=["name","value"],YE=["name","value"],GE=["name","value"],HE=["name","value"],JE={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},qE=e.defineComponent({__name:"MediaAttachment",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null),i={initialItem:t.modelValue,modelType:t.modelType,modelId:t.modelId,collection:t.collection,maxFileSize:t.maxFileSize,acceptedMimeTypes:t.acceptedMimeTypes,disabled:t.disabled,rules:t.rules,adapterType:t.adapter,onChange:k=>{a("update:modelValue",k),a("change",k)},onUpload:k=>{a("upload",k)},onUploadComplete:k=>{a("upload-complete",k)},onUploadError:k=>{a("upload-error",k)},onRemove:k=>{a("remove",k)},onReplace:(k,T)=>{a("replace",T)},onError:k=>{a("validation-error",k)},onReadyToSubmitChange:k=>{a("is-ready-to-submit-change",k)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,hasItem:g,errors:v,adapter:x,formValue:B,acceptString:E}=si(i);e.provide("mediaAdapter",x),e.watch(()=>t.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const y=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!g.value),f=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":h.value,"media-attachment--has-item":g.value}));function w(k){k.length>0&&c(k[0])}function $(){var k;(k=r.value)==null||k.click()}function C(k){const T=k.target,F=T.files;F&&F.length>0&&u(F[0]),T.value=""}function b(k){d()}function N(k){m()}function P(k){p()}return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(f.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",accept:e.unref(E),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:C},null,40,jE),y.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(ri,{accept:e.unref(E),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:w},null,8,["accept","disabled","max-file-size"])],!0):e.unref(g)&&e.unref(s)?e.renderSlot(k.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:$},()=>[e.createElementVNode("div",XE,[e.createVNode(ii,{item:e.unref(s),adapter:e.unref(x),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:b,onRetry:N,onCancel:P},null,8,["item","adapter","disabled","show-remove"]),k.showReplaceButton&&!k.readonly&&!k.disabled&&e.unref(s).media?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-attachment__replace-button",onClick:$},[...T[0]||(T[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElementVNode("polyline",{points:"17 8 12 3 7 8"}),e.createElementVNode("line",{x1:"12",y1:"3",x2:"12",y2:"15"})],-1),e.createTextVNode(" Replace ",-1)])])):e.createCommentVNode("",!0)])],!0):e.renderSlot(k.$slots,"empty",{key:2},()=>[T[1]||(T[1]=e.createElementVNode("div",{class:"media-attachment__empty"},[e.createElementVNode("p",null,"No file selected")],-1))],!0),k.generateFormFields&&e.unref(B)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(B).uuid},null,8,ZE),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(B).name},null,8,YE),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(B).order},null,8,GE),e.unref(B).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(B).custom_properties)},null,8,HE)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(v).length>0?(e.openBlock(),e.createElementBlock("div",JE,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),F=>(e.openBlock(),e.createElementBlock("p",{key:F.code||F.message,class:"media-attachment__error"},e.toDisplayString(F.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),KE=_e(qE,[["__scopeId","data-v-26911174"]]),Tc={dropzone:{title:"Drop files here",subtitle:"or click to browse",button:"Select files"},item:{remove:"Remove",replace:"Replace",edit:"Edit",download:"Download"},errors:{maxItems:"Maximum {max} files allowed",maxFileSize:"File exceeds maximum size of {max}",invalidType:"File type not allowed",uploadFailed:"Upload failed"},status:{uploading:"Uploading...",processing:"Processing...",completed:"Complete",error:"Error"}},QE=e.defineComponent({__name:"MediaCollectionProvider",props:{modelValue:{default:()=>[]},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxItems:{},maxFileSize:{},acceptedMimeTypes:{},sortable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","reorder","is-ready-to-submit-change","validation-error"],setup(n,{expose:o,emit:t}){const a=n,r=t,i={initialItems:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxItems:a.maxItems,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,sortable:a.sortable,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:k=>{r("update:modelValue",k),r("change",k)},onUpload:k=>{r("upload",k)},onUploadComplete:k=>{r("upload-complete",k)},onUploadError:k=>{r("upload-error",k)},onRemove:k=>{r("remove",k)},onReorder:k=>{r("reorder",k)},onError:k=>{r("validation-error",k)},onReadyToSubmitChange:k=>{r("is-ready-to-submit-change",k)}},{items:s,setItems:l,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:h,isLoading:g,isUploading:v,isReadyToSubmit:x,isAtMaxItems:B,errors:E,dragState:y,getDragProps:f,adapter:w,formValues:$,acceptString:C}=Aa(i);e.provide("mediaAdapter",w),e.provide("mediaCollection",{items:s,addFiles:c,removeItem:d,reorderItems:u}),e.watch(()=>a.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const b=e.computed(()=>({...Tc,...a.labels})),N=e.computed(()=>({accept:C.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||B.value})),P=e.computed(()=>({items:s.value,isLoading:g.value,isUploading:v.value,isReadyToSubmit:x.value,isAtMaxItems:B.value,errors:E.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:m,retryUpload:h,labels:b.value,dropzoneProps:N.value}));return o({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:p,cancelUpload:m,retryUpload:h,isLoading:g,isUploading:v,isReadyToSubmit:x,isAtMaxItems:B,errors:E,dragState:y,getDragProps:f,adapter:w,formValues:$,acceptString:C}),(k,T)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(P.value)))}}),e4=e.defineComponent({__name:"MediaAttachmentProvider",props:{modelValue:{default:null},name:{default:"media"},modelType:{},modelId:{},collection:{default:"images"},maxFileSize:{},acceptedMimeTypes:{},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},rules:{},adapter:{default:"mediables"},labels:{},showUploadZone:{type:Boolean,default:!0},generateFormFields:{type:Boolean,default:!0},showReplaceButton:{type:Boolean,default:!0}},emits:["update:modelValue","change","upload","upload-complete","upload-error","remove","replace","is-ready-to-submit-change","validation-error"],setup(n,{expose:o,emit:t}){const a=n,r=t,i={initialItem:a.modelValue,modelType:a.modelType,modelId:a.modelId,collection:a.collection,maxFileSize:a.maxFileSize,acceptedMimeTypes:a.acceptedMimeTypes,disabled:a.disabled,rules:a.rules,adapterType:a.adapter,onChange:b=>{r("update:modelValue",b),r("change",b)},onUpload:b=>{r("upload",b)},onUploadComplete:b=>{r("upload-complete",b)},onUploadError:b=>{r("upload-error",b)},onRemove:b=>{r("remove",b)},onReplace:(b,N)=>{r("replace",N)},onError:b=>{r("validation-error",b)},onReadyToSubmitChange:b=>{r("is-ready-to-submit-change",b)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:v,hasItem:x,errors:B,adapter:E,formValue:y,acceptString:f}=si(i);e.provide("mediaAdapter",E),e.watch(()=>a.modelValue,b=>{b!==s.value&&l(b)},{deep:!0});const w=e.computed(()=>({...Tc,...a.labels})),$=e.computed(()=>({accept:f.value,multiple:!1,disabled:a.disabled||a.readonly||x.value})),C=e.computed(()=>({item:s.value,hasItem:x.value,isLoading:h.value,isUploading:g.value,isReadyToSubmit:v.value,errors:B.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,labels:w.value,dropzoneProps:$.value}));return o({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:p,retryUpload:m,isLoading:h,isUploading:g,isReadyToSubmit:v,hasItem:x,errors:B,adapter:E,formValue:y,acceptString:f}),(b,N)=>e.renderSlot(b.$slots,"default",e.normalizeProps(e.guardReactiveProps(C.value)))}}),t4=["name","value"],n4=["name","value"],o4=["name","value"],a4=["name","value"],r4=e.defineComponent({__name:"MediaHiddenFields",props:{items:{default:()=>[]},item:{default:null},name:{default:"media"},format:{default:"mediables"}},setup(n){const o=n,t=e.computed(()=>o.item?[o.item]:o.items),a=e.computed(()=>ei(t.value));function r(l,c){var u;const d=((u=a.value[l])==null?void 0:u.uuid)||"";return`${o.name}[${d}][${c}]`}function i(l,c){return`${o.name}[${l}][${c}]`}function s(l,c){return o.format==="spatie"?r(l,c):i(l,c)}return(l,c)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(d,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:d.uuid},[e.createElementVNode("input",{type:"hidden",name:s(u,"uuid"),value:d.uuid},null,8,t4),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,n4),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,o4),d.custom_properties&&Object.keys(d.custom_properties).length>0?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:s(u,"custom_properties"),value:JSON.stringify(d.custom_properties)},null,8,a4)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=xc;exports.AlbumManager=AS;exports.AlbumMediaGrid=JS;exports.AlbumTree=kc;exports.ArrayBufferTarget=gl;exports.ImageEditor=nl;exports.ImageEditorModal=ol;exports.LiveStreamManager=uS;exports.ManagedMediaGallery=yu;exports.MediaAttachment=KE;exports.MediaCollection=WE;exports.MediaCollectionDropzone=ri;exports.MediaCollectionItem=ii;exports.MediaWorkspace=fu;exports.ModelMediaManager=hp;exports.Muxer=Bf;exports.VideoEditor=gc;exports.VideoEditorDialog=t2;exports.VideoEditorSimple=C2;exports.VideoExportPanel=ak;exports.VideoJobClient=Qr;exports.VideoPlayer=yc;exports.VideoTimeline=H2;exports.VideoToolsPanel=Aw;exports.VideoUploader=Uk;exports._sfc_main=QE;exports._sfc_main$1=e4;exports._sfc_main$2=r4;exports.applyTemporaryMediaStoreConfig=Ks;exports.configureMediaStore=Cn;exports.createAdapter=Sc;exports.createMediablesAdapter=ti;exports.createSpatieAdapter=ni;exports.formatFileSize=ua;exports.fromMediaArray=Fr;exports.getFileExtension=Ec;exports.getImageDimensions=Cc;exports.getMediablesAdapter=qS;exports.getSpatieAdapter=eE;exports.isImageFile=oi;exports.resetMediablesAdapter=KS;exports.resetSpatieAdapter=tE;exports.restoreMediaStoreConfig=qs;exports.snapshotMediaStoreConfig=Js;exports.toFormValues=ei;exports.useAdminMediaStore=Qs;exports.useAlbumDragDrop=wc;exports.useAlbumStore=za;exports.useAlbums=bc;exports.useMediaAttachment=si;exports.useMediaCollection=Aa;exports.useMediaDragSort=_c;exports.useMediaStore=vt;exports.useMediaUploadQueue=Nc;exports.useMediaValidation=ai;exports.validateFile=Vc;
|
|
76
|
-
//# sourceMappingURL=index-DTUgsw7J.cjs.map
|