@codingfactory/mediables-vue 2.0.5 → 2.1.0
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/dist/PixiFrameExporter-CaDjKfAG.cjs +2 -0
- package/dist/{PixiFrameExporter-BTXhmL54.cjs.map → PixiFrameExporter-CaDjKfAG.cjs.map} +1 -1
- package/dist/{PixiFrameExporter-B5tJ62bD.js → PixiFrameExporter-CvKLKOXx.js} +60 -60
- package/dist/{PixiFrameExporter-B5tJ62bD.js.map → PixiFrameExporter-CvKLKOXx.js.map} +1 -1
- package/dist/composables/useFloatingPills.d.ts +2 -0
- package/dist/composables/useVideoEditor.d.ts +3 -2
- package/dist/filters/index.d.ts +3 -3
- package/dist/filters/registry.d.ts +15 -0
- package/dist/index-CXQ4ykVw.cjs +39 -0
- package/dist/index-CXQ4ykVw.cjs.map +1 -0
- package/dist/{index-BsOWbGbb.js → index-DBM_ViWA.js} +1629 -1562
- package/dist/index-DBM_ViWA.js.map +1 -0
- package/dist/{index-CWcyKIOz.js → index-DRQBqLZX.js} +8593 -8668
- package/dist/index-DRQBqLZX.js.map +1 -0
- package/dist/index-HREFg1jF.cjs +42 -0
- package/dist/index-HREFg1jF.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/render-page/assets/{index-hBfvGPpt.js → index-SU1f_egA.js} +45095 -22643
- package/dist/render-page/index.html +1 -1
- package/dist/style.css +1 -1
- package/dist/types/video.d.ts +1 -0
- package/dist/video-engine/adapters/MediablesCompositionAdapter.d.ts +2 -1
- package/dist/video-engine/index.d.ts +0 -2
- package/package.json +17 -18
- package/dist/PixiFrameExporter-BTXhmL54.cjs +0 -2
- package/dist/index-BsOWbGbb.js.map +0 -1
- package/dist/index-CWcyKIOz.js.map +0 -1
- package/dist/index-C_X9_ptj.cjs +0 -42
- package/dist/index-C_X9_ptj.cjs.map +0 -1
- package/dist/index-DVJg3EKN.cjs +0 -76
- package/dist/index-DVJg3EKN.cjs.map +0 -1
- package/dist/video-engine/adapters/CSSFilterAdapter.d.ts +0 -106
package/dist/index-DVJg3EKN.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 W=(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-C_X9_ptj.cjs"),Gs=require("pixi-filters"),B=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),f=e.ref(new Map),m=e.ref(new Map),h=e.ref(new Set),v=e.ref(new Map),b=e.ref({}),x=5*60*1e3,R=e.computed(()=>{if(yt.apiScope)return yt.apiScope;if(yt.isAdmin)return"admin"}),S=e.computed(()=>R.value==="admin");function g(){return yt.httpClient||hd}function p(q){const ue=yt.apiBaseUrl||"/api/v1",he=R.value?`/${R.value}`:"";return`${ue}${he}${q}`}function w(q,ue){return`${R.value??"default"}-${q}-${JSON.stringify(ue)}`}function $(q){return Date.now()-q<x}function C(){v.value.clear(),b.value={}}function y(q){if(!q||!q.data)return;const ue={};q.data.forEach(he=>{const we=`${he.file_name}-${he.collection_name||"default"}`,oe=ue[we];(!oe||Object.keys(he.generated_conversions||{}).length>Object.keys(oe.generated_conversions||{}).length)&&(ue[we]=he)}),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 he=w(q,ue),we=v.value.get(he);if(we&&$(we.timestamp)){const oe=we.data;return y(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()),S.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 pe=await g()(p(`/media?${oe}`));return v.value.set(he,{data:pe,timestamp:Date.now()}),y(pe),pe}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 z(q,ue){t.value=!0,a.value=null;const he=`${q.name}-${Date.now()}`,we={file:q,progress:0,status:"uploading"};f.value.set(he,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 pe=await g()(p("/media"),{method:"POST",body:oe});return we.status="completed",we.progress=100,we.media=pe==null?void 0:pe.data,r.value===1&&(pe!=null&&pe.data)&&(n.value=[pe.data,...n.value]),C(),(pe==null?void 0:pe.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(()=>{f.value.delete(he)},5e3)}}async function k(q){t.value=!0,a.value=null;const ue=n.value.findIndex(we=>we.uuid===q);let he;ue!==-1&&(he=n.value.splice(ue,1)[0]);try{return await g()(p(`/media/${q}`),{method:"DELETE"}),h.value.delete(q),C(),!0}catch(we){throw he&&ue!==-1&&n.value.splice(ue,0,he),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 g()(p(`/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(he){throw a.value=he instanceof Error?he.message:"Failed to update media",new Error(a.value)}finally{t.value=!1}}async function M(){t.value=!0,a.value=null;try{const ue=await g()(p("/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,he="images",we){d.value=!0,u.value=null;try{const oe=new URLSearchParams;oe.append("collection",he),we&&oe.append("search",we);const pe=await g()(p(`/media/model/${q}/${ue}?${oe}`));return pe!=null&&pe.data?(c.value=pe.data,pe.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 P(q,ue,he,we="images"){d.value=!0,u.value=null;const oe=[...c.value];try{const pe=await g()(p(`/media/model/${q}/${ue}/attach`),{method:"POST",body:{media_uuids:he,collection:we}});return await D(q,ue,we),(pe==null?void 0:pe.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 L(q,ue,he,we="images"){d.value=!0,u.value=null;const oe=[...c.value];c.value=c.value.filter(ye=>ye.uuid!==he);try{return await g()(p(`/media/model/${q}/${ue}/detach`),{method:"POST",body:{media_uuid:he,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 I(q,ue,he,we="images"){d.value=!0,u.value=null;const oe=[...c.value],ye=new Map(c.value.map(pe=>[pe.uuid,pe]));c.value=he.map(pe=>ye.get(pe)).filter(pe=>pe!==void 0);try{return await g()(p(`/media/model/${q}/${ue}/reorder`),{method:"POST",body:{media_uuids:he,collection:we}}),!0}catch(pe){throw c.value=oe,u.value=pe instanceof Error?pe.message:"Failed to reorder media",new Error(u.value)}finally{d.value=!1}}async function _(q,ue,he={}){const we=g(),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:he.asVariant===!0};return he.name!==void 0&&(ye.name=he.name),(await we(`${oe}/editor/${q}/save`,{method:"POST",body:ye})).media}function j(q,ue,he){l.value=he!==void 0?{type:q,uuid:ue,collection:he}:{type:q,uuid:ue},b.value[`${q}-${ue}`]={timestamp:Date.now()}}function U(){l.value={type:null,uuid:null},c.value=[],u.value=null}async function Q(){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 ge(){n.value.forEach(q=>h.value.add(q.uuid))}function Be(){h.value.clear()}function Ce(q){h.value.has(q)?h.value.delete(q):h.value.add(q)}function ie(q){return h.value.has(q)}function F(){return Array.from(f.value.values()).some(q=>q.status==="uploading")}function X(q){return f.value.get(q)||m.value.get(q)}function te(){return[...Array.from(f.value.values()),...Array.from(m.value.values())]}async function ae(){const q=Array.from(h.value);let ue=0;for(const he of q)try{await k(he),ue++}catch{}return Be(),ue}function re(q,ue){var he;return ue&&((he=q.conversion_urls)!=null&&he[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:S,modelContext:l,modelMedia:c,isLoadingModelMedia:d,modelMediaError:u,selectedItems:h,uploadProgress:f,uploadQueue:m,cachedResponses:b,fetchMedia:N,uploadFile:z,deleteMedia:k,updateMedia:T,clearCache:C,fetchCollections:M,fetchModelMedia:D,attachMedia:P,detachMedia:L,reorderMedia:I,saveEditedImage:_,setModelContext:j,clearModelContext:U,refreshModelMedia:Q,selectAllItems:ge,clearSelection:Be,toggleSelection:Ce,isSelected:ie,deleteSelectedItems:ae,hasActiveUploads:F,getUploadProgress:X,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 _e(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++,_e({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=_e;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;_e({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;_e({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}]});_e({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}]});_e({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}]});_e({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;_e({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}]});_e({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}]});_e({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;_e({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;_e({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;_e({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;_e({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;_e({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),f=this._customParams||{};switch(this._customParams=f,f[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;_e({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;_e({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 f=Math.floor(Math.random()*255),m=Math.floor(Math.random()*255),h=Math.floor(Math.random()*255);return f<<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(f=>({offset:f.offset,color:typeof f.color=="number"?"#"+f.color.toString(16).padStart(6,"0"):f.color,alpha:f.alpha}));break;case"removeColorStop":const u=[...this.stops];u.length>2&&(u.pop(),this.stops=u,i.colorStops=this.stops.map(f=>({offset:f.offset,color:typeof f.color=="number"?"#"+f.color.toString(16).padStart(6,"0"):f.color,alpha:f.alpha})));break;case"cssGradient":if(r&&typeof r=="string"&&r.trim()!=="")try{const f=new Gi({css:r});this.type=f.type,this.angle=f.angle,this.stops=[...f.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 f=r.map(m=>({offset:m.offset,color:typeof m.color=="string"?parseInt(m.color.replace("#","0x")):m.color,alpha:m.alpha}));f.sort((m,h)=>m.offset-h.offset),this.stops=f}break;default:if(/colorStops\[\d+\]\..*/.test(a)){const f=a.match(/colorStops\[(\d+)\]\.(.*)/);if(f){const[m,h,v]=f,b=parseInt(h),x=[...this.stops];if(b>=0&&b<x.length)return v==="color"&&typeof r=="string"?x[b].color=parseInt(r.replace("#","0x")):(v==="offset"||v==="alpha")&&(x[b][v]=r),this.stops=x,this.stops.sort((R,S)=>R.offset-S.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)"'}]});_e({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;_e({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;_e({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;_e({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;_e({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;_e({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;_e({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;_e({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;_e({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,f;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,(f=this._updateStrength)==null||f.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;_e({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]};_e({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}]});_e({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}]});_e({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;_e({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}]});_e({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;_e({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};_e({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 f=this.green;l==="greenX"?f.x=c:f.y=c,this.green=f;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;_e({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;_e({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;_e({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 f=this._customParams||{};switch(this._customParams=f,f[d]=u,d){case"textureType":f.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 b=h.createRadialGradient(128,128,5,128,128,80);b.addColorStop(0,"white"),b.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),b.addColorStop(1,"rgba(0, 0, 0, 0)"),h.fillStyle=b,h.beginPath(),h.arc(128,128,100,0,Math.PI*2),h.fill()}else if(u==="softlight"){const b=h.createLinearGradient(0,0,256,256);b.addColorStop(0,"white"),b.addColorStop(.3,"rgba(220, 220, 220, 1)"),b.addColorStop(.7,"rgba(150, 150, 150, 1)"),b.addColorStop(1,"rgba(80, 80, 80, 1)"),h.fillStyle=b,h.fillRect(0,0,256,256)}else{const b=h.createRadialGradient(128,128,10,128,128,160);b.addColorStop(0,"white"),b.addColorStop(.3,"rgba(220, 220, 220, 1)"),b.addColorStop(.6,"rgba(150, 150, 150, 1)"),b.addColorStop(1,"black"),h.fillStyle=b,h.fillRect(0,0,256,256)}const v=Hi.from(m);if(this.lightMap=v,this.enabled!==void 0){const b=this.enabled;this.enabled=!1,setTimeout(()=>{this.enabled=b},0)}}break;case"color":f.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;_e({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;_e({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;_e({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;_e({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;_e({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;_e({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(f,m){const h=this._customParams||{};switch(this._customParams=h,h[f]=m,f){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[f]=m;break;case"animating":this.animating=m;break;default:f in this&&(this[f]=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;_e({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;_e({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()}}_e({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"},preset:{},primaryColor:{default:"#3880ff"},secondaryColor:{default:"#5260ff"},saveButtonColor:{default:"#3880ff"},downloadButtonColor:{default:"#2dd36f"}},emits:["save","cancel","error"],setup(n,{emit:o}){const t=n,a=o,r=e.ref(null);let i=null,s=null;function l(){if(!i){a("error",new Error("Editor not initialized"));return}const u=i.exportImage("png",.92);if(!u){a("error",new Error("Failed to export image — the image could not be processed"));return}const f=i.getState(),m=f.crop,h=f.activeFilters,v=f.filterValues,b=i._renderer.sprite,x={width:Math.round((b==null?void 0:b.width)??0),height:Math.round((b==null?void 0:b.height)??0)},R={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:v??{},aspectRatio:(m==null?void 0:m.aspect)??"free",dimensions:x}};a("save",R)}function c(){a("cancel")}function d(){if(!r.value||i)return;window.PIXI=Ae,nu();const u={theme:t.theme};t.preset&&(u.preset=t.preset),t.preset?t.cropShape==="circle"&&(u.cropShape="circle",u.initialAspectRatio="1:1",u.initialMode="crop"):(u.cropShape=t.cropShape==="circle"?"circle":"free",u.initialAspectRatio=t.cropShape==="circle"?"1:1":"free",u.initialMode=t.cropShape==="circle"?"crop":"adjust"),i=new no.VanillaImageEditor(r.value,u),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 f=u[0];f&&f.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,f)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:r,class:"vanilla-editor-wrapper","data-testid":"vanilla-image-editor"},null,512))}}),Te=(n,o)=>{const t=n.__vccOpts||n;for(const[a,r]of o)t[a]=r;return t},nl=Te(ou,[["__scopeId","data-v-3b3ff253"]]),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"},preset:{},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(null),i=e.ref(t.modelValue),s=e.ref(null),l=e.ref(!1),c=e.ref(null),d=S=>new Promise((g,p)=>{const w=new FileReader;w.onload=$=>{var y;const C=(y=$.target)==null?void 0:y.result;typeof C=="string"?g(C):p(new Error("Failed to read file"))},w.onerror=()=>p(new Error("Failed to read file")),w.readAsDataURL(S)}),u=S=>{a("error",S)},f=async()=>{if(t.initialImage instanceof File)try{const S=await d(t.initialImage);s.value=S}catch(S){u(S)}else typeof t.initialImage=="string"&&(s.value=t.initialImage)},m=()=>{e.nextTick(()=>{if(r.value){const S=r.value.querySelector("button:not([disabled]), [href], input:not([disabled])");S&&S.focus()}})};e.watch(()=>t.modelValue,S=>{i.value=S,S&&(c.value=document.activeElement,t.initialImage&&f(),m())},{immediate:!0}),e.watch(()=>t.initialImage,S=>{S&&i.value&&f()});const h=async S=>{try{l.value=!0,t.onSave&&await t.onSave(S),a("save",S)}catch(g){u(g)}finally{l.value=!1}},v=()=>{a("cancel"),x()},b=()=>{l.value||x()},x=()=>{i.value=!1,a("update:modelValue",!1),c.value&&c.value instanceof HTMLElement&&(c.value.focus(),c.value=null),setTimeout(()=>{s.value=null},300)},R=S=>{if(S.key==="Escape"&&i.value&&!l.value){x();return}if(S.key==="Tab"&&i.value&&r.value){const g=r.value.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const p=g[0],w=g[g.length-1];S.shiftKey&&document.activeElement===p?(S.preventDefault(),w.focus()):!S.shiftKey&&document.activeElement===w&&(S.preventDefault(),p.focus())}};return e.onMounted(()=>{document.addEventListener("keydown",R)}),e.onBeforeUnmount(()=>{document.removeEventListener("keydown",R)}),t.modelValue&&t.initialImage&&f(),(S,g)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[i.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"overlayRef",ref:r,role:"dialog","aria-modal":"true","aria-label":"Image editor",class:"editor-modal-overlay","data-testid":"image-editor-modal",onKeydown:e.withKeys(b,["escape"])},[e.createElementVNode("div",{class:"editor-modal-backdrop",onClick:b}),e.createElementVNode("div",au,[e.createElementVNode("div",ru,[e.createVNode(nl,{"initial-image":s.value??S.initialImage,theme:S.theme,"crop-shape":S.cropShape,preset:S.preset,"primary-color":S.primaryColor,"secondary-color":S.secondaryColor,"save-button-color":S.saveButtonColor,"download-button-color":S.downloadButtonColor,onSave:h,onCancel:v,onError:u},null,8,["initial-image","theme","crop-shape","preset","primary-color","secondary-color","save-button-color","download-button-color"])])])],544)):e.createCommentVNode("",!0)]))}}),ol=Te(iu,[["__scopeId","data-v-e19beb15"]]),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 f;const t=n,a=o,r=vt(),i=e.ref(t.initialScopeId??((f=t.subScopes[0])==null?void 0:f.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]=v=>i.value=v),"data-testid":"scope-select",class:"media-workspace-select"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,v=>(e.openBlock(),e.createElementBlock("option",{key:v.id,value:v.id},e.toDisplayString(v.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]=v=>a("upload"))}," Upload ")]),e.createElementVNode("div",uu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(r).items,v=>(e.openBlock(),e.createElementBlock("button",{key:v.uuid,type:"button",class:"media-workspace-item","data-testid":"media-item",onClick:b=>a("preview",v)},e.toDisplayString(v.file_name),9,mu))),128))])]))}}),fu=Te(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=Te(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((f,m)=>{r=o.rejectOnCancel?m:f,s=c,u&&!a&&(a=setTimeout(()=>{t&&i(t),a=null,f(s())},u)),t=setTimeout(()=>{a&&i(a),a=null,f(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 f(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 v(){n.value.forEach(w=>o.value.add(w.uuid))}function b(){o.value.clear(),t.value=null,a.value=-1}function x(){c.value?b():v()}function R(w,$){const C=n.value.findIndex(y=>y.uuid===w);if(C!==-1)if($!=null&&$.shiftKey&&a.value!==-1){const y=Math.min(a.value,C),N=Math.max(a.value,C);for(let z=y;z<=N;z++)o.value.add(n.value[z].uuid)}else f(w)}function S(){if(n.value.length===0)return;let w=a.value+1;w>=n.value.length&&(w=0),b(),m(n.value[w].uuid)}function g(){if(n.value.length===0)return;let w=a.value-1;w<0&&(w=n.value.length-1),b(),m(n.value[w].uuid)}function p(w){switch(w.key){case"ArrowDown":w.preventDefault(),S();break;case"ArrowUp":w.preventDefault(),g();break;case"a":(w.ctrlKey||w.metaKey)&&(w.preventDefault(),v());break;case"Escape":w.preventDefault(),b();break;case" ":t.value&&(w.preventDefault(),f(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:f,select:m,deselect:h,selectAll:v,clear:b,toggleAll:x,rangeSelect:R,selectNext:S,selectPrevious:g,handleKeydown:p,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)),f=e.ref(!1),m=e.ref({}),h=e.ref(["images","documents","videos"]),v=e.ref(1),b=e.ref(!0),x=e.ref(!1),R=Qs(),S=mm(c);function g(F){var he;const X=F.conversion_urls||{},te=F.proxy_url||F.original_url||F.url||"",ae=X.thumb||X.preview||F.preview_url||F.thumbnail_url||te,re=F.custom_properties||{},q=re.width,ue=re.height;return{...F,uuid:F.uuid,name:F.name||F.file_name,file_name:F.file_name,filename:F.file_name,mime_type:F.mime_type,size:F.size,collection_name:F.collection_name||"images",disk:F.disk,original_url:te,url:te,thumbnail_url:ae,conversions:F.conversions||{},conversion_urls:X,generated_conversions:F.generated_conversions||{},custom_properties:re,caption:F.caption||null,alt_text:F.alt_text||null,created_at:F.created_at,updated_at:F.updated_at,is_image:((he=F.mime_type)==null?void 0:he.startsWith("image/"))||!1,...typeof q=="number"?{width:q}:{},...typeof ue=="number"?{height:ue}:{},...F.formatted_size!==void 0?{formatted_size:F.formatted_size}:{}}}e.watch(()=>t.selectedItems,F=>{u.value=new Set(F),S.clear(),F.forEach(X=>S.select(X))});const p=e.computed(()=>{var X;let F=c.value;return(X=m.value.types)!=null&&X.length&&(F=F.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)&&(F=F.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)})),F}),w=e.computed(()=>{var X;let F=0;return m.value.search&&F++,m.value.collection&&F++,(m.value.dateFrom||m.value.dateTo)&&F++,(X=m.value.types)!=null&&X.length&&(F+=m.value.types.length),(m.value.sizeMin!==void 0||m.value.sizeMax!==void 0)&&F++,F}),$=e.computed(()=>{const F=S.selectedCount.value;return F===0?"Select Media":`Select ${t.selectionMode==="multiple"?`${F} ${F===1?"Item":"Items"}`:"Item"}`}),C=e.computed(()=>{const F=S.selectedCount.value;return!!(F===0||t.selectionMode==="single"&&F>1||t.maxSelection&&F>t.maxSelection)}),y=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(F=!0){F?(l.value=!0,c.value=[],v.value=1,b.value=!0):x.value=!0;try{const X={collection:m.value.collection||t.collection,per_page:24};switch((s.value||m.value.search)&&(X.search=s.value||m.value.search||""),m.value.dateFrom&&(X.from_date=m.value.dateFrom),m.value.dateTo&&(X.to_date=m.value.dateTo),r.value){case"recent":await R.fetchMedia(v.value,X),F?c.value=R.items.map(te=>g(te)):c.value=[...c.value,...R.items.map(te=>g(te))],b.value=R.currentPage<R.totalPages;break;case"model":if(t.modelType&&t.modelId){const te=await R.fetchModelMedia(t.modelType,t.modelId,X.collection,X.search);c.value=te?te.map(ae=>g(ae)):[],b.value=!1}break;case"library":await R.fetchMedia(v.value,X),F?c.value=R.items.map(te=>g(te)):c.value=[...c.value,...R.items.map(te=>g(te))],b.value=R.currentPage<R.totalPages;break}}catch{}finally{l.value=!1,x.value=!1}}async function z(F){if(!b.value||x.value){F!=null&&F.target&&F.target.complete();return}v.value++,await N(!1),F!=null&&F.target&&(F.target.complete(),b.value||(F.target.disabled=!0))}function k(F){return F==="recent"||F==="model"||F==="library"}function T(F){r.value=F,N()}function M(F){typeof F=="string"&&k(F)&&T(F)}async function D(F){t.selectionMode==="single"?(S.clear(),S.select(F.uuid)):(S.toggle(F.uuid),t.maxSelection&&S.selectedCount.value>t.maxSelection&&(S.deselect(F.uuid),await(await B.toastController.create({message:`Maximum ${t.maxSelection} items can be selected`,duration:2e3,color:"warning"})).present()))}function P(){a("confirm",S.selectedItems.value)}function L(){a("close")}function I(F){}const _=e.ref(null),j=e.ref(!1);function U(F){_.value=F,j.value=!0}function Q(F){const X=c.value.findIndex(ae=>ae.uuid===F.uuid);X!==-1&&(c.value[X]=F);const te={};F.alt_text!==void 0&&(te.alt_text=F.alt_text),F.caption!==void 0&&(te.caption=F.caption),F.custom_properties!==void 0&&(te.custom_properties=F.custom_properties),R.updateMedia(F.uuid,te)}function ge(){N()}function Be(){m.value={},s.value="",N()}const Ce=cm(()=>{N(!0)},300);e.watch(s,()=>{t.isOpen&&Ce()});async function ie(F){try{await(await B.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 R.deleteMedia(F),await N()}}]})).present()}catch{}}return e.watch(()=>t.isOpen,F=>{F&&N()}),e.onMounted(()=>{t.selectedItems.length>0&&t.selectedItems.forEach(F=>S.select(F))}),(F,X)=>{const te=e.resolveComponent("AdminMediaGrid"),ae=e.resolveComponent("AdminMediaListItem");return e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":F.isOpen,onDidDismiss:L,"backdrop-dismiss":!1,class:"media-browser-modal"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{onClick:L},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(y.value),1)]),_:1})]),_:1}),e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",pm,[e.createVNode(e.unref(B.IonSegment),{value:r.value,onIonChange:X[0]||(X[0]=re=>M(re.detail.value)),class:"max-w-xs"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonSegmentButton),{value:"recent"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...X[15]||(X[15]=[e.createTextVNode("Recent",-1)])]),_:1})]),_:1}),t.modelType&&t.modelId?(e.openBlock(),e.createBlock(e.unref(B.IonSegmentButton),{key:0,value:"model"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...X[16]||(X[16]=[e.createTextVNode("Model",-1)])]),_:1})]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonSegmentButton),{value:"library"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...X[17]||(X[17]=[e.createTextVNode("Library",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),e.createVNode(e.unref(B.IonButton),{fill:"clear",size:"small",onClick:X[1]||(X[1]=re=>f.value=!f.value),class:"relative"},{"icon-only":e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"filter-outline"})]),default:e.withCtx(()=>[w.value>0?(e.openBlock(),e.createBlock(e.unref(B.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(B.IonContent),null,{default:e.withCtx(()=>[e.createElementVNode("div",fm,[f.value?(e.openBlock(),e.createElementBlock("div",hm,[e.createElementVNode("div",vm,[e.createElementVNode("div",null,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...X[18]||(X[18]=[e.createTextVNode("Collection",-1)])]),_:1}),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":X[2]||(X[2]=re=>m.value.collection=re),class:"w-full p-2 border rounded"},[X[19]||(X[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(B.IonLabel),null,{default:e.withCtx(()=>[...X[20]||(X[20]=[e.createTextVNode("From Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":X[3]||(X[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(B.IonLabel),null,{default:e.withCtx(()=>[...X[21]||(X[21]=[e.createTextVNode("To Date",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":X[4]||(X[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(B.IonButton),{size:"small",onClick:ge},{default:e.withCtx(()=>[...X[22]||(X[22]=[e.createTextVNode("Apply",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{size:"small",fill:"clear",onClick:Be},{default:e.withCtx(()=>[...X[23]||(X[23]=[e.createTextVNode("Clear",-1)])]),_:1})])])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonSearchbar),{modelValue:s.value,"onUpdate:modelValue":X[5]||(X[5]=re=>s.value=re),placeholder:"Search media...",debounce:300,class:"mb-4"},null,8,["modelValue"]),e.createElementVNode("div",bm,[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{fill:i.value==="grid"?"solid":"clear",size:"small",onClick:X[6]||(X[6]=re=>i.value="grid")},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"grid-outline"})]),_:1},8,["fill"]),e.createVNode(e.unref(B.IonButton),{fill:i.value==="list"?"solid":"clear",size:"small",onClick:X[7]||(X[7]=re=>i.value="list")},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"list-outline"})]),_:1},8,["fill"])]),_:1})]),l.value?(e.openBlock(),e.createElementBlock("div",wm,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):p.value.length===0?(e.openBlock(),e.createElementBlock("div",km,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-theme-secondary mb-4"}),X[24]||(X[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":p.value,"selected-items":e.unref(S).selectedItems.value,"is-loading":!1,"selection-mode":!0,columns:{mobile:2,sm:3,md:4,lg:5,xl:6},onToggleSelect:D,onPreview:I,onEdit:U,onDelete:ie},null,8,["media-items","selected-items"])):(e.openBlock(),e.createBlock(e.unref(B.IonList),{key:4,lines:"none",class:"rounded-lg overflow-hidden"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(re,q)=>(e.openBlock(),e.createBlock(ae,{key:re.uuid,media:re,selected:e.unref(S).isSelected(re.uuid),"selection-mode":!0,index:q,onToggleSelect:D,onPreview:I,onEdit:U,onDelete:ie},null,8,["media","selected","index"]))),128))]),_:1})),!l.value&&p.value.length>0&&r.value!=="model"?(e.openBlock(),e.createBlock(e.unref(B.IonInfiniteScroll),{key:5,threshold:"100px",onIonInfinite:X[8]||(X[8]=re=>z(re))},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonInfiniteScrollContent),{"loading-spinner":"crescent","loading-text":"Loading more media..."})]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(e.unref(B.IonModal),{"is-open":j.value,onDidDismiss:X[14]||(X[14]=re=>j.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{end:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{onClick:X[9]||(X[9]=re=>j.value=!1)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{name:"close-outline"})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[...X[25]||(X[25]=[e.createTextVNode("Edit Media Info",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"p-4"},{default:e.withCtx(()=>[_.value?(e.openBlock(),e.createElementBlock("div",Sm,[e.createElementVNode("div",Em,[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...X[26]||(X[26]=[e.createTextVNode("Caption",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":X[10]||(X[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(B.IonLabel),null,{default:e.withCtx(()=>[...X[27]||(X[27]=[e.createTextVNode("Alt Text",-1)])]),_:1}),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":X[11]||(X[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(B.IonButton),{onClick:X[12]||(X[12]=re=>Q(_.value))},{default:e.withCtx(()=>[...X[28]||(X[28]=[e.createTextVNode("Save",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:X[13]||(X[13]=re=>j.value=!1)},{default:e.withCtx(()=>[...X[29]||(X[29]=[e.createTextVNode("Cancel",-1)])]),_:1})])])):e.createCommentVNode("",!0)]),_:1})]),_:1},8,["is-open"]),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createElementVNode("div",Nm,[e.createElementVNode("div",_m,[e.unref(S).selectedCount.value>0?(e.openBlock(),e.createElementBlock("span",Tm,[e.createTextVNode(e.toDisplayString(e.unref(S).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(B.IonButton),{fill:"clear",onClick:L},{default:e.withCtx(()=>[...X[30]||(X[30]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(B.IonButton),{disabled:C.value,onClick:P},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString($.value),1)]),_:1},8,["disabled"])])])]),_:1})]),_:1})]),_:1},8,["is-open"])}}}),Rm=Te(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(y=>y.uuid===C.uuid),d=e.computed(()=>{const C=t.columns,y=["grid","gap-4"];switch(C.mobile){case 1:y.push("grid-cols-1");break;case 2:y.push("grid-cols-2");break;case 3:y.push("grid-cols-3");break;case 4:y.push("grid-cols-4");break;default:y.push("grid-cols-2");break}switch(C.sm){case 1:y.push("sm:grid-cols-1");break;case 2:y.push("sm:grid-cols-2");break;case 3:y.push("sm:grid-cols-3");break;case 4:y.push("sm:grid-cols-4");break;case 5:y.push("sm:grid-cols-5");break;default:y.push("sm:grid-cols-3");break}switch(C.md){case 2:y.push("md:grid-cols-2");break;case 3:y.push("md:grid-cols-3");break;case 4:y.push("md:grid-cols-4");break;case 5:y.push("md:grid-cols-5");break;case 6:y.push("md:grid-cols-6");break;default:y.push("md:grid-cols-4");break}switch(C.lg){case 3:y.push("lg:grid-cols-3");break;case 4:y.push("lg:grid-cols-4");break;case 5:y.push("lg:grid-cols-5");break;case 6:y.push("lg:grid-cols-6");break;case 7:y.push("lg:grid-cols-7");break;default:y.push("lg:grid-cols-5");break}switch(C.xl){case 4:y.push("xl:grid-cols-4");break;case 5:y.push("xl:grid-cols-5");break;case 6:y.push("xl:grid-cols-6");break;case 7:y.push("xl:grid-cols-7");break;case 8:y.push("xl:grid-cols-8");break;default:y.push("xl:grid-cols-6");break}return y.join(" ")});function u(C,y,N){t.reorderable&&(r.value=y,C.dataTransfer&&(C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/html","")))}function f(C,y){t.reorderable&&(C.preventDefault(),i.value=y)}function m(){i.value=null}function h(C,y){if(!t.reorderable||!r.value)return;C.preventDefault();const N=[...t.mediaItems],z=N.findIndex(k=>{var T;return k.uuid===((T=r.value)==null?void 0:T.uuid)});if(z!==-1&&z!==y&&r.value){const[k]=N.splice(z,1);N.splice(y,0,k),a("reorder",N)}r.value=null,i.value=null}function v(C){return C<1024?C+" B":C<1024*1024?(C/1024).toFixed(1)+" KB":(C/(1024*1024)).toFixed(1)+" MB"}function b(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 z,k,T;const y=((z=C.mime_type)==null?void 0:z.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 y&&N}function R(C){var y;return((y=C.split(".").pop())==null?void 0:y.toUpperCase())||""}function S(C){var N;const y=((N=C.mime_type)==null?void 0:N.toLowerCase())||"";return y.startsWith("image/")?"image":y.startsWith("video/")?"videocam":y.startsWith("audio/")?"musical-notes":y.includes("pdf")?"document-text":y.includes("zip")||y.includes("rar")?"archive":y.includes("sheet")||y.includes("excel")?"grid":y.includes("document")||y.includes("word")?"document-text":"document"}e.onMounted(()=>{typeof window<"u"&&"IntersectionObserver"in window&&(l.value=new IntersectionObserver(C=>{C.forEach(y=>{var N;if(y.isIntersecting){const z=y.target.getAttribute("data-media-id");z&&(s.value.add(z),(N=l.value)==null||N.unobserve(y.target))}})},{rootMargin:"50px"}))}),e.onUnmounted(()=>{l.value&&l.value.disconnect()});function g(C){return!0}function p(){l.value&&e.nextTick(()=>{document.querySelectorAll("[data-media-id]").forEach(y=>{var z;const N=y.getAttribute("data-media-id");N&&!s.value.has(N)&&((z=l.value)==null||z.observe(y))})})}e.watch(()=>t.mediaItems,()=>{s.value.clear(),p()},{immediate:!0,deep:!0});function w(C,y){const N=C.target;delete N.dataset.fallbackIndex}function $(C,y){const N=C.target,z=N.closest("[data-media-id]"),k=[y.original_url,y.url,y.thumbnail_url,"preview_url"in y?y.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",z&&!z.querySelector(".media-fallback-icon")){const M=document.createElement("div");M.className="media-fallback-icon w-full h-full flex items-center justify-center bg-gray-100 dark:bg-gray-800",M.innerHTML=`
|
|
2
|
-
<div class="text-center">
|
|
3
|
-
<div class="text-4xl text-gray-400 mb-2">${S(y)}</div>
|
|
4
|
-
<p class="text-sm font-medium text-gray-500">${R(y.file_name)}</p>
|
|
5
|
-
</div>
|
|
6
|
-
`,z.appendChild(M)}}return(C,y)=>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"},[...y[1]||(y[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,[y[2]||(y[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)),y[3]||(y[3]=e.createElementVNode("h3",{class:"text-lg font-medium mb-2"}," No Media Items ",-1)),y[4]||(y[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:y[0]||(y[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,z)=>(e.openBlock(),e.createElementBlock("div",{key:N.uuid,class:e.normalizeClass(["relative group",{"ring-2 ring-blue-500 ring-offset-2":i.value===z}]),draggable:C.reorderable,onDragstart:k=>u(k,N),onDragover:k=>f(k,z),onDragleave:m,onDrop:k=>h(k,z)},[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:z},void 0,!0)],2)):e.createCommentVNode("",!0),C.reorderable?(e.openBlock(),e.createElementBlock("div",Dm,[...y[5]||(y[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)&&!g(N.uuid)?(e.openBlock(),e.createElementBlock("div",Om,[...y[6]||(y[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)&&g(N.uuid)?(e.openBlock(),e.createElementBlock("img",{key:1,src:b(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(S(N)),1),e.createElementVNode("p",Zm,e.toDisplayString(R(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"},[...y[7]||(y[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"},[...y[8]||(y[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"},[...y[9]||(y[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(v(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=Te(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),f=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(I=>I.uuid)),v=e.computed(()=>{if(!(!t.acceptedMimeTypes||t.acceptedMimeTypes.length===0))return t.acceptedMimeTypes.join(",")}),b=e.computed(()=>{if(d.value)return w(d.value)??void 0});function x(){Cn({isAdmin:t.mode==="admin"})}async function R(I){await(await B.toastController.create({message:I,duration:3e3,color:"danger",position:"bottom"})).present()}async function S(){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(I){const _=I instanceof Error?I.message:"Failed to fetch media";a("error",{operation:"fetch",message:_,details:I})}finally{i.value=!1,a("loading",!1)}}}e.watch(()=>r.modelMedia,I=>{s.value&&a("update:media",I)},{deep:!0}),e.watch(()=>[t.mediableType,t.mediableId,t.collection],()=>{s.value=!1,S()}),e.watch(()=>t.mode,()=>{x()}),e.onMounted(()=>{S()}),e.onUnmounted(()=>{r.clearModelContext()});function g(){return r.modelMedia.length>0}function p(){return t.maxFiles===void 0?!1:r.modelMedia.length>=t.maxFiles}function w(I){var j,U,Q;if(!((j=I.mime_type)!=null&&j.startsWith("image/")))return null;const _=I.original_url||I.url||((U=I.conversion_urls)==null?void 0:U.preview)||((Q=I.conversion_urls)==null?void 0:Q.thumb)||I.thumbnail_url;return _&&_.trim()!==""?_:null}function $(){l.value=!0}function C(){var I;(I=f.value)==null||I.click()}function y(){l.value=!1}function N(I){!t.allowEdit||!w(I)||(d.value=I,c.value=!0)}function z(){c.value=!1,d.value=null}async function k(I){if(!d.value)throw new Error("No media selected for editing");const _=d.value,j=t.editMode==="variant";try{u.value=null;const U=await r.saveEditedImage(_.uuid,I,{asVariant:j,name:_.file_name});j||await r.detachMedia(t.mediableType,t.mediableId,_.uuid,t.collection),await r.attachMedia(t.mediableType,t.mediableId,[U.uuid],t.collection),a("edit-complete",{originalMedia:_,editedMedia:U,mode:t.editMode}),c.value=!1,d.value=null}catch(U){const Q=U instanceof Error?U.message:"Failed to save edited image";throw u.value=Q,await R(Q),U}}function T(I){if(u.value===I.message){u.value=null;return}R(I.message)}async function M(I){const _=I.target,j=_.files;if(!(!j||j.length===0)){for(let U=0;U<j.length;U++){const Q=j[U];if(m.value!==void 0&&m.value<=0)break;if(t.acceptedMimeTypes&&t.acceptedMimeTypes.length>0&&!t.acceptedMimeTypes.includes(Q.type)){a("error",{operation:"upload",message:`File type ${Q.type} is not accepted`,details:{file:Q.name}});continue}if(t.maxFileSize!==void 0&&Q.size>t.maxFileSize){a("error",{operation:"upload",message:`File size exceeds limit of ${t.maxFileSize} bytes`,details:{file:Q.name,size:Q.size}});continue}a("upload-progress",{status:"uploading",progress:0,file:Q});try{const ge=await r.uploadFile(Q,{collection:t.collection});ge!=null&&ge.uuid&&(await r.attachMedia(t.mediableType,t.mediableId,[ge.uuid],t.collection),a("upload-progress",{status:"complete",progress:100,file:Q}),a("attach",[ge]))}catch(ge){const Be=ge instanceof Error?ge.message:"Upload failed";a("error",{operation:"upload",message:Be,details:ge}),a("upload-progress",{status:"error",progress:0,file:Q,error:Be})}}_.value=""}}async function D(I){const _=I.map(j=>j.uuid);try{await r.reorderMedia(t.mediableType,t.mediableId,_,t.collection),a("reorder",r.modelMedia)}catch(j){const U=j instanceof Error?j.message:"Failed to reorder media";a("error",{operation:"reorder",message:U,details:j}),await R(U)}}async function P(I){const _=r.modelMedia.find(j=>j.uuid===I);try{await r.detachMedia(t.mediableType,t.mediableId,I,t.collection),_&&a("detach",_)}catch(j){const U=j instanceof Error?j.message:"Failed to detach media";a("error",{operation:"detach",message:U,details:j}),await R(U)}}async function L(I){l.value=!1;const _=I.map(Q=>Q.uuid),j=new Set(h.value);let U=Array.from(new Set(_)).filter(Q=>!j.has(Q));if(m.value!==void 0&&U.length>m.value&&(U=U.slice(0,m.value)),U.length!==0)try{await r.attachMedia(t.mediableType,t.mediableId,U,t.collection);const Q=r.modelMedia.filter(ge=>U.includes(ge.uuid));a("attach",Q)}catch(Q){const ge=Q instanceof Error?Q.message:"Failed to attach media";a("error",{operation:"attach",message:ge,details:Q})}}return(I,_)=>(e.openBlock(),e.createElementBlock("div",ap,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:f,type:"file",accept:v.value,multiple:m.value===void 0||m.value>1,class:"hidden","data-testid":"upload-input",onChange:M},null,40,rp),e.createElementVNode("div",ip,[I.title?(e.openBlock(),e.createElementBlock("h3",sp,e.toDisplayString(I.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",lp,[I.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small",disabled:p(),"data-testid":"browse-button",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(Ka)},null,8,["icon"]),_[1]||(_[1]=e.createTextVNode(" Browse ",-1))]),_:1},8,["disabled"])):e.createCommentVNode("",!0),I.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small",disabled:p(),"data-testid":"upload-button",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(B.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(B.IonSpinner),{"data-testid":"spinner"})])):g()?(e.openBlock(),e.createBlock(op,{key:2,"media-items":e.unref(r).modelMedia,reorderable:!!I.allowReorder,"is-loading":i.value||e.unref(r).isLoadingModelMedia,"show-edit-button":!!I.allowEdit,"selection-mode":!1,onReorder:D,onDelete:P,onEdit:N},e.createSlots({_:2},[I.showPrimaryBadge?{name:"badge",fn:e.withCtx(({index:j})=>[j===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(B.IonIcon),{icon:e.unref(Ka),class:"w-12 h-12 text-gray-400 mb-4"},null,8,["icon"]),e.createElementVNode("p",up,e.toDisplayString(I.emptyText),1),e.createElementVNode("div",mp,[I.allowBrowse?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,fill:"outline",size:"small","data-testid":"browse-button-empty",onClick:$},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"start",icon:e.unref(Ka)},null,8,["icon"]),_[3]||(_[3]=e.createTextVNode(" Browse Library ",-1))]),_:1})):e.createCommentVNode("",!0),I.allowUpload?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:1,fill:"solid",size:"small","data-testid":"upload-button-empty",onClick:C},{default:e.withCtx(()=>[e.createVNode(e.unref(B.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:I.collection},m.value!==null&&m.value!==void 0?{maxSelection:m.value}:{},{onConfirm:L,onClose:y}),null,16,["is-open","selected-items","collection"]),e.createVNode(ol,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":_[0]||(_[0]=j=>c.value=j)},b.value?{initialImage:b.value}:{},{"on-save":k,onCancel:z,onError:T}),null,16,["modelValue"])]))}}),hp=Te(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),f=e.ref(),m=e.ref(0),h=e.ref(0),v=e.ref(!1);let b,x,R=null,S=null,g=null,p=[],w="",$=null,C=0,y=0,N=0,z=0,k=!1,T=0,M=0,D,P=null,L=!1;const I=e.computed(()=>i.source&&typeof i.source=="string"?i.source:"");async function _(){var me,ke;if(c.value&&!b&&!(!d.value||d.value.readyState<3))try{let O=((me=l.value)==null?void 0:me.clientWidth)||800,ne=((ke=l.value)==null?void 0:ke.clientHeight)||450;if((O<=0||ne<=0)&&(O=d.value.videoWidth||800,ne=d.value.videoHeight||450),b=new Ae.Application,await b.init({width:O,height:ne,background:0,resolution:window.devicePixelRatio||1,autoDensity:!0,antialias:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),c.value.appendChild(b.canvas),d.value){if(d.value.videoWidth===0||d.value.videoHeight===0){setTimeout(()=>{d.value&&d.value.videoWidth>0&&!b&&_()},100),b&&(b.destroy(!0),b=null);return}C=d.value.videoWidth,y=d.value.videoHeight,S=document.createElement("canvas"),S.width=C,S.height=y,g=S.getContext("2d"),g.drawImage(d.value,0,0,C,y);const K=Ae.Texture.from(S);R=K.source,x=new Ae.Sprite(K),x.visible=!0,x.alpha=1,pe(),b.stage.addChild(x),b.renderer&&!b.renderer.destroyed&&b.render()}ge(),i.targetFps<60?j():b.ticker.add(U),v.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===z||(N=se,z=xe,pe())}))}),$.observe(l.value)),i.filters&&i.filters.length>0&&ge(),i.showFps&&he()}catch{f.value="Failed to initialize video preview"}}function j(){const me=1e3/i.targetFps;let ke=performance.now();function O(){if(L||!b)return;const ne=performance.now(),K=ne-ke;K>=me&&(U(),ke=ne-K%me),P=requestAnimationFrame(O)}P=requestAnimationFrame(O)}function U(){if(!(!b||!x||L)&&i.active)try{g&&S&&R&&d.value&&(d.value.readyState>=2&&(g.drawImage(d.value,0,0,S.width,S.height),R.update()),d.value.paused||s("frame-update",ie())),i.showFps&&M++,b.renderer&&!b.renderer.destroyed&&b.render()}catch{L=!0}}function Q(){for(const me of p)try{me.destroy()}catch{}p=[]}function ge(){if(x){if(!i.filters||i.filters.length===0){x.filters=null,Q();return}Q(),i.filters.forEach(me=>{const ke=Be(me);ke&&p.push(ke)}),x.filters=p.length>0?p:null,w=JSON.stringify(i.filters),b&&b.render()}}function Be(me){const ke=me.filterId,O=me.params||{},ne=no.getFilter(ke);if(ne&&ne.createFilter)try{return ne.createFilter(O)}catch{}const K=(ee,be,Y)=>Math.min(Y,Math.max(be,ee));switch(ke){case"brightness":{const ee=new a,be=K(typeof O.brightness=="number"?O.brightness:typeof O.value=="number"?O.value:1,0,5);return ee.brightness(be,!0),ee}case"contrast":{const ee=new a,be=K(typeof O.contrast=="number"?O.contrast:typeof O.value=="number"?O.value:1,0,5);return ee.contrast(be,!0),ee}case"saturation":{const ee=new a,be=K(typeof O.saturation=="number"?O.saturation:typeof O.value=="number"?O.value:1,0,5);return ee.saturate(be,!0),ee}case"hue":{const ee=new a,be=K(typeof O.value=="number"?O.value:0,-180,180);return ee.hue(be,!0),ee}case"gaussian-blur":case"blur":{const ee=K(typeof O.blur=="number"?O.blur:typeof O.value=="number"?O.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 O.value=="number"?O.value:.3;return Ce(K(ee,0,1))}default:return null}}function Ce(me){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:me})}function ie(){var ke;return!b||!x?null:{dataUrl:b.canvas.toDataURL("image/jpeg",.8),timestamp:((ke=d.value)==null?void 0:ke.currentTime)||0,width:C||0,height:y||0}}function F(){var me;m.value=((me=d.value)==null?void 0:me.duration)||0,s("duration-change",m.value)}function X(){u.value=!1,f.value=void 0}function te(){u.value&&(u.value=!1),!v.value&&i.active?_():v.value}function ae(){var ke,O,ne;const me=((ke=d.value)==null?void 0:ke.currentTime)||0;s("frame-update",{dataUrl:null,timestamp:me,width:((O=d.value)==null?void 0:O.videoWidth)||0,height:((ne=d.value)==null?void 0:ne.videoHeight)||0})}function re(){s("play-pause")}function q(me){var O;const ke=me.target;if(ke!=null&&ke.error)switch(ke.error.code){case ke.error.MEDIA_ERR_ABORTED:f.value="Video playback aborted";break;case ke.error.MEDIA_ERR_NETWORK:f.value="Network error loading video";break;case ke.error.MEDIA_ERR_DECODE:f.value="Video format not supported";break;case ke.error.MEDIA_ERR_SRC_NOT_SUPPORTED:f.value=`Video source not supported: ${(O=ke.src)==null?void 0:O.substring(0,100)}`;break;default:f.value="Failed to load video"}else f.value="Failed to load video";s("error",f.value),u.value=!1}function ue(me){d.value&&(d.value.currentTime=Math.max(0,Math.min(me,m.value)))}function he(){D=window.setInterval(()=>{const me=performance.now(),ke=me-T;h.value=Math.round(M*1e3/ke),M=0,T=me},1e3)}function we(me){const ke=Math.floor(me/60),O=Math.floor(me%60);return`${ke.toString().padStart(2,"0")}:${O.toString().padStart(2,"0")}`}function oe(){f.value=void 0,u.value=!0,d.value&&d.value.load()}function ye(){b&&(k||(k=!0,requestAnimationFrame(()=>{k=!1,pe()})))}function pe(){if(!b||!x||!C||!y||!l.value)return;const me=Math.round(l.value.clientWidth),ke=Math.round(l.value.clientHeight);if(me<=0||ke<=0)return;b.renderer.resize(me,ke);const O=b.screen.width/C,ne=b.screen.height/y;let K=1;switch(i.fitMode){case"cover":K=Math.max(O,ne);break;case"none":K=1;break;case"contain":default:K=Math.min(O,ne);break}x.scale.set(K),x.anchor.set(.5),x.position.set(b.screen.width/2,b.screen.height/2),x.visible=!0,x.alpha=1,b.renderer&&!b.renderer.destroyed&&b.render()}e.watch(()=>i.filters,()=>{v.value&&ge()},{deep:!0}),e.watch(()=>i.active,async me=>{if(me&&!b&&d.value&&d.value.readyState>=2){await _();return}b&&(me&&(await e.nextTick(),l.value&&l.value.getBoundingClientRect(),x&&g&&S&&R&&(d.value&&d.value.readyState>=2&&(g.drawImage(d.value,0,0,S.width,S.height),R.update()),pe(),b.renderer&&!b.renderer.destroyed&&b.render())),i.targetFps>=60&&b.ticker&&(me?b.ticker.start():b.ticker.stop()))}),e.watch(I,me=>{me?(u.value=!0,f.value=void 0,e.nextTick(()=>{d.value&&d.value.load()})):(u.value=!1,f.value="No video source provided")},{immediate:!0}),e.watch(()=>i.isPlaying,me=>{d.value&&(me?d.value.play():d.value.pause())}),e.watch(()=>i.playhead,me=>{d.value&&Math.abs(d.value.currentTime-me)>.5&&ue(me)}),e.watch(()=>i.fitMode,()=>{pe()}),e.onMounted(()=>{L=!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&&!v.value&&_()})}),e.onUnmounted(()=>{if(L=!0,P&&(cancelAnimationFrame(P),P=null),window.removeEventListener("resize",ye),$&&($.disconnect(),$=null),D&&clearInterval(D),b&&b.ticker&&(b.ticker.stop(),b.ticker.remove(U)),b){try{b.destroy(!0,{children:!0,texture:!0})}catch{}b=null}p.forEach(me=>{try{me.destroy()}catch{}}),p=[],x=null,R=null,S=null,g=null,d.value&&(d.value.pause(),d.value.removeAttribute("src"),d.value.load())});async function Ze(me){if(!await Ke()||!d.value||!g||!S||!R)return null;const O=d.value,ne=Number.isFinite(m.value)&&m.value>0?m.value:Number.isFinite(O.duration)&&O.duration>0?O.duration:0,K=Math.max(0,Math.min(me,ne));await new Promise(ee=>{let be=!1,Y=0;const se=()=>{be||(be=!0,O.removeEventListener("seeked",xe),window.clearTimeout(Y),ee())},xe=()=>{se()},Ve=Number.isFinite(O.currentTime)?O.currentTime:0;if(Math.abs(Ve-K)<.016){requestAnimationFrame(()=>se());return}O.addEventListener("seeked",xe),Y=window.setTimeout(()=>se(),700),O.currentTime=K});try{g.drawImage(O,0,0,S.width,S.height),R.update(),b.render()}catch{return null}return b.canvas}async function Ke(){if(!d.value)return!1;if(!b){if(!(d.value.readyState>=2))return!1;await _()}if(!b||!x||!g||!S||!R)return!1;if(i.filters&&i.filters.length>0){const me=x.filters,ke=Array.isArray(me)?me.length:0,ne=JSON.stringify(i.filters)!==w;(ke===0||ke!==i.filters.length||ne)&&ge()}return await e.nextTick(),await new Promise(me=>{requestAnimationFrame(()=>me())}),!0}return o({captureFrameAt:Ze,ensureReadyForCapture:Ke,duration:m,pixiCanvas:e.computed(()=>b?b.canvas:null),videoElement:e.computed(()=>d.value??null)}),(me,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:I.value,onLoadedmetadata:F,onLoadeddata:X,onCanplay:te,onTimeupdate:ae,onEnded:re,onError:q,style:e.normalizeStyle({display:v.value?"none":"block",position:"relative",width:"100%",height:"100%",objectFit:me.fitMode}),crossorigin:"anonymous",playsinline:"",controls:""},null,44,vp),e.createElementVNode("div",gp,[e.createElementVNode("button",{class:"play-button",onClick:ke[0]||(ke[0]=O=>me.$emit("play-pause")),"aria-label":me.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:me.isPlaying?e.unref(sl):e.unref(ll)},null,8,["icon"])],8,yp),e.createElementVNode("div",bp,[e.createElementVNode("span",wp,e.toDisplayString(we(me.playhead)),1),ke[1]||(ke[1]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",kp,e.toDisplayString(we(m.value)),1)]),me.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(B.IonSpinner),{name:"crescent"}),ke[2]||(ke[2]=e.createElementVNode("p",null,"Loading video...",-1))])):e.createCommentVNode("",!0),f.value?(e.openBlock(),e.createElementBlock("div",Ep,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Br)},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(f.value),1),e.createElementVNode("button",{onClick:oe},"Retry")])):e.createCommentVNode("",!0)],512))}}),as=Te(Cp,[["__scopeId","data-v-e2065e0f"]]);var Rr=(n,o,t)=>{if(!o.has(n))throw TypeError("Cannot "+t)},A=(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 A(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]]),ve=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"),ve(o),kt("iso5"),kt("iso6"),kt("mp41")]):He("ftyp",[kt("isom"),ve(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:ve;return Le("mvhd",+r,0,[i(n),i(n),ve(hr),i(t),Bt(1),Pr(1),Array(10).fill(0),hl(fl),Array(24).fill(0),ve(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:ve,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),ve(n.id),ve(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:ve;return Le("mdhd",+r,0,[i(o),i(o),ve(n.timescale),i(a),ze(21956),ze(0)])},$p=n=>Le("hdlr",0,0,[kt("mhlr"),kt(n),ve(0),ve(0),ve(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,[ve(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,[ve(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),ve(4718592),ve(4718592),ve(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),ve(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,[ve(58753152),qe(32+o.byteLength),ze(1),qe(0),ve(75530368),qe(18+o.byteLength),qe(64),qe(21),ml(0),ve(130071),ve(130071),ve(92307584),qe(o.byteLength),...o,ve(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),ve(n.info.sampleRate),Pr(t),qe(0)])},of=n=>Le("stts",0,0,[ve(n.timeToSampleTable.length),n.timeToSampleTable.map(o=>[ve(o.sampleCount),ve(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,[ve(o.length),o.map(([t])=>ve(t+1))])},rf=n=>Le("stsc",0,0,[ve(n.compactlyCodedChunkTable.length),n.compactlyCodedChunkTable.map(o=>[ve(o.firstChunk),ve(o.samplesPerChunk),ve(1)])]),sf=n=>Le("stsz",0,0,[ve(0),ve(n.samples.length),n.samples.map(o=>ve(o.size))]),lf=n=>n.finalizedChunks.length>0&&Ko(n.finalizedChunks).offset>=2**32?Le("co64",0,0,[ve(n.finalizedChunks.length),n.finalizedChunks.map(o=>cn(o.offset))]):Le("stco",0,0,[ve(n.finalizedChunks.length),n.finalizedChunks.map(o=>ve(o.offset))]),cf=n=>Le("ctts",0,0,[ve(n.compositionTimeOffsetTable.length),n.compositionTimeOffsetTable.map(o=>[ve(o.sampleCount),ve(o.sampleCompositionTimeOffset)])]),df=n=>He("mvex",null,n.map(uf)),uf=n=>Le("trex",0,0,[ve(n.id),ve(1),ve(0),ve(0),ve(0)]),rs=(n,o)=>He("moof",null,[mf(n),...o.map(pf)]),mf=n=>Le("mfhd",0,0,[ve(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,[ve(n.id),ve(a.duration),ve(a.size),ve(a.flags)])},hf=n=>Le("tfdt",1,0,[cn(Pt(n.currentChunk.startTimestamp,n.timescale))]),vf=n=>{let o=n.currentChunk.samples.map(b=>b.timescaleUnitsToNextSample),t=n.currentChunk.samples.map(b=>b.size),a=n.currentChunk.samples.map(vl),r=n.currentChunk.samples.map(b=>Pt(b.presentationTimestamp-b.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,f=s.size>1,m=!d&&l.size>1,h=c.size>1||[...c].some(b=>b!==0),v=0;return v|=1,v|=4*+d,v|=256*+u,v|=512*+f,v|=1024*+m,v|=2048*+h,Le("trun",1,v,[ve(n.currentChunk.samples.length),ve(n.currentChunk.offset-n.currentChunk.moofOffset||0),d?ve(a[0]):[],n.currentChunk.samples.map((b,x)=>[u?ve(o[x]):[],f?ve(t[x]):[],m?ve(a[x]):[],h?_p(r[x]):[]])])},gf=n=>He("mfra",null,[...n.map(yf),bf()]),yf=(n,o)=>Le("tfra",1,0,[ve(n.id),ve(63),ve(n.finalizedChunks.length),n.finalizedChunks.map(a=>[cn(Pt(a.startTimestamp,n.timescale)),cn(a.moofOffset),ve(o+1),ve(1),ve(1)])]),bf=()=>Le("mfro",0,0,[ve(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(A(this,Qt).buffer)),this.offsets=new WeakMap}seek(n){this.pos=n}writeU32(n){A(this,kn).setUint32(0,n,!1),this.write(A(this,Qt).subarray(0,4))}writeU64(n){A(this,kn).setUint32(0,Math.floor(n/2**32),!1),A(this,kn).setUint32(4,n,!1),this.write(A(this,Qt).subarray(0,8))}writeAscii(n){for(let o=0;o<n.length;o++)A(this,kn).setUint8(o%8,n.charCodeAt(o)),o%8===7&&this.write(A(this,Qt));n.length%8!==0&&this.write(A(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(A(this,sn))),Fe(this,jn,0),tt(this,Oo,n)}write(n){Pe(this,Lo,pr).call(this,this.pos+n.byteLength),A(this,ro).set(n,this.pos),this.pos+=n.byteLength,tt(this,jn,Math.max(A(this,jn),this.pos))}finalize(){Pe(this,Lo,pr).call(this,this.pos),A(this,Oo).buffer=A(this,sn).slice(0,Math.max(A(this,jn),this.pos))}};Oo=new WeakMap;sn=new WeakMap;ro=new WeakMap;jn=new WeakMap;Lo=new WeakSet;pr=function(n){let o=A(this,sn).byteLength;for(;o<n;)o*=2;if(o===A(this,sn).byteLength)return;let t=new ArrayBuffer(o),a=new Uint8Array(t);a.set(A(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){A(this,en).push({data:n.slice(),start:this.pos}),this.pos+=n.byteLength}flush(){var t,a;if(A(this,en).length===0)return;let n=[],o=[...A(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 A(this,en))r.start<=i.start&&i.start<r.start+r.size&&r.data.set(i.data,i.start-r.start);A(this,Xn)?(Pe(this,Qo,fr).call(this,r.data,r.start),Pe(this,qn,ea).call(this)):(a=(t=A(this,Jn).options).onData)==null||a.call(t,r.data,r.start)}A(this,en).length=0}finalize(){A(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=A(this,bt).findIndex(l=>l.start<=o&&o<l.start+A(this,Lt));t===-1&&(t=Pe(this,Ar,kl).call(this,o));let a=A(this,bt)[t],r=o-a.start,i=n.subarray(0,Math.min(A(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===A(this,Lt)&&(a.shouldFlush=!0),A(this,bt).length>Nf){for(let l=0;l<A(this,bt).length-1;l++)A(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/A(this,Lt))*A(this,Lt),data:new Uint8Array(A(this,Lt)),written:[],shouldFlush:!1};return A(this,bt).push(t),A(this,bt).sort((a,r)=>a.start-r.start),A(this,bt).indexOf(t)};qn=new WeakSet;ea=function(n=!1){var o,t;for(let a=0;a<A(this,bt).length;a++){let r=A(this,bt)[a];if(!(!r.shouldFlush&&!n)){for(let i of r.written)(t=(o=A(this,Jn).options).onData)==null||t.call(o,r.data.subarray(i.start,i.end),r.start+i.start);A(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,Ne,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,Ne,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,Ne,new Cf(n.target));else if(n.target instanceof yl)tt(this,Ne,new Dr(n.target));else if(n.target instanceof Ef)tt(this,Ne,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),!A(this,Ee).video)throw new Error("No video track declared.");if(typeof A(this,Ee).fastStart=="object"&&A(this,at).samples.length===A(this,Ee).fastStart.expectedVideoChunks)throw new Error(`Cannot add more video chunks than specified in 'fastStart' (${A(this,Ee).fastStart.expectedVideoChunks}).`);let s=Pe(this,Wo,br).call(this,A(this,at),n,o,t,a,r,i);if(A(this,Ee).fastStart==="fragmented"&&A(this,et)){for(;A(this,nn).length>0&&A(this,nn)[0].decodeTimestamp<=s.decodeTimestamp;){let l=A(this,nn).shift();Pe(this,It,Ot).call(this,A(this,et),l)}s.decodeTimestamp<=A(this,et).lastDecodeTimestamp?Pe(this,It,Ot).call(this,A(this,at),s):A(this,tn).push(s)}else Pe(this,It,Ot).call(this,A(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),!A(this,Ee).audio)throw new Error("No audio track declared.");if(typeof A(this,Ee).fastStart=="object"&&A(this,et).samples.length===A(this,Ee).fastStart.expectedAudioChunks)throw new Error(`Cannot add more audio chunks than specified in 'fastStart' (${A(this,Ee).fastStart.expectedAudioChunks}).`);let i=Pe(this,Wo,br).call(this,A(this,et),n,o,t,a,r);if(A(this,Ee).fastStart==="fragmented"&&A(this,at)){for(;A(this,tn).length>0&&A(this,tn)[0].decodeTimestamp<=i.decodeTimestamp;){let s=A(this,tn).shift();Pe(this,It,Ot).call(this,A(this,at),s)}i.decodeTimestamp<=A(this,at).lastDecodeTimestamp?Pe(this,It,Ot).call(this,A(this,et),i):A(this,nn).push(i)}else Pe(this,It,Ot).call(this,A(this,et),i)}finalize(){if(A(this,Kn))throw new Error("Cannot finalize a muxer more than once.");if(A(this,Ee).fastStart==="fragmented"){for(let o of A(this,tn))Pe(this,It,Ot).call(this,A(this,at),o);for(let o of A(this,nn))Pe(this,It,Ot).call(this,A(this,et),o);Pe(this,oa,jr).call(this,!1)}else A(this,at)&&Pe(this,Qn,na).call(this,A(this,at)),A(this,et)&&Pe(this,Qn,na).call(this,A(this,et));let n=[A(this,at),A(this,et)].filter(Boolean);if(A(this,Ee).fastStart==="in-memory"){let o;for(let a=0;a<2;a++){let r=Uo(n,A(this,xn)),i=A(this,Ne).measureBox(r);o=A(this,Ne).measureBox(A(this,gt));let s=A(this,Ne).pos+i+o;for(let l of A(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&&(A(this,gt).largeSize=!0)}let t=Uo(n,A(this,xn));A(this,Ne).writeBox(t),A(this,gt).size=o,A(this,Ne).writeBox(A(this,gt));for(let a of A(this,Sn))for(let r of a.samples)A(this,Ne).write(r.data),r.data=null}else if(A(this,Ee).fastStart==="fragmented"){let o=A(this,Ne).pos,t=gf(n);A(this,Ne).writeBox(t);let a=A(this,Ne).pos-o;A(this,Ne).seek(A(this,Ne).pos-4),A(this,Ne).writeU32(a)}else{let o=A(this,Ne).offsets.get(A(this,gt)),t=A(this,Ne).pos-o;A(this,gt).size=t,A(this,gt).largeSize=t>=2**32,A(this,Ne).patchBox(A(this,gt));let a=Uo(n,A(this,xn));if(typeof A(this,Ee).fastStart=="object"){A(this,Ne).seek(A(this,ta)),A(this,Ne).writeBox(a);let r=o-A(this,Ne).pos;A(this,Ne).writeBox(Mp(r))}else A(this,Ne).writeBox(a)}Pe(this,Nn,uo).call(this),A(this,Ne).finalize(),tt(this,Kn,!0)}};Ee=new WeakMap;Ne=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(A(this,Ne).writeBox(Tp({holdsAvc:((n=A(this,Ee).video)==null?void 0:n.codec)==="avc",fragmented:A(this,Ee).fastStart==="fragmented"})),tt(this,ta,A(this,Ne).pos),A(this,Ee).fastStart==="in-memory")tt(this,gt,mr(!1));else if(A(this,Ee).fastStart!=="fragmented"){if(typeof A(this,Ee).fastStart=="object"){let o=Pe(this,Or,El).call(this);A(this,Ne).seek(A(this,Ne).pos+o)}tt(this,gt,mr(!0)),A(this,Ne).writeBox(A(this,gt))}Pe(this,Nn,uo).call(this)};Or=new WeakSet;El=function(){if(typeof A(this,Ee).fastStart!="object")return;let n=0,o=[A(this,Ee).fastStart.expectedVideoChunks,A(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(A(this,Ee).video&&tt(this,at,{id:1,info:{type:"video",codec:A(this,Ee).video.codec,width:A(this,Ee).video.width,height:A(this,Ee).video.height,rotation:A(this,Ee).video.rotation??0,decoderConfig:null},timescale:A(this,Ee).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),A(this,Ee).audio&&(tt(this,et,{id:A(this,Ee).video?2:1,info:{type:"audio",codec:A(this,Ee).audio.codec,numberOfChannels:A(this,Ee).audio.numberOfChannels,sampleRate:A(this,Ee).audio.sampleRate,decoderConfig:null},timescale:A(this,Ee).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),A(this,Ee).audio.codec==="aac")){let n=Pe(this,Lr,Vl).call(this,2,A(this,Ee).audio.sampleRate,A(this,Ee).audio.numberOfChannels);A(this,et).info.decoderConfig={codec:A(this,Ee).audio.codec,description:n,numberOfChannels:A(this,Ee).audio.numberOfChannels,sampleRate:A(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){A(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,A(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,A(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(A(this,Ee).fastStart==="fragmented"){let i=A(this,at)??A(this,et);const s=A(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=A(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(A(this,Ee).firstTimestampBehavior==="offset"||A(this,Ee).firstTimestampBehavior==="cross-track-offset"){t.firstDecodeTimestamp===void 0&&(t.firstDecodeTimestamp=o);let c;A(this,Ee).firstTimestampBehavior==="offset"?c=t.firstDecodeTimestamp:c=Math.min(((s=A(this,at))==null?void 0:s.firstDecodeTimestamp)??1/0,((l=A(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(A(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),A(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}),A(this,Ee).fastStart==="in-memory"){n.currentChunk.offset=0;return}n.currentChunk.offset=A(this,Ne).pos;for(let o of n.currentChunk.samples)A(this,Ne).write(o.data),o.data=null;Pe(this,Nn,uo).call(this)}};oa=new WeakSet;jr=function(n=!0){if(A(this,Ee).fastStart!=="fragmented")throw new Error("Can't finalize a fragment unless 'fastStart' is set to 'fragmented'.");let o=[A(this,at),A(this,et)].filter(l=>l&&l.currentChunk);if(o.length===0)return;let t=Vp(this,Ur)._++;if(t===1){let l=Uo(o,A(this,xn),!0);A(this,Ne).writeBox(l)}let a=A(this,Ne).pos,r=rs(t,o);A(this,Ne).writeBox(r);{let l=mr(!1),c=0;for(let u of o)for(let f of u.currentChunk.samples)c+=f.size;let d=A(this,Ne).measureBox(l)+c;d>=2**32&&(l.largeSize=!0,d=A(this,Ne).measureBox(l)+c),l.size=d,A(this,Ne).writeBox(l)}for(let l of o){l.currentChunk.offset=A(this,Ne).pos,l.currentChunk.moofOffset=a;for(let c of l.currentChunk.samples)A(this,Ne).write(c.data),c.data=null}let i=A(this,Ne).pos;A(this,Ne).seek(A(this,Ne).offsets.get(r));let s=rs(t,o);A(this,Ne).writeBox(s),A(this,Ne).seek(i);for(let l of o)l.finalizedChunks.push(l.currentChunk),A(this,Sn).push(l.currentChunk),l.currentChunk=null;n&&Pe(this,Nn,uo).call(this)};Nn=new WeakSet;uo=function(){A(this,Ne)instanceof Dr&&A(this,Ne).flush()};jo=new WeakSet;wr=function(){if(A(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);W(this,"message");W(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){W(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){W(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){W(this,"id",crypto.randomUUID());W(this,"text");W(this,"start");W(this,"stop");W(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){W(this,"id",crypto.randomUUID());W(this,"language",kr.en);W(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,f=Math.round(Zo(i,c,t)),m=Math.round(Zo(s,d,t)),h=Math.round(Zo(l,u,t));return`#${((1<<24)+(f<<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={}){W(this,"input");W(this,"output");W(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(){W(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 fe(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);W(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();W(this,"_name");W(this,"_start",new de);W(this,"_stop",de.fromSeconds(16));W(this,"type","base");W(this,"source");W(this,"view",new De.Container);W(this,"createdAt",new Date);W(this,"disabled",!1);W(this,"state","IDLE");W(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([fe()],po.prototype,"_name");ha([fe(de)],po.prototype,"_start");ha([fe(de)],po.prototype,"_stop");ha([fe()],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);W(this,"state","IDLE");W(this,"metadata");W(this,"objectURL");W(this,"duration",de.fromSeconds(16));W(this,"added",!1);W(this,"type","base");W(this,"name","");W(this,"mimeType");W(this,"externalURL");W(this,"external",!1);W(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([fe()],zt.prototype,"objectURL");un([fe()],zt.prototype,"duration");un([fe()],zt.prototype,"type");un([fe()],zt.prototype,"name");un([fe()],zt.prototype,"mimeType");un([fe()],zt.prototype,"externalURL");un([fe()],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();W(this,"type","html");W(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 f=0;f<s.length;f+=a){let m=0;const h=Math.min(f+a,s.length);for(let v=f;v<h;v++)m+=s[v]*s[v];m=Math.sqrt(m/(h-f)),m<t?(u+=a,d===null&&(d=f)):(d!==null&&u>=c&&i.push({start:de.fromSeconds(d/l),stop:de.fromSeconds(f/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);W(this,"type","audio");W(this,"decoding",!1);W(this,"_silences");W(this,"transcript");W(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 f=0;f<l;f+=c){let m=0;for(let h=f;h<f+s;h++)m+=Math.abs(d[f]);u.push(Math.log1p(m/s*100))}return u.map(f=>Math.round(f/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),f=new Float32Array(t);for(let m=0;m<t;m++){const h=c+m*u,v=h+u;let b=-1/0;for(let x=h;x<v;x++){const R=l[x];R>b&&(b=R)}f[m]=i?Math.log2(1+b):b}return f}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);W(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);W(this,"type","video");W(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();W(this,"source",new Jt);W(this,"_offset",new de);W(this,"playing",!1);W(this,"duration",new de);W(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([fe(de)],mn.prototype,"_offset",2);_n([fe(de)],mn.prototype,"duration",2);_n([fe(Wf)],mn.prototype,"range",2);_n([fe(an)],mn.prototype,"transcript",1);_n([fe()],mn.prototype,"muted",1);_n([fe()],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){W(this,"target");W(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);W(this,"filters");W(this,"_height");W(this,"_width");W(this,"_position",{x:this.view.position.x,y:this.view.position.y});W(this,"_scale");W(this,"rotation",this.view.angle);W(this,"alpha",1);W(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([fe(Bo)],o.prototype,"_height",2),Yt([fe(Bo)],o.prototype,"_width",2),Yt([fe(nr)],o.prototype,"_position",2),Yt([fe(nr)],o.prototype,"_scale",2),Yt([fe(Bo)],o.prototype,"rotation",2),Yt([fe(Bo)],o.prototype,"alpha",2),Yt([fe(nr)],o.prototype,"translate",2),Yt([fe()],o.prototype,"anchor",1),o}function ya(n,o,t){const a=t.value;return t.value=function(...r){var f,m,h,v;const i=r[0].subtract(this.start),s={width:((m=(f=this.track)==null?void 0:f.composition)==null?void 0:m.width)??1920,height:((v=(h=this.track)==null?void 0:h.composition)==null?void 0:v.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 b;typeof this._scale.x=="number"?b=this._scale.x:typeof this._scale.x=="function"?b=this._scale.x.bind(this)(i):b=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)&&(b*=this.view.scale._x,x*=this.view.scale._y),this.view.scale.set(b,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();W(this,"type","image");W(this,"element",new Image);W(this,"source",new aa);W(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();W(this,"loaded",!1);W(this,"family");W(this,"weight");W(this,"source");W(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([fe()],ho.prototype,"family");ba([fe()],ho.prototype,"weight");ba([fe()],ho.prototype,"source");ba([fe()],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();W(this,"type","text");W(this,"_text","");W(this,"_textCase");W(this,"_anchor",{x:0,y:0});W(this,"_font",new st);W(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([fe()],dt.prototype,"text");ft([fe(st)],dt.prototype,"font");ft([fe()],dt.prototype,"maxWidth");ft([fe()],dt.prototype,"textAlign");ft([fe()],dt.prototype,"padding");ft([fe()],dt.prototype,"textBaseline");ft([fe()],dt.prototype,"fillStyle");ft([fe()],dt.prototype,"anchor");ft([fe()],dt.prototype,"stroke");ft([fe()],dt.prototype,"textCase");ft([fe()],dt.prototype,"shadow");ft([fe()],dt.prototype,"fontSize");ft([fe()],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(){W(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(){W(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();W(this,"type","complex_text");W(this,"_maxWidth");W(this,"_textAlign","left");W(this,"_textBaseline","top");W(this,"model",new De.Container);W(this,"segments",[]);W(this,"metrics",new vs);W(this,"background");W(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 f=ah(De.CanvasTextMetrics.measureText(c.tokens[u],d)),m=(((i=r.lines.at(-1))==null?void 0:i.width)??0)+f.lineWidths[0],h=this.maxWidth??Number.POSITIVE_INFINITY,v=(s=c.tokens.at(u-1))==null?void 0:s.match(/(\n|\\n).$/gim);(m>h||v||!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:f,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([fe()],pn.prototype,"background",2);Mn([fe(ih)],pn.prototype,"styles",2);Mn([fe()],pn.prototype,"text",1);Mn([fe()],pn.prototype,"maxWidth",1);Mn([fe()],pn.prototype,"textAlign",1);Mn([fe()],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(){W(this,"frames",[]);W(this,"state","active");W(this,"onenqueue");W(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();W(this,"source",new ra);W(this,"type","video");W(this,"worker");W(this,"buffer");W(this,"canvas",document.createElement("canvas"));W(this,"context",this.canvas.getContext("2d"));W(this,"element",document.createElement("video"));W(this,"textrues",{html5:De.Texture.from(this.element),canvas:De.Texture.from(this.canvas)});W(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();W(this,"type","audio");W(this,"source",new Jt);W(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();W(this,"type","html");W(this,"source",new fs);W(this,"element",new Image);W(this,"canvas",document.createElement("canvas"));W(this,"context",this.canvas.getContext("2d"));W(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(){W(this,"mode",Ul[0]);W(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(){W(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);W(this,"_disabled",!1);W(this,"view",new De.Container);W(this,"clips",[]);W(this,"pointer",0);W(this,"composition");W(this,"type","base");W(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);W(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);W(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);W(this,"type","image")}}class Ch extends Ol{constructor(){super(...arguments);W(this,"type","audio")}}class xs extends Fn{constructor(){super(...arguments);W(this,"type","text")}}class Vh extends Fn{constructor(){super(...arguments);W(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();W(this,"generatorOptions");W(this,"type","CLASSIC");W(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([fe()],vo.prototype,"generatorOptions");Zr([fe()],vo.prototype,"type");Zr([fe()],vo.prototype,"position");class _h extends Fn{constructor(){super(...arguments);W(this,"clip");W(this,"type","caption");W(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();W(this,"generatorOptions");W(this,"type","SPOTLIGHT");W(this,"color");W(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(f=>f.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([fe()],go.prototype,"generatorOptions");ka([fe()],go.prototype,"type");ka([fe()],go.prototype,"color");ka([fe()],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();W(this,"type","GUINEA");W(this,"colors");W(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,f;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:v}=this.splitSequence(m);for(let b=0;b<m.words.length;b++){const x=(d=(c=v[b])==null?void 0:c.at(0))==null?void 0:d.start,R=(f=(u=v[b])==null?void 0:u.at(-1))==null?void 0:f.stop;!x||!R||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:R.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,b).join(" ").length,stop:h.slice(0,b+1).join(" ").length+b*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([fe()],xa.prototype,"type");Yr([fe()],xa.prototype,"colors");Yr([fe()],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();W(this,"generatorOptions");W(this,"type","CASCADE");W(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(f=>f.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([fe()],Sa.prototype,"generatorOptions");Gr([fe()],Sa.prototype,"type");Gr([fe()],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();W(this,"generatorOptions");W(this,"type","SOLAR");W(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([fe()],Ea.prototype,"generatorOptions");Hr([fe()],Ea.prototype,"type");Hr([fe()],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();W(this,"generatorOptions");W(this,"type","WHISPER");W(this,"color");W(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(f=>f.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([fe()],yo.prototype,"generatorOptions");Ca([fe()],yo.prototype,"type");Ca([fe()],yo.prototype,"color");Ca([fe()],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();W(this,"type","VERDANT");W(this,"generatorOptions");W(this,"color");W(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(f=>f.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([fe()],Na.prototype,"type");Va([fe()],Na.prototype,"generatorOptions");Va([fe()],Na.prototype,"color");Va([fe()],Na.prototype,"position");class Ph extends mo(xt){constructor({height:t=1080,width:a=1920,background:r="#000000",backend:i="webgpu"}={}){super();W(this,"_duration",new de);W(this,"renderer");W(this,"stage",new De.Container);W(this,"settings");W(this,"tracks",[]);W(this,"frame",0);W(this,"fixedDuration");W(this,"state","IDLE");W(this,"fps",io);W(this,"canvas");W(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 f=await l.source.decode(t,a),m=f.numberOfChannels-1;for(let h=0;h<t;h++){const v=i.getChannelData(h),b=f.getChannelData(h>m?m:h);for(let x=0;x<v.length-1;x++)x<c+d||x>c+u||x-c<0||(v[x]+=(b[x-c]??0)*l.volume,v[x]>1&&(v[x]=1),v[x]<-1&&(v[x]=-1));i.getChannelData(h).set(v)}}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),f=e.ref(0),m=e.ref(0);let h=null;const v=e.computed(()=>!!t.enableEngine&&!!t.recipe),b=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 R(){var k,T,M;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,P=((T=t.recipe.source)==null?void 0:T.original_height)||1080,L=((M=t.recipe.output)==null?void 0:M.fps)||30;h=new Ll(D,P,L,{fitMode:t.fitMode}),h.attachPlayer(i.value),c.value="Loading composition...",await h.loadFromRecipe(t.recipe),m.value=h.durationInSeconds,S(),l.value=!1,a("engine-ready",h),t.autoPlay&&(h.play(),u.value=!0)}catch(D){const P=D instanceof Error?D.message:String(D);d.value=`Failed to initialize: ${P}`,l.value=!1}}function S(){if(!h)return;const k=setInterval(()=>{h&&u.value&&(f.value=h.currentTimeInSeconds,a("time-update",f.value))},100);z.value=k}function g(){v.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 p(k){const T=Math.floor(k/60),M=Math.floor(k%60);return`${T}:${M.toString().padStart(2,"0")}`}function w(){d.value=null,v.value&&R()}function $(){!v.value&&s.value&&(m.value=s.value.duration,a("duration-change",m.value))}function C(){!v.value&&s.value&&(f.value=s.value.currentTime,a("time-update",f.value))}function y(){u.value=!1,a("play-state-change",!1)}function N(k){d.value="Failed to load video",a("error",d.value)}e.onMounted(()=>{v.value&&t.recipe&&R()}),e.onUnmounted(()=>{h&&(h.destroy(),h=null),z.value&&(clearInterval(z.value),z.value=null),s.value&&(s.value.pause(),s.value.removeAttribute("src"),s.value.load())}),e.watch(()=>t.recipe,async k=>{if(v.value&&k)if(h)try{await h.loadFromRecipe(k),m.value=h.durationInSeconds}catch{}else await R()}),e.watch(()=>t.enableEngine,async k=>{k?await R():h&&(z.value&&(clearInterval(z.value),z.value=null),h.destroy(),h=null)}),e.watch(()=>t.fitMode,async k=>{if(!(!v.value||!h))try{h.setFitMode(k||"contain")}catch{}});const z=e.ref(null);return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:"video-preview-engine",ref_key:"containerRef",ref:r},[v.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:y,onError:N,style:e.normalizeStyle({width:"100%",height:"100%",objectFit:b.value}),playsinline:"",controls:""},null,44,Dh)),e.createElementVNode("div",Uh,[e.createElementVNode("button",{class:"play-button",onClick:g,"aria-label":u.value?"Pause":"Play"},[e.createVNode(e.unref(B.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(p(f.value)),1),T[0]||(T[0]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",jh,e.toDisplayString(p(m.value)),1)])]),l.value?(e.openBlock(),e.createElementBlock("div",Xh,[e.createVNode(e.unref(B.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(B.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=Te(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)}`),f=e.computed(()=>{const y=t.clip.timelineEnd-t.clip.timelineStart;return v(y)}),m=e.computed(()=>t.clip.filters&&t.clip.filters.length>0),h=e.computed(()=>t.clip.filters||[]);function v(y){if(y<1)return`${Math.round(y*30)}f`;if(y<60)return`${y.toFixed(1)}s`;{const N=Math.floor(y/60),z=Math.floor(y%60);return`${N}:${z.toString().padStart(2,"0")}`}}function b(y){return!y||typeof y!="string"?ts:y.includes("color")||y.includes("brightness")?Ht:y.includes("blur")?Iu:y.includes("style")?Ln:y.includes("effect")?Gt:ts}function x(){i.value||a("select")}function R(y){y.button===0&&(p("move",y.clientX),y.preventDefault())}function S(y){if(y.touches.length!==1)return;const N=y.touches[0];p("move",N.clientX),y.preventDefault()}function g(y,N){const z="touches"in N?N.touches[0].clientX:N.clientX;s.value=y==="start"?"trim-start":"trim-end",p(s.value,z),N.preventDefault(),N.stopPropagation()}function p(y,N){i.value=!0,s.value=y,l.value=N,y==="move"?c.value=t.clip.timelineStart:y==="trim-start"?c.value=t.clip.sourceIn:y==="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(y){if(!i.value||!s.value)return;const N="touches"in y?y.touches[0].clientX:y.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 y=r.value,N=y.getContext("2d");if(!N)return;y.width=y.clientWidth*window.devicePixelRatio,y.height=y.clientHeight*window.devicePixelRatio,N.scale(window.devicePixelRatio,window.devicePixelRatio),N.strokeStyle="rgba(255, 255, 255, 0.3)",N.lineWidth=1,N.beginPath();const z=y.clientWidth,k=y.clientHeight,T=k/2;N.moveTo(0,T),N.lineTo(z,T);for(let M=0;M<z;M+=4){const D=Math.sin(M*.05)*(k*.3);N.moveTo(M,T-D),N.lineTo(M,T+D)}N.stroke()}return e.onMounted(()=>{C(),window.addEventListener("resize",C)}),e.onUnmounted(()=>{$(),window.removeEventListener("resize",C)}),(y,N)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["timeline-clip",{selected:y.selected,mobile:y.isMobile,"has-filters":m.value}]),style:e.normalizeStyle(d.value),onClick:x,onMousedown:R,onTouchstart:S},[e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:N[0]||(N[0]=e.withModifiers(z=>g("start",z),["stop"])),onTouchstart:N[1]||(N[1]=e.withModifiers(z=>g("start",z),["stop"])),"aria-label":`Trim start of ${y.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(z=>g("end",z),["stop"])),onTouchstart:N[3]||(N[3]=e.withModifiers(z=>g("end",z),["stop"])),"aria-label":`Trim end of ${y.clip.label||"clip"}`},[...N[5]||(N[5]=[e.createElementVNode("div",{class:"trim-grip"},null,-1)])],40,Hh),e.createElementVNode("div",Jh,[y.clip.thumbnail?(e.openBlock(),e.createElementBlock("div",qh,[e.createElementVNode("img",{src:y.clip.thumbnail,alt:y.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(f.value),1)]),m.value?(e.openBlock(),e.createElementBlock("div",o0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,z=>(e.openBlock(),e.createBlock(e.unref(B.IonIcon),{key:z.id||z.filterId,icon:b(z.filterId||z.id),title:`Filter: ${z.filterId||z.id}`},null,8,["icon","title"]))),128))])):e.createCommentVNode("",!0),y.clip.speed&&y.clip.speed!==1?(e.openBlock(),e.createElementBlock("div",a0,e.toDisplayString(y.clip.speed)+"x ",1)):e.createCommentVNode("",!0)]),y.selected?(e.openBlock(),e.createElementBlock("div",r0)):e.createCommentVNode("",!0)],38))}}),s0=Te(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),f=e.computed(()=>t.selectedClipId??s.value);e.watch(()=>t.selectedClipId,O=>{O!==void 0&&(s.value=O)});const m=new Wl(t.fps),h=e.ref(!1),v=e.ref(null),b=e.ref(0),x=e.ref(0),R=e.ref(0),S=e.ref(0),g=e.ref(0),p=e.ref(!1),w=e.ref(0),$=e.ref(t.zoomLevel),C=e.computed(()=>t.zoomLevel);function y(O){const ne=t.clips.find(ee=>ee.id===O);if(!ne)return null;const K=t.clips.filter(ee=>ee.id!==O&&ee.timelineStart>=ne.timelineEnd-1e-9).map(ee=>ee.timelineStart);return K.length?Math.min(...K):null}function N(O){const ne=O.sourceMaxOut??t.duration,K=O.timelineStart+(ne-O.sourceIn),ee=y(O.id),be=ee!=null?Math.max(O.timelineStart,ee):1/0;return Math.min(K,be)}function z(O){const ne=O.sourceMinIn??0,ee=(O.sourceMaxOut??t.duration)-ne,be=O.sourceIn-ne;return{left:`${(O.timelineStart-be)*C.value-c.value}px`,width:`${ee*C.value}px`,top:"0px",height:"80px",opacity:f.value===O.id?.25:.15}}const k=e.computed(()=>t.useFrameMode?t.zoomLevel:t.zoomLevel/t.fps),T=e.computed(()=>m.secondsToFrames(t.duration)),M=e.computed(()=>t.useFrameMode?T.value*k.value:t.duration*C.value),D=e.computed(()=>{var O;return u.value||((O=i.value)==null?void 0:O.clientWidth)||800}),P=e.computed(()=>M.value>D.value),L=e.computed(()=>Math.max(0,M.value-D.value)),I=e.computed(()=>c.value>0),_=e.computed(()=>c.value<L.value),j=e.computed(()=>t.useFrameMode?m.secondsToFrames(t.playhead)*k.value-c.value:t.playhead*C.value-c.value),U=e.computed(()=>{const O=Math.max(50,D.value/M.value*D.value),ne=c.value/L.value*(D.value-O);return{width:`${O}px`,left:`${ne}px`}}),Q=e.computed(()=>{const O=[],ne=ge();for(let K=0;K<=t.duration;K+=ne){const ee=K*C.value-c.value;ee>=-50&&ee<=D.value+50&&O.push({position:ee,label:Be(K),time:K})}return O});function ge(){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 Be(O){if(t.useFrameMode)return`F${m.secondsToFrames(O)}`;{const ne=Math.floor(O/60),K=Math.floor(O%60),ee=Math.floor(O%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 Ce(O){const ne=i.value.getBoundingClientRect();let ee=(O.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(O){if(!P.value)return;const ne=Math.abs(O.deltaX)>Math.abs(O.deltaY)?O.deltaX:O.deltaY;ne!==0&&(O.preventDefault(),c.value=Math.max(0,Math.min(L.value,c.value+ne)))}function F(O){if(O.touches.length===2){p.value=!0;const ne=O.touches[0],K=O.touches[1];w.value=Math.hypot(K.clientX-ne.clientX,K.clientY-ne.clientY),$.value=t.zoomLevel}else O.touches.length===1&&(R.value=O.touches[0].clientX,S.value=O.touches[0].clientY,g.value=R.value)}function X(O){if(p.value&&O.touches.length===2){const ne=O.touches[0],K=O.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(O.touches.length===1&&!p.value){const ne=O.touches[0],K=g.value-ne.clientX;Math.abs(K)>Math.abs(ne.clientY-S.value)&&(O.preventDefault(),c.value=Math.max(0,Math.min(M.value-D.value,c.value+K)),g.value=ne.clientX)}}function te(){p.value=!1}function ae(O){const ne=O.target;if(ne.closest(".playhead-handle"))return;const K=O.button===1,ee=!!ne.closest(".video-track");(K||!ee&&P.value)&&re(O)}function re(O){h.value=!0,v.value="pan",b.value=O.clientX,x.value=c.value,document.addEventListener("mousemove",he),document.addEventListener("mouseup",we)}function q(O){O.preventDefault(),O.stopPropagation(),h.value=!0,v.value="playhead";const ne="touches"in O?O.touches[0].clientX:O.clientX;b.value=ne,x.value=t.playhead,"touches"in O?(document.addEventListener("touchmove",he),document.addEventListener("touchend",we)):(document.addEventListener("mousemove",he),document.addEventListener("mouseup",we))}function ue(O){O.preventDefault(),O.stopPropagation(),h.value=!0,v.value="scrollbar";const ne="touches"in O?O.touches[0].clientX:O.clientX;b.value=ne,x.value=c.value,"touches"in O?(document.addEventListener("touchmove",he),document.addEventListener("touchend",we)):(document.addEventListener("mousemove",he),document.addEventListener("mouseup",we))}function he(O){if(!h.value)return;const K=("touches"in O?O.touches[0].clientX:O.clientX)-b.value;if(v.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(v.value==="scrollbar"){const ee=K/D.value*M.value;c.value=Math.max(0,Math.min(L.value,x.value+ee))}else if(v.value==="pan"){const ee=x.value-K;c.value=Math.max(0,Math.min(L.value,ee))}}function we(){h.value=!1,v.value=null,document.removeEventListener("mousemove",he),document.removeEventListener("mouseup",we),document.removeEventListener("touchmove",he),document.removeEventListener("touchend",we)}function oe(O){s.value=s.value===O?null:O,r("clip-select",s.value)}function ye(O,ne){const K=t.clips.find(be=>be.id===O);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",O,"start",xe)}else{const be=Math.max(0,K.sourceIn+ee);r("trim",O,"start",be)}}function pe(O,ne){const K=t.clips.find(Ye=>Ye.id===O);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,M.value-D.value);c.value=Math.min(Ye,c.value+8)}const se=be+c.value,xe=1/t.fps;let Ve=se/C.value;Ve=Math.max(0,Math.min(Ve,K.timelineEnd-xe));let Ue=K.sourceIn+(Ve-K.timelineStart);Ue=Math.round(Ue*t.fps)/t.fps,r("trim",O,"start",Ue)}function Ze(O,ne){const K=t.clips.find(nt=>nt.id===O);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,M.value-D.value);c.value=Math.min(nt,c.value+8)}const se=be+c.value,xe=1/t.fps,Ve=N(K);let Ue=se/C.value;Ue=Math.max(K.timelineStart+xe,Math.min(Ue,Ve));let Ye=K.sourceIn+(Ue-K.timelineStart);Ye=Math.round(Ye*t.fps)/t.fps,r("trim",O,"end",Ye)}function Ke(O,ne){const K=t.clips.find(Ve=>Ve.id===O);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",O,xe)}function me(O,ne){const K=t.clips.find(Y=>Y.id===O);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),Ve=K.sourceIn+(xe-K.timelineStart),Ue=m.secondsToFrames(Ve),Ye=Math.min(Ue,Y+se),nt=m.framesToSeconds(Ye);r("trim",O,"end",nt)}else{const Y=N(K),se=K.sourceIn+(Y-K.timelineStart),xe=Math.min(se,K.sourceOut+ee),Ve=be(xe);r("trim",O,"end",Ve)}}function ke(O,ne){const K=t.clips.find(Y=>Y.id===O);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),Ve=m.framesToSeconds(xe);r("clip-move",O,Ve)}else{const Y=Math.max(0,K.timelineStart+ee),se=be(Y);r("clip-move",O,se)}}return e.watch(()=>t.playhead,O=>{const ne=O*C.value;ne<c.value+50?c.value=Math.max(0,ne-50):ne>c.value+D.value-50&&(c.value=Math.min(L.value,ne-D.value+50))}),e.onMounted(()=>{const O=new ResizeObserver(ne=>{ne[0]&&(u.value=Math.round(ne[0].contentRect.width))});i.value&&O.observe(i.value),e.onUnmounted(()=>O.disconnect())}),e.onUnmounted(()=>{we()}),e.watch([M,D],()=>{c.value>L.value&&(c.value=L.value)}),(O,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:Ce},[e.createElementVNode("div",l0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Q.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":P.value,"is-panning":h.value&&v.value==="pan","overflow-left":I.value,"overflow-right":_.value}]),onTouchstart:F,onTouchmove:X,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(O.clips,K=>(e.openBlock(),e.createElementBlock("div",{key:`${K.id}-extent`,class:"clip-extent",style:e.normalizeStyle(z(K)),"aria-hidden":"true"},null,4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(O.clips,K=>(e.openBlock(),e.createBlock(s0,{key:K.id,clip:K,scale:C.value,"scroll-offset":c.value,selected:f.value===K.id,"is-mobile":a.value,onSelect:ee=>oe(K.id),onTrimStart:ee=>ye(K.id,ee),onTrimEnd:ee=>me(K.id,ee),onDrag:ee=>ke(K.id,ee),onTrimStartAbs:ee=>pe(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:`${j.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:`${j.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=>O.$emit("toggle-frame-mode")),"aria-label":O.useFrameMode?"Switch to time mode":"Switch to frame mode",title:O.useFrameMode?"Switch to time mode":"Switch to frame mode"},e.toDisplayString(O.useFrameMode?"F":"T"),9,c0))],34),P.value?(e.openBlock(),e.createElementBlock("div",d0,[e.createElementVNode("div",{class:"scrollbar-thumb",style:e.normalizeStyle(U.value),onMousedown:ue,onTouchstart:ue},null,36)])):e.createCommentVNode("",!0)],34))}}),Es=Te(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 f=u.target;t("zoom-change",Number(f.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 f=u.target;t("speed-change",Number(f.value))}return(u,f)=>(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:f[0]||(f[0]=m=>u.$emit("zoom-out")),"aria-label":"Zoom out"},[e.createVNode(e.unref(B.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:f[1]||(f[1]=m=>u.$emit("zoom-in")),"aria-label":"Zoom in"},[e.createVNode(e.unref(B.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(B.IonIcon),{icon:e.unref(Fu)},null,8,["icon"]),f[3]||(f[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(B.IonIcon),{icon:e.unref(Yu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button",onClick:s,"aria-label":"Previous frame"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Lu)},null,8,["icon"])]),e.createElementVNode("button",{class:"control-button play-button",onClick:f[2]||(f[2]=m=>u.$emit("play-pause")),"aria-label":u.isPlaying?"Pause":"Play"},[e.createVNode(e.unref(B.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(B.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(B.IonIcon),{icon:e.unref(Gu)},null,8,["icon"])])]),u.isMobile?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",g0,[f[5]||(f[5]=e.createElementVNode("label",{class:"speed-label"},"Speed:",-1)),e.createElementVNode("select",{value:u.playbackSpeed,onChange:d,class:"speed-select","aria-label":"Playback speed"},[...f[4]||(f[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=Te(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={key:0,class:"slider-control"},j0={class:"control-label"},X0={class:"slider-wrapper"},Z0={class:"slider-value"},Y0={key:1,class:"color-control"},G0={class:"control-label"},H0={class:"color-wrapper"},J0=["value","onInput","disabled"],q0={class:"color-value"},K0={key:2,class:"toggle-control"},Q0={class:"control-label"},ev={key:3,class:"select-control"},tv={class:"control-label"},nv=["value","onChange","disabled"],ov=["value"],av={key:1,class:"no-params"},rv=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(),f={all:Gt,adjust:$n,color:Ht,blur:Fo,light:zn,effects:qa,stylize:Ln,advanced:Gt,distortion:Wn,transform:Wn};function m(I){return I.replace(/[-_]/g," ").replace(/\b\w/g,_=>_.toUpperCase())}function h(I){return f[I.toLowerCase()]??Gt}const v=e.computed(()=>{const I=Array.from(new Set(t.filters.map(_=>_.category).filter(_=>typeof _=="string"&&_.length>0))).sort((_,j)=>_.localeCompare(j));return[{id:"all",name:"All",icon:Gt},...I.map(_=>({id:_,name:m(_),icon:h(_)}))]}),b=e.computed(()=>r.value==="all"?t.filters:t.filters.filter(I=>I.category===r.value));e.watch(v,I=>{new Set(I.map(U=>U.id)).has(r.value)||(r.value="all");const j=Math.max(0,I.length-3);s.value>j&&(s.value=j)},{immediate:!0});function x(I){var _;return((_=t.activeFilters)==null?void 0:_.has(I))||!1}function R(I){if(i.value=I,!x(I.id)&&(a("apply-filter",I),I.params&&I.params.length>0)){const _=new Map;I.params.forEach(j=>{_.set(j.id,j.default)}),c.value.set(I.id,_)}a("preview-filter",I)}function S(I){var _;a("remove-filter",I),c.value.delete(I),((_=i.value)==null?void 0:_.id)===I&&(i.value=null)}function g(I){if(typeof I=="number"&&Number.isFinite(I))return I;if(typeof I=="string"){const _=Number(I);return Number.isFinite(_)?_:null}return null}function p(I,_){var Be;const j=(Be=t.activeFilters)==null?void 0:Be.get(I);if(j&&j.params){const Ce=j.params[_];if(Ce!=null)return Ce}const U=c.value.get(I);if(U){const Ce=U.get(_);if(Ce!=null)return Ce}const Q=t.filters.find(Ce=>Ce.id===I),ge=Q==null?void 0:Q.params.find(Ce=>Ce.id===_);return(ge==null?void 0:ge.default)??0}function w(I,_,j){var U;c.value.has(I)||c.value.set(I,new Map),(U=c.value.get(I))==null||U.set(_,j),a("update-param",I,_,j)}function $(I){if(typeof I=="boolean")return I?"On":"Off";if(typeof I=="string")return I;const _=g(I);return _===null?"0":Number.isInteger(_)?_.toString():_.toFixed(2)}function C(){if(i.value&&(a("apply-filter",i.value),i.value.params&&i.value.params.length>0)){const I=new Map;i.value.params.forEach(_=>{I.set(_.id,_.default)}),c.value.set(i.value.id,I)}}function y(I){const _=t.filters.find(j=>j.id===I);_&&_.params&&_.params.forEach(j=>{w(I,j.id,j.default)})}function N(I){return{basic:$n,color:Ht,blur:Fo,light:zn,effects:qa,stylize:Ln,adjustment:$n,"color-matrix":Ht,glow:Gt,distortion:Wn}[I]||Gt}function z(I){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}[I.id]||N(I.category)}function k(){s.value>0&&(s.value--,L(d.value,s.value))}function T(){s.value<v.value.length-3&&(s.value++,L(d.value,s.value))}function M(){l.value>0&&(l.value--,L(u.value,l.value))}function D(){l.value<b.value.length-4&&(l.value++,L(u.value,l.value))}function P(I){l.value=I*4,L(u.value,l.value)}function L(I,_){var j;if(I){const U=((j=I.querySelector(".category-chip, .filter-card"))==null?void 0:j.clientWidth)||100;I.scrollTo({left:_*(U+8),behavior:"smooth"})}}return(I,_)=>{var j;return e.openBlock(),e.createElementBlock("div",k0,[I.showCategories?(e.openBlock(),e.createElementBlock("div",x0,[e.createElementVNode("div",S0,[e.createElementVNode("button",{onClick:k,class:"carousel-nav carousel-nav-left",disabled:s.value===0,"aria-label":"Previous categories"},[e.createVNode(e.unref(B.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(v.value,U=>(e.openBlock(),e.createElementBlock("button",{key:U.id,onClick:Q=>r.value=U.id,class:e.normalizeClass(["category-chip",{active:r.value===U.id}])},[e.createVNode(e.unref(B.IonIcon),{icon:U.icon,class:"category-icon"},null,8,["icon"]),e.createElementVNode("span",V0,e.toDisplayString(U.name),1)],10,C0))),128))],512),e.createElementVNode("button",{onClick:T,class:"carousel-nav carousel-nav-right",disabled:s.value>=v.value.length-3,"aria-label":"Next categories"},[e.createVNode(e.unref(B.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:M,class:"carousel-nav carousel-nav-left",disabled:l.value===0,"aria-label":"Previous filters"},[e.createVNode(e.unref(B.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(b.value,U=>{var Q;return e.openBlock(),e.createElementBlock("div",{key:U.id,class:e.normalizeClass(["filter-card",{active:x(U.id),selected:((Q=i.value)==null?void 0:Q.id)===U.id}]),onClick:ge=>R(U)},[x(U.id)?(e.openBlock(),e.createElementBlock("div",{key:0,class:"filter-checkmark",onClick:e.withModifiers(ge=>S(U.id),["stop"])},[e.createVNode(e.unref(B.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(B.IonIcon),{icon:z(U),class:"filter-icon"},null,8,["icon"])])]),e.createElementVNode("span",P0,e.toDisplayString(U.name),1)],10,F0)}),128))],512),e.createElementVNode("button",{onClick:D,class:"carousel-nav carousel-nav-right",disabled:l.value>=Math.max(0,b.value.length-4),"aria-label":"Next filters"},[e.createVNode(e.unref(B.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(b.value.length/4),(U,Q)=>(e.openBlock(),e.createElementBlock("span",{key:Q,class:e.normalizeClass(["pagination-dot",{active:Math.floor(l.value/4)===Q}]),onClick:ge=>P(Q)},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:C,class:"apply-btn"}," Apply Filter ")),x(i.value.id)?(e.openBlock(),e.createElementBlock("button",{key:1,onClick:_[0]||(_[0]=U=>S(i.value.id)),class:"remove-btn"}," Remove Filter ")):e.createCommentVNode("",!0),x(i.value.id)&&((j=i.value.params)==null?void 0:j.length)>0?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:_[1]||(_[1]=U=>y(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,U=>(e.openBlock(),e.createElementBlock("div",{key:U.id,class:"adjustment-control"},[!U.type||U.type==="slider"?(e.openBlock(),e.createElementBlock("div",W0,[e.createElementVNode("label",j0,e.toDisplayString(U.label||U.id),1),e.createElementVNode("div",X0,[e.createVNode(e.unref(B.IonRange),{value:p(i.value.id,U.id),onIonChange:Q=>w(i.value.id,U.id,Q.detail.value),min:U.min,max:U.max,step:U.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($(p(i.value.id,U.id))),1)])])):U.type==="color"?(e.openBlock(),e.createElementBlock("div",Y0,[e.createElementVNode("label",G0,e.toDisplayString(U.label||U.id),1),e.createElementVNode("div",H0,[e.createElementVNode("input",{type:"color",value:p(i.value.id,U.id),onInput:Q=>w(i.value.id,U.id,Q.target.value),disabled:!x(i.value.id),class:"color-input"},null,40,J0),e.createElementVNode("span",q0,e.toDisplayString(p(i.value.id,U.id)),1)])])):U.type==="toggle"?(e.openBlock(),e.createElementBlock("div",K0,[e.createElementVNode("label",Q0,e.toDisplayString(U.label||U.id),1),e.createVNode(e.unref(B.IonToggle),{checked:!!p(i.value.id,U.id),onIonChange:Q=>w(i.value.id,U.id,Q.detail.checked),disabled:!x(i.value.id),color:"primary"},null,8,["checked","onIonChange","disabled"])])):U.type==="select"?(e.openBlock(),e.createElementBlock("div",ev,[e.createElementVNode("label",tv,e.toDisplayString(U.label||U.id),1),e.createElementVNode("select",{value:p(i.value.id,U.id),onChange:Q=>w(i.value.id,U.id,Q.target.value),disabled:!x(i.value.id),class:"select-input"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.options,Q=>(e.openBlock(),e.createElementBlock("option",{key:String(Q.value),value:Q.value},e.toDisplayString(Q.label),9,ov))),128))],40,nv)])):e.createCommentVNode("",!0)]))),128))])):(e.openBlock(),e.createElementBlock("div",av," This filter has no adjustable parameters "))])):e.createCommentVNode("",!0)])}}}),Cs=Te(rv,[["__scopeId","data-v-88360322"]]);class iv{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 sv={class:"video-filter-preview"},lv={class:"preview-title"},cv={class:"filter-controls"},dv={class:"control-input"},uv=["value","onInput","min","max","step"],mv={class:"param-value"},pv={class:"preview-container"},fv={key:0,class:"filter-presets"},hv=["onClick"],vv={class:"preview-actions"},gv=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 f=e.computed(()=>{var y;return((y=t.filter)==null?void 0:y.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 v(){var y;if(r.value){t.useVideoEngine&&t.composition&&(u=new iv(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}),(y=t.currentFrame)!=null&&y.dataUrl){const N=await Ae.Assets.load(t.currentFrame.dataUrl);c=new Ae.Sprite(N);const z=Math.min(l.screen.width/c.texture.width,l.screen.height/c.texture.height);c.scale.set(z),c.anchor.set(.5),c.position.set(l.screen.width/2,l.screen.height/2),l.stage.addChild(c)}b()}catch{}}}function b(){if(!(!c||!t.filter))if(t.useVideoEngine&&u){const y={id:t.filter.id,filterId:t.filter.id,params:s.value,intensity:s.value.value??s.value.intensity??1};u.applyFilters([y]).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(y,N){switch(y){case"brightness":{const z=new Ae.ColorMatrixFilter,k=1+(N.value??0);return typeof z.brightness=="function"&&z.brightness(k,!1),z}case"contrast":{const z=new Ae.ColorMatrixFilter,k=N.value??1;return typeof z.contrast=="function"&&z.contrast(k,!1),z}case"saturation":{const z=new Ae.ColorMatrixFilter,k=N.value??1;return typeof z.saturate=="function"&&z.saturate(k,!1),z}case"hue":{const z=new Ae.ColorMatrixFilter,k=N.value??0;return typeof z.hue=="function"&&z.hue(k,!1),z}case"gaussian-blur":{const z=N.value??5;return new Ae.BlurFilter({strength:z,quality:4})}case"sepia":{const z=new Ae.ColorMatrixFilter;return typeof z.sepia=="function"&&z.sepia(!1),z}case"grayscale":{const z=new Ae.ColorMatrixFilter;return typeof z.desaturate=="function"&&z.desaturate(),z}default:return null}}function R(y,N){const z=N.target,k=Number.parseFloat(z.value),T=Number.isFinite(k)?k:0;s.value={...s.value,[y]:T},t.useVideoEngine&&u&&t.filter&&u.updateFilterParams(t.filter.id,s.value),a("update-params",s.value),b()}function S(y){return y.charAt(0).toUpperCase()+y.slice(1).replace(/_/g," ")}function g(y,N){var k;const z=typeof y=="number"?y:Number(y);return Number.isFinite(z)?N==="hue"||N==="angle"?`${z}°`:N==="value"&&((k=t.filter)==null?void 0:k.id)==="brightness"?`${Math.round((1+z)*100)}%`:Number.isInteger(z)?z.toString():z.toFixed(2):"0"}function p(){var y;s.value=((y=t.filter)==null?void 0:y.defaultParams)||{},a("update-params",s.value),b()}function w(y){s.value={...y.params},a("update-params",s.value),b()}function $(y){return JSON.stringify(y.params)===JSON.stringify(s.value)}function C(){a("apply")}return e.watch(()=>t.filter,y=>{y&&(s.value={...y.defaultParams},b())}),e.watch(()=>t.currentFrame,async y=>{if(y!=null&&y.dataUrl&&c){const N=await Ae.Assets.load(y.dataUrl);c.texture=N}}),e.watch(i,b),e.onMounted(()=>{t.filter&&(s.value={...t.filter.defaultParams}),v()}),e.onUnmounted(()=>{l&&l.destroy(!0,{children:!0,texture:!0}),d&&d.destroy(),u&&u.destroy()}),(y,N)=>{var z;return e.openBlock(),e.createElementBlock("div",sv,[e.createElementVNode("h4",lv,e.toDisplayString((z=y.filter)==null?void 0:z.name)+" Settings",1),e.createElementVNode("div",cv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(k,T)=>(e.openBlock(),e.createElementBlock("div",{key:T,class:"control-group"},[e.createElementVNode("label",null,e.toDisplayString(S(T)),1),e.createElementVNode("div",dv,[e.createElementVNode("input",{type:"range",value:s.value[T],onInput:M=>R(T,M),min:k.min,max:k.max,step:k.step,class:"param-slider"},null,40,uv),e.createElementVNode("span",mv,e.toDisplayString(g(s.value[T],T)),1)])]))),128))]),e.createElementVNode("div",pv,[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(B.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",fv,[(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,hv))),128))])):e.createCommentVNode("",!0),e.createElementVNode("div",vv,[e.createElementVNode("button",{class:"action-button",onClick:p},[e.createVNode(e.unref(B.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(B.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),N[6]||(N[6]=e.createTextVNode(" Apply Filter ",-1))])])])}}}),Vs=Te(gv,[["__scopeId","data-v-3de3dd04"]]),yv={class:"export-settings"},bv={class:"setting-group"},wv={class:"setting-group"},kv={class:"estimated-size"},xv={key:0,class:"export-progress"},Sv={class:"progress-header"},Ev={class:"progress-percentage"},Cv={class:"progress-time"},Vv={class:"action-buttons"},Nv=["disabled"],_v=["disabled"],Tv=["disabled"],Mv={class:"export-options"},Fv=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 f=null;const m=e.computed(()=>{const p=({"360p":1,"480p":2.5,"720p":5,"1080p":8,"1440p":16,"2160p":35}[r.value]||8)*t.duration/8;return p<1e3?`~${Math.round(p)} MB`:`~${(p/1e3).toFixed(1)} GB`});function h(){t.isExporting?(a("cancel-export"),x()):v()}function v(){const S={quality:r.value,format:i.value,optimizeForWeb:s.value,includeWatermark:l.value};a("export",S),b()}function b(){c.value=Date.now(),d.value=0,f=window.setInterval(()=>{if(d.value=Math.floor((Date.now()-c.value)/1e3),t.exportProgress>0){const S=d.value/t.exportProgress*100;u.value=Math.max(0,S-d.value)}},1e3)}function x(){f&&(clearInterval(f),f=null)}function R(S){const g=Math.floor(S/60),p=Math.floor(S%60);return`${g}:${p.toString().padStart(2,"0")}`}return e.watch(()=>t.isExporting,S=>{S||x()}),e.onUnmounted(()=>{x()}),(S,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["editor-controls",{mobile:S.isMobile}])},[e.createElementVNode("div",yv,[g[10]||(g[10]=e.createElementVNode("h3",{class:"section-title"},"Export Settings",-1)),e.createElementVNode("div",bv,[g[7]||(g[7]=e.createElementVNode("label",null,"Quality",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[0]||(g[0]=p=>r.value=p),class:"setting-select"},[...g[6]||(g[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",wv,[g[9]||(g[9]=e.createElementVNode("label",null,"Format",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":g[1]||(g[1]=p=>i.value=p),class:"setting-select"},[...g[8]||(g[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",kv,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Pu)},null,8,["icon"]),e.createElementVNode("span",null,"Estimated size: "+e.toDisplayString(m.value),1)])]),S.isExporting?(e.openBlock(),e.createElementBlock("div",xv,[e.createElementVNode("div",Sv,[g[11]||(g[11]=e.createElementVNode("span",null,"Exporting...",-1)),e.createElementVNode("span",Ev,e.toDisplayString(S.exportProgress??0)+"%",1)]),e.createVNode(e.unref(B.IonProgressBar),{value:(S.exportProgress??0)/100},null,8,["value"]),e.createElementVNode("div",Cv,[e.createElementVNode("span",null,e.toDisplayString(R(d.value))+" elapsed",1),e.createElementVNode("span",null,e.toDisplayString(R(u.value))+" remaining",1)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Vv,[e.createElementVNode("button",{class:"control-button secondary",onClick:g[2]||(g[2]=p=>S.$emit("save-draft")),disabled:!S.canExport||S.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(cl)},null,8,["icon"]),g[12]||(g[12]=e.createTextVNode(" Save Draft ",-1))],8,Nv),e.createElementVNode("button",{class:"control-button secondary",onClick:g[3]||(g[3]=p=>S.$emit("reset")),disabled:S.isExporting},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(co)},null,8,["icon"]),g[13]||(g[13]=e.createTextVNode(" Reset ",-1))],8,_v),e.createElementVNode("button",{class:"control-button primary",onClick:h,disabled:!S.canExport&&!S.isExporting,"data-testid":"video-export-button"},[e.createVNode(e.unref(B.IonIcon),{icon:S.isExporting?e.unref(ao):e.unref(pa)},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(S.isExporting?"Cancel":"Export Video"),1)],8,Tv)]),e.createElementVNode("div",Mv,[e.createVNode(e.unref(B.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonCheckbox),{modelValue:s.value,"onUpdate:modelValue":g[4]||(g[4]=p=>s.value=p)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...g[14]||(g[14]=[e.createTextVNode("Optimize for web streaming",-1)])]),_:1})]),_:1}),e.createVNode(e.unref(B.IonItem),{lines:"none"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonCheckbox),{modelValue:l.value,"onUpdate:modelValue":g[5]||(g[5]=p=>l.value=p)},null,8,["modelValue"]),e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...g[15]||(g[15]=[e.createTextVNode("Include watermark",-1)])]),_:1})]),_:1})])],2))}}),Ns=Te(Fv,[["__scopeId","data-v-e1338d5e"]]),Iv={class:"thumbnail-picker"},Bv={class:"thumbnail-grid"},Rv=["onClick"],Pv=["src","alt"],$v={key:1,class:"thumbnail-placeholder"},zv={class:"thumbnail-time"},Av={class:"custom-selector"},Dv={class:"time-input-group"},Uv=["max"],Ov={class:"time-value"},Lv=["disabled"],Wv={class:"picker-actions"},jv=["disabled"],Xv=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 R=[];if(t.duration<=10)for(let g=0;g<Math.min(9,t.duration);g++)R.push(g);else{const g=t.duration/10;for(let p=1;p<=9;p++)R.push(g*p)}return R}async function d(R){try{const S=document.createElement("video");return S.crossOrigin="anonymous",S.src=await u(),new Promise(g=>{S.addEventListener("loadedmetadata",()=>{S.currentTime=R}),S.addEventListener("seeked",()=>{const p=document.createElement("canvas");p.width=S.videoWidth,p.height=S.videoHeight;const w=p.getContext("2d");w?(w.drawImage(S,0,0),g(p.toDataURL("image/jpeg",.8))):g(null),S.remove()}),S.addEventListener("error",()=>{g(null),S.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 f(){const R=c();r.value=R.map(g=>({time:g,loading:!0}));const S=3;for(let g=0;g<r.value.length;g+=S){const p=r.value.slice(g,g+S);await Promise.all(p.map(async w=>{const $=await d(w.time);$&&(w.dataUrl=$),w.loading=!1}))}}function m(R){i.value=R,s.value=r.value[R].time}function h(){i.value=-1}async function v(){l.value=!0;try{const R=await d(s.value);if(R){const S=r.value.findIndex(g=>Math.abs(g.time-s.value)<.1);S>=0?(r.value[S].dataUrl=R,i.value=S):(r.value.push({time:s.value,dataUrl:R}),i.value=r.value.length-1,r.value.sort((g,p)=>g.time-p.time),i.value=r.value.findIndex(g=>g.time===s.value))}}finally{l.value=!1}}function b(){const R=i.value>=0?r.value[i.value].time:s.value;a("select",R)}function x(R){const S=Math.floor(R/60),g=Math.floor(R%60),p=Math.floor(R%1*100);return S>0?`${S}:${g.toString().padStart(2,"0")}.${p.toString().padStart(2,"0")}`:`${g}.${p.toString().padStart(2,"0")}s`}return e.onMounted(()=>{f()}),(R,S)=>(e.openBlock(),e.createElementBlock("div",Iv,[S[5]||(S[5]=e.createElementVNode("h4",{class:"picker-title"},"Select Video Thumbnail",-1)),e.createElementVNode("div",Bv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(g,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass(["thumbnail-item",{selected:i.value===p}]),onClick:w=>m(p)},[g.dataUrl?(e.openBlock(),e.createElementBlock("img",{key:0,src:g.dataUrl,alt:`Frame at ${x(g.time)}`},null,8,Pv)):(e.openBlock(),e.createElementBlock("div",$v,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])),e.createElementVNode("div",zv,e.toDisplayString(x(g.time)),1)],10,Rv))),128))]),e.createElementVNode("div",Av,[S[3]||(S[3]=e.createElementVNode("label",null,"Custom time:",-1)),e.createElementVNode("div",Dv,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":S[0]||(S[0]=g=>s.value=g),min:0,max:R.duration,step:.1,onInput:h,class:"time-slider"},null,40,Uv),[[e.vModelText,s.value]]),e.createElementVNode("span",Ov,e.toDisplayString(x(s.value)),1)]),e.createElementVNode("button",{class:"capture-button",onClick:v,disabled:l.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Su)},null,8,["icon"]),S[2]||(S[2]=e.createTextVNode(" Capture Frame ",-1))],8,Lv)]),e.createElementVNode("div",Wv,[e.createElementVNode("button",{class:"action-button",onClick:S[1]||(S[1]=g=>R.$emit("cancel"))}," Cancel "),e.createElementVNode("button",{class:"action-button primary",onClick:b,disabled:i.value===-1},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(rl)},null,8,["icon"]),S[4]||(S[4]=e.createTextVNode(" Set Thumbnail ",-1))],8,jv)])]))}}),Zv=Te(Xv,[["__scopeId","data-v-336c322c"]]),Yv={class:"text-overlay-panel p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Gv={class:"mb-4"},Hv={class:"space-y-2 max-h-64 overflow-y-auto"},Jv={class:"flex items-center justify-between"},qv={class:"flex-1"},Kv={class:"font-medium text-gray-900 dark:text-white"},Qv={class:"text-sm text-gray-500 dark:text-gray-400"},eg={class:"flex items-center space-x-2"},tg=["onClick"],ng=["onClick"],og={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},ag={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},rg={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},ig={class:"space-y-4"},sg={class:"grid grid-cols-2 gap-4"},lg={class:"grid grid-cols-2 gap-4"},cg={key:0,class:"p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},dg={class:"grid grid-cols-2 gap-3"},ug={class:"flex justify-end space-x-3 mt-6"},mg=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 f(m){const h=Math.floor(m/60),v=Math.floor(m%60);return`${h}:${v.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",Yv,[e.createElementVNode("div",Gv,[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]=v=>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",Hv,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.overlays,v=>(e.openBlock(),e.createElementBlock("div",{key:v.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",Jv,[e.createElementVNode("div",qv,[e.createElementVNode("div",Kv,e.toDisplayString(v.text.substring(0,30))+e.toDisplayString(v.text.length>30?"...":""),1),e.createElementVNode("div",Qv,e.toDisplayString(f(v.startTime??0))+" - "+e.toDisplayString(f((v.startTime||0)+(v.duration||5))),1)]),e.createElementVNode("div",eg,[e.createElementVNode("button",{onClick:b=>l(v),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,tg),e.createElementVNode("button",{onClick:b=>u(v.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,ng)])])]))),128)),m.overlays.length===0?(e.openBlock(),e.createElementBlock("div",og," 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",ag,[e.createElementVNode("h4",rg,e.toDisplayString(r.value?"Edit":"Add")+" Text Overlay ",1),e.createElementVNode("div",ig,[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]=v=>s.text=v),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",sg,[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]=v=>s.fontSize=v),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]=v=>s.color=v),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]=v=>s.position=v),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",lg,[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]=v=>s.startTime=v),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]=v=>s.duration=v),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]=v=>s.animationType=v),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",cg,[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",dg,[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]=v=>s.animationDuration=v),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]=v=>s.animationEasing=v),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",ug,[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=Te(mg,[["__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 pg={class:"transition-selector p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},fg={class:"grid grid-cols-3 gap-3 max-h-96 overflow-y-auto"},hg=["onClick"],vg={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"},gg={key:0,class:"w-8 h-8 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},yg={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"},bg={key:1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M14 5l7 7m0 0l-7 7m7-7H3"},wg={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"},kg={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"},xg={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"},Sg={class:"text-sm font-medium text-gray-900 dark:text-white text-center"},Eg={key:0,class:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},Cg={class:"space-y-3"},Vg={class:"flex items-center space-x-2"},Ng=["disabled"],_g=["disabled"],Tg={key:1,class:"mt-4"},Mg={class:"space-y-2 max-h-32 overflow-y-auto"},Fg={class:"text-sm text-gray-700 dark:text-gray-300"},Ig=["onClick"],Bg=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(v){i.value=v}function u(){if(!i.value||!c.value)return;const v={type:i.value.type,duration:s.value,easing:l.value};a("apply-transition",v),i.value=null}function f(){if(!i.value)return;const v={type:i.value.type,duration:s.value,easing:l.value};a("preview-transition",v)}function m(v){a("remove-transition",v)}function h(v){return["fade","wipe","slide","zoom"].some(b=>v.includes(b))}return(v,b)=>(e.openBlock(),e.createElementBlock("div",pg,[b[9]||(b[9]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"}," Transitions ",-1)),e.createElementVNode("div",fg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,x=>{var R;return e.openBlock(),e.createElementBlock("div",{key:x.type,onClick:S=>d(x),class:e.normalizeClass(["transition-item cursor-pointer rounded-lg p-3 border-2 transition-all",((R=i.value)==null?void 0:R.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",vg,[h(x.type)?(e.openBlock(),e.createElementBlock("svg",gg,[x.type.includes("fade")?(e.openBlock(),e.createElementBlock("path",yg)):x.type.includes("wipe")?(e.openBlock(),e.createElementBlock("path",bg)):x.type.includes("slide")?(e.openBlock(),e.createElementBlock("path",wg)):x.type.includes("zoom")?(e.openBlock(),e.createElementBlock("path",kg)):(e.openBlock(),e.createElementBlock("path",xg))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Sg,e.toDisplayString(x.name),1)],10,hg)}),128))]),i.value?(e.openBlock(),e.createElementBlock("div",Eg,[b[6]||(b[6]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3"}," Transition Settings ",-1)),e.createElementVNode("div",Cg,[e.createElementVNode("div",null,[b[3]||(b[3]=e.createElementVNode("label",{class:"block text-xs text-gray-600 dark:text-gray-400 mb-1"}," Duration (seconds) ",-1)),e.createElementVNode("div",Vg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[0]||(b[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":b[1]||(b[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,[b[5]||(b[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":b[2]||(b[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"},[...b[4]||(b[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,Ng),e.createElementVNode("button",{onClick:f,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,_g)])])):e.createCommentVNode("",!0),v.appliedTransitions.length>0?(e.openBlock(),e.createElementBlock("div",Tg,[b[8]||(b[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"}," Applied Transitions ",-1)),e.createElementVNode("div",Mg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.appliedTransitions,(x,R)=>(e.openBlock(),e.createElementBlock("div",{key:R,class:"flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-700 rounded"},[e.createElementVNode("div",Fg,e.toDisplayString(x.name)+" ("+e.toDisplayString(x.duration)+"s) ",1),e.createElementVNode("button",{onClick:S=>m(R),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded"},[...b[7]||(b[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,Ig)]))),128))])])):e.createCommentVNode("",!0),b[10]||(b[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=Te(Bg,[["__scopeId","data-v-5ef1b100"]]),Rg={class:"audio-track-manager p-4 bg-white dark:bg-gray-800 rounded-lg shadow-lg"},Pg={class:"mb-4"},$g={class:"mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg"},zg={class:"flex items-center justify-between mb-2"},Ag={class:"text-sm text-gray-600 dark:text-gray-400"},Dg={class:"flex items-center space-x-2"},Ug={class:"space-y-3 max-h-64 overflow-y-auto"},Og={class:"flex items-center justify-between mb-2"},Lg={class:"font-medium text-gray-900 dark:text-white"},Wg={class:"flex items-center space-x-2"},jg=["onClick","title"],Xg={key:0,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Zg={key:1,class:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20"},Yg=["onClick"],Gg=["onClick"],Hg={class:"flex items-center space-x-2"},Jg={class:"text-xs text-gray-500 dark:text-gray-400 w-10"},qg=["value","onInput","disabled"],Kg={class:"mt-2 text-xs text-gray-500 dark:text-gray-400"},Qg={key:0,class:"ml-2"},e1={key:1,class:"ml-2"},t1={key:0,class:"text-center py-8 text-gray-500 dark:text-gray-400"},n1={class:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-lg mx-4"},o1={class:"text-lg font-semibold text-gray-900 dark:text-white mb-4"},a1={class:"space-y-4"},r1={class:"space-y-2"},i1={class:"flex items-center"},s1={class:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1"},l1={class:"grid grid-cols-2 gap-4"},c1={class:"grid grid-cols-2 gap-4"},d1={class:"flex items-center"},u1={class:"flex justify-end space-x-3 mt-6"},m1=["disabled"],p1=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(g){const p=g.target;p.files&&p.files[0]&&(c.sourceFile=p.files[0],c.name=c.name||p.files[0].name.replace(/\.[^/.]+$/,""))}function f(g){Object.assign(c,g),i.value=g}function m(){r.value=!1,i.value=null,Object.assign(c,l())}function h(){if(!d.value)return;const g={source:c.sourceFile??c.sourceUrl??"",name:c.name,volume:c.volume,startTime:c.startTime,loop:c.loop};c.duration!==void 0&&(g.duration=c.duration),c.fadeIn>0&&(g.fadeIn=c.fadeIn),c.fadeOut>0&&(g.fadeOut=c.fadeOut),i.value?a("update-track",i.value.id,g):a("add-track",g),m()}function v(g){confirm("Are you sure you want to remove this audio track?")&&a("remove-track",g)}function b(g,p){const w=p.target,$=parseFloat(w.value);a("update-volume",g.id,$)}function x(g){a("toggle-mute",g.id,!g.muted)}function R(){a("update-master-volume",s.value)}function S(g){const p=Math.floor(g/60),w=Math.floor(g%60);return`${p}:${w.toString().padStart(2,"0")}`}return(g,p)=>(e.openBlock(),e.createElementBlock("div",Rg,[e.createElementVNode("div",Pg,[p[11]||(p[11]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-900 dark:text-white mb-2"}," Audio Tracks ",-1)),e.createElementVNode("button",{onClick:p[0]||(p[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"},[...p[10]||(p[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",$g,[e.createElementVNode("div",zg,[p[12]||(p[12]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-700 dark:text-gray-300"}," Master Volume ",-1)),e.createElementVNode("span",Ag,e.toDisplayString(Math.round(s.value*100))+"% ",1)]),e.createElementVNode("div",Dg,[p[13]||(p[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":p[1]||(p[1]=w=>s.value=w),onInput:R,type:"range",min:"0",max:"1",step:"0.01",class:"flex-1"},null,544),[[e.vModelText,s.value,void 0,{number:!0}]]),p[14]||(p[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",Ug,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.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",Og,[e.createElementVNode("div",Lg,e.toDisplayString(w.name),1),e.createElementVNode("div",Wg,[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",Zg,[...p[16]||(p[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",Xg,[...p[15]||(p[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,jg),e.createElementVNode("button",{onClick:$=>f(w),class:"p-1 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900 rounded",title:"Settings"},[...p[17]||(p[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,Yg),e.createElementVNode("button",{onClick:$=>v(w.id),class:"p-1 text-red-600 hover:bg-red-50 dark:hover:bg-red-900 rounded",title:"Remove"},[...p[18]||(p[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,Gg)])]),e.createElementVNode("div",Hg,[e.createElementVNode("span",Jg,e.toDisplayString(Math.round((w.volume||1)*100))+"% ",1),e.createElementVNode("input",{value:w.volume||1,onInput:$=>b(w,$),type:"range",min:"0",max:"1",step:"0.01",class:"flex-1",disabled:w.muted},null,40,qg)]),e.createElementVNode("div",Kg,[e.createTextVNode(e.toDisplayString(S(w.startTime||0))+" - "+e.toDisplayString(S((w.startTime||0)+(w.duration||0)))+" ",1),w.fadeIn?(e.openBlock(),e.createElementBlock("span",Qg,"Fade In: "+e.toDisplayString(w.fadeIn)+"s",1)):e.createCommentVNode("",!0),w.fadeOut?(e.openBlock(),e.createElementBlock("span",e1,"Fade Out: "+e.toDisplayString(w.fadeOut)+"s",1)):e.createCommentVNode("",!0)])]))),128)),g.audioLayers.length===0?(e.openBlock(),e.createElementBlock("div",t1," 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",n1,[e.createElementVNode("h4",o1,e.toDisplayString(i.value?"Edit":"Add")+" Audio Track ",1),e.createElementVNode("div",a1,[e.createElementVNode("div",null,[p[20]||(p[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",r1,[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",i1,[p[19]||(p[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":p[2]||(p[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,[p[21]||(p[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":p[3]||(p[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",s1," Volume: "+e.toDisplayString(Math.round(c.volume*100))+"% ",1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[4]||(p[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",l1,[e.createElementVNode("div",null,[p[22]||(p[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":p[5]||(p[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,[p[23]||(p[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":p[6]||(p[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",c1,[e.createElementVNode("div",null,[p[24]||(p[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":p[7]||(p[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,[p[25]||(p[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":p[8]||(p[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",d1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":p[9]||(p[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]]),p[26]||(p[26]=e.createElementVNode("label",{for:"loop-checkbox",class:"text-sm text-gray-700 dark:text-gray-300"}," Loop audio track ",-1))])]),e.createElementVNode("div",u1,[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,m1)])])])):e.createCommentVNode("",!0)]))}}),Ms=Te(p1,[["__scopeId","data-v-593719ac"]]);function Fs(n){var s,l;f1(n);const o=h1(n.clips),t=[],a=v1(n),r=g1(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 f1(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 h1(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 v1(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 g1(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 y1(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),f=new Wl(30),m=e.ref(30),h=e.ref(!1),v=e.ref(!1);o&&o.timeline&&o.timeline.length>0?(g(o),(ee=o.output)!=null&&ee.fps&&(m.value=o.output.fps,f.setFps(m.value))):(S(),o&&((be=o.output)!=null&&be.fps&&(m.value=o.output.fps,f.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 b=e.computed(()=>r.selectedClipId?r.clips.find(Y=>Y.id===r.selectedClipId)??null:null),x=e.computed(()=>s.value.length>0),R=e.computed(()=>l.value.length>0);function S(){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=Ce(),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 Ve=await fetch(`/api/v1/video/${encodeURIComponent(a)}`);if(!Ve.ok)throw new Error(`Failed to fetch media: ${Ve.status}`);const Ue=await Ve.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,M()}catch{}})()}function g(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),M()}function p(){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(!R.value)return;const Y=l.value.pop();s.value.push(JSON.parse(JSON.stringify(r))),Object.assign(r,Y)}function C(Y,se,xe){p();const Ve=r.clips.find(ut=>ut.id===Y);if(!Ve)return;const Ye=1/30,nt=Ve.sourceMinIn??0,At=Ve.sourceMaxOut??r.originalDuration;if(se==="start"){const ut=Ve.sourceIn,fn=Math.max(nt,Math.min(xe,Ve.sourceOut-Ye));Ve.sourceIn=fn;const Da=fn-ut;Ve.timelineStart+=Da}else{const ut=Math.max(Ve.sourceIn+Ye,Math.min(xe,At));Ve.sourceOut=ut;const fn=Ve.sourceOut-Ve.sourceIn;Ve.timelineEnd=Ve.timelineStart+fn}M(),u.value&&u.value.trimClip(Y,Ve.sourceIn,Ve.sourceOut)}function y(Y){p();const se=r.clips.find(nt=>Y>nt.timelineStart&&Y<nt.timelineEnd);if(!se)return;const xe=Y-se.timelineStart,Ve=se.sourceIn+xe,Ue={id:Ce(),type:"clip",timelineStart:Y,timelineEnd:se.timelineEnd,sourceIn:Ve,sourceOut:se.sourceOut,speed:se.speed??1,sourceMinIn:se.sourceMinIn??0,sourceMaxOut:se.sourceMaxOut??r.originalDuration,filters:[...se.filters||[]]};se.timelineEnd=Y,se.sourceOut=Ve;const Ye=r.clips.indexOf(se);r.clips.splice(Ye+1,0,Ue),r.selectedClipId=Ue.id}function N(){y(r.playheadPosition)}function z(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;p();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,M()}}function T(Y,se){p();const xe=r.clips.find(Ue=>Ue.id===Y);if(!xe)return;const Ve=se-xe.timelineStart;xe.timelineStart=se,xe.timelineEnd+=Ve,M(),u.value&&u.value.moveClip(Y,se)}function M(){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 P(){r.zoomLevel=Math.max(10,r.zoomLevel/1.2)}function L(Y){r.zoomLevel=Math.max(10,Math.min(600,Math.round(Y)))}function I(){r.isPlaying=!r.isPlaying}function _(Y){r.isPlaying=Y}function j(Y){r.playheadPosition=Math.max(0,Math.min(Y,r.totalDuration))}function U(){const Y=Fs(r);return localStorage.setItem(`video-draft-${a}`,JSON.stringify(Y)),Y}function Q(){r.hasChanges=!1}function ge(){return confirm("Are you sure you want to reset all changes?")?(p(),S(),r.hasChanges=!1,!0):!1}function Be(){return Fs(r)}function Ce(){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 F()}catch{u.value=null}}async function F(){if(!(!u.value||v.value)){v.value=!0;try{const Y=Be();await u.value.loadFromRecipe(Y);const se=f.secondsToFrames(r.playheadPosition);u.value.seek(se)}catch{}finally{v.value=!1}}}function X(Y){}function te(Y){return f.secondsToFrames(Y)}function ae(Y){return f.framesToSeconds(Y)}function re(Y){const se=ae(Y);j(se),u.value&&u.value.seek(Y)}function q(){h.value=!h.value}function ue(){F()}function he(Y){d.value=!1,u.value=null}e.watch(()=>r.clips,()=>{r.hasChanges=!0,d.value&&u.value&&F()},{deep:!0}),e.watch(()=>r.filters,()=>{r.hasChanges=!0,d.value&&u.value&&F()},{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(Ve=>Ve.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=>{f.setFps(Y)});const pe=e.ref(1);function Ze(){if(!r.selectedClipId)return;p();const Y=r.clips.find(Ve=>Ve.id===r.selectedClipId);if(!Y)return;const se={...Y,id:Ce(),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 me(){const Y=1/m.value;j(Math.min(r.playheadPosition+Y,r.totalDuration))}function ke(){const Y=1/m.value;j(Math.max(r.playheadPosition-Y,0))}function O(){j(0)}function ne(){j(r.totalDuration)}function K(Y){pe.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:b,zoomLevel:e.computed(()=>r.zoomLevel),playbackSpeed:pe,useVideoEngine:d,compositionAdapter:e.computed(()=>u.value),fps:m,useFrameMode:h,handleTrim:C,handleSplit:y,handleClipSelect:z,splitAtPlayhead:N,deleteSelectedClip:k,duplicateSelectedClip:Ze,setFilters:we,setTextOverlays:oe,setAudioTracks:ye,moveClip:T,saveDraft:U,clearHasChanges:Q,resetChanges:ge,generateRecipe:Be,zoomIn:D,zoomOut:P,setZoomLevel:L,fitToWindow:Ke,togglePlayback:I,setPlaying:_,seekTo:j,frameForward:me,frameBackward:ke,skipToStart:O,skipToEnd:ne,setPlaybackSpeed:K,undo:w,redo:$,canUndo:x,canRedo:R,initializeComposition:ie,syncCompositionWithState:F,syncWithComposition:X,convertToFrames:te,convertToSeconds:ae,seekToFrame:re,toggleFrameMode:q,onCompositionReady:ue,onCompositionError:he}}const b1=[{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}}}],w1={dropShadow:"drop-shadow",softFocus:"blur",blackAndWhite:"grayscale",gaussianBlur:"blur","gaussian-blur":"blur"};function _a(n){return typeof n=="object"&&n!==null}function k1(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 x1(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),n.options!==void 0&&(o.options=n.options),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 S1(n,o,t,a){const r=a.map(x1);return{id:n,name:o,category:t,controls:r,params:r,defaultParams:jl(n,r),paramRanges:Xl(r)}}function E1(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 C1(n,o){return o.toLowerCase()!=="unlisted"}function ir(n){return w1[n]??n}function Zn(n){const o=k1(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 V1(n){return!_a(n)||typeof n.filterId!="string"?null:{filterId:n.filterId,params:Yn(n.params),intensity:Zn(n.intensity)}}function N1(n){if(!_a(n)||typeof n.id!="string"||typeof n.name!="string")return null;const t=(Array.isArray(n.filters)?n.filters:[]).map(r=>V1(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 _1(){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 M=new Map,D=no.getRegisteredFilters();for(const P of D)C1(P.id,P.category)&&M.set(P.id,S1(P.id,P.name,P.category,P.controls));for(const P of b1)M.has(P.id)||M.set(P.id,E1(P));return Array.from(M.values())}),l=e.computed(()=>{const M=new Map;for(const D of s.value)M.set(D.id,D);return M}),c=e.computed(()=>n.value.length>0),d=e.computed(()=>{const M={};for(const D of s.value)M[D.category]||(M[D.category]=[]),M[D.category].push(D);return M});function u(M){const D=l.value.get(M);if(D)return D;const P=ir(M);return l.value.get(P)??null}function f(M){const D=l.value.get(M);if(D)return D.id;const P=ir(M),L=l.value.get(P);return L?L.id:null}function m(M){const D=M?u(M):o.value;if(!D)return;const P=D.defaultParams||{},L={id:N(),filterId:D.id,params:{...P},intensity:1};return n.value.push(L),r.value=L.id,o.value=D,Object.keys(i).forEach(I=>delete i[I]),Object.assign(i,L.params),t.value=null,L}function h(M){const D=u(M);if(!D)return;o.value=D;const P=D.defaultParams||k(M);Object.assign(i,P),t.value={id:"preview",filterId:D.id,params:{...P},intensity:1}}function v(M){if(Object.assign(i,M),t.value&&(t.value.params={...i}),r.value){const D=n.value.find(P=>P.id===r.value);D&&(D.params={...i})}}function b(M){const D=n.value.findIndex(P=>P.id===M);D!==-1&&n.value.splice(D,1)}function x(M,D){if(M<0||M>=n.value.length||D<0||D>=n.value.length)return;const[P]=n.value.splice(M,1);n.value.splice(D,0,P)}function R(M,D){const P=n.value.find(L=>L.id===M);P&&(P.intensity=Math.max(0,Math.min(1,D)))}function S(M){const D=n.value.find(P=>P.id===M);D&&(D.intensity=D.intensity>0?0:1)}function g(){n.value=[],t.value=null,o.value=null,r.value=null,Object.keys(i).forEach(M=>delete i[M])}function p(M){const D={id:z(),name:M,filters:n.value.map(L=>({filterId:L.filterId,params:Yn(L.params),intensity:Zn(L.intensity)})),created_at:new Date().toISOString()};a.value.push(D);const P=a.value.map(L=>({...L}));return localStorage.setItem("video-filter-presets",JSON.stringify(P)),D}function w(M){const D=a.value.find(P=>P.id===M);if(D){g();for(const P of D.filters){const L=u(P.filterId);L&&n.value.push({id:N(),filterId:L.id,params:{...P.params},intensity:Zn(P.intensity)})}}}function $(M){const D=a.value.findIndex(P=>P.id===M);D!==-1&&(a.value.splice(D,1),localStorage.setItem("video-filter-presets",JSON.stringify(a.value)))}function C(){try{const M=localStorage.getItem("video-filter-presets");if(!M)return;const D=JSON.parse(M);if(!Array.isArray(D))return;a.value=D.map(P=>N1(P)).filter(P=>P!==null)}catch{}}function y(){if(n.value.length===0)return"No filters applied";const M=n.value.map(D=>{const P=T(D.filterId);return(P==null?void 0:P.name)||D.filterId});return M.length===1?M[0]:M.length===2?`${M[0]} + ${M[1]}`:`${M[0]} + ${M.length-1} more`}function N(){return`filter-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function z(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}function k(M){const D=u(M);return D?D.defaultParams||{}:{}}function T(M){return u(M)}return C(),{videoCompatibleFilters:s,activeFilters:n,selectedFilter:o,previewFilter:t,filterPresets:a,filterParams:i,hasActiveFilters:c,filtersByCategory:d,applyFilter:m,previewFilterEffect:h,updateFilterParams:v,removeFilter:b,reorderFilters:x,updateFilterIntensity:R,toggleFilter:S,clearAllFilters:g,saveFilterPreset:p,loadFilterPreset:w,deleteFilterPreset:$,getFilterSummary:y,setActiveFilters(M){var P;const D=[];for(const L of M){const I=f(L.filterId);if(!I){const _=ir(L.filterId);D.push({...L,filterId:_,params:Yn(L.params),intensity:Zn(L.intensity)});continue}D.push({...L,filterId:I,params:Yn(L.params),intensity:Zn(L.intensity)})}n.value=D,r.value=((P=n.value[0])==null?void 0:P.id)??null,Object.keys(i).forEach(L=>delete i[L]),n.value[0]&&Object.assign(i,Yn(n.value[0].params))}}}class T1{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 M1{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:F1}=Object.prototype,{getPrototypeOf:Jr}=Object,{iterator:Ma,toStringTag:Yl}=Symbol,Fa=(n=>o=>{const t=F1.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 I1(n){let o;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?o=ArrayBuffer.isView(n):o=n&&n.buffer&&Gl(n.buffer),o}const B1=Ia("string"),mt=Ia("function"),Hl=Ia("number"),wo=n=>n!==null&&typeof n=="object",R1=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)},P1=n=>{if(!wo(n)||bo(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},$1=Ct("Date"),z1=Ct("File"),A1=Ct("Blob"),D1=Ct("FileList"),U1=n=>wo(n)&&mt(n.pipe),O1=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]"))},L1=Ct("URLSearchParams"),[W1,j1,X1,Z1]=["ReadableStream","Request","Response","Headers"].map(Ct),Y1=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 G1=(n,o,t,{allOwnKeys:a}={})=>(ko(o,(r,i)=>{t&&mt(r)?n[i]=Zl(r,t):n[i]=r},{allOwnKeys:a}),n),H1=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),J1=(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)},q1=(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},K1=(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},Q1=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},ey=(n=>o=>n&&o instanceof n)(typeof Uint8Array<"u"&&Jr(Uint8Array)),ty=(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])}},ny=(n,o)=>{let t;const a=[];for(;(t=n.exec(o))!==null;)a.push(t);return a},oy=Ct("HTMLFormElement"),ay=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),ry=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)},iy=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+"'")})}})},sy=(n,o)=>{const t={},a=r=>{r.forEach(i=>{t[i]=!0})};return In(n)?a(n):a(String(n).split(o)),t},ly=()=>{},cy=(n,o)=>n!=null&&Number.isFinite(n=+n)?n:o;function dy(n){return!!(n&&mt(n.append)&&n[Yl]==="FormData"&&n[Ma])}const uy=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)},my=Ct("AsyncFunction"),py=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)),fy=typeof queueMicrotask<"u"?queueMicrotask.bind(rn):typeof process<"u"&&process.nextTick||Ql,hy=n=>n!=null&&mt(n[Ma]),G={isArray:In,isArrayBuffer:Gl,isBuffer:bo,isFormData:O1,isArrayBufferView:I1,isString:B1,isNumber:Hl,isBoolean:R1,isObject:wo,isPlainObject:Yo,isEmptyObject:P1,isReadableStream:W1,isRequest:j1,isResponse:X1,isHeaders:Z1,isUndefined:lo,isDate:$1,isFile:z1,isBlob:A1,isRegExp:ry,isFunction:mt,isStream:U1,isURLSearchParams:L1,isTypedArray:ey,isFileList:D1,forEach:ko,merge:Cr,extend:G1,trim:Y1,stripBOM:H1,inherits:J1,toFlatObject:q1,kindOf:Fa,kindOfTest:Ct,endsWith:K1,toArray:Q1,forEachEntry:ty,matchAll:ny,isHTMLForm:oy,hasOwnProperty:Is,hasOwnProp:Is,reduceDescriptors:Kl,freezeMethods:iy,toObjectSet:sy,toCamelCase:ay,noop:ly,toFiniteNumber:cy,findKey:Jl,global:rn,isContextDefined:ql,isSpecCompliantForm:dy,toJSONObject:uy,isAsyncFn:my,isThenable:py,setImmediate:Ql,asap:fy,isIterable:hy};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 vy=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 gy(n){return G.isArray(n)&&!n.some(Vr)}const yy=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(b,x){return!G.isUndefined(x[b])});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(v){if(v===null)return"";if(G.isDate(v))return v.toISOString();if(G.isBoolean(v))return v.toString();if(!c&&G.isBlob(v))throw new Me("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(v)||G.isTypedArray(v)?c&&typeof Blob=="function"?new Blob([v]):Buffer.from(v):v}function u(v,b,x){let R=v;if(v&&!x&&typeof v=="object"){if(G.endsWith(b,"{}"))b=a?b:b.slice(0,-2),v=JSON.stringify(v);else if(G.isArray(v)&&gy(v)||(G.isFileList(v)||G.endsWith(b,"[]"))&&(R=G.toArray(v)))return b=nc(b),R.forEach(function(g,p){!(G.isUndefined(g)||g===null)&&o.append(s===!0?Bs([b],p,i):s===null?b:b+"[]",d(g))}),!1}return Vr(v)?!0:(o.append(Bs(x,b,i),d(v)),!1)}const f=[],m=Object.assign(yy,{defaultVisitor:u,convertValue:d,isVisitable:Vr});function h(v,b){if(!G.isUndefined(v)){if(f.indexOf(v)!==-1)throw Error("Circular reference detected in "+b.join("."));f.push(v),G.forEach(v,function(R,S){(!(G.isUndefined(R)||R===null)&&r.call(o,R,G.isString(S)?S.trim():S,b,m))===!0&&h(R,b?b.concat(S):[S])}),f.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 by(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||by;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},wy=typeof URLSearchParams<"u"?URLSearchParams:qr,ky=typeof FormData<"u"?FormData:null,xy=typeof Blob<"u"?Blob:null,Sy={isBrowser:!0,classes:{URLSearchParams:wy,FormData:ky,Blob:xy},protocols:["http","https","file","blob","url","data"]},Kr=typeof window<"u"&&typeof document<"u",Nr=typeof navigator=="object"&&navigator||void 0,Ey=Kr&&(!Nr||["ReactNative","NativeScript","NS"].indexOf(Nr.product)<0),Cy=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Vy=Kr&&window.location.href||"http://localhost",Ny=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Kr,hasStandardBrowserEnv:Ey,hasStandardBrowserWebWorkerEnv:Cy,navigator:Nr,origin:Vy},Symbol.toStringTag,{value:"Module"})),lt={...Ny,...Sy};function _y(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 Ty(n){return G.matchAll(/\w+|\[(\w*)]/g,n).map(o=>o[0]==="[]"?"":o[1]||o[0])}function My(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]=My(r[s])),!l)}if(G.isFormData(n)&&G.isFunction(n.entries)){const t={};return G.forEachEntry(n,(a,r)=>{o(Ty(a),r,t,0)}),t}return null}function Fy(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 _y(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),Fy(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 Iy=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"]),By=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]&&Iy[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 Ry(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 Py=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 $y(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(o,t,a)=>t.toUpperCase()+a)}function zy(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 f=G.findKey(r,u);(!f||r[f]===void 0||d===!0||d===void 0&&r[f]!==!1)&&(r[f||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())&&!Py(o))s(By(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 Ry(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?$y(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]||(zy(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 Ay(n){const o=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return o&&o[1]||""}function Dy(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 f=i,m=0;for(;f!==r;)m+=t[f++],f=f%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 Uy(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(),f=u-t;f>=a?s(d,u):(r=d,i||(i=setTimeout(()=>{i=null,s(r)},a-f)))},()=>r&&s(r)]}const ca=(n,o,t=3)=>{let a=0;const r=Dy(50,250);return Uy(i=>{const s=i.loaded,l=i.lengthComputable?i.total:void 0,c=s-a,d=r(c),u=s<=l;a=s;const f={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(f)},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)),Oy=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,Ly=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 Wy(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function jy(n,o){return o?n.replace(/\/?\/$/,"")+"/"+o.replace(/^\/+/,""):n}function cc(n,o,t){let a=!Wy(o);return n&&(a||t==!1)?jy(n,o):o}const Ds=n=>n instanceof pt?{...n}:n;function dn(n,o){o=o||{};const t={};function a(d,u,f,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,f,m){if(G.isUndefined(u)){if(!G.isUndefined(d))return a(void 0,d,f,m)}else return a(d,u,f,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,f){if(f in o)return a(d,u);if(f 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,f)=>r(Ds(d),Ds(u),f,!0)};return G.forEach(Object.keys({...n,...o}),function(u){const f=c[u]||r,m=f(n[u],o[u],u);G.isUndefined(m)&&f!==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(f=>f.trim()).filter(Boolean):[];s.setContentType([d||"multipart/form-data",...u].join("; "))}}if(lt.hasStandardBrowserEnv&&(a&&G.isFunction(a)&&(a=a(o)),a||a!==!1&&Oy(o.url))){const d=r&&i&&Ly.read(i);d&&s.set(r,d)}return o},Xy=typeof XMLHttpRequest<"u",Zy=Xy&&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,f,m,h,v;function b(){h&&h(),v&&v(),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 R(){if(!x)return;const g=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:g,config:n,request:x};lc(function(C){t(C),b()},function(C){a(C),b()},w),x=null}"onloadend"in x?x.onloadend=R:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(R)},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 p=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const w=r.transitional||rc;r.timeoutErrorMessage&&(p=r.timeoutErrorMessage),a(new Me(p,w.clarifyTimeoutError?Me.ETIMEDOUT:Me.ECONNABORTED,n,x)),x=null},i===void 0&&s.setContentType(null),"setRequestHeader"in x&&G.forEach(s.toJSON(),function(p,w){x.setRequestHeader(w,p)}),G.isUndefined(r.withCredentials)||(x.withCredentials=!!r.withCredentials),l&&l!=="json"&&(x.responseType=r.responseType),d&&([m,v]=ca(d,!0),x.addEventListener("progress",m)),c&&x.upload&&([f,h]=ca(c),x.upload.addEventListener("progress",f),x.upload.addEventListener("loadend",h)),(r.cancelToken||r.signal)&&(u=g=>{x&&(a(!g||g.type?new Bn(null,n,x):g),x.abort(),x=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const S=Ay(r.url);if(S&<.protocols.indexOf(S)===-1){a(new Me("Unsupported protocol "+S+":",Me.ERR_BAD_REQUEST,n));return}x.send(i||null)})},Yy=(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}},Gy=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},Hy=async function*(n,o){for await(const t of Jy(n))yield*Gy(t,o)},Jy=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=Hy(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 f=u.byteLength;if(t){let m=i+=f;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",qy=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}},Ky=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 Qy=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 qy(n)).byteLength},eb=async(n,o)=>{const t=G.toFiniteNumber(n.getContentLength());return t??Qy(o)},tb=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:f="same-origin",fetchOptions:m}=dc(n);d=d?(d+"").toLowerCase():"text";let h=Yy([r,i&&i.toAbortSignal()],s),v;const b=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let x;try{if(c&&Ky&&t!=="get"&&t!=="head"&&(x=await eb(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,y]=zs(x,ca(As(c)));a=Us(w.body,Os,C,y)}}G.isString(f)||(f=f?"include":"omit");const R="credentials"in Request.prototype;v=new Request(o,{...m,signal:h,method:t.toUpperCase(),headers:u.normalize().toJSON(),body:a,duplex:"half",credentials:R?f:void 0});let S=await fetch(v,m);const g=_r&&(d==="stream"||d==="response");if(_r&&(l||g&&b)){const w={};["status","statusText","headers"].forEach(N=>{w[N]=S[N]});const $=G.toFiniteNumber(S.headers.get("content-length")),[C,y]=l&&zs($,ca(As(l),!0))||[];S=new Response(Us(S.body,Os,C,()=>{y&&y(),b&&b()}),w)}d=d||"text";let p=await da[G.findKey(da,d)||"text"](S,n);return!g&&b&&b(),await new Promise((w,$)=>{lc(w,$,{data:p,headers:pt.from(S.headers),status:S.status,statusText:S.statusText,config:n,request:v})})}catch(R){throw b&&b(),R&&R.name==="TypeError"&&/Load failed|fetch/i.test(R.message)?Object.assign(new Me("Network Error",Me.ERR_NETWORK,n,v),{cause:R.cause||R}):Me.from(R,R&&R.code,n,v)}}),Tr={http:vy,xhr:Zy,fetch:tb};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}`,nb=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,!nb(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 ob(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:ob,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"],v=>{delete i[v]}),t.headers=pt.concat(s,i);const l=[];let c=!0;this.interceptors.request.forEach(function(b){typeof b.runWhen=="function"&&b.runWhen(t)===!1||(c=c&&b.synchronous,l.unshift(b.fulfilled,b.rejected))});const d=[];this.interceptors.response.forEach(function(b){d.push(b.fulfilled,b.rejected)});let u,f=0,m;if(!c){const v=[Ws.bind(this),void 0];for(v.unshift(...l),v.push(...d),m=v.length,u=Promise.resolve(t);f<m;)u=u.then(v[f++],v[f++]);return u}m=l.length;let h=t;for(f=0;f<m;){const v=l[f++],b=l[f++];try{h=v(h)}catch(x){b.call(this,x);break}}try{u=Ws.call(this,h)}catch(v){return Promise.reject(v)}for(f=0,m=d.length;f<m;)u=u.then(d[f++],d[f++]);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 ab=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 rb(n){return function(t){return n.apply(null,t)}}function ib(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=ab;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=rb;Xe.isAxiosError=ib;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:C3,AxiosError:V3,CanceledError:N3,isCancel:_3,CancelToken:T3,VERSION:M3,all:F3,Cancel:I3,isAxiosError:B3,spread:R3,toFormData:P3,AxiosHeaders:$3,HttpStatusCode:z3,formToJSON:A3,getAdapter:D3,mergeConfig:U3}=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{const t=await this.api.post("/video/jobs",o);return this.normalizeJob(t.data.data)}catch(t){throw t}}async createRenderJob(o){try{const t=await this.api.post("/video/jobs/render",o);return this.normalizeJob(t.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.error_message??"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{const t=await this.api.get(`/video/jobs/${o}`);return this.normalizeJob(t.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{const t=await this.api.post(`/video/jobs/${o}/retry`);return this.normalizeJob(t.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}}normalizeJob(o){const t=o,a={...t,user_id:t.user_id??t.userId??"",source_media_id:t.source_media_id??t.sourceMediaId??"",created_at:t.created_at??t.createdAt??"",updated_at:t.updated_at??t.updatedAt??""},r=t.output_media_id??t.outputMediaId;typeof r=="string"&&r!==""&&(a.output_media_id=r);const i=t.error_message??t.errorMessage;typeof i=="string"&&i!==""&&(a.error_message=i);const s=t.started_at??t.startedAt;typeof s=="string"&&s!==""&&(a.started_at=s);const l=t.completed_at??t.completedAt;return typeof l=="string"&&l!==""&&(a.completed_at=l),a}}new Qr;const sb={key:0,class:"mobile-layout"},lb={class:"preview-section"},cb={class:"timeline-section"},db={class:"controls-section"},ub={class:"tab-nav"},mb=["onClick"],pb={class:"tab-content"},fb={class:"filters-panel"},hb={class:"adjustments-panel"},vb={class:"text-panel"},gb={class:"transitions-panel"},yb={class:"audio-panel"},bb={class:"export-panel"},wb={key:0,"data-testid":"video-export-status-completed"},kb={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},xb={key:1,class:"desktop-layout"},Sb={class:"desktop-main-row"},Eb={class:"preview-panel"},Cb={class:"fit-toggle"},Vb={class:"editor-content"},Nb={class:"editor-tabs"},_b={class:"tab-header"},Tb=["onClick"],Mb={class:"tab-content-area"},Fb={class:"filter-controls"},Ib={class:"text-controls"},Bb={class:"transition-controls"},Rb={class:"audio-controls"},Pb={class:"adjustments-controls"},$b={key:1,class:"no-filter-selected"},zb={class:"export-controls"},Ab={key:0,"data-testid":"video-export-status-completed"},Db={key:1,"data-testid":"video-export-status-message",class:"export-status-message"},Ub={class:"desktop-timeline-row"},Ob={class:"timeline-container"},Lb={class:"timeline-zoom"},Wb=["value"],jb={class:"zoom-readout"},Xb={key:0,class:"dev-editor-controls","data-testid":"video-editor-dev-controls"},Zb={class:"dev-editor-row"},Yb={class:"dev-editor-field"},Gb={class:"dev-editor-field"},Hb=["disabled"],Jb=["disabled"],qb=["disabled"],Kb={class:"dev-editor-row"},Qb={class:"dev-editor-field dev-editor-field--wide"},e2=["value"],t2=["disabled"],n2=["disabled"],o2=["disabled"],a2=["disabled"],r2=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 E=a.media.uuid??a.media.id;return typeof E=="string"&&E.trim()!==""?E.trim():void 0}),s=e.computed(()=>{const E=typeof a.mediaUuid=="string"?a.mediaUuid.trim():"";return E!==""?E: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 E=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:E.filters,adjustments:typeof V.adjustments=="boolean"?V.adjustments:E.adjustments,text:typeof V.text=="boolean"?V.text:E.text,transitions:typeof V.transitions=="boolean"?V.transitions:E.transitions,audio:typeof V.audio=="boolean"?V.audio:E.audio,export:typeof V.export=="boolean"?V.export:E.export}:E}),f=e.computed(()=>l.value?c.value:d.value),m=e.computed(()=>f.value==="filters"||x.value),h=e.computed(()=>f.value!=="filters"&&!x.value),v=e.ref(null),b=e.ref(null),x=e.ref(!1),R=e.computed(()=>l.value?v.value:b.value),S=e.shallowRef(null),g=e.ref(null),p=e.ref("cover"),w=e.ref(null),$=e.ref(null),C=e.ref(null),y=e.ref(!1),N=new Map,z=e.ref([]),k=e.ref([]),T=e.ref([]),M=e.ref([]),D=e.ref(1),P=()=>{l.value=window.innerWidth<768},L=[{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}],I=[{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(()=>L.filter(E=>u.value[E.id])),j=e.computed(()=>I.filter(E=>u.value[E.id])),U=e.computed(()=>{var E,V;return((E=j.value[0])==null?void 0:E.id)??((V=_.value[0])==null?void 0:V.id)??"filters"});e.watch(u,E=>{E[c.value]||(c.value=U.value),E[d.value]||(d.value=U.value)},{immediate:!0,deep:!0}),e.watch(U,E=>{u.value[c.value]||(c.value=E),u.value[d.value]||(d.value=E)},{immediate:!0}),e.watch(u,E=>{E.export||(c.value==="export"&&(c.value=U.value),d.value==="export"&&(d.value=U.value))},{immediate:!0,deep:!0});const Q=e.computed(()=>typeof window>"u"?!1:window.__MEDIABLES_EDITOR_DEV__===!0),{currentFrame:ge,playheadPosition:Be,timelineClips:Ce,totalDuration:ie,hasChanges:F,isPlaying:X,selectedClip:te,zoomLevel:ae,playbackSpeed:re,handleTrim:q,handleSplit:ue,handleClipSelect:he,splitAtPlayhead:we,deleteSelectedClip:oe,duplicateSelectedClip:ye,setZoomLevel:pe,moveClip:Ze,setFilters:Ke,setTextOverlays:me,setAudioTracks:ke,saveDraft:O,clearHasChanges:ne,resetChanges:K,generateRecipe:ee,zoomIn:be,zoomOut:Y,fitToWindow:se,togglePlayback:xe,setPlaying:Ve,seekTo:Ue,frameForward:Ye,frameBackward:nt,skipToStart:At,skipToEnd:ut,setPlaybackSpeed:fn}=y1(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}=_1();function Rn(E){var Z,H;const V=((Z=te.value)==null?void 0:Z.id)??((H=Ce.value[0])==null?void 0:H.id);V&&(y.value=!0,typeof E=="object"&&E.id?li(E.id):typeof E=="string"&&li(E),Ke(Je.value),S.value?S.value.setClipFilters(V,Je.value):N.set(V,[...Je.value]),he(V),y.value=!1,Nt())}function Rc(){var V,Z;const E=((V=te.value)==null?void 0:V.id)??((Z=Ce.value[0])==null?void 0:Z.id);E&&he(E)}function di(E){const V=Je.value.find(Z=>Z.filterId===E);V&&Ic(V.id)}const Co=e.computed(()=>Da.value.map(V=>{var H;const Z=[];if(V.controls&&V.controls.length>0)for(const le of V.controls){const J=le.type;if(J==="button"||J==="text"||J==="range")continue;const ce={id:le.property||le.id,label:le.label||le.id,type:J,default:le.default??(J==="toggle"?!1:J==="color"?"#ffffff":0)};J==="slider"&&(ce.min=le.min??0,ce.max=le.max??1,ce.step=le.step??.01),J==="select"&&le.options&&(ce.options=le.options),Z.push(ce)}else if(V.paramRanges){const le=Object.entries(V.paramRanges);for(const[J,ce]of le){const Re=J.replace(/[-_]/g," ").replace(/\b\w/g,_t=>_t.toUpperCase()),ct=(H=V.defaultParams)==null?void 0:H[J],Ut=(ce.min+ce.max)/2;Z.push({id:J,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:Z}})),hn=e.ref("0.00"),vn=e.ref("0.00"),Xt=e.ref("");e.watch(Co,E=>{if(E.length===0){Xt.value="";return}E.some(Z=>Z.id===Xt.value)||(Xt.value=E[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 E=new Map;return Je.value.forEach(V=>E.set(V.filterId,V)),E}),mi=e.computed(()=>{var E,V;return ge.value?ge.value:((E=a.media)==null?void 0:E.thumbnail_url)||((V=a.media)==null?void 0:V.url)}),Vt=e.ref("");e.watch(()=>{var E,V;return{file:(E=a.media)==null?void 0:E.file,url:(V=a.media)==null?void 0:V.url}},(E,V,Z)=>{var le,J;const H=Vt.value;Z(()=>{H&&H.startsWith("blob:")&&URL.revokeObjectURL(H)}),(le=a.media)!=null&&le.file?Vt.value=URL.createObjectURL(a.media.file):(J=a.media)!=null&&J.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:E,...V}=a.media;return{...V,url:Vt.value}}),fi=e.computed(()=>{var V;const E=(V=a.media)==null?void 0:V.url;return!!(E&&/^https?:/i.test(E))}),hi=e.computed(()=>Je.value),vi=e.computed(()=>Be.value),Pc=e.computed(()=>!!te.value&&Be.value>0),$c=e.computed(()=>!!te.value&&Ce.value.length>1),Oa=e.ref(0),gn=e.computed(()=>{try{const E=ie.value??ie;return E&&typeof E=="number"&&E>0?E:Oa.value}catch{return Oa.value}});function yn(E){return Number.isFinite(E)?E.toFixed(2):"0.00"}function gi(E){const V=Number(E);return Number.isFinite(V)?V:null}function zc(E){E&&(hn.value=yn(E.sourceIn),vn.value=yn(E.sourceOut))}e.watch(()=>{var E,V,Z;return[(E=te.value)==null?void 0:E.id,(V=te.value)==null?void 0:V.sourceIn,(Z=te.value)==null?void 0:Z.sourceOut]},()=>{zc(te.value)},{immediate:!0});function yi(E){const V=te.value;if(!V)return;const Z=1/30,H=V.sourceMinIn??0,le=V.sourceMaxOut??gn.value,J=V.sourceIn+(Be.value-V.timelineStart);if(E==="start"){const Re=Math.max(H,Math.min(J,V.sourceOut-Z));hn.value=yn(Re);return}const ce=Math.max(V.sourceIn+Z,Math.min(J,le));vn.value=yn(ce)}function Ac(){const E=te.value;if(!E)return;const V=gi(hn.value),Z=gi(vn.value);if(V===null||Z===null)return;const H=1/30,le=E.sourceMinIn??0,J=E.sourceMaxOut??gn.value,ce=Math.max(le,Math.min(V,J-H)),Re=Math.max(ce+H,Math.min(Z,J));q(E.id,"start",ce),q(E.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 E;ci(),Ke(Je.value),(E=te.value)!=null&&E.id&&(S.value?S.value.setClipFilters(te.value.id,Je.value):N.set(te.value.id,[...Je.value])),Nt()}function bi(E,V,Z){var le,J;const H=Je.value.find(ce=>ce.filterId===E);H?(H.params={...H.params,[V]:Z},Ke(Je.value),S.value&&((le=te.value)!=null&&le.id)?S.value.setClipFilters(te.value.id,Je.value):(J=te.value)!=null&&J.id&&N.set(te.value.id,[...Je.value]),Nt(),Rc()):Eo.value&&Eo.value.filterId===E&&(Eo.value.params={...Eo.value.params||{},[V]:Z})}function wi(E){Ue(E)}function ki(E){Ve(E)}function No(E){Oa.value=E}function Oc(E){const V=E.target,Z=Number(V.value);pe(Z)}function xi(E){var V;S.value=E,(V=S.value)!=null&&V.composition&&(w.value=new T1(S.value.composition),$.value=new la(S.value.composition),C.value=new M1(S.value.composition));try{N.size&&(N.forEach((Z,H)=>{S.value.setClipFilters(H,Z)}),N.clear(),S.value.composition.computeFrame())}catch{}}function Si(E){E!=null&&E.id&&Mc(E.id)}function Ei(E){Fc(E),Nt()}async function Ci(E){if(!w.value)return;const V=await w.value.addTextOverlay(E);z.value.push({id:V,...E})}async function Vi(E,V){if(!w.value)return;await w.value.updateTextOverlay(E,V);const Z=z.value.findIndex(H=>H.id===E);Z!==-1&&(z.value[Z]={...z.value[Z],...V})}async function Ni(E){w.value&&(await w.value.removeTextOverlay(E),z.value=z.value.filter(V=>V.id!==E))}async function _i(E){if(!$.value||M.value.length<2)return;const[V,Z]=M.value,H=await $.value.applyTransition(V,Z,E);k.value.push({id:H,...E,name:E.type})}function Ti(E){if(!$.value)return;const V=k.value[E];V&&($.value.removeTransition(V.id),k.value.splice(E,1))}function Mi(E){}async function Fi(E){if(!C.value)return;const V=await C.value.addAudioTrack(E);T.value.push({id:V,...E})}async function Ii(E,V){if(!C.value)return;const Z=T.value.findIndex(H=>H.id===E);Z!==-1&&(T.value[Z]={...T.value[Z],...V})}async function Bi(E){C.value&&(await C.value.removeAudioTrack(E),T.value=T.value.filter(V=>V.id!==E))}async function Ri(E,V){if(!C.value)return;await C.value.updateVolume(E,V);const Z=T.value.find(H=>H.id===E);Z&&(Z.volume=V)}async function Pi(E,V){if(!C.value)return;await C.value.muteTrack(E,V);const Z=T.value.find(H=>H.id===E);Z&&(Z.muted=V)}function $i(E){C.value&&(C.value.setMasterVolume(E),D.value=E)}function Lc(E){r("thumbnail-selected",E)}function Zt(){Vo!==null&&(clearInterval(Vo),Vo=null)}function Wc(E,V){return V?{...E,output:{...E.output,format:V.format,quality:V.quality}}:E}function je(E,V,Z){return Math.min(Z,Math.max(V,E))}function La(E,V){if(typeof E=="number"&&Number.isFinite(E))return E;if(typeof E=="string"){const Z=Number(E);if(Number.isFinite(Z))return Z}return V}function rt(E,V,Z){for(const H of V)if(H in E)return La(E[H],Z);return Z}function jc(E){const V=typeof E.params=="object"&&E.params!==null?E.params:{};switch(E.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 H=je(rt(V,["brightness"],1)-1,-1,1),le=je(rt(V,["contrast"],1),.1,3),J=je(rt(V,["saturation"],1),0,3);return[{type:"brightness",value:H},{type:"contrast",value:le},{type:"saturation",value:J}]}default:return[]}}function Xc(E){const V=E.timeline[0],Z=Array.isArray(V==null?void 0:V.filters)?V.filters:[],H=[];for(const J of Z)if(H.push(...jc(J)),H.length>=12)break;const le={...E,filters:H.slice(0,12)};if(E.timeline.length===1&&V){const J=Math.max(0,La(V.sourceIn,0)),ce=La(V.sourceOut,J);ce>J&&(le.trim={start:J,end:ce})}return le}function Zc(E){return{"360p":[640,360],"480p":[854,480],"720p":[1280,720],"1080p":[1920,1080],"1440p":[2560,1440],"2160p":[3840,2160]}[E??""]??[1920,1080]}function Yc(E){if(!E||typeof E!="object")return null;const V=E.duration;if(typeof V=="number"&&Number.isFinite(V)&&V>0)return V;if(V&&typeof V=="object"&&"value"in V){const Z=V.value;if(typeof Z=="number"&&Number.isFinite(Z)&&Z>0)return Z}return null}async function zi(E,V,Z){var Ut,_t,Tt,Mt;const H=E.timeline[0],le=H?Math.max(0,H.sourceIn):0,J=H?H.sourceOut:void 0,[ce,Re]=Zc((V==null?void 0:V.quality)??((Ut=E.output)==null?void 0:Ut.quality)),ct=((_t=E.output)==null?void 0:_t.fps)||30;Ve(!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=R.value;if(!(!To||typeof To.captureFrameAt!="function")&&typeof To.ensureReadyForCapture=="function"&&(it=await To.ensureReadyForCapture(),it))break}const ht=R.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-BTXhmL54.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};J!==void 0&&(bn.trimEnd=J),Z&&(bn.onProgress=Z);const Zi=Vt.value;Zi!==""&&(bn.sourceUrl=Zi);const sd=typeof ht.duration=="number"&&ht.duration>0?ht.duration:((Tt=E.source)==null?void 0:Tt.duration)??J??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=E.source)==null?void 0:Mt.duration)??0,ud=Math.max(0,(J??cd??dd)-le);return{file:Ga,recipe:E,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(E,V){var Mt;Zt(),wt=!1,Dt=null,Et.value=null,Oe.value=null,St.value=!1,We.value=0;const Z=E??ee(),H=ji(Z),le=Array.isArray(H.filters)&&H.filters.length>0,J=Xa(H);if(!(F.value||le||J))return ne(),r("video-exported",null),null;const Re=H.timeline[0],ct=Re?Math.max(0,Re.sourceIn):0,_t=((Re==null?void 0:Re.sourceOut)??((Mt=H.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(H),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(H,V,it=>{wt||(We.value=it)});return wt?(Oe.value="Export canceled.",We.value=0,r("video-exported",null),null):(ne(),r("recipe-generated",H),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(E){const V=new Qr(a.serverRenderEndpoint??"/api/v1");Oe.value="Starting server render...",We.value=0;const Z=await V.createRenderJob({source_media_uuid:s.value,recipe:E});Et.value=Z.id,r("server-render-started",Z.id),r("export-started",Z.id),Oe.value="Rendering on server...";const H=await V.pollRenderJob(Z.id,(J,ce)=>{We.value=J,ce==="processing"&&(Oe.value=`Server rendering: ${J}%`)},3e3,(a.maxDuration>0?a.maxDuration*3:1800)*1e3);We.value=100,St.value=!0,Oe.value="Server render complete!",ne(),r("recipe-generated",E);const le={id:H.id};typeof H.output_media_id=="string"&&H.output_media_id!==""&&(le.output_media_id=H.output_media_id),r("server-render-completed",le)}async function Ai(){if(!ot.value)return;wt=!0,x.value=!1,Dt&&(Dt.abort(),Dt=null),Zt();const E=Et.value;if(E)try{const V=await fetch(`/api/v1/video/jobs/${E}`,{method:"DELETE"});if(!V.ok)throw new Error(`Cancel failed: ${V.status} ${V.statusText}`)}catch(V){const Z=V instanceof Error?V.message:"Failed to cancel export";Oe.value=Z,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(E){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(),E);r("recipe-generated",V);const Z=s.value.startsWith("temp-"),H=V.timeline[0],le=Array.isArray(H==null?void 0:H.filters)?H.filters:[],J=!0,ce=typeof window<"u"&&window.MEDIABLES_ALLOW_SERVER_EXPORT_FALLBACK===1||typeof localStorage<"u"&&localStorage.getItem("mediables.export.allowServerFallback")==="1";if(J)try{const ht=await zi(V,E,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(Z||!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=(E==null?void 0:E.quality)??V.output.quality,Ut=Re[ct]??"high",_t={...Xc(V),export:{format:(E==null?void 0:E.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 Z=ee(),H=new Blob([JSON.stringify(Z,null,2)],{type:"application/json"}),le=URL.createObjectURL(H),J=document.createElement("a");J.href=le,J.download=`video-recipe-${Date.now()}.json`,J.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 E=>{await new Promise(V=>{window.setTimeout(V,E)})},ja=E=>{if(!E||E.width<=0||E.height<=0)return null;try{return E.toDataURL("image/jpeg",.85)}catch{return null}},Jc=E=>{if(!E||typeof E!="object")return null;const Z=E.pixiCanvas;if(Z&&typeof Z=="object"&&"value"in Z){const H=Z.value;return H instanceof HTMLCanvasElement?H:null}return Z instanceof HTMLCanvasElement?Z:null},qc=E=>{if(!E||typeof E!="object")return null;const V=E.duration;if(typeof V=="number"&&Number.isFinite(V))return V;if(V&&typeof V=="object"&&"value"in V){const Z=V.value;if(typeof Z=="number"&&Number.isFinite(Z))return Z}return null},Kc=E=>{if(!E||typeof E!="object")return null;const Z=E.videoElement;if(Z&&typeof Z=="object"&&"value"in Z){const H=Z.value;return H instanceof HTMLVideoElement?H:null}return Z instanceof HTMLVideoElement?Z:null},Ui=E=>typeof E.params=="object"&&E.params!==null?E.params:{},Qc=E=>{const V=[];for(const Z of E){const H=Ui(Z),le=Z.filterId.trim().toLowerCase();if(le==="brightness"){const ce=(je(rt(H,["value","brightness"],0),-1,1)+1)*100;V.push(`brightness(${ce.toFixed(2)}%)`);continue}if(le==="contrast"){const J=je(rt(H,["value","contrast"],1),.1,4);V.push(`contrast(${(J*100).toFixed(2)}%)`);continue}if(le==="saturation"||le==="saturate"){const J=je(rt(H,["value","saturation"],1),0,4);V.push(`saturate(${(J*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 J=je(rt(H,["value","blur","radius"],0),0,30);J>.01&&V.push(`blur(${J.toFixed(2)}px)`);continue}if(le==="adjustment"){const J=rt(H,["brightness"],1),ce=rt(H,["contrast"],1),Re=rt(H,["saturation"],1);Math.abs(J-1)>.01&&V.push(`brightness(${(je(J,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=E=>{const V=E.find(le=>le.filterId.trim().toLowerCase()==="noise");if(!V)return 0;const Z=Ui(V),H=rt(Z,["noise","value","amount","intensity"],.2);return H<=1?je(H,0,1):je(H/100,0,1)},td=(E,V,Z,H)=>{if(H<=0)return;const le=E.getImageData(0,0,V,Z),J=255*H;for(let ce=0;ce<le.data.length;ce+=4){const Re=(Math.random()*2-1)*J;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)}E.putImageData(le,0,0)},Oi=async E=>{E.readyState>=2&&E.videoWidth>0&&E.videoHeight>0||await new Promise(V=>{let Z=!1,H=0;const le=()=>{Z||(Z=!0,E.removeEventListener("loadedmetadata",J),E.removeEventListener("loadeddata",J),E.removeEventListener("canplay",J),window.clearTimeout(H),V())},J=()=>{le()};E.addEventListener("loadedmetadata",J),E.addEventListener("loadeddata",J),E.addEventListener("canplay",J),H=window.setTimeout(()=>le(),800),E.play().catch(()=>{})})},nd=async(E,V)=>{await new Promise(Z=>{let H=!1,le=0;const J=()=>{H||(H=!0,E.removeEventListener("seeked",ce),window.clearTimeout(le),Z())},ce=()=>{J()};if(Math.abs(E.currentTime-V)<.016){requestAnimationFrame(()=>J());return}E.addEventListener("seeked",ce),le=window.setTimeout(()=>J(),700),E.currentTime=V})},Li=async(E,V)=>{await Oi(E);const Z=Math.floor(E.videoWidth),H=Math.floor(E.videoHeight);if(Z<=0||H<=0)return null;const le=Number.isFinite(E.duration)&&E.duration>0?E.duration:0,J=le>0?je(V,0,le):0;await nd(E,J);const ce=document.createElement("canvas");ce.width=Z,ce.height=H;const Re=ce.getContext("2d");if(!Re)return null;const ct=Qc(Je.value);ct!==""&&(Re.filter=ct);try{Re.drawImage(E,0,0,Z,H)}catch{return null}const Ut=ed(Je.value);return td(Re,Z,H,Ut),ja(ce)},od=async(E,V)=>{const Z=document.createElement("video");Z.src=E,Z.muted=!0,Z.playsInline=!0,Z.preload="auto",E.startsWith("blob:")||(Z.crossOrigin="anonymous");try{return await Oi(Z),await Li(Z,V)}catch{return null}finally{Z.pause(),Z.removeAttribute("src"),Z.load()}},ad=async E=>{const V=R.value,Z=ja(Jc(V));if(Z)return Z;if(V!=null&&V.captureFrameAt)for(let J=0;J<4;J+=1){const ce=qc(V);if(ce!==null&&ce<=0&&J<2){await Wa(80);continue}const Re=await Promise.race([V.captureFrameAt(E),Wa(450).then(()=>null)]),ct=ja(Re);if(ct)return ct;await Wa(80)}const H=Kc(V);if(H){const J=await Li(H,E);if(J)return J}const le=Ua.value.trim();if(le!==""){const J=await od(le,E);if(J)return J}return null},Wi=E=>E.map(V=>({...V,params:V.params&&typeof V.params=="object"?{...V.params}:V.params}));function ji(E){const V=Wi(Je.value);if(!Xa(E)&&V.length>0&&Array.isArray(E.timeline)&&E.timeline.length>0){const H=E.timeline[0];H&&(E.timeline=[{...H,filters:V},...E.timeline.slice(1)])}return E}const Xa=E=>Array.isArray(E.timeline)?E.timeline.some(V=>Array.isArray(V.filters)&&V.filters.length>0):!1,rd=E=>{if(!E||typeof E!="object")return null;const V=E.posterFrame;if(typeof V!="string")return null;const Z=V.trim();return Z!==""?Z:null};async function Za(){const E=ji(O()),V=Wi(Je.value),Z=Xa(E)||V.length>0,H=rd(a.initialRecipe);if(Z){const le=Be.value>0?Be.value:.1;try{const J=await ad(le);J?E.posterFrame=J:H&&(E.posterFrame=H)}catch{H&&(E.posterFrame=H)}}else delete E.posterFrame;return ne(),r("draft-saved",E),E}function Xi(){K()&&(ci(),Nt())}async function id(E){Zt(),Vo=window.setInterval(async()=>{var V,Z;try{if(wt){Zt();return}const H=await fetch(`/api/v1/video/jobs/${E}`);if(!H.ok)throw new Error(`Status poll failed: ${H.status} ${H.statusText}`);const le=await H.json(),J=(le==null?void 0:le.data)??le,ce=Number((J==null?void 0:J.progress)??0);if(We.value=Number.isFinite(ce)?ce:0,J.status==="completed"||J.status==="failed"||J.status==="cancelled")if(Zt(),ot.value=!1,Et.value=null,J.status==="completed"){const Re=((V=J==null?void 0:J.output_media)==null?void 0:V.url)??(J==null?void 0:J.output_url);We.value=100,St.value=!0,Oe.value=null}else{const Re=!!((Z=J==null?void 0:J.meta)!=null&&Z.is_cancelled)||J.status==="cancelled"||typeof(J==null?void 0:J.error_message)=="string"&&/cancel/i.test(J.error_message);Oe.value=Re?"Export canceled.":typeof(J==null?void 0:J.error_message)=="string"&&J.error_message.trim()!==""?J.error_message:"Export failed"}}catch(H){Zt(),ot.value=!1,Et.value=null,Oe.value=H instanceof Error?H.message:"Failed to check export progress"}},2e3)}function Ya(){var V,Z;const E=ee();((V=a.media)!=null&&V.url||(Z=a.media)!=null&&Z.file)&&(E.metadata||(E.metadata={created_at:new Date().toISOString(),editor_version:"2.0.0"}),a.media.url&&/^https?:/i.test(a.media.url)?E.metadata.source_url=a.media.url:delete E.metadata.source_url);try{const H=E.timeline??[]}catch{}g.value=E}let qt=null;function Nt(){qt&&clearTimeout(qt),qt=setTimeout(()=>{Ya(),qt=null},200)}return e.watch(()=>Ce.value,Nt,{deep:!0}),e.watch(()=>te.value,E=>{if(y.value||!E)return;const V=(E==null?void 0:E.filters)??[];Bc(V)},{immediate:!0}),e.watch(()=>Je.value,E=>{Ke(E),Nt()},{deep:!0}),e.watch(()=>z.value,E=>{me(E),Nt()},{deep:!0}),e.watch(()=>T.value,E=>{const V=E.map(Z=>({...Z,source:typeof Z.source=="string"?Z.source:void 0}));ke(V),Nt()},{deep:!0}),e.watch(()=>Be.value,Nt),o({saveDraft:Za,exportForUpload:Gc}),Ya(),e.onUnmounted(()=>{Zt(),wt=!0,qt&&(clearTimeout(qt),qt=null),S.value&&(S.value.destroy(),S.value=null),w.value=null,$.value=null,C.value=null}),e.onMounted(()=>{window.addEventListener("resize",P),a.media&&Ya(),e.nextTick(()=>{const E=document.querySelector(".video-editor");E&&E.getBoundingClientRect();const V=document.querySelector(".mobile-layout");V&&V.getBoundingClientRect()})}),e.onUnmounted(()=>{window.removeEventListener("resize",P)}),(E,V)=>{var Z,H,le,J;return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-editor",{mobile:l.value}])},[l.value?(e.openBlock(),e.createElementBlock("div",sb,[e.createElementVNode("div",lb,[e.withDirectives(e.createVNode(as,{ref_key:"pixiPreviewMobileRef",ref:v,"aria-hidden":!m.value,class:"preview-host-child",source:Ua.value,filters:hi.value,playhead:vi.value,"is-playing":e.unref(X),"fit-mode":p.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:g.value,media:pi.value,"enable-engine":h.value&&fi.value,"fit-mode":p.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",cb,[e.createVNode(Es,{playhead:e.unref(Be),clips:e.unref(Ce),"selected-clip-id":((Z=e.unref(te))==null?void 0:Z.id)??((H=e.unref(Ce)[0])==null?void 0:H.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(he),onClipMove:e.unref(Ze)},null,8,["playhead","clips","selected-clip-id","duration","zoom-level","onUpdate:playhead","onTrim","onSplit","onClipSelect","onClipMove"])]),e.createElementVNode("div",db,[e.createElementVNode("div",ub,[(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(B.IonIcon),{icon:ce.icon},null,8,["icon"]),e.createElementVNode("span",null,e.toDisplayString(ce.label),1)],10,mb))),128))]),e.createElementVNode("div",pb,[e.withDirectives(e.createElementVNode("div",fb,[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",hb,[e.unref(So)?(e.openBlock(),e.createBlock(Vs,{key:0,filter:e.unref(So),"current-frame":e.unref(ge),onUpdateParams:Ei},null,8,["filter","current-frame"])):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="adjustments"]]),e.withDirectives(e.createElementVNode("div",vb,[e.createVNode(_s,{overlays:z.value,onAddOverlay:Ci,onUpdateOverlay:Vi,onRemoveOverlay:Ni},null,8,["overlays"])],512),[[e.vShow,c.value==="text"]]),e.withDirectives(e.createElementVNode("div",gb,[e.createVNode(Ts,{"selected-clips":M.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",yb,[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",bb,[e.createVNode(Ns,{"can-export":e.unref(F),"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",wb," Export complete ")):e.createCommentVNode("",!0),Oe.value&&!St.value?(e.openBlock(),e.createElementBlock("div",kb,e.toDisplayString(Oe.value),1)):e.createCommentVNode("",!0)],512),[[e.vShow,c.value==="export"]])])])])):(e.openBlock(),e.createElementBlock("div",xb,[e.createElementVNode("div",Sb,[e.createElementVNode("div",Eb,[e.createElementVNode("div",Cb,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":V[0]||(V[0]=ce=>p.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,p.value]])])]),e.withDirectives(e.createVNode(as,{ref_key:"pixiPreviewDesktopRef",ref:b,"aria-hidden":!m.value,class:"preview-host-child",source:Ua.value,filters:hi.value,playhead:vi.value,"is-playing":e.unref(X),"fit-mode":p.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:g.value,media:pi.value,"enable-engine":h.value&&fi.value,"fit-mode":p.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.showThumbnailPicker?(e.openBlock(),e.createBlock(Zv,{key:0,"media-uuid":s.value,duration:gn.value,onSelect:Lc},null,8,["media-uuid","duration"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",Vb,[e.createElementVNode("div",Nb,[e.createElementVNode("div",_b,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(j.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,Tb))),128))]),e.createElementVNode("div",Mb,[e.withDirectives(e.createElementVNode("div",Fb,[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",Ib,[e.createVNode(_s,{overlays:z.value,onAddOverlay:Ci,onUpdateOverlay:Vi,onRemoveOverlay:Ni},null,8,["overlays"])],512),[[e.vShow,d.value==="text"]]),e.withDirectives(e.createElementVNode("div",Bb,[e.createVNode(Ts,{"selected-clips":M.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",Rb,[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",Pb,[e.unref(So)?(e.openBlock(),e.createBlock(Vs,{key:0,filter:e.unref(So),"current-frame":e.unref(ge),onUpdateParams:Ei},null,8,["filter","current-frame"])):(e.openBlock(),e.createElementBlock("div",$b,[...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",zb,[e.createVNode(Ns,{"can-export":e.unref(F),"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",Ab," 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,d.value==="export"]])])])])]),e.createElementVNode("div",Ub,[e.createElementVNode("div",Ob,[e.createElementVNode("div",Lb,[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,Wb)]),e.createElementVNode("span",jb,e.toDisplayString(Math.round(e.unref(ae)))+" px/s",1)]),e.createVNode(Es,{playhead:e.unref(Be),clips:e.unref(Ce),"selected-clip-id":((le=e.unref(te))==null?void 0:le.id)??((J=e.unref(Ce)[0])==null?void 0:J.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(he),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(X),"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(pe),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"]),Q.value?(e.openBlock(),e.createElementBlock("div",Xb,[e.createElementVNode("div",Zb,[e.createElementVNode("label",Yb,[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",Gb,[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,Hb),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,Jb),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,qb)]),e.createElementVNode("div",Kb,[e.createElementVNode("label",Qb,[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,e2))),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,t2),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,n2),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,o2),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,a2)])])):e.createCommentVNode("",!0)])])]))],2)}}}),gc=Te(r2,[["__scopeId","data-v-72f5d7b9"]]),i2=["aria-label"],s2={class:"ve-header"},l2={class:"ve-title"},c2={class:"ve-body"},d2={class:"ve-footer"},u2=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",s2,[e.createElementVNode("h2",l2,e.toDisplayString(l.title),1),e.createElementVNode("button",{class:"ve-close",onClick:s,"aria-label":"Close"}," ✕ ")]),e.createElementVNode("section",c2,[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",d2,[e.renderSlot(l.$slots,"footer",{},()=>[e.createElementVNode("button",{class:"ve-btn",onClick:s},"Cancel")],!0)])],8,i2)])):e.createCommentVNode("",!0)}}),m2=Te(u2,[["__scopeId","data-v-710e8e26"]]),p2={class:"video-editor-modal"},f2={class:"video-preview-container"},h2=["src"],v2={class:"video-overlay-controls"},g2=["aria-label"],y2={class:"time-display"},b2={class:"timeline-container"},w2={class:"clip-name"},k2={class:"timeline-time-labels"},x2={class:"tool-tabs"},S2=["onClick"],E2={class:"tool-panel"},C2={key:0,class:"trim-panel"},V2={class:"trim-controls"},N2={key:1,class:"filters-panel"},_2={class:"filter-grid"},T2=["onClick"],M2={key:2,class:"text-panel"},F2={key:3,class:"transitions-panel"},I2={class:"transition-grid"},B2=["onClick"],R2={class:"action-buttons"},P2=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),f=e.ref(0),m=e.ref(null),h=e.ref("trim"),v=e.ref(null),b=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}],R=[{id:"none",name:"None"},{id:"grayscale",name:"Grayscale"},{id:"sepia",name:"Sepia"},{id:"blur",name:"Blur"},{id:"brightness",name:"Brightness"},{id:"contrast",name:"Contrast"}],S=[{id:"fade",name:"Fade"},{id:"slide",name:"Slide"},{id:"zoom",name:"Zoom"},{id:"wipe",name:"Wipe"}],g=e.ref();e.onMounted(()=>{var _,j;(_=t.media)!=null&&_.url?i.value=t.media.url:(j=t.media)!=null&&j.file&&(i.value=URL.createObjectURL(t.media.file))}),e.onUnmounted(()=>{var _;(_=t.media)!=null&&_.file&&i.value&&URL.revokeObjectURL(i.value)});function p(){r.value&&(c.value=r.value.duration,f.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 y(_){if(!_||isNaN(_))return"00:00";const j=Math.floor(_/60),U=Math.floor(_%60);return`${j.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}`}function N(_){if(!r.value||!g.value)return;const j=g.value.getBoundingClientRect(),ge=(_.clientX-j.left)/j.width*c.value;r.value.currentTime=Math.max(0,Math.min(ge,c.value))}function z(){u.value=l.value}function k(){f.value=l.value}function T(){u.value=0,f.value=c.value}function M(_){m.value=_;const j=Q=>{if(!m.value||!g.value)return;const ge=g.value.getBoundingClientRect(),ie=(Q.clientX-ge.left)/ge.width*c.value;m.value==="start"?u.value=Math.max(0,Math.min(ie,f.value-1)):f.value=Math.max(u.value+1,Math.min(ie,c.value))},U=()=>{m.value=null,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",U)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",U)}function D(_){if(v.value=_,!r.value)return;const j={none:"none",grayscale:"grayscale(100%)",sepia:"sepia(100%)",blur:"blur(5px)",brightness:"brightness(150%)",contrast:"contrast(150%)"};r.value.style.filter=j[_]||"none"}function P(){}function L(_){}function I(){const _={timeline:[{id:d.value,url:i.value,startTime:0,endTime:c.value,sourceIn:u.value,sourceOut:f.value,track:0}],filters:v.value?[{type:v.value}]:[],textOverlays:b.value?[{content:b.value}]:[],duration:f.value-u.value};a("save",_)}return(_,j)=>(e.openBlock(),e.createElementBlock("div",p2,[e.createElementVNode("div",f2,[e.createElementVNode("video",{ref_key:"videoElement",ref:r,class:"video-preview",src:i.value,onLoadedmetadata:p,onTimeupdate:w,onEnded:$,controls:""},null,40,h2),e.createElementVNode("div",v2,[e.createElementVNode("button",{class:"play-pause-btn",onClick:C,"aria-label":s.value?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:s.value?e.unref(Au):e.unref(Wu)},null,8,["icon"])],8,g2),e.createElementVNode("div",y2,e.toDisplayString(y(l.value))+" / "+e.toDisplayString(y(c.value)),1)])]),e.createElementVNode("div",b2,[e.createElementVNode("div",{class:"timeline-track",onClick:N,ref_key:"timelineTrack",ref:g},[e.createElementVNode("div",{class:"timeline-clip",style:e.normalizeStyle({left:`${u.value/c.value*100}%`,right:`${100-f.value/c.value*100}%`})},[e.createElementVNode("span",w2,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:j[0]||(j[0]=U=>M("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:`${f.value/c.value*100}%`}),onMousedown:j[1]||(j[1]=U=>M("end"))},null,36)):e.createCommentVNode("",!0)],512),e.createElementVNode("div",k2,[e.createElementVNode("span",null,e.toDisplayString(y(0)),1),e.createElementVNode("span",null,e.toDisplayString(y(c.value)),1)])]),e.createElementVNode("div",x2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(x,U=>e.createElementVNode("button",{key:U.id,class:e.normalizeClass(["tool-tab",{active:h.value===U.id}]),onClick:Q=>h.value=U.id},[e.createVNode(e.unref(B.IonIcon),{icon:U.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(U.label),1)],10,S2)),64))]),e.createElementVNode("div",E2,[h.value==="trim"?(e.openBlock(),e.createElementBlock("div",C2,[j[7]||(j[7]=e.createElementVNode("h3",null,"Trim Video",-1)),j[8]||(j[8]=e.createElementVNode("p",null,"Click and drag on the timeline to set trim points",-1)),e.createElementVNode("div",V2,[e.createElementVNode("button",{class:"btn-trim",onClick:z},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),j[4]||(j[4]=e.createTextVNode(" Set Start ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:k},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Qi)},null,8,["icon"]),j[5]||(j[5]=e.createTextVNode(" Set End ",-1))]),e.createElementVNode("button",{class:"btn-trim",onClick:T},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ao)},null,8,["icon"]),j[6]||(j[6]=e.createTextVNode(" Clear ",-1))])])])):h.value==="filters"?(e.openBlock(),e.createElementBlock("div",N2,[j[9]||(j[9]=e.createElementVNode("h3",null,"Filters",-1)),e.createElementVNode("div",_2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(R,U=>e.createElementVNode("button",{key:U.id,class:e.normalizeClass(["filter-option",{active:v.value===U.id}]),onClick:Q=>D(U.id)},e.toDisplayString(U.name),11,T2)),64))])])):h.value==="text"?(e.openBlock(),e.createElementBlock("div",M2,[j[10]||(j[10]=e.createElementVNode("h3",null,"Text Overlay",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":j[2]||(j[2]=U=>b.value=U),type:"text",placeholder:"Enter text...",class:"text-input"},null,512),[[e.vModelText,b.value]]),e.createElementVNode("button",{class:"btn-add-text",onClick:P},"Add Text")])):h.value==="transitions"?(e.openBlock(),e.createElementBlock("div",F2,[j[11]||(j[11]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",I2,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(S,U=>e.createElementVNode("button",{key:U.id,class:"transition-option",onClick:Q=>(U.id,void 0)},e.toDisplayString(U.name),9,B2)),64))])])):e.createCommentVNode("",!0)]),e.createElementVNode("div",R2,[e.createElementVNode("button",{class:"btn-cancel",onClick:j[3]||(j[3]=U=>_.$emit("cancel"))},"CANCEL"),e.createElementVNode("button",{class:"btn-save",onClick:I},"SAVE")])]))}}),$2=Te(P2,[["__scopeId","data-v-b933f33b"]]),z2={class:"time-label"},A2=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),f=c%(l*5)===0;s.push({time:c,position:d,label:u,major:f})}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",z2,e.toDisplayString(c.label),1),e.createElementVNode("div",{class:e.normalizeClass(["time-tick",{major:c.major}])},null,2)],4))),128))],4))}}),D2=Te(A2,[["__scopeId","data-v-0ef9c910"]]),U2=["data-track-index"],O2={class:"track-header"},L2={class:"track-label"},W2={class:"track-controls"},j2=["data-testid","aria-label"],X2=["data-testid","onMousedown","onClick"],Z2={class:"clip-content"},Y2={class:"clip-name"},G2={key:0,class:"clip-thumbnail"},H2=["src","alt"],J2=["onMousedown","aria-label"],q2=["onMousedown","aria-label"],K2=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 R=x.timelineEnd-x.timelineStart,S=x.timelineStart/t.duration*100,g=R/t.duration*100;return{left:`${S}%`,width:`${g}%`,backgroundColor:u(x)}}function u(x){const R=["#4A90E2","#7ED321","#F5A623","#BD10E0","#9013FE","#50E3C2","#B8E986","#F8E71C"],S=parseInt(x.id.replace(/\D/g,""))%R.length;return R[S]}function f(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 v(x,R){if(l.value)return;s.value=!0;const S=R.clientX,g=x.timelineStart,p=$=>{if(!s.value)return;const C=$.clientX-S,y=parseFloat(c.value.width),N=C/(t.zoom*100)*(t.duration/y),z=Math.max(0,g+N);a("clip-move",x.id,z)},w=()=>{s.value=!1,document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",w)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",w)}function b(x,R,S){l.value=R;const g=S.clientX,p=x.sourceIn,w=x.sourceOut,$=y=>{if(!l.value)return;const N=y.clientX-g,z=parseFloat(c.value.width),k=N/(t.zoom*100)*(t.duration/z);if(l.value==="start"){const T=Math.max(0,p+k);a("clip-trim",x.id,T,w)}else{const T=Math.max(p+1,w+k);a("clip-trim",x.id,p,T)}},C=()=>{l.value=null,document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",C)};document.addEventListener("mousemove",$),document.addEventListener("mouseup",C)}return(x,R)=>(e.openBlock(),e.createElementBlock("div",{class:"video-track","data-track-index":x.trackIndex},[e.createElementVNode("div",O2,[e.createElementVNode("span",L2,"Track "+e.toDisplayString(x.trackIndex+1),1),e.createElementVNode("div",W2,[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(B.IonIcon),{icon:i.value?e.unref(rm):e.unref(om)},null,8,["icon"])],8,j2)):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,S=>(e.openBlock(),e.createElementBlock("div",{key:S.id,class:e.normalizeClass(["timeline-clip",{selected:S.id===r.value}]),style:e.normalizeStyle(d(S)),"data-testid":`clip-${S.id}`,onMousedown:g=>v(S,g),onClick:g=>m(S)},[e.createElementVNode("div",Z2,[e.createElementVNode("span",Y2,e.toDisplayString(f(S)),1),S.thumbnail?(e.openBlock(),e.createElementBlock("div",G2,[e.createElementVNode("img",{src:S.thumbnail,alt:f(S)},null,8,H2)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"trim-handle trim-start",onMousedown:e.withModifiers(g=>b(S,"start",g),["stop"]),"aria-label":`Trim start of ${f(S)}`},null,40,J2),e.createElementVNode("div",{class:"trim-handle trim-end",onMousedown:e.withModifiers(g=>b(S,"end",g),["stop"]),"aria-label":`Trim end of ${f(S)}`},null,40,q2)],46,X2))),128))],4)],8,U2))}}),Q2=Te(K2,[["__scopeId","data-v-48e480d2"]]),ew={class:"video-timeline"},tw={class:"timeline-tracks"},nw=["aria-label","aria-valuenow","aria-valuemax"],ow={class:"timeline-controls"},aw={class:"zoom-level"},rw=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 g=Math.max(0,...t.clips.map(p=>p.track||0));return Array(g+1).fill(null)}),d=e.computed(()=>`${t.currentTime/t.duration*100}%`);function u(g){return t.clips.filter(p=>(p.track||0)===g)}function f(g){const p=Math.floor(g/60),w=Math.floor(g%60);return`${p}:${w.toString().padStart(2,"0")}`}function m(g,p){a("clip-move",g,p)}function h(g,p,w){a("clip-trim",g,p,w)}function v(g){i.value=g}function b(){r.value=Math.min(r.value*1.2,5)}function x(){r.value=Math.max(r.value/1.2,.5)}function R(){s.value=!0;const g=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)},p=()=>{s.value=!1,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",g),document.addEventListener("mouseup",p)}function S(g){let p=t.currentTime;switch(g.key){case"ArrowLeft":p=Math.max(0,t.currentTime-1);break;case"ArrowRight":p=Math.min(t.duration,t.currentTime+1);break;case"Home":p=0;break;case"End":p=t.duration;break;default:return}g.preventDefault(),a("seek",p)}return e.onMounted(()=>{l.value=document.querySelector(".video-timeline")}),e.onUnmounted(()=>{}),(g,p)=>(e.openBlock(),e.createElementBlock("div",ew,[e.createVNode(D2,{duration:g.duration,zoom:r.value},null,8,["duration","zoom"]),e.createElementVNode("div",tw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(w,$)=>(e.openBlock(),e.createBlock(Q2,{key:`track-${$}`,"data-testid":`track-${$}`,clips:u($),"track-index":$,zoom:r.value,duration:g.duration,onClipMove:m,onClipTrim:h,onClipSelect:v},null,8,["data-testid","clips","track-index","zoom","duration"]))),128))]),e.createElementVNode("div",{class:"timeline-playhead",style:e.normalizeStyle({left:d.value}),onMousedown:R,"data-testid":"playhead","aria-label":`Playhead at ${f(g.currentTime)}`,role:"slider","aria-valuenow":g.currentTime,"aria-valuemax":g.duration,tabindex:"0",onKeydown:S},null,44,nw),e.createElementVNode("div",ow,[e.createElementVNode("button",{"data-testid":"btn-zoom-in","aria-label":"Zoom in",onClick:b},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ir)},null,8,["icon"])]),e.createElementVNode("span",aw,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(B.IonIcon),{icon:e.unref(Ju)},null,8,["icon"])])])]))}}),iw=Te(rw,[["__scopeId","data-v-001df415"]]),sw={class:"video-filters-panel"},lw={class:"filter-controls"},cw=["for"],dw={class:"filter-slider-group"},uw=["id","onUpdate:modelValue","min","max","step","data-testid","aria-label","aria-valuenow","aria-valuemin","aria-valuemax","onInput"],mw={class:"filter-value"},pw={class:"filter-actions"},fw={key:0,class:"filter-presets"},hw={class:"preset-list"},vw=["data-testid","aria-label","onClick"],gw=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 f(m){Object.entries(m.values).forEach(([h,v])=>{r[h]=v,c(h)})}return(m,h)=>(e.openBlock(),e.createElementBlock("div",sw,[h[3]||(h[3]=e.createElementVNode("h3",null,"Video Filters",-1)),e.createElementVNode("div",lw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,v=>e.createElementVNode("div",{key:v.type,class:"filter-control"},[e.createElementVNode("label",{for:`filter-${v.type}`},e.toDisplayString(v.label),9,cw),e.createElementVNode("div",dw,[e.withDirectives(e.createElementVNode("input",{id:`filter-${v.type}`,"onUpdate:modelValue":b=>r[v.type]=b,type:"range",min:v.min,max:v.max,step:v.step,class:"filter-slider","data-testid":`filter-${v.type}`,"aria-label":`${v.label} filter`,"aria-valuenow":r[v.type],"aria-valuemin":v.min,"aria-valuemax":v.max,onInput:b=>c(v.type)},null,40,uw),[[e.vModelText,r[v.type],void 0,{number:!0}]]),e.createElementVNode("span",mw,e.toDisplayString(s(v.type,r[v.type])),1)])])),64))]),e.createElementVNode("div",pw,[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(B.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(B.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",fw,[h[2]||(h[2]=e.createElementVNode("h4",null,"Presets",-1)),e.createElementVNode("div",hw,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,v=>(e.openBlock(),e.createElementBlock("button",{key:v.id,class:"preset-btn","data-testid":`preset-${v.id}`,"aria-label":`Apply ${v.name} preset`,onClick:b=>f(v)},e.toDisplayString(v.name),9,vw))),128))])])):e.createCommentVNode("",!0)]))}}),yw=Te(gw,[["__scopeId","data-v-5ad2ac63"]]),bw={class:"video-text-panel"},ww={class:"text-input-group"},kw={class:"text-options"},xw={class:"option-row"},Sw={class:"option-row"},Ew={class:"option-row"},Cw={class:"option-row"},Vw={class:"checkbox-label"},Nw={class:"option-row"},_w={class:"text-overlay-list"},Tw={key:0,class:"empty-state"},Mw=["data-testid"],Fw={class:"overlay-preview"},Iw={class:"overlay-controls"},Bw=["data-testid","aria-label","onClick"],Rw=["data-testid","aria-label","onClick"],Pw=["data-testid","aria-label","onClick"],$w=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(f=>f.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",bw,[u[17]||(u[17]=e.createElementVNode("h3",null,"Text Overlays",-1)),e.createElementVNode("div",ww,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[0]||(u[0]=f=>r.text=f),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(B.IonIcon),{icon:e.unref(Ir)},null,8,["icon"]),u[7]||(u[7]=e.createTextVNode(" Add ",-1))])]),e.createElementVNode("div",kw,[e.createElementVNode("div",xw,[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]=f=>r.fontFamily=f),"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",Sw,[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]=f=>r.fontSize=f),type:"number",min:"10",max:"200","data-testid":"input-font-size"},null,512),[[e.vModelText,r.fontSize,void 0,{number:!0}]])]),e.createElementVNode("div",Ew,[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]=f=>r.color=f),type:"color","data-testid":"input-text-color"},null,512),[[e.vModelText,r.color]])]),e.createElementVNode("div",Cw,[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]=f=>r.backgroundColor=f),type:"color","data-testid":"input-bg-color"},null,512),[[e.vModelText,r.backgroundColor]]),e.createElementVNode("label",Vw,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[5]||(u[5]=f=>r.hasBackground=f),type:"checkbox","data-testid":"checkbox-bg"},null,512),[[e.vModelCheckbox,r.hasBackground]]),u[12]||(u[12]=e.createTextVNode(" Enable ",-1))])]),e.createElementVNode("div",Nw,[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]=f=>r.animation=f),"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",_w,[u[16]||(u[16]=e.createElementVNode("h4",null,"Active Overlays",-1)),a.value.length===0?(e.openBlock(),e.createElementBlock("div",Tw," No text overlays added yet ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(f,m)=>(e.openBlock(),e.createElementBlock("div",{key:f.id,class:"text-overlay-item","data-testid":`overlay-${m}`},[e.createElementVNode("div",Fw,[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:f.fontFamily,fontSize:`${Math.min(f.fontSize/4,16)}px`,color:f.color})},e.toDisplayString(f.text),5)]),e.createElementVNode("div",Iw,[e.createElementVNode("button",{class:"edit-btn","data-testid":`btn-edit-${m}`,"aria-label":`Edit overlay: ${f.text}`,onClick:h=>l(f)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Tu)},null,8,["icon"])],8,Bw),e.createElementVNode("button",{class:"duplicate-btn","data-testid":`btn-duplicate-${m}`,"aria-label":`Duplicate overlay: ${f.text}`,onClick:h=>c(f)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(_u)},null,8,["icon"])],8,Rw),e.createElementVNode("button",{class:"remove-btn","data-testid":`btn-remove-${m}`,"aria-label":`Remove overlay: ${f.text}`,onClick:h=>s(f.id)},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Qu)},null,8,["icon"])],8,Pw)])],8,Mw))),128))])]))}}),zw=Te($w,[["__scopeId","data-v-4d240e1e"]]),Aw={class:"video-tools-panel"},Dw={class:"tool-tabs"},Uw=["data-testid","aria-label","aria-selected","onClick"],Ow={class:"tool-content"},Lw={key:0,class:"trim-panel",role:"tabpanel","aria-label":"Trim controls"},Ww={class:"trim-actions"},jw={key:3,class:"transitions-panel",role:"tabpanel","aria-label":"Transition controls"},Xw={class:"transition-types"},Zw=["data-testid","aria-label","onClick"],Yw={class:"transition-preview"},Gw=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",Aw,[e.createElementVNode("div",Dw,[(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(B.IonIcon),{icon:i.icon},null,8,["icon"]),e.createTextVNode(" "+e.toDisplayString(i.name),1)],10,Uw)),64))]),e.createElementVNode("div",Ow,[a.activeTool==="trim"?(e.openBlock(),e.createElementBlock("div",Lw,[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",Ww,[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(B.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(B.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(B.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(yw,{key:1,onFilterChange:r[3]||(r[3]=i=>a.$emit("filter-change",i))})):e.createCommentVNode("",!0),a.activeTool==="text"?(e.openBlock(),e.createBlock(zw,{key:2,onTextAdd:r[4]||(r[4]=i=>a.$emit("text-add",i))})):e.createCommentVNode("",!0),a.activeTool==="transitions"?(e.openBlock(),e.createElementBlock("div",jw,[r[10]||(r[10]=e.createElementVNode("h3",null,"Transitions",-1)),e.createElementVNode("div",Xw,[(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",Yw,[e.createVNode(e.unref(B.IonIcon),{icon:i.icon},null,8,["icon"])]),e.createElementVNode("span",null,e.toDisplayString(i.name),1)],8,Zw)),64))])])):e.createCommentVNode("",!0)])]))}}),Hw=Te(Gw,[["__scopeId","data-v-fc135306"]]),Jw={class:"video-export-panel"},qw={class:"export-presets"},Kw=["value"],Qw={key:0,class:"preset-details"},ek={class:"detail-row"},tk={class:"detail-row"},nk={class:"detail-row"},ok={class:"advanced-options"},ak={class:"options-content"},rk={class:"option-group"},ik={class:"option-group"},sk={class:"option-group"},lk=["disabled"],ck={key:1,class:"export-progress"},dk={class:"progress-message"},uk={class:"progress-bar"},mk=["aria-valuenow"],pk={class:"progress-percentage"},fk=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",Jw,[u[14]||(u[14]=e.createElementVNode("h3",null,"Export Video",-1)),e.createElementVNode("div",qw,[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]=f=>r.value=f),"data-testid":"preset-select","aria-label":"Select export preset"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.presets,f=>(e.openBlock(),e.createElementBlock("option",{key:f.id,value:f.id},e.toDisplayString(f.name),9,Kw))),128))],512),[[e.vModelSelect,r.value]])]),s.value?(e.openBlock(),e.createElementBlock("div",Qw,[e.createElementVNode("div",ek,[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",tk,[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",nk,[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",ok,[u[12]||(u[12]=e.createElementVNode("summary",null,"Advanced Options",-1)),e.createElementVNode("div",ak,[e.createElementVNode("div",rk,[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]=f=>i.quality=f),"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",ik,[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]=f=>i.bitrate=f),type:"number",min:"1",max:"50","data-testid":"bitrate-input"},null,512),[[e.vModelText,i.bitrate,void 0,{number:!0}]])]),e.createElementVNode("div",sk,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":u[3]||(u[3]=f=>i.includeAudio=f),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(B.IonSpinner),{key:0,name:"crescent"})):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(pa)},null,8,["icon"]),u[13]||(u[13]=e.createTextVNode(" Export Video ",-1))],64))],8,lk),d.isExporting?(e.openBlock(),e.createElementBlock("div",ck,[e.createElementVNode("div",dk,e.toDisplayString(l.value),1),e.createElementVNode("div",uk,[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,mk)]),e.createElementVNode("div",pk,e.toDisplayString(d.exportProgress)+"% ",1)])):e.createCommentVNode("",!0)]))}}),hk=Te(fk,[["__scopeId","data-v-5caf8fe6"]]),vk=["data-testid"],gk={class:"progress-header"},yk={class:"file-info"},bk={class:"file-details"},wk={class:"file-name"},kk={class:"file-meta"},xk={class:"file-size"},Sk={key:0,class:"separator"},Ek={key:1,class:"upload-speed"},Ck={key:2,class:"separator"},Vk={key:3,class:"time-remaining"},Nk={class:"progress-actions"},_k={key:0,class:"status-icon completed","data-testid":"video-upload-status-completed"},Tk={key:1,class:"status-icon error","data-testid":"video-upload-status-error"},Mk={key:2,class:"status-icon processing","data-testid":"video-upload-status-processing",role:"status","aria-label":"Processing video"},Fk=["aria-valuenow","aria-label"],Ik={class:"progress-bar"},Bk={class:"progress-percent"},Rk={key:1,class:"error-message","data-testid":"video-upload-error"},Pk={key:2,class:"thumbnail-preview","data-testid":"video-upload-thumbnail"},$k=["src","alt"],zk={key:0,class:"video-duration"},Ak=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"],v=1024,b=Math.floor(Math.log(m)/Math.log(v));return`${(m/Math.pow(v,b)).toFixed(1)} ${h[b]}`}function u(m){if(m===0)return"0 B/s";const h=["B/s","KB/s","MB/s","GB/s"],v=1024,b=Math.floor(Math.log(m)/Math.log(v));return`${(m/Math.pow(v,b)).toFixed(1)} ${h[b]}`}function f(m){const h=Math.floor(m/3600),v=Math.floor(m%3600/60),b=Math.floor(m%60);return h>0?`${h}:${v.toString().padStart(2,"0")}:${b.toString().padStart(2,"0")}`:`${v}:${b.toString().padStart(2,"0")}`}return(m,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["upload-progress-item",t.value]),"data-testid":`video-upload-progress-${m.upload.id}`},[e.createElementVNode("div",gk,[e.createElementVNode("div",yk,[e.createVNode(e.unref(B.IonIcon),{icon:a.value,class:"file-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("div",bk,[e.createElementVNode("h4",wk,e.toDisplayString(m.upload.filename),1),e.createElementVNode("p",kk,[e.createElementVNode("span",xk,e.toDisplayString(d(m.upload.bytesTotal||0)),1),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Sk,"•")):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createElementBlock("span",Ek,e.toDisplayString(u(m.upload.uploadSpeed||0)),1)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Ck,"•")):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",Vk,e.toDisplayString(s.value)+" remaining ",1)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",Nk,[m.upload.status==="completed"?(e.openBlock(),e.createElementBlock("div",_k,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(al)},null,8,["icon"])])):m.upload.status==="error"?(e.openBlock(),e.createElementBlock("div",Tk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(wu),"aria-hidden":"true"},null,8,["icon"])])):m.upload.status==="processing"?(e.openBlock(),e.createElementBlock("div",Mk,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),m.upload.status==="uploading"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:3,fill:"clear",size:"small",onClick:h[0]||(h[0]=v=>m.$emit("cancel")),"data-testid":"btn-cancel-video-upload","aria-label":"Cancel upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ao),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="error"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:4,fill:"clear",size:"small",onClick:h[1]||(h[1]=v=>m.$emit("retry")),"data-testid":"btn-retry-video-upload","aria-label":"Retry upload"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(co),slot:"icon-only"},null,8,["icon"])]),_:1})):m.upload.status==="completed"?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:5,fill:"clear",size:"small",onClick:h[2]||(h[2]=v=>m.$emit("remove")),"data-testid":"btn-remove-video-upload","aria-label":"Remove from list"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ao),slot:"icon-only"},null,8,["icon"])]),_:1})):e.createCommentVNode("",!0)])]),r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"progress-bar-container","data-testid":"video-upload-progress-bar",role:"progressbar","aria-valuenow":Math.round(i.value),"aria-valuemin":"0","aria-valuemax":"100","aria-label":m.upload.status==="processing"?"Processing progress":"Upload progress"},[e.createElementVNode("div",Ik,[e.createElementVNode("div",{class:e.normalizeClass(["progress-fill",{indeterminate:m.upload.status==="processing"}]),style:e.normalizeStyle({width:i.value+"%"})},null,6)]),e.createElementVNode("span",Bk,e.toDisplayString(Math.round(i.value))+"%",1)],8,Fk)):e.createCommentVNode("",!0),m.upload.error?(e.openBlock(),e.createElementBlock("div",Rk,[e.createVNode(e.unref(B.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",Pk,[e.createElementVNode("img",{src:l.value,alt:m.upload.filename},null,8,$k),c.value?(e.openBlock(),e.createElementBlock("div",zk,e.toDisplayString(f(c.value)),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)],10,vk))}}),Dk=Te(Ak,[["__scopeId","data-v-9eacbf91"]]);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 Uk(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 Ok(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 Lk(n){return n.resumable===!0?!0:/tusupload/i.test(n.upload_url)}function Wk(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 jk(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} ${Wk(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 Xk(n,o){return n instanceof Error?n:new Error(o)}function Zk(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((M,D)=>M+D.progress,0)/k.length});function d(k){a.value=k}function u(){}async function f(k){var M;const T=k.filter(D=>m(D));if(T.length!==0&&((M=n.onFilesSelected)==null||M.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,P,L;const T=z(k);if(o.value.has(T)){const I=o.value.get(T);if((I==null?void 0:I.status)==="uploading")return}const M={id:T,file:k,filename:k.name,progress:0,status:"pending",startedAt:new Date,bytesTotal:k.size,bytesUploaded:0};o.value.set(M.id,M),t.value.add(M.id);try{M.status="uploading",(D=n.onUploadStart)==null||D.call(n,M);const I=await v(k);n.resumable===!0||I.resumable===!0?await x(M,I):await b(M,I),M.status="processing",M.progress=100;const j=await w(I.media_uuid);M.status="completed",M.media=j,(P=n.onUploadComplete)==null||P.call(n,j)}catch(I){if(M.status!=="cancelled"){const _=Xk(I,"Upload failed");M.status="error",M.error=_.message,(L=n.onUploadError)==null||L.call(n,_,M)}}finally{t.value.delete(M.id),r.delete(M.id),i.delete(M.id)}}async function v(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}:{}},M=await a.value.post("/api/v1/video/upload",T);return Uk(M)}async function b(k,T){const M=new XMLHttpRequest,D=Ys(T),P=Po(T.headers);return new Promise((L,I)=>{M.upload.addEventListener("progress",_=>{var j;_.lengthComputable&&($o(k,_.loaded),(j=n.onUploadProgress)==null||j.call(n,k))}),M.addEventListener("load",()=>{r.delete(k.id),M.status>=200&&M.status<300?L():I(new Error(`Upload failed with status ${M.status}`))}),M.addEventListener("error",()=>{r.delete(k.id),I(new Error("Upload failed"))}),M.addEventListener("abort",()=>{r.delete(k.id),I(new Error("Upload cancelled"))}),M.open(D,T.upload_url),Object.entries(P).forEach(([_,j])=>{M.setRequestHeader(_,j)}),!Object.keys(P).some(_=>_.toLowerCase()==="content-type")&&k.file.type&&M.setRequestHeader("Content-Type",k.file.type),r.set(k.id,M),M.send(k.file)})}async function x(k,T){var I;if(Lk(T)){await R(k,T);return}const M=n.chunkSize||5*1024*1024,D=S(k.file,M),P=new AbortController;i.set(k.id,P);const L=await p(T.upload_id);L&&(D.forEach(_=>{_.end<=L.bytesUploaded&&(_.uploaded=!0)}),$o(k,L.bytesUploaded));for(const _ of D)_.uploaded||(await g(k,T,_,P),$o(k,_.end),(I=n.onUploadProgress)==null||I.call(n,k))}async function R(k,T){var U;const M=new AbortController;i.set(k.id,M);const D={...Po(T.headers),"Tus-Resumable":"1.0.0","Upload-Length":String(k.file.size),"Upload-Metadata":jk(k,T)},P=await fetch(T.upload_url,{method:"POST",headers:D,signal:M.signal});if(!P.ok)throw new Error(`Failed to initialize resumable upload: ${P.status}`);const L=P.headers.get("Location");if(!L)throw new Error("Resumable upload endpoint did not return upload location");const I=new URL(L,T.upload_url).toString(),_=n.chunkSize||5*1024*1024;let j=0;for(;j<k.file.size;){const Q=Math.min(j+_,k.file.size),ge=k.file.slice(j,Q),Be={...Po(T.headers),"Tus-Resumable":"1.0.0","Upload-Offset":String(j),"Content-Type":"application/offset+octet-stream"},Ce=await fetch(I,{method:"PATCH",headers:Be,body:ge,signal:M.signal});if(Ce.status===409){const F=Number(Ce.headers.get("Upload-Offset")??"-1");if(Number.isFinite(F)&&F>=0){j=F;continue}}if(!Ce.ok)throw new Error(`Resumable chunk upload failed: ${Ce.status}`);const ie=Number(Ce.headers.get("Upload-Offset")??String(Q));j=Number.isFinite(ie)&&ie>j?ie:Q,$o(k,j),(U=n.onUploadProgress)==null||U.call(n,k)}}function S(k,T){const M=[];let D=0,P=0;for(;D<k.size;){const L=Math.min(D+T,k.size);M.push({start:D,end:L,blob:k.slice(D,L),index:P,uploaded:!1}),D=L,P++}return M}async function g(k,T,M,D){const P={...Po(T.headers),"Content-Range":`bytes ${M.start}-${M.end-1}/${k.file.size}`,"Content-Type":k.file.type||"application/octet-stream"},L=await fetch(T.upload_url,{method:Ys(T),headers:P,body:M.blob,signal:D.signal});if(!L.ok)throw new Error(`Chunk upload failed: ${L.status}`);M.uploaded=!0}async function p(k){return null}async function w(k){if(!a.value)throw new Error("API client not configured");const T=60;let M=0;for(;M<T;){const D=await a.value.get(`/api/v1/video/${k}`),P=Ok(D),L=String(P.processing_status);if(L==="ready")return P;if(L==="failed"||L==="error")throw new Error("Video processing failed");await new Promise(I=>{window.setTimeout(I,5e3)}),M++}throw new Error("Video processing timeout")}function $(k){const T=o.value.get(k);if(!T)return;const M=r.get(k);M&&(M.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 y(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 z(k){return`${k.name}-${k.size}-${Date.now()}`}return{uploads:l,isUploading:s,totalProgress:c,openFilePicker:u,handleFileSelect:f,validateFile:m,startUpload:h,cancelUpload:$,retryUpload:C,removeUpload:y,clearCompleted:N,setApiClient:d}}const Yk=["accept","multiple"],Gk={key:0,class:"upload-trigger","data-testid":"video-uploader-trigger"},Hk=["onKeydown"],Jk={key:1,class:"upload-list","data-testid":"video-upload-list"},qk={class:"drag-content"},Kk=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:f,setApiClient:m}=Zk({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:p=>a("upload-start",p),onUploadProgress:p=>a("upload-progress",p),onUploadComplete:p=>a("upload-complete",p),onUploadError:(p,w)=>a("upload-error",p,w),onFilesSelected:p=>a("files-selected",p)});t.apiClient&&m(t.apiClient);const h=e.computed(()=>t.allowedFormats.join(",")),v=e.computed(()=>t.multiple||s.value.length===0);function b(){r.value&&r.value.click()}function x(p){const w=p.target,$=Array.from(w.files||[]);$.length>0&&(c($),w.value="")}function R(p){var C;p.preventDefault(),i.value=!1;const $=Array.from(((C=p.dataTransfer)==null?void 0:C.files)||[]).filter(y=>y.type.startsWith("video/"));$.length>0&&c($)}function S(p){var w;p.preventDefault(),(w=p.dataTransfer)!=null&&w.types.includes("Files")&&(i.value=!0)}function g(p){p.target.closest(".video-uploader")||(i.value=!1)}return e.onMounted(()=>{document.addEventListener("dragover",S),document.addEventListener("dragleave",g),document.addEventListener("drop",p=>p.preventDefault())}),e.onUnmounted(()=>{document.removeEventListener("dragover",S),document.removeEventListener("dragleave",g),document.removeEventListener("drop",p=>p.preventDefault())}),(p,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:p.multiple,onChange:x,"data-testid":"video-uploader-input","aria-label":"Select video files to upload",hidden:""},null,40,Yk),!e.unref(l)||v.value?(e.openBlock(),e.createElementBlock("div",Gk,[e.renderSlot(p.$slots,"trigger",{open:b},()=>[e.createElementVNode("div",{class:"default-upload-area","data-testid":"video-uploader-area",role:"button",tabindex:"0","aria-label":"Click to select video for upload",onClick:b,onKeydown:[e.withKeys(b,["enter"]),e.withKeys(e.withModifiers(b,["prevent"]),["space"])]},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ul),class:"upload-icon","aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("h3",null,e.toDisplayString(p.label),1),e.createElementVNode("p",null,e.toDisplayString(p.description),1),e.createVNode(e.unref(B.IonButton),{size:"small","data-testid":"btn-select-video","aria-label":"Select video file"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ir),slot:"start","aria-hidden":"true"},null,8,["icon"]),w[2]||(w[2]=e.createTextVNode(" Select Video ",-1))]),_:1})],40,Hk)],!0)])):e.createCommentVNode("",!0),e.unref(s).length>0?(e.openBlock(),e.createElementBlock("div",Jk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s),$=>(e.openBlock(),e.createBlock(Dk,{key:$.id,upload:$,onCancel:C=>e.unref(d)($.id),onRetry:C=>e.unref(u)($.id),onRemove:C=>e.unref(f)($.id)},null,8,["upload","onCancel","onRetry","onRemove"]))),128))])):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"drag-overlay","data-testid":"video-uploader-drag-overlay",onDrop:R,onDragover:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDragleave:w[1]||(w[1]=$=>i.value=!1)},[e.createElementVNode("div",qk,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(pa),"aria-hidden":"true"},null,8,["icon"]),w[3]||(w[3]=e.createElementVNode("p",null,"Drop video files here",-1))])],32)):e.createCommentVNode("",!0)],2))}}),Qk=Te(Kk,[["__scopeId","data-v-ea7587f7"]]),ex=["aria-valuenow","aria-valuemax","aria-label"],tx={class:"progress-bar"},nx={class:"time-display","data-testid":"video-time-display"},ox={class:"current-time"},ax={class:"duration"},rx={class:"control-buttons"},ix={class:"controls-left"},sx=["aria-label"],lx={class:"controls-center"},cx={key:0,class:"volume-controls"},dx=["aria-label"],ux=["value"],mx={class:"controls-right"},px={key:0,class:"quality-selector"},fx=["aria-expanded"],hx={class:"quality-label"},vx={key:0,class:"quality-menu","data-testid":"video-quality-menu",role:"menu"},gx=["data-testid","aria-label","onClick"],yx=["aria-label"],bx=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=B.isPlatform("mobile"),c="pictureInPictureEnabled"in document,d=e.computed(()=>({width:`${t.currentTime/t.duration*100}%`})),u=e.computed(()=>({left:`${t.currentTime/t.duration*100}%`})),f=e.computed(()=>{if(!t.buffered||t.buffered.length===0)return{width:"0%"};for(let p=0;p<t.buffered.length;p++){const w=t.buffered.start(p),$=t.buffered.end(p);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 v(){r.value=!0,b()}function b(){h&&clearTimeout(h),t.playing&&!l&&(h=setTimeout(()=>{r.value=!1},3e3))}function x(p){if(!s.value||t.isLive)return;const w=s.value.getBoundingClientRect(),C=(p.clientX-w.left)/w.width*t.duration;a("seek",Math.max(0,Math.min(C,t.duration)))}function R(p){const w=p.target;a("setVolume",parseInt(w.value))}function S(p){a("selectQuality",p),i.value=!1}function g(p){if(!isFinite(p))return"0:00";const w=Math.floor(p/3600),$=Math.floor(p%3600/60),C=Math.floor(p%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",v),b()}),e.onUnmounted(()=>{document.removeEventListener("mousemove",v),h&&clearTimeout(h)}),(p,w)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-controls",{"controls-visible":r.value}]),"data-testid":"video-controls"},[e.createElementVNode("div",{class:"progress-container","data-testid":"video-progress-bar",role:"slider","aria-valuenow":Math.round(p.currentTime),"aria-valuemin":"0","aria-valuemax":Math.round(p.duration),"aria-label":p.isLive?"Live stream":"Video progress",tabindex:"0",onClick:x},[e.createElementVNode("div",tx,[e.createElementVNode("div",{class:"progress-buffered",style:e.normalizeStyle(f.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",nx,[e.createElementVNode("span",ox,e.toDisplayString(g(p.currentTime)),1),w[7]||(w[7]=e.createElementVNode("span",{class:"separator"},"/",-1)),e.createElementVNode("span",ax,e.toDisplayString(p.isLive?"LIVE":g(p.duration)),1)])],8,ex),e.createElementVNode("div",rx,[e.createElementVNode("div",ix,[e.createElementVNode("button",{class:"control-btn play-pause","data-testid":"btn-video-play-pause",onClick:w[0]||(w[0]=$=>p.$emit("play-pause")),"aria-label":p.playing?"Pause":"Play"},[e.createVNode(e.unref(B.IonIcon),{icon:p.playing?e.unref(zu):e.unref(Uu),"aria-hidden":"true"},null,8,["icon"])],8,sx),p.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"control-btn skip-backward","data-testid":"btn-video-skip-backward",onClick:w[1]||(w[1]=$=>p.$emit("skip-backward")),"aria-label":"Skip backward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ou),"aria-hidden":"true"},null,8,["icon"]),w[8]||(w[8]=e.createElementVNode("span",{class:"skip-label"},"10",-1))])),p.isLive?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn skip-forward","data-testid":"btn-video-skip-forward",onClick:w[2]||(w[2]=$=>p.$emit("skip-forward")),"aria-label":"Skip forward 10 seconds"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(ju),"aria-hidden":"true"},null,8,["icon"]),w[9]||(w[9]=e.createElementVNode("span",{class:"skip-label"},"10",-1))]))]),e.createElementVNode("div",lx,[e.unref(l)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",cx,[e.createElementVNode("button",{class:"control-btn mute-btn","data-testid":"btn-video-mute",onClick:w[3]||(w[3]=$=>p.$emit("toggleMute")),"aria-label":p.muted?"Unmute":"Mute"},[e.createVNode(e.unref(B.IonIcon),{icon:m.value,"aria-hidden":"true"},null,8,["icon"])],8,dx),e.createElementVNode("input",{type:"range",class:"volume-slider","data-testid":"slider-video-volume",min:"0",max:"100",value:p.muted?0:p.volume,onInput:R,"aria-label":"Volume"},null,40,ux)]))]),e.createElementVNode("div",mx,[p.qualityLevels.length>1?(e.openBlock(),e.createElementBlock("div",px,[e.createElementVNode("button",{class:"control-btn quality-btn","data-testid":"btn-video-quality",onClick:w[4]||(w[4]=$=>i.value=!i.value),"aria-label":"Quality settings","aria-expanded":i.value},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(qu),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("span",hx,e.toDisplayString(p.currentQuality),1)],8,fx),i.value?(e.openBlock(),e.createElementBlock("div",vx,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.qualityLevels,$=>(e.openBlock(),e.createElementBlock("button",{key:$.label,class:e.normalizeClass(["quality-option",{active:$.label===p.currentQuality}]),"data-testid":`btn-video-quality-${$.label}`,"aria-label":`Set quality to ${$.label}`,role:"menuitem",onClick:C=>S($)},e.toDisplayString($.label),11,gx))),128))])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),!e.unref(l)&&c?(e.openBlock(),e.createElementBlock("button",{key:1,class:"control-btn pip-btn","data-testid":"btn-video-pip",onClick:w[5]||(w[5]=$=>p.$emit("togglePiP")),"aria-label":"Picture in Picture"},[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Ku),"aria-hidden":"true"},null,8,["icon"])])):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"control-btn fullscreen-btn","data-testid":"btn-video-fullscreen",onClick:w[6]||(w[6]=$=>p.$emit("toggleFullscreen")),"aria-label":p.fullscreen?"Exit fullscreen":"Enter fullscreen"},[e.createVNode(e.unref(B.IonIcon),{icon:p.fullscreen?e.unref(Nu):e.unref(Mu),"aria-hidden":"true"},null,8,["icon"])],8,yx)])])],2))}}),wx=Te(bx,[["__scopeId","data-v-2ae77c13"]]);function kx(n={}){var ge,Be,Ce;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),f=e.ref(!1),m=e.ref(null),h=e.ref("idle"),v=e.ref(n.playbackUrl||((ge=n.media)==null?void 0:ge.playback_url)||((Be=n.media)==null?void 0:Be.url)||""),b=e.ref(null),x=e.ref(n.isLive||!1),R=e.ref(null),S=e.ref(null);function g(ie){S.value=ie}if((Ce=n.media)!=null&&Ce.token_expires_at){const ie=new Date(n.media.token_expires_at);b.value=Number.isNaN(ie.getTime())?null:ie}async function p(){var F;const ie=x.value?t.value:o.value;if(ie)try{await ie.play(),a.value=!0,h.value=x.value?"live":"playing",(F=n.onPlay)==null||F.call(n)}catch{m.value="Failed to play video",h.value="error"}}function w(){var F;const ie=x.value?t.value:o.value;ie&&(ie.pause(),a.value=!1,h.value="paused",(F=n.onPause)==null||F.call(n))}function $(){a.value?w():p()}function C(ie){const F=x.value?t.value:o.value;if(!F||x.value)return;const X=Number.isFinite(F.duration)?F.duration:ie;F.currentTime=Math.max(0,Math.min(ie,X)),r.value=F.currentTime}function y(ie=10){const F=o.value;!F||x.value||C(F.currentTime+ie)}function N(ie=10){const F=o.value;!F||x.value||C(F.currentTime-ie)}function z(){const ie=x.value?t.value:o.value;ie&&(ie.muted=!ie.muted,l.value=ie.muted)}function k(ie){const F=x.value?t.value:o.value;if(!F)return;const X=Math.max(0,Math.min(100,ie));F.volume=X/100,s.value=X,X>0&&F.muted&&(F.muted=!1,l.value=!1)}function T(ie){const F=o.value;!F||x.value||(F.playbackRate=ie,u.value=ie)}async function M(){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 P(){var F;m.value=null,h.value="loading",(F=n.media)!=null&&F.provider&&n.media.provider!=="local"&&await L();const ie=x.value?t.value:o.value;ie&&(ie.load(),await p())}async function L(){if(!(!S.value||!n.media))try{f.value=!0;const ie=await S.value.get(`/api/v1/video/${n.media.uuid}/playback`);v.value=ie.playback_url,b.value=new Date(ie.token_expires_at);const F=x.value?t.value:o.value;if(F&&F.src!==v.value){const X=!F.paused,te=F.currentTime;F.src=v.value,x.value||(F.currentTime=te),X&&await p()}}catch{m.value="Failed to refresh playback token",h.value="error"}finally{f.value=!1}}async function I(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 _(){R.value&&(R.value.destroy(),R.value=null)}function j(){var F;const ie=x.value?t.value:o.value;ie&&(r.value=ie.currentTime,i.value=ie.duration,(F=n.onTimeUpdate)==null||F.call(n,ie.currentTime))}const U=e.computed(()=>{if(!d.value||d.value.length===0||!i.value)return 0;for(let ie=0;ie<d.value.length;ie++){const F=d.value.start(ie),X=d.value.end(ie);if(r.value>=F&&r.value<=X)return X/i.value*100}return 0});function Q(){if(!b.value)return!1;const ie=new Date;return b.value.getTime()-ie.getTime()<5*60*1e3}return e.watch([o,t],([ie,F])=>{const X=x.value?F:ie;X&&(X.addEventListener("timeupdate",j),X.addEventListener("loadedmetadata",()=>{i.value=X.duration,h.value="ready"}),X.addEventListener("progress",()=>{d.value=X.buffered}),X.addEventListener("ended",()=>{var te;a.value=!1,h.value="ended",(te=n.onEnded)==null||te.call(n)}),X.addEventListener("error",te=>{var ae;h.value="error",(ae=n.onError)==null||ae.call(n,"Video playback error")}),X.volume=s.value/100,X.muted=l.value)}),e.onUnmounted(()=>{_();const ie=x.value?t.value:o.value;ie&&ie.removeEventListener("timeupdate",j)}),{videoEl:o,liveVideoEl:t,playing:a,currentTime:r,duration:i,volume:s,muted:l,isFullscreen:c,bufferedRanges:d,bufferedPercent:U,playbackRate:u,isLoading:f,error:m,status:h,currentPlaybackUrl:v,tokenExpiresAt:b,play:p,pause:w,togglePlayPause:$,seek:C,skipForward:y,skipBackward:N,toggleMute:z,setVolume:k,setPlaybackRate:T,toggleFullscreen:M,togglePiP:D,retry:P,refreshToken:L,setupLiveStream:I,setApiClient:g,shouldRefreshToken:Q}}const xx=["src","poster","controls","autoplay","muted","loop","preload"],Sx={key:1,ref:"livePlayerEl",class:"live-player"},Ex=["controls","muted"],Cx={key:0,class:"live-indicator","data-testid":"video-live-indicator","aria-label":"Live stream"},Vx={key:2,class:"video-loading","data-testid":"video-loading",role:"status","aria-label":"Loading video"},Nx={key:3,class:"video-error","data-testid":"video-error",role:"alert"},_x={key:5,class:"gesture-zones","data-testid":"video-gesture-zones"},Tx=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:f,bufferedRanges:m,isLoading:h,error:v,status:b,currentPlaybackUrl:x,tokenExpiresAt:R,play:S,pause:g,seek:p,toggleMute:w,setVolume:$,toggleFullscreen:C,togglePlayPause:y,skipForward:N,skipBackward:z,retry:k,refreshToken:T,setApiClient:M,shouldRefreshToken:D,setupLiveStream:P}=kx({...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 L(){await T()}const I=e.computed(()=>{const ae=["video-player-container"];return t.className&&ae.push(t.className),f.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 j(ae){const re=ae.target;a("loadedmetadata",{duration:re.duration,width:re.videoWidth,height:re.videoHeight})}function U(ae){const re=ae.target;l.value=re.currentTime,a("timeupdate",re.currentTime)}function Q(){s.value=!0,a("play")}function ge(){s.value=!1,a("pause")}function Be(){s.value=!1,a("ended")}function Ce(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}v.value=q,a("error",q)}function ie(ae){const re=ae.target;m.value=re.buffered,a("progress",re.buffered)}function F(){h.value=!0}function X(){h.value=!1}e.watch(()=>t.apiClient,ae=>{ae&&M(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){R.value=null;return}const re=new Date(ae);R.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,he=q.currentTime;x.value=ae,await e.nextTick();try{q.currentTime=he}catch{}ue&&await S()},{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 P(re)},{immediate:!0}),e.onMounted(()=>{var ae;(ae=t.media)!=null&&ae.provider&&t.media.provider!=="local"&&(te=setInterval(()=>{D()&&L()},3e4)),B.isPlatform("mobile")&&t.showCustomControls}),e.onUnmounted(()=>{te&&clearInterval(te)}),(ae,re)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["video-player-container",I.value]),"data-testid":"video-player"},[ae.isLive?(e.openBlock(),e.createElementBlock("div",Sx,[e.createElementVNode("video",{ref_key:"liveVideoEl",ref:i,controls:ae.controls&&!ae.showCustomControls,autoplay:!0,muted:e.unref(u),onPlay:Q,onPause:ge,onError:Ce,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,Ex),e.unref(b)==="live"?(e.openBlock(),e.createElementBlock("div",Cx,[...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:j,onTimeupdate:U,onPlay:Q,onPause:ge,onEnded:Be,onError:Ce,onProgress:ie,onWaiting:F,onCanplay:X,playsinline:"",class:"video-element","data-testid":"video-element"},null,40,xx)),e.unref(h)?(e.openBlock(),e.createElementBlock("div",Vx,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",Nx,[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(Br),"aria-hidden":"true"},null,8,["icon"]),e.createElementVNode("p",null,e.toDisplayString(e.unref(v)),1),e.createVNode(e.unref(B.IonButton),{size:"small",onClick:e.unref(k),"data-testid":"btn-video-retry","aria-label":"Retry loading video"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{icon:e.unref(co),slot:"start","aria-hidden":"true"},null,8,["icon"]),re[4]||(re[4]=e.createTextVNode(" Retry ",-1))]),_:1},8,["onClick"])])):e.createCommentVNode("",!0),ae.showCustomControls&&!e.unref(v)?(e.openBlock(),e.createBlock(wx,{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(f),isLive:ae.isLive,onPlay:e.unref(S),onPause:e.unref(g),onSeek:e.unref(p),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(v)?(e.openBlock(),e.createElementBlock("div",_x,[e.createElementVNode("div",{class:"gesture-left","data-testid":"video-gesture-skip-back","aria-label":"Double tap to skip backward",onDblclick:re[0]||(re[0]=(...q)=>e.unref(z)&&e.unref(z)(...q))},null,32),e.createElementVNode("div",{class:"gesture-center","data-testid":"video-gesture-play-pause","aria-label":"Tap to play or pause",onClick:re[1]||(re[1]=(...q)=>e.unref(y)&&e.unref(y)(...q))}),e.createElementVNode("div",{class:"gesture-right","data-testid":"video-gesture-skip-forward","aria-label":"Double tap to skip forward",onDblclick:re[2]||(re[2]=(...q)=>e.unref(N)&&e.unref(N)(...q))},null,32)])):e.createCommentVNode("",!0)],2))}}),yc=Te(Tx,[["__scopeId","data-v-b8db4951"]]),Mx=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(P=>P.status==="live")),c=e.computed(()=>i.value.filter(P=>P.processing_status==="processing"));function d(P){n.value.set(P.uuid,P)}function u(P,L){const I=n.value.get(P);I&&n.value.set(P,{...I,...L})}function f(P){n.value.delete(P)}function m(P){return n.value.get(P)}function h(P){o.value.set(P.id,P)}function v(P,L){const I=o.value.get(P);I&&o.value.set(P,{...I,...L})}function b(P,L){const I=o.value.get(P);I&&o.value.set(P,{...I,status:L.status,viewer_count:L.viewer_count,peak_viewers:L.peak_viewers})}function x(P){o.value.delete(P)}function R(P){return o.value.get(P)}function S(P){return s.value.find(L=>L.media_uuid===P)}function g(P){t.value.set(P.id,P)}function p(P,L){const I=t.value.get(P);I&&t.value.set(P,{...I,...L})}function w(P){t.value.delete(P)}function $(P){return t.value.get(P)}function C(P){return Array.from(t.value.values()).filter(L=>L.media_uuid===P)}function y(P){a.value=P}function N(P){a.value&&(a.value={...a.value,...P})}function z(){a.value=null}function k(P){r.value=P}function T(){n.value.clear(),o.value.clear(),t.value.clear(),a.value=null,r.value=!1}function M(P){n.value.clear(),P.forEach(L=>{n.value.set(L.uuid,L)})}function D(P){o.value.clear(),P.forEach(L=>{o.value.set(L.id,L)})}return{videos:n,liveStreams:o,exportJobs:t,currentEditorState:a,isProcessing:r,allVideos:i,allLiveStreams:s,activeLiveStreams:l,processingVideos:c,setVideo:d,updateVideo:u,removeVideo:f,getVideo:m,setLiveStream:h,updateLiveStream:v,updateLiveStreamStats:b,removeLiveStream:x,getLiveStream:R,getLiveStreamByMedia:S,addExportJob:g,updateExportJob:p,removeExportJob:w,getExportJob:$,getExportJobsByMedia:C,setEditorState:y,updateEditorState:N,clearEditorState:z,setProcessing:k,clearAll:T,loadVideos:M,loadLiveStreams:D}});let on=null;function Fx(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 Ix(n){const o=Mx(),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),f=e.ref(0);let m;const h=e.computed(()=>d.value?Math.floor((new Date().getTime()-d.value.getTime())/1e3):0),v=e.computed(()=>{var z;if(!((z=t.value)!=null&&z.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()}),b=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"}),R=e.computed(()=>{var N;return((N=t.value)==null?void 0:N.status)==="ended"});async function S(N={}){s.value=!0,c.value=null;try{const z=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(z);return t.value=k,o.setLiveStream(k),$(),k}catch(z){throw c.value=dr(z,"Failed to create stream"),z instanceof Error?z:new Error(c.value)}finally{s.value=!1}}async function g(){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`),z=Ao(N,t.value);return t.value=z,o.setLiveStream(z),C(),z}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 p(){if(t.value)try{const N=await zo.get(`/live/${t.value.id}`),z=Ao(N,t.value);u.value=z.viewer_count,f.value=z.peak_viewers,t.value=z;const k={status:z.status,viewer_count:z.viewer_count,peak_viewers:z.peak_viewers};z.started_at&&(k.started_at=z.started_at),z.ended_at&&(k.ended_at=z.ended_at),o.updateLiveStreamStats(z.id,k),z.status==="live"&&!d.value&&z.started_at&&(d.value=new Date(z.started_at)),z.status==="ended"&&C()}catch{}}async function w(N){try{const z=await zo.get(`/live/${N}`),k=Ao(z,t.value);return{rtmp_url:k.rtmp_url,stream_key:k.stream_key,playback_url:k.playback_url||""}}catch(z){throw c.value=dr(z,"Failed to get stream credentials"),z instanceof Error?z:new Error(c.value)}}function $(N=5e3){C(),m=window.setInterval(()=>{p()},N)}function C(){m!==void 0&&(clearInterval(m),m=void 0)}async function y(){if(!n)return;const N=o.getLiveStreamByMedia(n);N&&(t.value=N,u.value=N.viewer_count,f.value=N.peak_viewers,N.status==="live"&&($(),N.started_at&&(d.value=new Date(N.started_at))))}return n&&y(),e.onUnmounted(()=>{C()}),{stream:t,lowLatency:a,autoRecord:r,streamTitle:i,isCreating:s,isEnding:l,error:c,streamDuration:h,viewerCount:u,peakViewers:f,playbackUrl:v,isLive:b,isIdle:x,hasEnded:R,createStream:S,endStream:g,refreshStreamStatus:p,getStreamCredentials:w,startStatusPolling:$,stopStatusPolling:C}}const Bx={class:"stream-status"},Rx={class:"flex items-center justify-between"},Px={class:"flex items-center gap-3"},$x={key:0,class:"flex items-center"},zx={key:2,class:"text-sm text-gray-600"},Ax={key:0,class:"flex items-center gap-2"},Dx={class:"text-sm font-medium text-gray-700"},Ux={key:0,class:"text-xs text-gray-500"},Ox=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",Bx,[e.createElementVNode("div",Rx,[e.createElementVNode("div",Px,[i.status==="live"?(e.openBlock(),e.createElementBlock("div",$x,[...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",zx,e.toDisplayString(r.value),1)):e.createCommentVNode("",!0)]),i.viewers!==void 0?(e.openBlock(),e.createElementBlock("div",Ax,[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",Dx,e.toDisplayString(i.viewers)+" "+e.toDisplayString(i.viewers===1?"viewer":"viewers"),1),i.peakViewers>i.viewers?(e.openBlock(),e.createElementBlock("span",Ux," (Peak: "+e.toDisplayString(i.peakViewers)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)])]))}}),Lx=Te(Ox,[["__scopeId","data-v-1d09c19f"]]),Wx={class:"stream-credentials"},jx={class:"space-y-3"},Xx={class:"credential-field"},Zx={class:"flex gap-2"},Yx=["value"],Gx={class:"credential-field"},Hx={class:"flex gap-2"},Jx=["value","type"],qx=["aria-label"],Kx={key:0,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Qx={key:1,class:"w-4 h-4 text-gray-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},eS={key:0,class:"mt-2 text-sm text-green-600"},tS=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",Wx,[u[8]||(u[8]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Stream Settings",-1)),e.createElementVNode("div",jx,[e.createElementVNode("div",Xx,[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",Zx,[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,Yx),e.createElementVNode("button",{onClick:u[0]||(u[0]=f=>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",Gx,[u[7]||(u[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 mb-1"},"Stream Key",-1)),e.createElementVNode("div",Hx,[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,Jx),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",Qx,[...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",Kx,[...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,qx),e.createElementVNode("button",{onClick:u[1]||(u[1]=f=>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",eS,e.toDisplayString(i.value)+" copied to clipboard! ",1)):e.createCommentVNode("",!0)]),_:1})]))}}),nS=Te(tS,[["__scopeId","data-v-306d92f6"]]),oS={class:"live-stream-manager","data-testid":"live-stream-manager"},aS={key:0,class:"stream-setup"},rS={class:"space-y-4"},iS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},sS={class:"flex items-center justify-between p-4 bg-gray-50 rounded-lg"},lS=["disabled"],cS={key:0},dS={key:1,class:"flex items-center justify-center"},uS={key:1,class:"stream-active space-y-6"},mS={key:1,class:"video-preview"},pS={key:2,class:"analytics-panel"},fS={class:"grid grid-cols-2 gap-4"},hS={class:"bg-gray-50 p-3 rounded"},vS={class:"text-2xl font-bold text-gray-900"},gS={class:"bg-gray-50 p-3 rounded"},yS={class:"text-2xl font-bold text-gray-900"},bS={class:"stream-controls flex gap-3"},wS=["disabled"],kS={key:0},xS={key:1},SS={key:2,class:"mt-4 p-4 bg-red-50 border border-red-200 rounded-lg"},ES={class:"text-red-600 text-sm"},CS=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&&Fx(t.httpClient);const{stream:r,lowLatency:i,autoRecord:s,streamTitle:l,isCreating:c,isEnding:d,error:u,createStream:f,endStream:m,streamDuration:h,playbackUrl:v,refreshStreamStatus:b}=Ix(t.mediaUuid),x=e.ref(!1);async function R(){var $;try{const C=await f({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 S(){var $;try{const C=await m();a("stream-ended",C),($=t.onStreamEnded)==null||$.call(t,C)}catch(C){a("error",C)}}function g(){r.value=null,l.value="",x.value=!1,u.value=null}async function p($,C){try{await navigator.clipboard.writeText($)}catch{}}let w;return e.onMounted(()=>{var $;(($=r.value)==null?void 0:$.status)==="live"&&(w=window.setInterval(()=>{b()},5e3))}),e.onUnmounted(()=>{w&&clearInterval(w)}),($,C)=>(e.openBlock(),e.createElementBlock("div",oS,[e.unref(r)?(e.openBlock(),e.createElementBlock("div",uS,[e.createVNode(Lx,{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(nS,{key:0,"rtmp-url":e.unref(r).rtmp_url,"stream-key":e.unref(r).stream_key,onCopy:p},null,8,["rtmp-url","stream-key"])):e.createCommentVNode("",!0),e.unref(v)?(e.openBlock(),e.createElementBlock("div",mS,[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(v),"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",pS,[C[12]||(C[12]=e.createElementVNode("h4",{class:"text-sm font-medium text-gray-700 mb-3"},"Live Analytics",-1)),e.createElementVNode("div",fS,[e.createElementVNode("div",hS,[e.createElementVNode("div",vS,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",gS,[e.createElementVNode("div",yS,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",bS,[e.unref(r).status==="idle"?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:C[3]||(C[3]=y=>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:S,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",xS,"Ending...")):(e.openBlock(),e.createElementBlock("span",kS,"End Stream"))],8,wS)):e.createCommentVNode("",!0),e.unref(r).status==="ended"?(e.openBlock(),e.createElementBlock("button",{key:2,onClick:g,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",aS,[C[8]||(C[8]=e.createElementVNode("h3",{class:"text-lg font-semibold mb-4"},"Start Live Stream",-1)),e.createElementVNode("div",rS,[e.createElementVNode("div",iS,[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]=y=>e.isRef(i)?i.value=y: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",sS,[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]=y=>e.isRef(s)?s.value=y: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]=y=>e.isRef(l)?l.value=y: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:R,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",dS,[...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",cS,"Create Stream"))],8,lS)])])),e.unref(u)?(e.openBlock(),e.createElementBlock("div",SS,[e.createElementVNode("p",ES,e.toDisplayString(e.unref(u)),1)])):e.createCommentVNode("",!0)]))}}),VS=Te(CS,[["__scopeId","data-v-26291f6f"]]),NS={class:"album-tree-node"},_S=["data-album-id","draggable","aria-selected","aria-expanded"],TS={key:1,class:"album-node__chevron-placeholder"},MS={key:2,"data-testid":"media-count",class:"album-node__count"},FS={key:0,class:"album-tree-node__children",role:"group"},IS=16,BS=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*IS}px`),d=e.computed(()=>{var g;return((g=t.dragState)==null?void 0:g.draggedAlbumId)===t.album.id}),u=e.computed(()=>{var g;return((g=t.dragState)==null?void 0:g.dropTargetId)===t.album.id}),f=e.computed(()=>{var g;return(g=t.dragState)!=null&&g.draggedAlbumId?t.dragState.draggedAlbumId===t.album.id:!1}),m=e.computed(()=>{const g=["album-node"];return i.value&&g.push("album-node--selected"),s.value&&g.push("album-node--focused"),t.compact&&g.push("album-node--compact"),d.value&&g.push("album-node--dragging"),u.value&&g.push("album-node--drop-target"),f.value&&g.push("album-node--invalid-drop"),g});function h(){a("select",t.album)}function v(g){g.stopPropagation(),a("toggle-expand",t.album.id)}function b(g){t.draggable&&(g.dataTransfer&&(g.dataTransfer.setData("text/plain",t.album.id),g.dataTransfer.effectAllowed="move"),a("drag-start",t.album.id))}function x(g){t.draggable&&(g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="move"),a("drag-over",t.album.id))}function R(){a("drag-leave",t.album.id)}function S(g){t.draggable&&(g.preventDefault(),a("drop",t.album.id))}return(g,p)=>{var $;const w=e.resolveComponent("AlbumTreeNode",!0);return e.openBlock(),e.createElementBlock("div",NS,[e.createElementVNode("div",{"data-testid":"album-node","data-album-id":g.album.id,class:e.normalizeClass(m.value),style:e.normalizeStyle({paddingLeft:c.value}),draggable:g.draggable,role:"treeitem","aria-selected":i.value,"aria-expanded":l.value?r.value:void 0,onDragstart:b,onDragover:x,onDragleave:R,onDrop:S},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,"data-testid":"expand-chevron",class:"album-node__chevron",type:"button","aria-label":"Toggle expand",onClick:v},[e.createVNode(e.unref(B.IonIcon),{icon:r.value?e.unref(Eu):e.unref(Cu)},null,8,["icon"])])):(e.openBlock(),e.createElementBlock("span",TS)),e.createVNode(e.unref(B.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(g.album.name),1),g.showMediaCount?(e.openBlock(),e.createElementBlock("span",MS,e.toDisplayString(g.album.media_count),1)):e.createCommentVNode("",!0)],46,_S),r.value&&(($=g.album.children)!=null&&$.length)?(e.openBlock(),e.createElementBlock("div",FS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.album.children,C=>(e.openBlock(),e.createBlock(w,{key:C.id,album:C,depth:g.depth+1,"selected-id":g.selectedId,"expanded-ids":g.expandedIds,"focused-id":g.focusedId,draggable:g.draggable,"show-media-count":g.showMediaCount,compact:g.compact,onSelect:p[0]||(p[0]=y=>a("select",y)),onToggleExpand:p[1]||(p[1]=y=>a("toggle-expand",y))},null,8,["album","depth","selected-id","expanded-ids","focused-id","draggable","show-media-count","compact"]))),128))])):e.createCommentVNode("",!0)])}}}),RS=Te(BS,[["__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 p=new Map;return n.value.forEach(w=>p.set(w.id,w)),p}),s=e.computed(()=>n.value.filter(p=>p.parent_id===null));async function l(p){t.value=!0,a.value=null;try{const w=(p==null?void 0:p.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(z=>{const k=n.value.findIndex(T=>T.id===z.id);k>=0?n.value[k]=z:n.value.push(z)}),w!==null&&r.value.add(w)}catch(w){a.value=w instanceof Error?w.message:"Unknown error"}finally{t.value=!1}}async function c(p){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${p}`);if(!w.ok)throw new Error("Failed to fetch album");const C=(await w.json()).data,y=n.value.findIndex(N=>N.id===C.id);return y>=0?n.value[y]=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(p){t.value=!0,a.value=null;try{const w=await fetch(`/api/v1/albums/${p}/media`);if(!w.ok)throw new Error("Failed to fetch album media");const C=(await w.json()).data||[];return o.value.set(p,C),C}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}async function u(p,w){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${p}/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(p)||[],y=w.map(N=>C.find(z=>z.uuid===N)).filter(N=>N!==void 0);o.value.set(p,y)}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function f(p){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(p)});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(p,w){t.value=!0,a.value=null;try{const $=await fetch(`/api/v1/albums/${p}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(w)});if(!$.ok)throw new Error("Failed to update album");const y=(await $.json()).data,N=n.value.findIndex(z=>z.id===y.id);return N>=0&&(n.value[N]=y),y}catch($){throw a.value=$ instanceof Error?$.message:"Unknown error",$}finally{t.value=!1}}async function h(p){t.value=!0,a.value=null;try{if(!(await fetch(`/api/v1/albums/${p}`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include"})).ok)throw new Error("Failed to delete album");const $=n.value.findIndex(C=>C.id===p);$>=0&&n.value.splice($,1),o.value.delete(p)}catch(w){throw a.value=w instanceof Error?w.message:"Unknown error",w}finally{t.value=!1}}function v(p){return n.value.filter(w=>w.parent_id===p)}function b(p){return r.value.has(p)}function x(p){return o.value.get(p)||[]}async function R(p,w){const $=n.value.findIndex(y=>y.id===p);if($<0)return;const C=n.value[$];n.value[$]={...C,parent_id:w};try{if(!(await fetch(`/api/v1/albums/${p}/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(y){throw n.value[$]=C,a.value=y instanceof Error?y.message:"Unknown error",y instanceof Error?y:new Error("Failed to move album")}}function S(p){n.value=p}function g(){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:f,updateAlbum:m,deleteAlbum:h,getChildrenOf:v,childrenLoaded:b,getAlbumMedia:x,moveAlbum:R,setAlbums:S,reset:g}});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,f){await n.moveAlbum(u,f)}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(f,m){if(f===m)return!0;const h=new Set,v=[f];for(;v.length>0;){const b=v.shift();if(!b||h.has(b))continue;h.add(b);const x=o.get(b)||[];for(const R of x){if(R===m)return!0;v.push(R)}}return!1}function i(f,m){return f===m?!1:m===null?!0:!r(f,m)}function s(f){a.value={isDragging:!0,draggedAlbumId:f,dropTargetId:null,dropPosition:null}}function l(){a.value={isDragging:!1,draggedAlbumId:null,dropTargetId:null,dropPosition:null}}function c(f){a.value.dropTargetId=f}function d(){a.value.dropTargetId=null,a.value.dropPosition=null}async function u(){const{draggedAlbumId:f,dropTargetId:m}=a.value;if(!f){l();return}if(!i(f,m)){l();return}try{await t(f,m)}finally{l()}}return{dragState:a,isDescendant:r,canDropOn:i,startDrag:s,endDrag:l,setDropTarget:c,clearDropTarget:d,executeDrop:u}}const PS={key:0,"data-testid":"loading-spinner",class:"album-tree__loading"},$S={key:1,"data-testid":"error-state",class:"album-tree__error"},zS={key:2,"data-testid":"empty-state",class:"album-tree__empty"},AS={key:3,class:"album-tree__content",role:"group"},DS=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:f,fetchAlbums:m,getChildrenOf:h,childrenLoaded:v,moveAlbum:b}=bc(),x=e.shallowRef(new Set(a.expandedIds)),R=e.ref(a.modelValue??null),S=e.ref(null),g=new Map,p=new Map;function w(F){g.clear(),p.clear();for(const X of F){g.set(X.id,X);const te=X.parent_id??null,ae=p.get(te)??[];ae.push(X.id),p.set(te,ae)}}e.watch(c,F=>{w(F)},{immediate:!0});const{dragState:$,canDropOn:C,startDrag:y,endDrag:N,setDropTarget:z,clearDropTarget:k,executeDrop:T}=wc({childrenByParentId:p,onMove:async(F,X)=>{await b(F,X),r("album-moved",{albumId:F,newParentId:X})}});e.watch(()=>a.modelValue,F=>{R.value=F??null}),e.watch(()=>a.expandedIds,F=>{x.value=new Set(F)}),e.onMounted(async()=>{await m({parent_id:null})});const M=e.computed(()=>d.value.map(F=>D(F)));function D(F){if(!x.value.has(F.id))return F;const X=h(F.id);return{...F,children:X.map(te=>D(te))}}const P=e.computed(()=>{const F=[];function X(te){var ae;for(const re of te)F.push(re),x.value.has(re.id)&&((ae=re.children)!=null&&ae.length)&&X(re.children)}return X(M.value),F});function L(F){var ae;if(!P.value.length)return;const X=S.value?P.value.findIndex(re=>re.id===S.value):-1,te=X>=0?P.value[X]:null;switch(F.key){case"ArrowDown":F.preventDefault(),X<P.value.length-1?S.value=P.value[X+1].id:X===-1&&P.value.length>0&&(S.value=P.value[0].id);break;case"ArrowUp":F.preventDefault(),X>0&&(S.value=P.value[X-1].id);break;case"ArrowRight":F.preventDefault(),te&&(te.children_count>0&&!x.value.has(te.id)?I(te.id):x.value.has(te.id)&&((ae=te.children)!=null&&ae.length)&&(S.value=te.children[0].id));break;case"ArrowLeft":F.preventDefault(),te&&(x.value.has(te.id)&&te.children_count>0?I(te.id):te.parent_id&&(S.value=te.parent_id));break;case"Enter":case" ":F.preventDefault(),te&&_(te);break;case"Home":F.preventDefault(),P.value.length>0&&(S.value=P.value[0].id);break;case"End":F.preventDefault(),P.value.length>0&&(S.value=P.value[P.value.length-1].id);break}}async function I(F){x.value.has(F)?(x.value.delete(F),r("album-collapsed",F)):(v(F)||await m({parent_id:F}),x.value.add(F),r("album-expanded",F))}function _(F){R.value=F.id,r("update:modelValue",F.id),r("album-selected",F)}function j(F){a.draggable&&y(F)}function U(F){var te;if(!a.draggable)return;const X=(te=$.value)==null?void 0:te.draggedAlbumId;X&&(z(F),C(X,F))}function Q(){a.draggable&&k()}async function ge(F){a.draggable&&(z(F),await T())}function Be(F){a.draggable&&(F.preventDefault(),z(null))}async function Ce(F){a.draggable&&(F.preventDefault(),z(null),await T())}function ie(){N()}return o({focusedId:S}),(F,X)=>(e.openBlock(),e.createElementBlock("div",{class:"album-tree","data-testid":"album-tree",tabindex:"0",role:"tree","aria-label":"Album tree",onKeydown:L,onDragover:Be,onDrop:Ce,onDragend:ie},[e.unref(u)?(e.openBlock(),e.createElementBlock("div",PS,[e.createVNode(e.unref(B.IonSpinner),{name:"crescent"})])):e.unref(f)?(e.openBlock(),e.createElementBlock("div",$S,[e.createElementVNode("p",null,e.toDisplayString(e.unref(f)),1)])):e.unref(d).length?(e.openBlock(),e.createElementBlock("div",AS,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,te=>(e.openBlock(),e.createBlock(RS,{key:te.id,album:te,depth:0,"selected-id":R.value,"expanded-ids":x.value,"focused-id":S.value,draggable:i.value,"drag-state":i.value?e.unref($):null,"show-media-count":s.value,compact:l.value,onSelect:_,onToggleExpand:I,onDragStart:j,onDragOver:U,onDragLeave:Q,onDrop:ge},null,8,["album","selected-id","expanded-ids","focused-id","draggable","drag-state","show-media-count","compact"]))),128))])):(e.openBlock(),e.createElementBlock("div",zS,[X[0]||(X[0]=e.createElementVNode("p",null,"No albums yet",-1)),e.renderSlot(F.$slots,"empty-action",{},void 0,!0)]))],32))}}),kc=Te(DS,[["__scopeId","data-v-ae3dea7a"]]),US=300,OS=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 v=Date.now();if(l.value===h.id&&v-s.value<US){a("confirm",h);return}s.value=v,l.value=h.id,r.value=h.id,i.value=h}function u(){i.value&&a("confirm",i.value)}function f(){a("close")}function m(){a("close")}return(h,v)=>(e.openBlock(),e.createBlock(e.unref(B.IonModal),{"is-open":h.isOpen,class:"album-browser-modal",onDidDismiss:m},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(h.title),1)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-button",onClick:f},{default:e.withCtx(()=>[...v[1]||(v[1]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"album-browser-content"},{default:e.withCtx(()=>[e.createVNode(kc,{modelValue:r.value,"onUpdate:modelValue":v[0]||(v[0]=b=>r.value=b),draggable:!1,"show-media-count":!0,compact:!1,onAlbumSelected:d},null,8,["modelValue"])]),_:1}),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{fill:"clear",onClick:f},{default:e.withCtx(()=>[...v[2]||(v[2]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(e.unref(B.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=Te(OS,[["__scopeId","data-v-21676ec1"]]),LS={class:"ion-padding-start text-sm"},WS={class:"ion-padding-start text-sm"},jS={key:1},XS={key:1,class:"album-manager-inline rounded-lg border border-gray-200 bg-white p-4"},ZS={class:"flex items-center justify-between gap-3 pb-3"},YS={class:"text-base font-semibold text-gray-900"},GS={class:"ion-padding-start text-sm"},HS={class:"ion-padding-start text-sm"},JS={class:"flex justify-between pt-2"},qS={key:1},Un=255,On=1e3,KS=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),f=e.ref(!1),m=e.ref(null),h=e.ref(!1),v=e.ref(!1),b=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),R=e.computed(()=>{const L=c.value.name.trim().length>0,I=c.value.name.length<=Un,_=c.value.description.length<=On;return L&&I&&_&&!h.value}),S=e.computed(()=>{var L;return((L=u.value)==null?void 0:L.name)??"None (Root)"}),g=e.computed(()=>m.value?m.value.children_count===0&&m.value.media_count===0:!1),p=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 L=await r.fetchAlbum(t.albumId);m.value=L,c.value={name:L.name,description:L.description??"",parent_id:L.parent_id},L.parent_id&&(u.value={id:L.parent_id,name:"Parent Album"})}catch(L){a("error",L)}}function $(){d.value.name=!0}function C(){d.value.description=!0}function y(){f.value=!0}function N(L){u.value={id:L.id,name:L.name},c.value.parent_id=L.id,f.value=!1}function z(){f.value=!1}function k(){a("close")}function T(){a("close")}async function M(){if(d.value.name=!0,d.value.description=!0,!(!R.value||h.value)){h.value=!0;try{const L={name:c.value.name.trim(),description:c.value.description.trim(),parent_id:c.value.parent_id};if(i.value&&t.albumId){const I=await r.updateAlbum(t.albumId,L);a("updated",I)}else{const I=await r.createAlbum(L);a("created",I)}a("close")}catch(L){a("error",L)}finally{h.value=!1}}}function D(){g.value&&(v.value=!0)}async function P(L){var _;if((((_=L.detail)==null?void 0:_.role)??"")!=="confirm"){v.value=!1;return}if(t.albumId){h.value=!0;try{await r.deleteAlbum(t.albumId),a("deleted",t.albumId),a("close")}catch(j){a("error",j)}finally{h.value=!1,v.value=!1}}}return(L,I)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[L.mode==="modal"?(e.openBlock(),e.createBlock(e.unref(B.IonModal),{key:0,"is-open":L.isOpen,class:"album-manager-modal",onDidDismiss:T},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonHeader),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonTitle),null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...I[4]||(I[4]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),_:1})]),_:1})]),_:1}),e.createVNode(e.unref(B.IonContent),{class:"album-manager-content"},{default:e.withCtx(()=>[e.createElementVNode("form",{"data-testid":"album-form",class:"p-4 space-y-3",onSubmit:e.withModifiers(M,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...I[5]||(I[5]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":I[0]||(I[0]=_=>c.value.name=_),"data-testid":"name-input",maxlength:Un,onIonBlur:$},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",LS,e.toDisplayString(b.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...I[6]||(I[6]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":I[1]||(I[1]=_=>c.value.description=_),"data-testid":"description-input",maxlength:On,onIonBlur:C},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",WS,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...I[7]||(I[7]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(B.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1})],32)]),_:1}),e.createVNode(e.unref(B.IonFooter),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonToolbar),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButtons),{slot:"start"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",disabled:!g.value,title:g.value?void 0:p.value,onClick:D},{default:e.withCtx(()=>[...I[8]||(I[8]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),_:1}),e.createVNode(e.unref(B.IonButtons),{slot:"end"},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!R.value,onClick:M},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",jS,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1})]),_:1},8,["is-open"])):(e.openBlock(),e.createElementBlock("div",XS,[e.createElementVNode("div",ZS,[e.createElementVNode("h2",YS,e.toDisplayString(s.value),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"cancel-btn",fill:"clear",onClick:k},{default:e.withCtx(()=>[...I[9]||(I[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1})]),e.createElementVNode("form",{"data-testid":"album-form",class:"space-y-3",onSubmit:e.withModifiers(M,["prevent"])},[e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...I[10]||(I[10]=[e.createTextVNode("Name *",-1)])]),_:1}),e.createVNode(e.unref(B.IonInput),{modelValue:c.value.name,"onUpdate:modelValue":I[2]||(I[2]=_=>c.value.name=_),"data-testid":"name-input",maxlength:Un,onIonBlur:$},null,8,["modelValue"])]),_:1}),b.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:0,color:"danger","data-testid":"name-error"},{default:e.withCtx(()=>[e.createElementVNode("p",GS,e.toDisplayString(b.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),null,{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),{position:"stacked"},{default:e.withCtx(()=>[...I[11]||(I[11]=[e.createTextVNode("Description",-1)])]),_:1}),e.createVNode(e.unref(B.IonTextarea),{modelValue:c.value.description,"onUpdate:modelValue":I[3]||(I[3]=_=>c.value.description=_),"data-testid":"description-input",maxlength:On,onIonBlur:C},null,8,["modelValue"])]),_:1}),x.value?(e.openBlock(),e.createBlock(e.unref(B.IonText),{key:1,color:"danger","data-testid":"description-error"},{default:e.withCtx(()=>[e.createElementVNode("p",HS,e.toDisplayString(x.value),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonItem),{button:"","data-testid":"parent-selector",onClick:y},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonLabel),null,{default:e.withCtx(()=>[...I[12]||(I[12]=[e.createTextVNode("Parent Album",-1)])]),_:1}),e.createVNode(e.unref(B.IonNote),{slot:"end","data-testid":"parent-name"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1})]),_:1}),e.createElementVNode("div",JS,[e.createElementVNode("div",null,[i.value?(e.openBlock(),e.createBlock(e.unref(B.IonButton),{key:0,"data-testid":"delete-btn",color:"danger",fill:"outline",disabled:!g.value,title:g.value?void 0:p.value,onClick:D},{default:e.withCtx(()=>[...I[13]||(I[13]=[e.createTextVNode(" Delete ",-1)])]),_:1},8,["disabled","title"])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(B.IonButton),{"data-testid":"submit-btn",type:"submit",color:"primary",disabled:!R.value,onClick:M},{default:e.withCtx(()=>[h.value?(e.openBlock(),e.createBlock(e.unref(B.IonSpinner),{key:0,"data-testid":"loading-spinner",name:"crescent"})):(e.openBlock(),e.createElementBlock("span",qS,e.toDisplayString(l.value),1))]),_:1},8,["disabled"])])],32)])),e.createVNode(xc,{"is-open":f.value,"selected-album-id":c.value.parent_id,title:"Select Parent Album",onClose:z,onConfirm:N},null,8,["is-open","selected-album-id"]),e.createVNode(e.unref(B.IonAlert),{"is-open":v.value,header:"Delete Album?",message:p.value,buttons:[{text:"Cancel",role:"cancel"},{text:"Delete",role:"confirm",cssClass:"alert-button-danger"}],onDidDismiss:P},null,8,["is-open","message"])],64))}}),QS=Te(KS,[["__scopeId","data-v-22083f3a"]]),eE={class:"album-media-grid"},tE={class:"aspect-square"},nE={key:1,"data-testid":"empty-state",class:"flex flex-col items-center justify-center py-12 gap-4"},oE={class:"text-gray-500"},aE=["data-media-id","draggable","onDragstart","onDragover","onDrop","onMouseenter"],rE={key:0,"data-testid":"drop-indicator",class:"absolute inset-0 border-2 border-primary rounded-lg pointer-events-none z-30"},iE={key:1,class:"absolute top-2 right-2 z-20 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab"},sE={class:"aspect-square relative"},lE=["src","alt"],cE={key:0,class:"absolute inset-0 bg-black/50 flex items-center justify-center gap-2 transition-opacity"},dE=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),f=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 v()}),e.watch(()=>t.albumId,async()=>{await v()});async function v(){s.value=!0;try{const T=await r.fetchAlbumMedia(t.albumId);i.value=T}catch{i.value=[]}finally{s.value=!1}}function b(T){return t.selectedItems.includes(T)}function x(T){a("toggle-select",T);const M=b(T.uuid)?t.selectedItems.filter(D=>D!==T.uuid):[...t.selectedItems,T.uuid];a("selection-change",M)}function R(T){if(T.conversions&&typeof T.conversions=="object"){const M=T.conversions.thumb;if(typeof M=="string")return M}return T.original_url}function S(T){l.value=T}function g(){l.value=null}function p(T){a("preview",T)}function w(T){a("edit",T)}function $(T){a("detach",T.uuid)}function C(){a("add")}function y(T,M){t.reorderable&&(c.value=M,T.dataTransfer&&(T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("text/plain",String(M))))}function N(T,M){!t.reorderable||c.value===null||(T.preventDefault(),d.value=M)}function z(T,M){if(!t.reorderable||c.value===null)return;T.preventDefault();const D=c.value;if(D!==M){const P=[...i.value],[L]=P.splice(D,1);P.splice(M,0,L),i.value=P;const I=P.map(_=>_.uuid);a("reorder",I),r.reorderAlbumMedia(t.albumId,I).catch(()=>{v()})}c.value=null,d.value=null}function k(){c.value=null,d.value=null}return(T,M)=>(e.openBlock(),e.createElementBlock("div",eE,[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(B.IonCard),{key:D,class:"m-0"},{default:e.withCtx(()=>[e.createElementVNode("div",tE,[e.createVNode(e.unref(B.IonSkeletonText),{animated:"",class:"w-full h-full skeleton"})])]),_:1}))),128))],2)):f.value?(e.openBlock(),e.createElementBlock("div",nE,[e.createVNode(e.unref(B.IonIcon),{name:"images-outline",class:"text-6xl text-gray-400"}),e.createElementVNode("p",oE,e.toDisplayString(T.emptyText),1),e.createVNode(e.unref(B.IonButton),{"data-testid":"add-media-btn",onClick:C},{default:e.withCtx(()=>[...M[0]||(M[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,P)=>(e.openBlock(),e.createElementBlock("div",{key:D.uuid,"data-media-id":D.uuid,class:e.normalizeClass(["media-item relative group",{"opacity-50":c.value===P,"ring-2 ring-primary":d.value===P&&c.value!==P}]),draggable:T.reorderable,onDragstart:L=>y(L,P),onDragover:L=>N(L,P),onDrop:L=>z(L,P),onDragend:k,onMouseenter:L=>S(D.uuid),onMouseleave:g},[d.value===P&&c.value!==P&&T.reorderable?(e.openBlock(),e.createElementBlock("div",rE)):e.createCommentVNode("",!0),T.reorderable?(e.openBlock(),e.createElementBlock("div",iE,[e.createVNode(e.unref(B.IonIcon),{name:"reorder-three-outline",class:"text-white drop-shadow-md"})])):e.createCommentVNode("",!0),T.selectionMode?(e.openBlock(),e.createBlock(e.unref(B.IonCheckbox),{key:2,"data-testid":"media-checkbox",checked:b(D.uuid),class:"absolute top-2 left-2 z-20",onIonChange:L=>x(D)},null,8,["checked","onIonChange"])):e.createCommentVNode("",!0),e.createVNode(e.unref(B.IonCard),{class:"m-0 overflow-hidden"},{default:e.withCtx(()=>[e.createElementVNode("div",sE,[e.createElementVNode("img",{src:R(D),alt:D.file_name,class:"w-full h-full object-cover"},null,8,lE),T.showActions&&l.value===D.uuid?(e.openBlock(),e.createElementBlock("div",cE,[e.createVNode(e.unref(B.IonButton),{"data-testid":"action-preview",fill:"clear",size:"small",color:"light",onClick:L=>p(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"eye-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(B.IonButton),{"data-testid":"action-edit",fill:"clear",size:"small",color:"light",onClick:L=>w(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"create-outline"})]),_:1},8,["onClick"]),e.createVNode(e.unref(B.IonButton),{"data-testid":"action-detach",fill:"clear",size:"small",color:"danger",onClick:L=>$(D)},{default:e.withCtx(()=>[e.createVNode(e.unref(B.IonIcon),{slot:"icon-only",name:"close-circle-outline"})]),_:1},8,["onClick"])])):e.createCommentVNode("",!0)])]),_:2},1024)],42,aE))),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(B.IonIcon),{name:"add-circle-outline",class:"text-4xl text-gray-400"}),M[1]||(M[1]=e.createElementVNode("span",{class:"text-sm text-gray-500"},"Add Media",-1))])],2))]))}}),uE=Te(dE,[["__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 mE(){return Jo||(Jo=ti()),Jo}function pE(){Jo=null}const fE={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={...fE,...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(),f=ur(u);return r!=null&&r.onProgress&&r.onProgress(100),{media:f,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 hE(){return qo||(qo=ni()),qo}function vE(){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 f=await a(u);d.set(u,f)})),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 gE(){return`upload-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function yE(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),f=e.ref(new Set),m=a?{rules:a}:{},{validateFile:h}=ai(m);async function v(){if(f.value.size>=t)return;const k=Array.from(u.value.entries()).find(([D,P])=>P.status==="pending"&&!f.value.has(D));if(!k){Array.from(u.value.values()).every(P=>P.status==="completed"||P.status==="error")&&u.value.size>0&&(d==null||d());return}const[T,M]=k;await b(T,M)}async function b(k,T){f.value.add(k),T.status="uploading",T.abortController=new AbortController,u.value.set(k,{...T}),i==null||i(T);try{const M={onProgress:P=>{T.progress=P,u.value.set(k,{...T}),s==null||s(T)},signal:T.abortController.signal};r&&(M.collection=r);const D=await o.upload(T.file,M);T.status="completed",T.progress=100,T.media=D.media,u.value.set(k,{...T}),l==null||l(T,D.media)}catch(M){M.name==="AbortError"?u.value.delete(k):(T.status="error",T.error=M.message,u.value.set(k,{...T}),c==null||c(T,M))}finally{f.value.delete(k),delete T.abortController,v()}}async function x(k){var D;const T=Array.from(k),M=[];for(const P of T){const L=await h(P),I=gE(),_=yE(P),j={id:I,file:P,progress:0,status:L.valid?"pending":"error"};!L.valid&&((D=L.errors[0])!=null&&D.message)&&(j.error=L.errors[0].message),_&&(j.previewUrl=_),u.value.set(I,j);const U={media:null,clientId:I,name:P.name,order:0,upload:j,errors:L.errors};M.push(U)}for(let P=0;P<t;P++)v();return M}function R(k){const T=u.value.get(k);T&&(T.abortController&&T.abortController.abort(),T.previewUrl&&URL.revokeObjectURL(T.previewUrl),u.value.delete(k),f.value.delete(k),v())}async function S(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}),v())}function g(){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 p(){for(const k of u.value.values())k.abortController&&k.abortController.abort(),k.previewUrl&&URL.revokeObjectURL(k.previewUrl);u.value.clear(),f.value.clear()}function w(k){return u.value.get(k)}const $=e.computed(()=>f.value.size>0),C=e.computed(()=>f.value.size),y=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")),z=e.computed(()=>Array.from(u.value.values()));return{uploads:u,isUploading:$,activeCount:C,pendingCount:y,isComplete:N,addFiles:x,cancelUpload:R,retryUpload:S,clearCompleted:g,clearAll:p,getUpload:w,uploadsArray:z}}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(S,g,p){o&&("dataTransfer"in S&&S.dataTransfer&&(S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("text/plain",String(p))),d=S.target,d&&d.classList.add(i),l.value={isDragging:!0,dragIndex:p,dropIndex:p,draggedItem:g},c.value=!0,a==null||a(g,p))}function f(S,g){var p;if(!(!o||!l.value.isDragging)&&(S.preventDefault(),l.value.dropIndex!==g)){const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s);const $=(p=S.target)==null?void 0:p.closest("[data-index]");$==null||$.classList.add(s),l.value.dropIndex=g}}function m(){if(!l.value.isDragging)return;const{dragIndex:S,dropIndex:g,draggedItem:p}=l.value;d&&d.classList.remove(i);const w=document.querySelector(`.${s}`);w==null||w.classList.remove(s),S!==null&&g!==null&&S!==g&&p&&(t==null||t({fromIndex:S,toIndex:g,item:p})),v(),r==null||r()}function h(){d&&d.classList.remove(i);const S=document.querySelector(`.${s}`);S==null||S.classList.remove(s),v(),r==null||r()}function v(){l.value={isDragging:!1,dragIndex:null,dropIndex:null,draggedItem:null},c.value=!1,d=null}function b(S,g,p){const w=[...S],[$]=w.splice(g,1);return w.splice(p,0,$),w.map((C,y)=>({...C,order:y}))}function x(S,g){return{draggable:o,"data-index":g,onDragstart:p=>u(p,S,g),onDragover:p=>f(p,g),onDragend:()=>m(),onDrop:p=>{p.preventDefault(),m()}}}function R(S){S.key==="Escape"&&l.value.isDragging&&h()}return e.onMounted(()=>{document.addEventListener("keydown",R)}),e.onUnmounted(()=>{document.removeEventListener("keydown",R),h()}),{dragState:l,isDragging:c,startDrag:u,handleDragOver:f,endDrag:m,cancelDrag:h,reorderItems:b,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:f="mediables",adapter:m,maxConcurrentUploads:h=3,onChange:v,onUpload:b,onUploadComplete:x,onUploadError:R,onRemove:S,onReorder:g,onError:p,onReadyToSubmitChange:w}=n,$={maxItems:i,maxFileSize:s,acceptedMimeTypes:l,...u},C=m||Sc(f),y=e.ref([]),N=e.ref(!1),z=e.ref([]);function k(oe){if(oe.length===0)return[];const ye=oe[0];return"media"in ye&&"clientId"in ye?oe:Fr(oe)}y.value=k(o);const{acceptString:T,canAddFiles:M}=ai({rules:$}),D=Nc({adapter:C,maxConcurrent:h,rules:$,collection:r,onUploadStart:oe=>{b==null||b(oe)},onUploadComplete:(oe,ye)=>{const pe=y.value.findIndex(Ze=>Ze.clientId===oe.id);pe!==-1&&(y.value[pe]={...y.value[pe],media:ye,name:ye.name||ye.file_name,upload:{...oe,status:"completed"}}),x==null||x(ye)},onUploadError:(oe,ye)=>{const pe=y.value.findIndex(Ze=>Ze.clientId===oe.id);pe!==-1&&(y.value[pe]={...y.value[pe],upload:{...oe,status:"error",error:ye.message},errors:[{field:"upload",message:ye.message,code:"UPLOAD_ERROR"}]}),R==null||R({file:oe.file,message:ye.message})},onQueueComplete:()=>{v==null||v(y.value)}}),{dragState:P,getDragProps:L,reorderItems:I}=_c({enabled:c&&!d,onReorder:oe=>{y.value=I(y.value,oe.fromIndex,oe.toIndex),g==null||g(y.value),v==null||v(y.value)}}),_=e.computed(()=>D.isUploading.value),j=e.computed(()=>!D.isUploading.value&&D.pendingCount.value===0),U=e.computed(()=>i?y.value.length>=i:!1),Q=e.computed(()=>ei(y.value)),ge=e.computed(()=>y.value.length),Be=e.computed(()=>i?Math.max(0,i-y.value.length):1/0);e.watch(j,oe=>{w==null||w(oe)});function Ce(oe){y.value=k(oe),v==null||v(y.value)}async function ie(oe){if(d)return;const ye=Array.from(oe);if(!M(ye.length,y.value.length)){const me={field:"count",message:`Maximum ${i} files allowed`,code:"MAX_ITEMS"};z.value=[me],p==null||p([me]);return}const pe=await D.addFiles(ye),Ze=y.value.length,Ke=pe.map((me,ke)=>({...me,order:Ze+ke}));y.value=[...y.value,...Ke],v==null||v(y.value)}function F(oe){d||(oe.upload&&(oe.upload.status==="uploading"||oe.upload.status==="pending")&&D.cancelUpload(oe.clientId),y.value=y.value.filter(ye=>ye.clientId!==oe.clientId),y.value=y.value.map((ye,pe)=>({...ye,order:pe})),S==null||S(oe),v==null||v(y.value))}function X(oe){const ye=y.value.find(pe=>pe.clientId===oe);ye&&F(ye)}function te(){d||(D.clearAll(),y.value=[],v==null||v(y.value))}function ae(oe,ye){d||!c||(y.value=I(y.value,oe,ye),g==null||g(y.value),v==null||v(y.value))}function re(oe,ye){if(d)return;const pe=y.value.findIndex(Ze=>Ze.clientId===oe);pe!==-1&&(y.value[pe]={...y.value[pe],...ye},v==null||v(y.value))}function q(oe){D.cancelUpload(oe),X(oe)}async function ue(oe){await D.retryUpload(oe)}async function he(){if(!t||!a)throw new Error("modelType and modelId are required for save()");const oe={modelType:t,modelId:a,collection:r},ye=y.value.filter(pe=>pe.media&&!pe.markedForRemoval).map(pe=>pe.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);y.value=Fr(ye),v==null||v(y.value)}finally{N.value=!1}}return e.onMounted(()=>{t&&a&&o.length===0&&we().catch(console.error)}),e.onUnmounted(()=>{D.clearAll()}),{items:y,setItems:Ce,addFiles:ie,removeItem:F,removeItemById:X,clearAll:te,reorderItems:ae,updateItem:re,cancelUpload:q,retryUpload:ue,save:he,load:we,isLoading:N,isUploading:_,isReadyToSubmit:j,isAtMaxItems:U,errors:z,dragState:P,getDragProps:L,adapter:C,formValues:Q,acceptString:T,count:ge,remainingSlots:Be}}const bE=["aria-disabled"],wE=["accept","multiple","disabled"],kE={class:"media-dropzone__content"},xE={class:"media-dropzone__title"},SE={class:"media-dropzone__subtitle"},EE=["disabled"],CE={key:0,class:"media-dropzone__helper"},VE=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 b=[];return t.maxFileSize&&b.push(`Max size: ${ua(t.maxFileSize)}`),t.maxItems&&t.maxItems>1&&b.push(`Max files: ${t.maxItems}`),b.join(" • ")});function c(b){b.preventDefault(),!t.disabled&&(r.value=!0)}function d(b){b.preventDefault(),r.value=!1}function u(b){b.preventDefault()}function f(b){var R;if(b.preventDefault(),r.value=!1,t.disabled)return;const x=(R=b.dataTransfer)==null?void 0:R.files;x&&x.length>0&&a("files",x)}function m(){var b;t.disabled||(b=i.value)==null||b.click()}function h(b){const x=b.target,R=x.files;R&&R.length>0&&a("files",R),x.value=""}function v(b){(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),m())}return(b,x)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(s.value),role:"button",tabindex:"0","aria-disabled":b.disabled,"aria-label":"Upload files",onClick:m,onKeydown:v,onDragenter:c,onDragleave:d,onDragover:u,onDrop:f},[e.createElementVNode("input",{ref_key:"fileInput",ref:i,type:"file",accept:b.accept,multiple:b.multiple,disabled:b.disabled,class:"media-dropzone__input",onChange:h},null,40,wE),e.createElementVNode("div",kE,[e.renderSlot(b.$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",xE,[e.renderSlot(b.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(b.title),1)],!0)]),e.createElementVNode("p",SE,[e.renderSlot(b.$slots,"subtitle",{},()=>[e.createTextVNode(e.toDisplayString(b.subtitle),1)],!0)]),e.createElementVNode("button",{type:"button",class:"media-dropzone__button",disabled:b.disabled,onClick:e.withModifiers(m,["stop"])},[e.renderSlot(b.$slots,"button",{},()=>[e.createTextVNode(e.toDisplayString(b.buttonText),1)],!0)],8,EE),l.value?(e.openBlock(),e.createElementBlock("p",CE,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)])],42,bE))}}),ri=Te(VE,[["__scopeId","data-v-b1366c1e"]]),NE=["data-index"],_E={key:0,class:"media-item__drag-handle","aria-label":"Drag to reorder",role:"button",tabindex:"0"},TE={class:"media-item__thumbnail"},ME=["src","alt"],FE={key:1,class:"media-item__file-icon"},IE={key:2,class:"media-item__progress-overlay"},BE={class:"media-item__progress-text"},RE={key:3,class:"media-item__processing-overlay"},PE={key:4,class:"media-item__error-overlay"},$E={class:"media-item__info"},zE=["title"],AE={key:0,class:"media-item__size"},DE={key:1,class:"media-item__error-message"},UE={class:"media-item__actions"},OE=["disabled"],LE=["disabled"],WE=["disabled"],jE=["disabled"],XE=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 g;return(g=t.item.upload)!=null&&g.previewUrl?t.item.upload.previewUrl:t.item.media?t.adapter.getThumbnailUrl(t.item.media):null}),s=e.computed(()=>{var g,p,w;return((g=t.item.upload)==null?void 0:g.status)==="uploading"||((p=t.item.upload)==null?void 0:p.status)==="pending"||((w=t.item.upload)==null?void 0:w.status)==="queued"}),l=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="processing"}),c=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.status)==="error"||t.item.errors&&t.item.errors.length>0}),d=e.computed(()=>{var g;return(g=t.item.upload)!=null&&g.error?t.item.upload.error:t.item.errors&&t.item.errors.length>0?t.item.errors[0].message:null}),u=e.computed(()=>{var g;return((g=t.item.upload)==null?void 0:g.progress)||0}),f=e.computed(()=>{var g;return t.item.name||((g=t.item.media)==null?void 0:g.file_name)||"Unknown file"}),m=e.computed(()=>{var C,y;const g=((C=t.item.media)==null?void 0:C.size)||((y=t.item.upload)==null?void 0:y.file.size);if(!g)return"";const p=1024,w=["Bytes","KB","MB","GB"],$=Math.floor(Math.log(g)/Math.log(p));return parseFloat((g/Math.pow(p,$)).toFixed(2))+" "+w[$]}),h=e.computed(()=>{var p,w;const g=((p=t.item.media)==null?void 0:p.mime_type)||((w=t.item.upload)==null?void 0:w.file.type);return g==null?void 0:g.startsWith("image/")}),v=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 b(){t.disabled||a("remove",t.item)}function x(){t.disabled||a("edit",t.item)}function R(){t.disabled||a("retry",t.item)}function S(){t.disabled||a("cancel",t.item)}return(g,p)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(v.value),"data-index":g.index,onMouseenter:p[0]||(p[0]=w=>r.value=!0),onMouseleave:p[1]||(p[1]=w=>r.value=!1)},[g.sortable&&!g.disabled?(e.openBlock(),e.createElementBlock("div",_E,[...p[2]||(p[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",TE,[i.value&&h.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,alt:f.value,class:"media-item__image"},null,8,ME)):(e.openBlock(),e.createElementBlock("div",FE,[...p[3]||(p[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",IE,[e.createElementVNode("div",{class:"media-item__progress-bar",style:e.normalizeStyle({width:`${u.value}%`})},null,4),e.createElementVNode("span",BE,e.toDisplayString(u.value)+"%",1)])):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",RE,[...p[4]||(p[4]=[e.createElementVNode("div",{class:"media-item__spinner","aria-label":"Processing"},null,-1)])])):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("div",PE,[...p[5]||(p[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",$E,[e.createElementVNode("span",{class:"media-item__name",title:f.value},e.toDisplayString(f.value),9,zE),m.value?(e.openBlock(),e.createElementBlock("span",AE,e.toDisplayString(m.value),1)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock("span",DE,e.toDisplayString(d.value),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",UE,[s.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"media-item__action media-item__action--cancel",disabled:g.disabled,"aria-label":"Cancel upload",onClick:S},[...p[6]||(p[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,OE)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"media-item__action media-item__action--retry",disabled:g.disabled,"aria-label":"Retry upload",onClick:R},[...p[7]||(p[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,LE)):e.createCommentVNode("",!0),g.showEdit&&g.item.media&&!s.value?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"media-item__action media-item__action--edit",disabled:g.disabled,"aria-label":"Edit",onClick:x},[...p[8]||(p[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,WE)):e.createCommentVNode("",!0),g.showRemove?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",class:"media-item__action media-item__action--remove",disabled:g.disabled,"aria-label":"Remove",onClick:b},[...p[9]||(p[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,jE)):e.createCommentVNode("",!0)])],42,NE))}}),ii=Te(XE,[["__scopeId","data-v-ff81c9ec"]]),ZE=["aria-label"],YE=["draggable","data-index","onDragstart","onDragover","onDragend","onDrop"],GE={key:0,class:"media-collection__footer"},HE={class:"media-collection__count"},JE={key:0},qE={key:0,class:"media-collection__uploading"},KE=["name","value"],QE=["name","value"],e3=["name","value"],t3=["name","value"],n3={key:3,class:"media-collection__errors",role:"alert","aria-live":"polite"},o3=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:f,isLoading:m,isUploading:h,isAtMaxItems:v,errors:b,dragState:x,getDragProps:R,adapter:S,formValues:g,acceptString:p,count:w,remainingSlots:$}=Aa(r);e.provide("mediaAdapter",S),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&&!v.value),y=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 z(_){c(_)}function k(_){f(_.clientId)}function T(_){u(_.clientId)}function M(_){}function D(_,j,U){if(!t.sortable||t.disabled)return;const Q=R(j,U);Q.onDragstart&&Q.onDragstart(_)}function P(_,j){if(!t.sortable||t.disabled)return;_.preventDefault();const U=i.value[j],Q=R(U,j);Q.onDragover&&Q.onDragover(_)}function L(_,j){const U=R(_,j);U.onDragend&&U.onDragend()}function I(_,j){_.preventDefault();const U=i.value[j],Q=R(U,j);Q.onDrop&&Q.onDrop(_)}return(_,j)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(y.value)},[e.renderSlot(_.$slots,"dropzone",{addFiles:e.unref(l)},()=>[C.value?(e.openBlock(),e.createBlock(ri,{key:0,accept:e.unref(p),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),(U,Q)=>e.renderSlot(_.$slots,"item",{key:U.clientId,item:U,index:Q,remove:()=>z(U)},()=>[e.createElementVNode("div",{class:e.normalizeClass(["media-collection__item-wrapper",{"media-collection__item-wrapper--drag-over":e.unref(x).dropIndex===Q}]),draggable:_.sortable&&!_.disabled,"data-index":Q,onDragstart:ge=>D(ge,U,Q),onDragover:ge=>P(ge,Q),onDragend:ge=>L(U,Q),onDrop:ge=>I(ge,Q)},[e.createVNode(ii,{item:U,adapter:e.unref(S),disabled:_.disabled,sortable:_.sortable,"show-remove":!_.readonly,"show-edit":!1,index:Q,onRemove:z,onRetry:k,onCancel:T,onEdit:M},null,8,["item","adapter","disabled","sortable","show-remove","index"])],42,YE)],!0)),128))],8,ZE)):C.value?e.createCommentVNode("",!0):e.renderSlot(_.$slots,"empty",{key:1},()=>[j[0]||(j[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",GE,[e.createElementVNode("span",HE,[e.createTextVNode(e.toDisplayString(e.unref(w))+" "+e.toDisplayString(e.unref(w)===1?"file":"files")+" ",1),_.maxItems?(e.openBlock(),e.createElementBlock("span",JE," / "+e.toDisplayString(_.maxItems)+" max",1)):e.createCommentVNode("",!0)]),e.unref(h)?(e.openBlock(),e.createElementBlock("span",qE," 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(g),(U,Q)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${U.uuid}`,type:"hidden",name:`${_.name}[${Q}][uuid]`,value:U.uuid},null,8,KE))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(U,Q)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${U.uuid}-name`,type:"hidden",name:`${_.name}[${Q}][name]`,value:U.name},null,8,QE))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(U,Q)=>(e.openBlock(),e.createElementBlock("input",{key:`${_.name}-${U.uuid}-order`,type:"hidden",name:`${_.name}[${Q}][order]`,value:U.order},null,8,e3))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(U,Q)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:`${_.name}-${U.uuid}-props`},[U.custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${_.name}[${Q}][custom_properties]`,value:JSON.stringify(U.custom_properties)},null,8,t3)):e.createCommentVNode("",!0)],64))),128))],64)):e.createCommentVNode("",!0),e.unref(b).length>0?(e.openBlock(),e.createElementBlock("div",n3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),U=>(e.openBlock(),e.createElementBlock("p",{key:U.code||U.message,class:"media-collection__error"},e.toDisplayString(U.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),a3=Te(o3,[["__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),v=e.computed(()=>h.items.value[0]||null),b=e.computed(()=>v.value!==null),x=e.computed(()=>h.formValues.value[0]||null);function R(C){C===null?h.clearAll():h.setItems([C])}async function S(C){const y=v.value;y&&h.removeItem(y),await h.addFiles([C])}function g(){v.value&&h.removeItem(v.value)}async function p(C){const y=v.value;y&&h.removeItem(y),await h.addFiles([C]);const N=h.items.value[0];N&&(a==null||a(y,N))}function w(){var C;(C=v.value)!=null&&C.upload&&h.cancelUpload(v.value.clientId)}async function $(){var C,y;((y=(C=v.value)==null?void 0:C.upload)==null?void 0:y.status)==="error"&&await h.retryUpload(v.value.clientId)}return{item:v,setItem:R,addFile:S,removeItem:g,replaceItem:p,cancelUpload:w,retryUpload:$,save:h.save,load:h.load,isLoading:h.isLoading,isUploading:h.isUploading,isReadyToSubmit:h.isReadyToSubmit,hasItem:b,errors:h.errors,adapter:h.adapter,formValue:x,acceptString:h.acceptString}}const r3=["accept","disabled"],i3={class:"media-attachment__preview"},s3=["name","value"],l3=["name","value"],c3=["name","value"],d3=["name","value"],u3={key:4,class:"media-attachment__errors",role:"alert","aria-live":"polite"},m3=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:f,retryUpload:m,isLoading:h,hasItem:v,errors:b,adapter:x,formValue:R,acceptString:S}=si(i);e.provide("mediaAdapter",x),e.watch(()=>t.modelValue,k=>{k!==s.value&&l(k)},{deep:!0});const g=e.computed(()=>t.showUploadZone&&!t.disabled&&!t.readonly&&!v.value),p=e.computed(()=>({"media-attachment":!0,"media-attachment--disabled":t.disabled,"media-attachment--readonly":t.readonly,"media-attachment--loading":h.value,"media-attachment--has-item":v.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,M=T.files;M&&M.length>0&&u(M[0]),T.value=""}function y(k){d()}function N(k){m()}function z(k){f()}return(k,T)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(p.value)},[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",accept:e.unref(S),disabled:k.disabled,class:"media-attachment__hidden-input",onChange:C},null,40,r3),g.value?e.renderSlot(k.$slots,"dropzone",{key:0,addFile:e.unref(c)},()=>[e.createVNode(ri,{accept:e.unref(S),multiple:!1,disabled:k.disabled,"max-file-size":k.maxFileSize,onFiles:w},null,8,["accept","disabled","max-file-size"])],!0):e.unref(v)&&e.unref(s)?e.renderSlot(k.$slots,"preview",{key:1,item:e.unref(s),remove:e.unref(d),replace:$},()=>[e.createElementVNode("div",i3,[e.createVNode(ii,{item:e.unref(s),adapter:e.unref(x),disabled:k.disabled,sortable:!1,"show-remove":!k.readonly,"show-edit":!1,onRemove:y,onRetry:N,onCancel:z},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(R)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.createElementVNode("input",{type:"hidden",name:`${k.name}[uuid]`,value:e.unref(R).uuid},null,8,s3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[name]`,value:e.unref(R).name},null,8,l3),e.createElementVNode("input",{type:"hidden",name:`${k.name}[order]`,value:e.unref(R).order},null,8,c3),e.unref(R).custom_properties?(e.openBlock(),e.createElementBlock("input",{key:0,type:"hidden",name:`${k.name}[custom_properties]`,value:JSON.stringify(e.unref(R).custom_properties)},null,8,d3)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.unref(b).length>0?(e.openBlock(),e.createElementBlock("div",u3,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(b),M=>(e.openBlock(),e.createElementBlock("p",{key:M.code||M.message,class:"media-attachment__error"},e.toDisplayString(M.message),1))),128))])):e.createCommentVNode("",!0)],2))}}),p3=Te(m3,[["__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"}},f3=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:f,cancelUpload:m,retryUpload:h,isLoading:v,isUploading:b,isReadyToSubmit:x,isAtMaxItems:R,errors:S,dragState:g,getDragProps:p,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 y=e.computed(()=>({...Tc,...a.labels})),N=e.computed(()=>({accept:C.value,multiple:a.maxItems!==1,disabled:a.disabled||a.readonly||R.value})),z=e.computed(()=>({items:s.value,isLoading:v.value,isUploading:b.value,isReadyToSubmit:x.value,isAtMaxItems:R.value,errors:S.value,addFiles:c,removeItem:d,reorderItems:u,clearAll:()=>{s.value.forEach(k=>d(k))},cancelUpload:m,retryUpload:h,labels:y.value,dropzoneProps:N.value}));return o({items:s,addFiles:c,removeItem:d,reorderItems:u,updateItem:f,cancelUpload:m,retryUpload:h,isLoading:v,isUploading:b,isReadyToSubmit:x,isAtMaxItems:R,errors:S,dragState:g,getDragProps:p,adapter:w,formValues:$,acceptString:C}),(k,T)=>e.renderSlot(k.$slots,"default",e.normalizeProps(e.guardReactiveProps(z.value)))}}),h3=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:y=>{r("update:modelValue",y),r("change",y)},onUpload:y=>{r("upload",y)},onUploadComplete:y=>{r("upload-complete",y)},onUploadError:y=>{r("upload-error",y)},onRemove:y=>{r("remove",y)},onReplace:(y,N)=>{r("replace",N)},onError:y=>{r("validation-error",y)},onReadyToSubmitChange:y=>{r("is-ready-to-submit-change",y)}},{item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:h,isUploading:v,isReadyToSubmit:b,hasItem:x,errors:R,adapter:S,formValue:g,acceptString:p}=si(i);e.provide("mediaAdapter",S),e.watch(()=>a.modelValue,y=>{y!==s.value&&l(y)},{deep:!0});const w=e.computed(()=>({...Tc,...a.labels})),$=e.computed(()=>({accept:p.value,multiple:!1,disabled:a.disabled||a.readonly||x.value})),C=e.computed(()=>({item:s.value,hasItem:x.value,isLoading:h.value,isUploading:v.value,isReadyToSubmit:b.value,errors:R.value,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:m,labels:w.value,dropzoneProps:$.value}));return o({item:s,setItem:l,addFile:c,removeItem:d,replaceItem:u,cancelUpload:f,retryUpload:m,isLoading:h,isUploading:v,isReadyToSubmit:b,hasItem:x,errors:R,adapter:S,formValue:g,acceptString:p}),(y,N)=>e.renderSlot(y.$slots,"default",e.normalizeProps(e.guardReactiveProps(C.value)))}}),v3=["name","value"],g3=["name","value"],y3=["name","value"],b3=["name","value"],w3=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,v3),e.createElementVNode("input",{type:"hidden",name:s(u,"name"),value:d.name},null,8,g3),e.createElementVNode("input",{type:"hidden",name:s(u,"order"),value:d.order},null,8,y3),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,b3)):e.createCommentVNode("",!0)],64))),128))}});exports.AlbumBrowser=xc;exports.AlbumManager=QS;exports.AlbumMediaGrid=uE;exports.AlbumTree=kc;exports.ArrayBufferTarget=gl;exports.ImageEditor=nl;exports.ImageEditorModal=ol;exports.LiveStreamManager=VS;exports.ManagedMediaGallery=yu;exports.MediaAttachment=p3;exports.MediaCollection=a3;exports.MediaCollectionDropzone=ri;exports.MediaCollectionItem=ii;exports.MediaWorkspace=fu;exports.ModelMediaManager=hp;exports.Muxer=Bf;exports.VideoEditor=gc;exports.VideoEditorDialog=m2;exports.VideoEditorSimple=$2;exports.VideoExportPanel=hk;exports.VideoJobClient=Qr;exports.VideoPlayer=yc;exports.VideoTimeline=iw;exports.VideoToolsPanel=Hw;exports.VideoUploader=Qk;exports._sfc_main=f3;exports._sfc_main$1=h3;exports._sfc_main$2=w3;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=mE;exports.getSpatieAdapter=hE;exports.isImageFile=oi;exports.resetMediablesAdapter=pE;exports.resetSpatieAdapter=vE;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-DVJg3EKN.cjs.map
|